[RFC PATCH 1/2] remoteproc: qcom: Report last event on SSR notifier registration
Yassine Oudjana
yassine.oudjana at gmail.com
Tue May 10 16:42:18 CEST 2022
From: Yassine Oudjana <y.oudjana at protonmail.com>
Keep track of the last SSR event of a remoteproc, then report it
to each newly registered notifier block. This prevents drivers
from waiting indefinitely for an event that has already happened
before they registered their notifier blocks.
Fixes: a899d324863a3 ("slimbus: qcom-ngd-ctrl: add Sub System Restart support")
Signed-off-by: Yassine Oudjana <y.oudjana at protonmail.com>
---
drivers/remoteproc/qcom_common.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 4b91e3c9eafa..ff85ea564129 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -85,6 +85,7 @@ struct qcom_ssr_subsystem {
const char *name;
struct srcu_notifier_head notifier_list;
struct list_head list;
+ enum qcom_ssr_notify_type current_state;
};
static LIST_HEAD(qcom_ssr_subsystem_list);
@@ -392,6 +393,9 @@ void *qcom_register_ssr_notifier(const char *name, struct notifier_block *nb)
srcu_notifier_chain_register(&info->notifier_list, nb);
+ /* Notify newly registered notifier block of current remoteproc state */
+ nb->notifier_call(nb, info->current_state, NULL);
+
return &info->notifier_list;
}
EXPORT_SYMBOL_GPL(qcom_register_ssr_notifier);
@@ -420,8 +424,9 @@ static int ssr_notify_prepare(struct rproc_subdev *subdev)
.crashed = false,
};
+ ssr->info->current_state = QCOM_SSR_BEFORE_POWERUP;
srcu_notifier_call_chain(&ssr->info->notifier_list,
- QCOM_SSR_BEFORE_POWERUP, &data);
+ ssr->info->current_state, &data);
return 0;
}
@@ -433,8 +438,9 @@ static int ssr_notify_start(struct rproc_subdev *subdev)
.crashed = false,
};
+ ssr->info->current_state = QCOM_SSR_AFTER_POWERUP;
srcu_notifier_call_chain(&ssr->info->notifier_list,
- QCOM_SSR_AFTER_POWERUP, &data);
+ ssr->info->current_state, &data);
return 0;
}
@@ -446,8 +452,9 @@ static void ssr_notify_stop(struct rproc_subdev *subdev, bool crashed)
.crashed = crashed,
};
+ ssr->info->current_state = QCOM_SSR_BEFORE_SHUTDOWN;
srcu_notifier_call_chain(&ssr->info->notifier_list,
- QCOM_SSR_BEFORE_SHUTDOWN, &data);
+ ssr->info->current_state, &data);
}
static void ssr_notify_unprepare(struct rproc_subdev *subdev)
@@ -458,8 +465,9 @@ static void ssr_notify_unprepare(struct rproc_subdev *subdev)
.crashed = false,
};
+ ssr->info->current_state = QCOM_SSR_AFTER_SHUTDOWN;
srcu_notifier_call_chain(&ssr->info->notifier_list,
- QCOM_SSR_AFTER_SHUTDOWN, &data);
+ ssr->info->current_state, &data);
}
/**
@@ -484,6 +492,7 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr,
}
ssr->info = info;
+ ssr->info->current_state = QCOM_SSR_BEFORE_POWERUP;
ssr->subdev.prepare = ssr_notify_prepare;
ssr->subdev.start = ssr_notify_start;
ssr->subdev.stop = ssr_notify_stop;
--
2.36.0
More information about the Alsa-devel
mailing list