2020-04-28 22:22:39

by Rishabh Bhatnagar

[permalink] [raw]
Subject: [PATCH v3 0/2] Extend SSR notifications framework

This set of patches gives kernel client drivers the ability to register
for a particular remoteproc's SSR notifications. Also the notifications
are extended to before/after-powerup/shutdown stages.
It also fixes the bug where clients need to register for notifications
again if the platform driver is removed. This is done by creating a
global list of per-remoteproc notification info data structures which
remain static. An API is exported to register for a remoteproc's SSR
notifications and uses remoteproc's ssr_name and notifier block as
arguments.

Rishabh Bhatnagar (1):
remoteproc: qcom: Add per subsystem SSR notification

Siddharth Gupta (1):
remoteproc: qcom: Add notification types to SSR

v3 -> v2:
- Create a global list of per remoteproc notification data structure
- Pass ssr_name and crashed information as part of notification data
- Move notification type enum to qcom_rproc.h from remoteproc.h

v2 -> v1:
- Fix commit text

drivers/remoteproc/qcom_common.c | 133 ++++++++++++++++++++++++++++++----
drivers/remoteproc/qcom_common.h | 11 ++-
include/linux/remoteproc/qcom_rproc.h | 34 +++++++--
3 files changed, 157 insertions(+), 21 deletions(-)

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


2020-04-28 22:22:58

by Rishabh Bhatnagar

[permalink] [raw]
Subject: [PATCH v3 2/2] remoteproc: qcom: Add notification types to SSR

From: Siddharth Gupta <[email protected]>

The SSR subdevice only adds callback for the unprepare event. Add callbacks
for unprepare, start and prepare events. The client driver for a particular
remoteproc might be interested in knowing the status of the remoteproc
while undergoing SSR, not just when the remoteproc has finished shutting
down.

Signed-off-by: Siddharth Gupta <[email protected]>
Signed-off-by: Rishabh Bhatnagar <[email protected]>
---
drivers/remoteproc/qcom_common.c | 46 +++++++++++++++++++++++++++++++++--
include/linux/remoteproc/qcom_rproc.h | 14 +++++++++++
2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 7cd17be..0d91cf3 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -197,7 +197,7 @@ struct rproc_notif_info *find_notif_info(const char *name)
*
* This registers the @nb notifier block as part the notifier chain for a
* remoteproc associated with @name. The notifier block's callback
- * will be invoked when the particular remote processor is stopped.
+ * will be invoked when the particular remote processor is started/stopped.
*/
void *qcom_register_ssr_notifier(const char *name, struct notifier_block *nb)
{
@@ -239,6 +239,44 @@ int qcom_unregister_ssr_notifier(void *notify, struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(qcom_unregister_ssr_notifier);

+static int ssr_notify_prepare(struct rproc_subdev *subdev)
+{
+ struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
+ struct rproc_notif_data data = {
+ .name = ssr->info->name,
+ .crashed = false,
+ };
+
+ srcu_notifier_call_chain(&ssr->info->notifier_list,
+ RPROC_BEFORE_POWERUP, &data);
+ return 0;
+}
+
+static int ssr_notify_start(struct rproc_subdev *subdev)
+{
+ struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
+ struct rproc_notif_data data = {
+ .name = ssr->info->name,
+ .crashed = false,
+ };
+
+ srcu_notifier_call_chain(&ssr->info->notifier_list,
+ RPROC_AFTER_POWERUP, &data);
+ return 0;
+}
+
+static void ssr_notify_stop(struct rproc_subdev *subdev, bool crashed)
+{
+ struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
+ struct rproc_notif_data data = {
+ .name = ssr->info->name,
+ .crashed = crashed,
+ };
+
+ srcu_notifier_call_chain(&ssr->info->notifier_list,
+ RPROC_BEFORE_SHUTDOWN, &data);
+}
+
static void ssr_notify_unprepare(struct rproc_subdev *subdev)
{
struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
@@ -247,7 +285,8 @@ static void ssr_notify_unprepare(struct rproc_subdev *subdev)
.crashed = false,
};

- srcu_notifier_call_chain(&ssr->info->notifier_list, 0, &data);
+ srcu_notifier_call_chain(&ssr->info->notifier_list,
+ RPROC_AFTER_SHUTDOWN, &data);
}


@@ -282,6 +321,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr,
}
mutex_unlock(&rproc_notif_lock);
ssr->info = info;
+ ssr->subdev.prepare = ssr_notify_prepare;
+ ssr->subdev.start = ssr_notify_start;
+ ssr->subdev.stop = ssr_notify_stop;
ssr->subdev.unprepare = ssr_notify_unprepare;

rproc_add_subdev(rproc, &ssr->subdev);
diff --git a/include/linux/remoteproc/qcom_rproc.h b/include/linux/remoteproc/qcom_rproc.h
index 3dc65c0..567c1f9 100644
--- a/include/linux/remoteproc/qcom_rproc.h
+++ b/include/linux/remoteproc/qcom_rproc.h
@@ -5,6 +5,20 @@

#if IS_ENABLED(CONFIG_QCOM_RPROC_COMMON)

+/**
+ * enum rproc_notif_type - Different stages of remoteproc notifications
+ * @RPROC_BEFORE_SHUTDOWN: unprepare stage of remoteproc
+ * @RPROC_AFTER_SHUTDOWN: stop stage of remoteproc
+ * @RPROC_BEFORE_POWERUP: prepare stage of remoteproc
+ * @RPROC_AFTER_POWERUP: start stage of remoteproc
+ */
+enum rproc_notif_type {
+ RPROC_BEFORE_SHUTDOWN,
+ RPROC_AFTER_SHUTDOWN,
+ RPROC_BEFORE_POWERUP,
+ RPROC_AFTER_POWERUP,
+};
+
struct rproc_notif_data {
const char *name;
bool crashed;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

2020-05-19 20:43:42

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v3 2/2] remoteproc: qcom: Add notification types to SSR

On Tue 28 Apr 15:16 PDT 2020, Rishabh Bhatnagar wrote:

> From: Siddharth Gupta <[email protected]>
>
> The SSR subdevice only adds callback for the unprepare event. Add callbacks
> for unprepare, start and prepare events. The client driver for a particular
> remoteproc might be interested in knowing the status of the remoteproc
> while undergoing SSR, not just when the remoteproc has finished shutting
> down.
>
> Signed-off-by: Siddharth Gupta <[email protected]>
> Signed-off-by: Rishabh Bhatnagar <[email protected]>
> ---
> drivers/remoteproc/qcom_common.c | 46 +++++++++++++++++++++++++++++++++--
> include/linux/remoteproc/qcom_rproc.h | 14 +++++++++++
> 2 files changed, 58 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
> index 7cd17be..0d91cf3 100644
> --- a/drivers/remoteproc/qcom_common.c
> +++ b/drivers/remoteproc/qcom_common.c
> @@ -197,7 +197,7 @@ struct rproc_notif_info *find_notif_info(const char *name)
> *
> * This registers the @nb notifier block as part the notifier chain for a
> * remoteproc associated with @name. The notifier block's callback
> - * will be invoked when the particular remote processor is stopped.
> + * will be invoked when the particular remote processor is started/stopped.
> */
> void *qcom_register_ssr_notifier(const char *name, struct notifier_block *nb)
> {
> @@ -239,6 +239,44 @@ int qcom_unregister_ssr_notifier(void *notify, struct notifier_block *nb)
> }
> EXPORT_SYMBOL_GPL(qcom_unregister_ssr_notifier);
>
> +static int ssr_notify_prepare(struct rproc_subdev *subdev)
> +{
> + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
> + struct rproc_notif_data data = {
> + .name = ssr->info->name,
> + .crashed = false,
> + };
> +
> + srcu_notifier_call_chain(&ssr->info->notifier_list,
> + RPROC_BEFORE_POWERUP, &data);
> + return 0;
> +}
> +
> +static int ssr_notify_start(struct rproc_subdev *subdev)
> +{
> + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
> + struct rproc_notif_data data = {
> + .name = ssr->info->name,
> + .crashed = false,
> + };
> +
> + srcu_notifier_call_chain(&ssr->info->notifier_list,
> + RPROC_AFTER_POWERUP, &data);
> + return 0;
> +}
> +
> +static void ssr_notify_stop(struct rproc_subdev *subdev, bool crashed)
> +{
> + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
> + struct rproc_notif_data data = {
> + .name = ssr->info->name,
> + .crashed = crashed,
> + };
> +
> + srcu_notifier_call_chain(&ssr->info->notifier_list,
> + RPROC_BEFORE_SHUTDOWN, &data);
> +}
> +
> static void ssr_notify_unprepare(struct rproc_subdev *subdev)
> {
> struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
> @@ -247,7 +285,8 @@ static void ssr_notify_unprepare(struct rproc_subdev *subdev)
> .crashed = false,
> };
>
> - srcu_notifier_call_chain(&ssr->info->notifier_list, 0, &data);
> + srcu_notifier_call_chain(&ssr->info->notifier_list,
> + RPROC_AFTER_SHUTDOWN, &data);
> }
>
>
> @@ -282,6 +321,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr,
> }
> mutex_unlock(&rproc_notif_lock);
> ssr->info = info;
> + ssr->subdev.prepare = ssr_notify_prepare;
> + ssr->subdev.start = ssr_notify_start;
> + ssr->subdev.stop = ssr_notify_stop;
> ssr->subdev.unprepare = ssr_notify_unprepare;
>
> rproc_add_subdev(rproc, &ssr->subdev);
> diff --git a/include/linux/remoteproc/qcom_rproc.h b/include/linux/remoteproc/qcom_rproc.h
> index 3dc65c0..567c1f9 100644
> --- a/include/linux/remoteproc/qcom_rproc.h
> +++ b/include/linux/remoteproc/qcom_rproc.h
> @@ -5,6 +5,20 @@
>
> #if IS_ENABLED(CONFIG_QCOM_RPROC_COMMON)
>
> +/**
> + * enum rproc_notif_type - Different stages of remoteproc notifications
> + * @RPROC_BEFORE_SHUTDOWN: unprepare stage of remoteproc
> + * @RPROC_AFTER_SHUTDOWN: stop stage of remoteproc
> + * @RPROC_BEFORE_POWERUP: prepare stage of remoteproc
> + * @RPROC_AFTER_POWERUP: start stage of remoteproc
> + */
> +enum rproc_notif_type {
> + RPROC_BEFORE_SHUTDOWN,
> + RPROC_AFTER_SHUTDOWN,
> + RPROC_BEFORE_POWERUP,
> + RPROC_AFTER_POWERUP,

Given that these are not generic remoteproc things I would like a qcom
prefix on them.

How about QCOM_SSR_BEFORE_SHUTDOWN ...

Apart from that, this looks good.

Thanks,
Bjorn

> +};
> +
> struct rproc_notif_data {
> const char *name;
> bool crashed;
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project