Skip to content

Commit 880f5b3

Browse files
committed
remoteproc: Pass type of shutdown to subdev remove
remoteproc instances can be stopped either by invoking shutdown or by an attempt to recover from a crash. For some subdev types it's expected to clean up gracefully during a shutdown, but are unable to do so during a crash - so pass this information to the subdev remove functions. Acked-By: Chris Lew <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]>
1 parent dcb57ed commit 880f5b3

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

drivers/remoteproc/qcom_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int glink_subdev_probe(struct rproc_subdev *subdev)
4242
return PTR_ERR_OR_ZERO(glink->edge);
4343
}
4444

45-
static void glink_subdev_remove(struct rproc_subdev *subdev)
45+
static void glink_subdev_remove(struct rproc_subdev *subdev, bool crashed)
4646
{
4747
struct qcom_rproc_glink *glink = to_glink_subdev(subdev);
4848

@@ -132,7 +132,7 @@ static int smd_subdev_probe(struct rproc_subdev *subdev)
132132
return PTR_ERR_OR_ZERO(smd->edge);
133133
}
134134

135-
static void smd_subdev_remove(struct rproc_subdev *subdev)
135+
static void smd_subdev_remove(struct rproc_subdev *subdev, bool crashed)
136136
{
137137
struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
138138

@@ -201,7 +201,7 @@ static int ssr_notify_start(struct rproc_subdev *subdev)
201201
return 0;
202202
}
203203

204-
static void ssr_notify_stop(struct rproc_subdev *subdev)
204+
static void ssr_notify_stop(struct rproc_subdev *subdev, bool crashed)
205205
{
206206
struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
207207

drivers/remoteproc/remoteproc_core.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static int rproc_vdev_do_probe(struct rproc_subdev *subdev)
308308
return rproc_add_virtio_dev(rvdev, rvdev->id);
309309
}
310310

311-
static void rproc_vdev_do_remove(struct rproc_subdev *subdev)
311+
static void rproc_vdev_do_remove(struct rproc_subdev *subdev, bool crashed)
312312
{
313313
struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
314314

@@ -789,17 +789,17 @@ static int rproc_probe_subdevices(struct rproc *rproc)
789789

790790
unroll_registration:
791791
list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node)
792-
subdev->remove(subdev);
792+
subdev->remove(subdev, true);
793793

794794
return ret;
795795
}
796796

797-
static void rproc_remove_subdevices(struct rproc *rproc)
797+
static void rproc_remove_subdevices(struct rproc *rproc, bool crashed)
798798
{
799799
struct rproc_subdev *subdev;
800800

801801
list_for_each_entry_reverse(subdev, &rproc->subdevs, node)
802-
subdev->remove(subdev);
802+
subdev->remove(subdev, crashed);
803803
}
804804

805805
/**
@@ -1009,13 +1009,13 @@ static int rproc_trigger_auto_boot(struct rproc *rproc)
10091009
return ret;
10101010
}
10111011

1012-
static int rproc_stop(struct rproc *rproc)
1012+
static int rproc_stop(struct rproc *rproc, bool crashed)
10131013
{
10141014
struct device *dev = &rproc->dev;
10151015
int ret;
10161016

10171017
/* remove any subdevices for the remote processor */
1018-
rproc_remove_subdevices(rproc);
1018+
rproc_remove_subdevices(rproc, crashed);
10191019

10201020
/* the installed resource table is no longer accessible */
10211021
rproc->table_ptr = rproc->cached_table;
@@ -1163,7 +1163,7 @@ int rproc_trigger_recovery(struct rproc *rproc)
11631163
if (ret)
11641164
return ret;
11651165

1166-
ret = rproc_stop(rproc);
1166+
ret = rproc_stop(rproc, false);
11671167
if (ret)
11681168
goto unlock_mutex;
11691169

@@ -1316,7 +1316,7 @@ void rproc_shutdown(struct rproc *rproc)
13161316
if (!atomic_dec_and_test(&rproc->power))
13171317
goto out;
13181318

1319-
ret = rproc_stop(rproc);
1319+
ret = rproc_stop(rproc, true);
13201320
if (ret) {
13211321
atomic_inc(&rproc->power);
13221322
goto out;
@@ -1663,7 +1663,7 @@ EXPORT_SYMBOL(rproc_del);
16631663
void rproc_add_subdev(struct rproc *rproc,
16641664
struct rproc_subdev *subdev,
16651665
int (*probe)(struct rproc_subdev *subdev),
1666-
void (*remove)(struct rproc_subdev *subdev))
1666+
void (*remove)(struct rproc_subdev *subdev, bool crashed))
16671667
{
16681668
subdev->probe = probe;
16691669
subdev->remove = remove;

include/linux/remoteproc.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,14 @@ struct rproc {
478478
* struct rproc_subdev - subdevice tied to a remoteproc
479479
* @node: list node related to the rproc subdevs list
480480
* @probe: probe function, called as the rproc is started
481-
* @remove: remove function, called as the rproc is stopped
481+
* @remove: remove function, called as the rproc is being stopped, the @crashed
482+
* parameter indicates if this originates from the a recovery
482483
*/
483484
struct rproc_subdev {
484485
struct list_head node;
485486

486487
int (*probe)(struct rproc_subdev *subdev);
487-
void (*remove)(struct rproc_subdev *subdev);
488+
void (*remove)(struct rproc_subdev *subdev, bool crashed);
488489
};
489490

490491
/* we currently support only two vrings per rvdev */
@@ -568,7 +569,7 @@ static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)
568569
void rproc_add_subdev(struct rproc *rproc,
569570
struct rproc_subdev *subdev,
570571
int (*probe)(struct rproc_subdev *subdev),
571-
void (*remove)(struct rproc_subdev *subdev));
572+
void (*remove)(struct rproc_subdev *subdev, bool graceful));
572573

573574
void rproc_remove_subdev(struct rproc *rproc, struct rproc_subdev *subdev);
574575

0 commit comments

Comments
 (0)