diff --git a/patches.suse/remoteproc-stm32_rproc-Add-mutex-protection-for-work.patch b/patches.suse/remoteproc-stm32_rproc-Add-mutex-protection-for-work.patch new file mode 100644 index 0000000..9af9831 --- /dev/null +++ b/patches.suse/remoteproc-stm32_rproc-Add-mutex-protection-for-work.patch @@ -0,0 +1,58 @@ +From 35bdafda40cc343ad2ba2cce105eba03a70241cc Mon Sep 17 00:00:00 2001 +From: Arnaud Pouliquen +Date: Fri, 31 Mar 2023 18:06:34 +0200 +Subject: [PATCH] remoteproc: stm32_rproc: Add mutex protection for workqueue +Git-commit: 35bdafda40cc343ad2ba2cce105eba03a70241cc +Patch-mainline: v6.4-rc1 +References: git-fixes + +The workqueue may execute late even after remoteproc is stopped or +stopping, some resources (rpmsg device and endpoint) have been +released in rproc_stop_subdevices(), then rproc_vq_interrupt() +accessing these resources will cause kernel dump. + +Call trace: +virtqueue_add_inbuf +virtqueue_add_inbuf +rpmsg_recv_single +rpmsg_recv_done +vring_interrupt +stm32_rproc_mb_vq_work +process_one_work +worker_thread +kthread + +Suggested-by: Mathieu Poirier +Signed-off-by: Arnaud Pouliquen +Link: https://lore.kernel.org/r/20230331160634.3113031-1-arnaud.pouliquen@foss.st.com +Signed-off-by: Mathieu Poirier +Acked-by: Takashi Iwai + +--- + drivers/remoteproc/stm32_rproc.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c +index 23c1690b8d73..8746cbb1f168 100644 +--- a/drivers/remoteproc/stm32_rproc.c ++++ b/drivers/remoteproc/stm32_rproc.c +@@ -291,8 +291,16 @@ static void stm32_rproc_mb_vq_work(struct work_struct *work) + struct stm32_mbox *mb = container_of(work, struct stm32_mbox, vq_work); + struct rproc *rproc = dev_get_drvdata(mb->client.dev); + ++ mutex_lock(&rproc->lock); ++ ++ if (rproc->state != RPROC_RUNNING) ++ goto unlock_mutex; ++ + if (rproc_vq_interrupt(rproc, mb->vq_id) == IRQ_NONE) + dev_dbg(&rproc->dev, "no message found in vq%d\n", mb->vq_id); ++ ++unlock_mutex: ++ mutex_unlock(&rproc->lock); + } + + static void stm32_rproc_mb_callback(struct mbox_client *cl, void *data) +-- +2.35.3 + diff --git a/series.conf b/series.conf index 1e053ef..52fc3d3 100644 --- a/series.conf +++ b/series.conf @@ -19870,6 +19870,7 @@ patches.suse/remoteproc-stm32-Call-of_node_put-on-iteration-error.patch patches.suse/remoteproc-st-Call-of_node_put-on-iteration-error.patch patches.suse/remoteproc-imx_rproc-Call-of_node_put-on-iteration-e.patch + patches.suse/remoteproc-stm32_rproc-Add-mutex-protection-for-work.patch patches.suse/dt-bindings-remoteproc-stm32-rproc-Typo-fix.patch patches.suse/hwmon-k10temp-Check-range-scale-when-CUR_TEMP-regist.patch patches.suse/hwmon-adt7475-Use-device_property-APIs-when-configur.patch