Subdevices at the beginning of the subdev list should have higher priority than those at the end of the list. Reverse traversal of the list causes priority inversion, which can impact the performance of the device. For example a device adds the glink, sysmon and ssr subdevs to its list. During a crash the ssr notification would go before the glink and sysmon notifications. This can cause a degraded response when a client driver waits for a response from the crashed rproc. Signed-off-by: Siddharth Gupta <sidgup@xxxxxxxxxxxxxx> --- drivers/remoteproc/remoteproc_core.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 626a6b90f..ac8fc42 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1167,7 +1167,7 @@ static int rproc_handle_resources(struct rproc *rproc, static int rproc_prepare_subdevices(struct rproc *rproc) { - struct rproc_subdev *subdev; + struct rproc_subdev *subdev, *itr; int ret; list_for_each_entry(subdev, &rproc->subdevs, node) { @@ -1181,9 +1181,11 @@ static int rproc_prepare_subdevices(struct rproc *rproc) return 0; unroll_preparation: - list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node) { - if (subdev->unprepare) - subdev->unprepare(subdev); + list_for_each_entry(itr, &rproc->subdevs, node) { + if (itr == subdev) + break; + if (itr->unprepare) + itr->unprepare(subdev); } return ret; @@ -1191,7 +1193,7 @@ static int rproc_prepare_subdevices(struct rproc *rproc) static int rproc_start_subdevices(struct rproc *rproc) { - struct rproc_subdev *subdev; + struct rproc_subdev *subdev, *itr; int ret; list_for_each_entry(subdev, &rproc->subdevs, node) { @@ -1205,9 +1207,11 @@ static int rproc_start_subdevices(struct rproc *rproc) return 0; unroll_registration: - list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node) { - if (subdev->stop) - subdev->stop(subdev, true); + list_for_each_entry(itr, &rproc->subdevs, node) { + if (itr == subdev) + break; + if (itr->stop) + itr->stop(itr, true); } return ret; @@ -1217,7 +1221,7 @@ static void rproc_stop_subdevices(struct rproc *rproc, bool crashed) { struct rproc_subdev *subdev; - list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { + list_for_each_entry(subdev, &rproc->subdevs, node) { if (subdev->stop) subdev->stop(subdev, crashed); } @@ -1227,7 +1231,7 @@ static void rproc_unprepare_subdevices(struct rproc *rproc) { struct rproc_subdev *subdev; - list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { + list_for_each_entry(subdev, &rproc->subdevs, node) { if (subdev->unprepare) subdev->unprepare(subdev); } -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project