remoteproc: updates for new events
Subsystems (2)
cover remoteproc: updates for new events
(This is just a rebase of https://lkml.org/lkml/2018/5/15/919)
This series changes the prototype for rproc_add_subdev(). The caller is now responsible for populating the function pointers recorded in the rproc_subdev structure, rather than having them be passed as arguments. These two existing function pointers have been renamed ("probe" is now "start" and "remove" is now "stop"), and they are now optional. Callback functions may now also be assigned for two new events (prior to start and after stop).
-Alex
Alex Elder (1):
remoteproc: rename subdev probe and remove functions
Bjorn Andersson (4):
remoteproc: Rename subdev functions to start/stop
remoteproc: Make start and stop in subdev optional
remoteproc: Make client initialize ops in rproc_subdev
remoteproc: Introduce prepare and unprepare for subdevices
drivers/remoteproc/qcom_common.c | 26 ++++--- drivers/remoteproc/qcom_sysmon.c | 5 +- drivers/remoteproc/remoteproc_core.c | 110 ++++++++++++++++++++------- include/linux/remoteproc.h | 19 ++--- 4 files changed, 109 insertions(+), 51 deletions(-)
Signature · 1 line
2.17.1
PATCH RESEND 1/5 remoteproc: Rename subdev functions to start/stop
From: Bjorn Andersson <[email protected]>
"start" and "stop" are more suitable names for how these two operations are used, and they fit better with the upcoming introduction of two additional operations in the struct.
[[email protected]: minor comment edits]
--- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++-------------- include/linux/remoteproc.h | 14 ++++++------- 2 files changed, 22 insertions(+), 22 deletions(-)
drivers/remoteproc/remoteproc_core.c +15 -15
@@ -774,13 +774,13 @@ static int rproc_handle_resources(struct rproc *rproc,return ret; } -static int rproc_probe_subdevices (struct rproc *rproc) +static int rproc_start_subdevices (struct rproc *rproc) {struct rproc_subdev *subdev;int ret;list_for_each_entry (subdev, &rproc->subdevs, node) { - ret = subdev->probe (subdev); + ret = subdev->start (subdev);if (ret) goto unroll_registration; }
@@ -789,17 +789,17 @@ static int rproc_probe_subdevices(struct rproc *rproc) unroll_registration:list_for_each_entry_continue_reverse (subdev, &rproc->subdevs, node) - subdev->remove (subdev, true); + subdev->stop (subdev, true);return ret; } -static void rproc_remove_subdevices (struct rproc *rproc,bool crashed) +static void rproc_stop_subdevices (struct rproc *rproc,bool crashed) {struct rproc_subdev *subdev;list_for_each_entry_reverse (subdev, &rproc->subdevs, node) - subdev->remove (subdev, crashed); + subdev->stop (subdev, crashed); }/**
@@ -901,8 +901,8 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)return ret; } -/* probe any subdevices for the remote processor */ - ret =rproc_probe_subdevices (rproc); +/* Start any subdevices for the remote processor */ + ret =rproc_start_subdevices (rproc);if (ret) {dev_err (dev,"failed to probe subdevices for %s: %d\n" , rproc->name, ret);
@@ -1014,8 +1014,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed)struct device *dev = &rproc->dev;int ret; -/* remove any subdevices for the remote processor */ -rproc_remove_subdevices (rproc, crashed); +/* Stop any subdevices for the remote processor */ +rproc_stop_subdevices (rproc, crashed);/* the installed resource table is no longer accessible */ rproc->table_ptr = rproc->cached_table;
@@ -1657,16 +1657,16 @@ EXPORT_SYMBOL(rproc_del);* rproc_add_subdev() - add a subdevice to a remoteproc * @rproc: rproc handle to add the subdevice to * @subdev: subdev handle to register -* @probe: function to call when the rproc boots -* @remove: function to call when the rproc shuts down +* @start: function to call after the rproc is started +* @stop: function to call before the rproc is stopped */ void rproc_add_subdev (struct rproc *rproc,struct rproc_subdev *subdev, -int (*probe)(struct rproc_subdev *subdev), -void (*remove)(struct rproc_subdev *subdev,bool crashed)) +int (*start)(struct rproc_subdev *subdev), +void (*stop)(struct rproc_subdev *subdev,bool crashed)) { - subdev->probe = probe; - subdev->remove = remove; + subdev->start = start; + subdev->stop = stop;list_add_tail (&subdev->node, &rproc->subdevs); }
include/linux/remoteproc.h +7 -7
@@ -477,15 +477,15 @@ struct rproc {/** * struct rproc_subdev - subdevice tied to a remoteproc * @node: list node related to the rproc subdevs list -* @probe: probe function, called as the rproc is started -* @remove: remove function, called as the rproc is being stopped, the @crashed -* parameter indicates if this originates from the a recovery +* @start: start function, called after the rproc has been started +* @stop: stop function, called before the rproc is stopped; the @crashed +* parameter indicates if this originates from a recovery */ struct rproc_subdev {struct list_head node; -int (*probe)(struct rproc_subdev *subdev); -void (*remove)(struct rproc_subdev *subdev,bool crashed); +int (*start)(struct rproc_subdev *subdev); +void (*stop)(struct rproc_subdev *subdev,bool crashed); };/* we currently support only two vrings per rvdev */
@@ -568,8 +568,8 @@ static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)void rproc_add_subdev (struct rproc *rproc,struct rproc_subdev *subdev, -int (*probe)(struct rproc_subdev *subdev), -void (*remove)(struct rproc_subdev *subdev,bool crashed)); +int (*start)(struct rproc_subdev *subdev), +void (*stop)(struct rproc_subdev *subdev,bool crashed));void rproc_remove_subdev (struct rproc *rproc,struct rproc_subdev *subdev);
Signature · 1 line
2.17.1
Re: [PATCH resend 1/5] remoteproc: Rename subdev functions to start/stop
Quoted 11 lines · Alex Elder
From: Bjorn Andersson <[email protected]>
"start" and "stop" are more suitable names for how these two operations are used, and they fit better with the upcoming introduction of two additional operations in the struct.
[[email protected]: minor comment edits]
Signed-off-by Bjorn Andersson <[email protected]>Acked-by Alex Elder <[email protected]>Tested-by Fabien Dessenne <[email protected]>
Sorry for not spotting this before, but per section 11 of Documentation/process/submitting-patches.rst the tag part should read:
I.e. as you're sending the email you must be the last one certifying the origin of the patch.
Regards,
Bjorn
Quoted 130 lines
--- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++-------------- include/linux/remoteproc.h | 14 ++++++------- 2 files changed, 22 insertions(+), 22 deletions(-)drivers/remoteproc/remoteproc_core.c +15
-15@@ -774,13 +774,13 @@ static int rproc_handle_resources(struct rproc *rproc,return ret; } -static int rproc_probe_subdevices (struct rproc *rproc) +static int rproc_start_subdevices (struct rproc *rproc) {struct rproc_subdev *subdev;int ret;list_for_each_entry (subdev, &rproc->subdevs, node) { - ret = subdev->probe (subdev); + ret = subdev->start (subdev);if (ret) goto unroll_registration; }@@ -789,17 +789,17 @@ static int rproc_probe_subdevices(struct rproc *rproc) unroll_registration:list_for_each_entry_continue_reverse (subdev, &rproc->subdevs, node) - subdev->remove (subdev, true); + subdev->stop (subdev, true);return ret; } -static void rproc_remove_subdevices (struct rproc *rproc,bool crashed) +static void rproc_stop_subdevices (struct rproc *rproc,bool crashed) {struct rproc_subdev *subdev;list_for_each_entry_reverse (subdev, &rproc->subdevs, node) - subdev->remove (subdev, crashed); + subdev->stop (subdev, crashed); }/** @@ -901,8 +901,8 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)return ret; } -/* probe any subdevices for the remote processor */ - ret =rproc_probe_subdevices (rproc); +/* Start any subdevices for the remote processor */ + ret =rproc_start_subdevices (rproc);if (ret) {dev_err (dev,"failed to probe subdevices for %s: %d\n" , rproc->name, ret);@@ -1014,8 +1014,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed)struct device *dev = &rproc->dev;int ret; -/* remove any subdevices for the remote processor */ -rproc_remove_subdevices (rproc, crashed); +/* Stop any subdevices for the remote processor */ +rproc_stop_subdevices (rproc, crashed);/* the installed resource table is no longer accessible */ rproc->table_ptr = rproc->cached_table;@@ -1657,16 +1657,16 @@ EXPORT_SYMBOL(rproc_del);* rproc_add_subdev() - add a subdevice to a remoteproc * @rproc: rproc handle to add the subdevice to * @subdev: subdev handle to register -* @probe: function to call when the rproc boots -* @remove: function to call when the rproc shuts down +* @start: function to call after the rproc is started +* @stop: function to call before the rproc is stopped */ void rproc_add_subdev (struct rproc *rproc,struct rproc_subdev *subdev, -int (*probe)(struct rproc_subdev *subdev), -void (*remove)(struct rproc_subdev *subdev,bool crashed)) +int (*start)(struct rproc_subdev *subdev), +void (*stop)(struct rproc_subdev *subdev,bool crashed)) { - subdev->probe = probe; - subdev->remove = remove; + subdev->start = start; + subdev->stop = stop;list_add_tail (&subdev->node, &rproc->subdevs); }include/linux/remoteproc.h +7
-7@@ -477,15 +477,15 @@ struct rproc {/** * struct rproc_subdev - subdevice tied to a remoteproc * @node: list node related to the rproc subdevs list -* @probe: probe function, called as the rproc is started -* @remove: remove function, called as the rproc is being stopped, the @crashed -* parameter indicates if this originates from the a recovery +* @start: start function, called after the rproc has been started +* @stop: stop function, called before the rproc is stopped; the @crashed +* parameter indicates if this originates from a recovery */ struct rproc_subdev {struct list_head node; -int (*probe)(struct rproc_subdev *subdev); -void (*remove)(struct rproc_subdev *subdev,bool crashed); +int (*start)(struct rproc_subdev *subdev); +void (*stop)(struct rproc_subdev *subdev,bool crashed); };/* we currently support only two vrings per rvdev */ @@ -568,8 +568,8 @@ static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)void rproc_add_subdev (struct rproc *rproc,struct rproc_subdev *subdev, -int (*probe)(struct rproc_subdev *subdev), -void (*remove)(struct rproc_subdev *subdev,bool crashed)); +int (*start)(struct rproc_subdev *subdev), +void (*stop)(struct rproc_subdev *subdev,bool crashed));void rproc_remove_subdev (struct rproc *rproc,struct rproc_subdev *subdev);Signature · 1 line
2.17.1
Re: [PATCH resend 1/5] remoteproc: Rename subdev functions to start/stop
Sorry about that. I will take care if it in the morning. Feel free to edit yourself, I certify it either way.
-Alex
Quoted 174 lines · Bjorn Andersson
Quoted 11 lines · Alex Elder
From: Bjorn Andersson <[email protected]>
"start" and "stop" are more suitable names for how these two operations are used, and they fit better with the upcoming introduction of two additional operations in the struct.
[[email protected]: minor comment edits]
Signed-off-by Bjorn Andersson <[email protected]>Acked-by Alex Elder <[email protected]>Tested-by Fabien Dessenne <[email protected]>Sorry for not spotting this before, but per section 11 of
Documentation/process/submitting-patches.rstthe tag part should read:Tested-by Fabien Dessenne <[email protected]>Signed-off-by Bjorn Andersson <[email protected]>[[email protected]: minor comment edits]Signed-off-by Alex Elder <[email protected]>I.e. as you're sending the email you must be the last one certifying the origin of the patch.
Regards,
BjornReview
Quoted 6 lines
--- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++-------------- include/linux/remoteproc.h | 14 ++++++------- 2 files changed, 22 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/drivers/remoteproc/remoteproc_core.cdrivers/remoteproc/remoteproc_core.c static int rproc_handle_resources(struct rproc
Quoted 4 lines
index
a9609d971f7f..5dd58e6bea88100644drivers/remoteproc/remoteproc_core.c +0
-0@@ -774,13 +774,13 @@ static int rproc_handle_resources(struct rproc*rproc,
drivers/remoteproc/remoteproc_core.c static int rproc_probe_subdevices(struct rproc
Quoted 16 lines
drivers/remoteproc/remoteproc_core.c +2
-2return ret; } -static int rproc_probe_subdevices (struct rproc *rproc) +static int rproc_start_subdevices (struct rproc *rproc) {struct rproc_subdev *subdev;int ret;list_for_each_entry (subdev, &rproc->subdevs, node) { - ret = subdev->probe (subdev); + ret = subdev->start (subdev);if (ret) goto unroll_registration; }@@ -789,17 +789,17 @@ static int rproc_probe_subdevices(struct rproc*rproc)
drivers/remoteproc/remoteproc_core.c static int rproc_start(struct rproc *rproc, const
Quoted 21 lines
drivers/remoteproc/remoteproc_core.c +3
-3unroll_registration:list_for_each_entry_continue_reverse (subdev, &rproc->subdevs, node) - subdev->remove (subdev, true); + subdev->stop (subdev, true);return ret; } -static void rproc_remove_subdevices (struct rproc *rproc,bool crashed) +static void rproc_stop_subdevices (struct rproc *rproc,bool crashed) {struct rproc_subdev *subdev;list_for_each_entry_reverse (subdev, &rproc->subdevs, node) - subdev->remove (subdev, crashed); + subdev->stop (subdev, crashed); }/** @@ -901,8 +901,8 @@ static int rproc_start(struct rproc *rproc, conststruct firmware *fw)
drivers/remoteproc/remoteproc_core.c static int rproc_stop(struct rproc *rproc, bool
Quoted 11 lines
drivers/remoteproc/remoteproc_core.c +2
-2return ret; } -/* probe any subdevices for the remote processor */ - ret =rproc_probe_subdevices (rproc); +/* Start any subdevices for the remote processor */ + ret =rproc_start_subdevices (rproc);if (ret) {dev_err (dev,"failed to probe subdevices for %s: %d\n" , rproc->name, ret);@@ -1014,8 +1014,8 @@ static int rproc_stop(struct rproc *rproc, boolcrashed)
Quoted 13 lines
drivers/remoteproc/remoteproc_core.c +2
-2struct device *dev = &rproc->dev;int ret; -/* remove any subdevices for the remote processor */ -rproc_remove_subdevices (rproc, crashed); +/* Stop any subdevices for the remote processor */ +rproc_stop_subdevices (rproc, crashed);/* the installed resource table is no longer accessible */ rproc->table_ptr = rproc->cached_table;@@ -1657,16 +1657,16 @@ EXPORT_SYMBOL(rproc_del);* rproc_add_subdev() - add a subdevice to a remoteproc * @rproc: rproc handle to add the subdevice to drivers/remoteproc/remoteproc_core.c EXPORT_SYMBOL(rproc_del); · line 1666
Quoted 10 lines
drivers/remoteproc/remoteproc_core.c +2
-4* @subdev: subdev handle to register -* @probe: function to call when the rproc boots -* @remove: function to call when the rproc shuts down +* @start: function to call after the rproc is started +* @stop: function to call before the rproc is stopped */ void rproc_add_subdev(struct rproc *rproc, struct rproc_subdev *subdev, - int (*probe)(struct rproc_subdev *subdev), - void (*remove)(struct rproc_subdev *subdev, boolcrashed))
drivers/remoteproc/remoteproc_core.c EXPORT_SYMBOL(rproc_del); · line 1666
Quoted 2 lines
drivers/remoteproc/remoteproc_core.c +2
-0+int (*start)(struct rproc_subdev *subdev), + void (*stop)(struct rproc_subdev *subdev, boolcrashed))
Quoted 13 lines
drivers/remoteproc/remoteproc_core.c +2
-2{ - subdev->probe = probe; - subdev->remove = remove; + subdev->start = start; + subdev->stop = stop;list_add_tail (&subdev->node, &rproc->subdevs); }include/linux/remoteproc.h +0
-0include/linux/remoteproc.h struct rproc { · line 481
Quoted 5 lines
include/linux/remoteproc.h +0
-2@@ -477,15 +477,15 @@ struct rproc {/** * struct rproc_subdev - subdevice tied to a remoteproc * @node: list node related to the rproc subdevs list -* @probe: probe function, called as the rproc is started -* @remove: remove function, called as the rproc is being stopped, the @crashed
include/linux/remoteproc.h struct rproc {
Quoted 3 lines
include/linux/remoteproc.h +2
-1-* parameter indicates if this originates from the a recovery +* @start: start function, called after the rproc has been started +* @stop: stop function, called before the rproc is stopped; the @crashed
include/linux/remoteproc.h static inline struct rproc *vdev_to_rproc(struct
Quoted 13 lines
include/linux/remoteproc.h +3
-2+* parameter indicates if this originates from a recovery */ struct rproc_subdev {struct list_head node; -int (*probe)(struct rproc_subdev *subdev); -void (*remove)(struct rproc_subdev *subdev,bool crashed); +int (*start)(struct rproc_subdev *subdev); +void (*stop)(struct rproc_subdev *subdev,bool crashed); };/* we currently support only two vrings per rvdev */ @@ -568,8 +568,8 @@ static inline struct rproc *vdev_to_rproc(struct
virtio_device*vdev)include/linux/remoteproc.h static inline struct rproc *vdev_to_rproc(struct · line 571
Quoted 5 lines
include/linux/remoteproc.h +0
-2void rproc_add_subdev(struct rproc *rproc, struct rproc_subdev *subdev, - int (*probe)(struct rproc_subdev *subdev), - void (*remove)(struct rproc_subdev *subdev, boolcrashed));
include/linux/remoteproc.h static inline struct rproc *vdev_to_rproc(struct · line 571
Quoted 2 lines
include/linux/remoteproc.h +2
-0+int (*start)(struct rproc_subdev *subdev), + void (*stop)(struct rproc_subdev *subdev, boolcrashed));
include/linux/remoteproc.h static inline struct rproc *vdev_to_rproc(struct · line 572
Quoted 2 lines
include/linux/remoteproc.h +0
-0void rproc_remove_subdev(struct rproc *rproc, struct rproc_subdev*subdev);
Quoted 4 lines
include/linux/remoteproc.h +0
-1--2.17.1
PATCH RESEND 2/5 remoteproc: Make start and stop in subdev optional
In reply to Alex ElderFrom: Bjorn Andersson <[email protected]>
Some subdevices, such as glink ssr only care about the stop operation, so make the operations optional to reduce client code.
--- drivers/remoteproc/remoteproc_core.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/remoteproc/remoteproc_core.c +13 -7
@@ -780,16 +780,20 @@ static int rproc_start_subdevices(struct rproc *rproc)int ret;list_for_each_entry (subdev, &rproc->subdevs, node) { - ret = subdev->start (subdev); -if (ret) - goto unroll_registration; +if (subdev->start) { + ret = subdev->start (subdev); +if (ret) + goto unroll_registration; + } }return 0 ; unroll_registration: -list_for_each_entry_continue_reverse (subdev, &rproc->subdevs, node) - subdev->stop (subdev, true); +list_for_each_entry_continue_reverse (subdev, &rproc->subdevs, node) { +if (subdev->stop) + subdev->stop (subdev, true); + }return ret; }
@@ -798,8 +802,10 @@ static void rproc_stop_subdevices(struct rproc *rproc, bool crashed) {struct rproc_subdev *subdev; -list_for_each_entry_reverse (subdev, &rproc->subdevs, node) - subdev->stop (subdev, crashed); +list_for_each_entry_reverse (subdev, &rproc->subdevs, node) { +if (subdev->stop) + subdev->stop (subdev, crashed); + } }/**
Signature · 1 line
2.17.1
PATCH RESEND 3/5 remoteproc: Make client initialize ops in rproc_subdev
In reply to Alex ElderFrom: Bjorn Andersson <[email protected]>
In preparation of adding the additional prepare and unprepare operations make the client responsible for filling out the function pointers of the rproc_subdev. This makes the arguments to rproc_add_subdev() more manageable, in particular when some of the functions are left out.
[[email protected]: added comment about assigning function pointers]
--- drivers/remoteproc/qcom_common.c | 18 ++++++++++-------- drivers/remoteproc/qcom_sysmon.c | 5 ++++- drivers/remoteproc/remoteproc_core.c | 18 +++++++----------- include/linux/remoteproc.h | 5 +---- 4 files changed, 22 insertions(+), 24 deletions(-)
drivers/remoteproc/qcom_common.c +10 -8
@@ -64,7 +64,10 @@ void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink)return ; glink->dev = dev; -rproc_add_subdev (rproc, &glink->subdev, glink_subdev_probe, glink_subdev_remove); + glink->subdev.start = glink_subdev_probe; + glink->subdev.stop = glink_subdev_remove; + +rproc_add_subdev (rproc, &glink->subdev); }EXPORT_SYMBOL_GPL (qcom_add_glink_subdev);
@@ -157,7 +160,10 @@ void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)return ; smd->dev = dev; -rproc_add_subdev (rproc, &smd->subdev, smd_subdev_probe, smd_subdev_remove); + smd->subdev.start = smd_subdev_probe; + smd->subdev.stop = smd_subdev_remove; + +rproc_add_subdev (rproc, &smd->subdev); }EXPORT_SYMBOL_GPL (qcom_add_smd_subdev);
@@ -202,11 +208,6 @@ void qcom_unregister_ssr_notifier(struct notifier_block *nb) }EXPORT_SYMBOL_GPL (qcom_unregister_ssr_notifier); -static int ssr_notify_start (struct rproc_subdev *subdev) -{ -return 0 ; -} -static void ssr_notify_stop (struct rproc_subdev *subdev,bool crashed) {struct qcom_rproc_ssr *ssr =to_ssr_subdev (subdev);
@@ -227,8 +228,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr, const char *ssr_name) { ssr->name = ssr_name; + ssr->subdev.stop = ssr_notify_stop; -rproc_add_subdev (rproc, &ssr->subdev, ssr_notify_start, ssr_notify_stop); +rproc_add_subdev (rproc, &ssr->subdev); }EXPORT_SYMBOL_GPL (qcom_add_ssr_subdev);
drivers/remoteproc/qcom_sysmon.c +4 -1
@@ -469,7 +469,10 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,qmi_add_lookup (&sysmon->qmi,43 ,0 ,0 ); -rproc_add_subdev (rproc, &sysmon->subdev, sysmon_start, sysmon_stop); + sysmon->subdev.start = sysmon_start; + sysmon->subdev.stop = sysmon_stop; + +rproc_add_subdev (rproc, &sysmon->subdev); sysmon->nb.notifier_call = sysmon_notify;blocking_notifier_chain_register (&sysmon_notifiers, &sysmon->nb);
drivers/remoteproc/remoteproc_core.c +7 -11
@@ -399,8 +399,10 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,list_add_tail (&rvdev->node, &rproc->rvdevs); -rproc_add_subdev (rproc, &rvdev->subdev, - rproc_vdev_do_probe, rproc_vdev_do_remove); + rvdev->subdev.start = rproc_vdev_do_probe; + rvdev->subdev.stop = rproc_vdev_do_remove; + +rproc_add_subdev (rproc, &rvdev->subdev);return 0 ;
@@ -1663,17 +1665,11 @@ EXPORT_SYMBOL(rproc_del);* rproc_add_subdev() - add a subdevice to a remoteproc * @rproc: rproc handle to add the subdevice to * @subdev: subdev handle to register -* @start: function to call after the rproc is started -* @stop: function to call before the rproc is stopped +* +* Caller is responsible for populating optional subdevice function pointers. */ -void rproc_add_subdev (struct rproc *rproc, -struct rproc_subdev *subdev, -int (*start)(struct rproc_subdev *subdev), -void (*stop)(struct rproc_subdev *subdev,bool crashed)) +void rproc_add_subdev (struct rproc *rproc,struct rproc_subdev *subdev) { - subdev->start = start; - subdev->stop = stop; -list_add_tail (&subdev->node, &rproc->subdevs); }EXPORT_SYMBOL (rproc_add_subdev);
include/linux/remoteproc.h +1 -4
@@ -566,10 +566,7 @@ static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)return rvdev->rproc; } -void rproc_add_subdev (struct rproc *rproc, -struct rproc_subdev *subdev, -int (*start)(struct rproc_subdev *subdev), -void (*stop)(struct rproc_subdev *subdev,bool crashed)); +void rproc_add_subdev (struct rproc *rproc,struct rproc_subdev *subdev);void rproc_remove_subdev (struct rproc *rproc,struct rproc_subdev *subdev);
Signature · 1 line
2.17.1
PATCH RESEND 4/5 remoteproc: rename subdev probe and remove functions
In reply to Alex ElderRename functions used when subdevices are started and stopped to reflect the new naming scheme.
--- drivers/remoteproc/qcom_common.c | 16 ++++++++-------- drivers/remoteproc/remoteproc_core.c | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/remoteproc/qcom_common.c +8 -8
@@ -33,7 +33,7 @@static BLOCKING_NOTIFIER_HEAD (ssr_notifiers); -static int glink_subdev_probe (struct rproc_subdev *subdev) +static int glink_subdev_start (struct rproc_subdev *subdev) {struct qcom_rproc_glink *glink =to_glink_subdev (subdev);
@@ -42,7 +42,7 @@ static int glink_subdev_probe(struct rproc_subdev *subdev)return PTR_ERR_OR_ZERO (glink->edge); } -static void glink_subdev_remove (struct rproc_subdev *subdev,bool crashed) +static void glink_subdev_stop (struct rproc_subdev *subdev,bool crashed) {struct qcom_rproc_glink *glink =to_glink_subdev (subdev);
@@ -64,8 +64,8 @@ void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink)return ; glink->dev = dev; - glink->subdev.start = glink_subdev_probe; - glink->subdev.stop = glink_subdev_remove; + glink->subdev.start = glink_subdev_start; + glink->subdev.stop = glink_subdev_stop;rproc_add_subdev (rproc, &glink->subdev); }
@@ -129,7 +129,7 @@ int qcom_register_dump_segments(struct rproc *rproc, }EXPORT_SYMBOL_GPL (qcom_register_dump_segments); -static int smd_subdev_probe (struct rproc_subdev *subdev) +static int smd_subdev_start (struct rproc_subdev *subdev) {struct qcom_rproc_subdev *smd =to_smd_subdev (subdev);
@@ -138,7 +138,7 @@ static int smd_subdev_probe(struct rproc_subdev *subdev)return PTR_ERR_OR_ZERO (smd->edge); } -static void smd_subdev_remove (struct rproc_subdev *subdev,bool crashed) +static void smd_subdev_stop (struct rproc_subdev *subdev,bool crashed) {struct qcom_rproc_subdev *smd =to_smd_subdev (subdev);
@@ -160,8 +160,8 @@ void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)return ; smd->dev = dev; - smd->subdev.start = smd_subdev_probe; - smd->subdev.stop = smd_subdev_remove; + smd->subdev.start = smd_subdev_start; + smd->subdev.stop = smd_subdev_stop;rproc_add_subdev (rproc, &smd->subdev); }
drivers/remoteproc/remoteproc_core.c +4 -4
@@ -301,14 +301,14 @@ void rproc_free_vring(struct rproc_vring *rvring) rsc->vring[idx].notifyid =-1 ; } -static int rproc_vdev_do_probe (struct rproc_subdev *subdev) +static int rproc_vdev_do_start (struct rproc_subdev *subdev) { struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);return rproc_add_virtio_dev (rvdev, rvdev->id); } -static void rproc_vdev_do_remove (struct rproc_subdev *subdev,bool crashed) +static void rproc_vdev_do_stop (struct rproc_subdev *subdev,bool crashed) { struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
@@ -399,8 +399,8 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,list_add_tail (&rvdev->node, &rproc->rvdevs); - rvdev->subdev.start = rproc_vdev_do_probe; - rvdev->subdev.stop = rproc_vdev_do_remove; + rvdev->subdev.start = rproc_vdev_do_start; + rvdev->subdev.stop = rproc_vdev_do_stop;rproc_add_subdev (rproc, &rvdev->subdev);
Signature · 1 line
2.17.1
PATCH RESEND 5/5 remoteproc: Introduce prepare and unprepare for subdevices
In reply to Alex ElderFrom: Bjorn Andersson <[email protected]>
On rare occasions a subdevice might need to prepare some hardware resources before a remote processor is booted, and clean up some state after it has been shut down.
One such example is the IP Accelerator found in various Qualcomm platforms, which is accessed directly from both the modem remoteproc and the application subsystem and requires an intricate lockstep process when bringing the modem up and down.
[[email protected]: minor description and comment edits]
--- drivers/remoteproc/remoteproc_core.c | 56 ++++++++++++++++++++++++++-- include/linux/remoteproc.h | 4 ++ 2 files changed, 57 insertions(+), 3 deletions(-)
drivers/remoteproc/remoteproc_core.c +53 -3
@@ -776,6 +776,30 @@ static int rproc_handle_resources(struct rproc *rproc,return ret; } +static int rproc_prepare_subdevices (struct rproc *rproc) +{ +struct rproc_subdev *subdev; +int ret; + +list_for_each_entry (subdev, &rproc->subdevs, node) { +if (subdev->prepare) { + ret = subdev->prepare (subdev); +if (ret) + goto unroll_preparation; + } + } + +return 0 ; + +unroll_preparation: +list_for_each_entry_continue_reverse (subdev, &rproc->subdevs, node) { +if (subdev->unprepare) + subdev->unprepare (subdev); + } + +return ret; +} +static int rproc_start_subdevices (struct rproc *rproc) {struct rproc_subdev *subdev;
@@ -810,6 +834,16 @@ static void rproc_stop_subdevices(struct rproc *rproc, bool crashed) } } +static void rproc_unprepare_subdevices (struct rproc *rproc) +{ +struct rproc_subdev *subdev; + +list_for_each_entry_reverse (subdev, &rproc->subdevs, node) { +if (subdev->unprepare) + subdev->unprepare (subdev); + } +} +/** * rproc_coredump_cleanup() - clean up dump_segments list * @rproc: the remote processor handle
@@ -902,11 +936,18 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) rproc->table_ptr = loaded_table; } + ret =rproc_prepare_subdevices (rproc); +if (ret) { +dev_err (dev,"failed to prepare subdevices for %s: %d\n" , + rproc->name, ret); +return ret; + } +/* power up the remote processor */ ret = rproc->ops->start (rproc);if (ret) {dev_err (dev,"can't start rproc %s: %d\n" , rproc->name, ret); -return ret; + goto unprepare_subdevices; }/* Start any subdevices for the remote processor */
@@ -914,8 +955,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)if (ret) {dev_err (dev,"failed to probe subdevices for %s: %d\n" , rproc->name, ret); - rproc->ops->stop (rproc); -return ret; + goto stop_rproc; } rproc->state =RPROC_RUNNING ;
@@ -923,6 +963,14 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)dev_info (dev,"remote processor %s is now up\n" , rproc->name);return 0 ; + +stop_rproc: + rproc->ops->stop (rproc); + +unprepare_subdevices: +rproc_unprepare_subdevices (rproc); + +return ret; }/*
@@ -1035,6 +1083,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed)return ret; } +rproc_unprepare_subdevices (rproc); + rproc->state =RPROC_OFFLINE ;dev_info (dev,"stopped remote processor %s\n" , rproc->name);
include/linux/remoteproc.h +4 -0
@@ -477,15 +477,19 @@ struct rproc {/** * struct rproc_subdev - subdevice tied to a remoteproc * @node: list node related to the rproc subdevs list +* @prepare: prepare function, called before the rproc is started * @start: start function, called after the rproc has been started * @stop: stop function, called before the rproc is stopped; the @crashed * parameter indicates if this originates from a recovery +* @unprepare: unprepare function, called after the rproc has been stopped */ struct rproc_subdev {struct list_head node; +int (*prepare)(struct rproc_subdev *subdev);int (*start)(struct rproc_subdev *subdev);void (*stop)(struct rproc_subdev *subdev,bool crashed); +void (*unprepare)(struct rproc_subdev *subdev); };/* we currently support only two vrings per rvdev */
Signature · 1 line
2.17.1