|
Takashi Iwai |
be85db |
From 35bdafda40cc343ad2ba2cce105eba03a70241cc Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
be85db |
From: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
|
|
Takashi Iwai |
be85db |
Date: Fri, 31 Mar 2023 18:06:34 +0200
|
|
Takashi Iwai |
be85db |
Subject: [PATCH] remoteproc: stm32_rproc: Add mutex protection for workqueue
|
|
Takashi Iwai |
be85db |
Git-commit: 35bdafda40cc343ad2ba2cce105eba03a70241cc
|
|
Takashi Iwai |
be85db |
Patch-mainline: v6.4-rc1
|
|
Takashi Iwai |
be85db |
References: git-fixes
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
The workqueue may execute late even after remoteproc is stopped or
|
|
Takashi Iwai |
be85db |
stopping, some resources (rpmsg device and endpoint) have been
|
|
Takashi Iwai |
be85db |
released in rproc_stop_subdevices(), then rproc_vq_interrupt()
|
|
Takashi Iwai |
be85db |
accessing these resources will cause kernel dump.
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
Call trace:
|
|
Takashi Iwai |
be85db |
virtqueue_add_inbuf
|
|
Takashi Iwai |
be85db |
virtqueue_add_inbuf
|
|
Takashi Iwai |
be85db |
rpmsg_recv_single
|
|
Takashi Iwai |
be85db |
rpmsg_recv_done
|
|
Takashi Iwai |
be85db |
vring_interrupt
|
|
Takashi Iwai |
be85db |
stm32_rproc_mb_vq_work
|
|
Takashi Iwai |
be85db |
process_one_work
|
|
Takashi Iwai |
be85db |
worker_thread
|
|
Takashi Iwai |
be85db |
kthread
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
Suggested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
|
|
Takashi Iwai |
be85db |
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
|
|
Takashi Iwai |
be85db |
Link: https://lore.kernel.org/r/20230331160634.3113031-1-arnaud.pouliquen@foss.st.com
|
|
Takashi Iwai |
be85db |
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
|
|
Takashi Iwai |
be85db |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
---
|
|
Takashi Iwai |
be85db |
drivers/remoteproc/stm32_rproc.c | 8 ++++++++
|
|
Takashi Iwai |
be85db |
1 file changed, 8 insertions(+)
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
|
|
Takashi Iwai |
be85db |
index 23c1690b8d73..8746cbb1f168 100644
|
|
Takashi Iwai |
be85db |
--- a/drivers/remoteproc/stm32_rproc.c
|
|
Takashi Iwai |
be85db |
+++ b/drivers/remoteproc/stm32_rproc.c
|
|
Takashi Iwai |
be85db |
@@ -291,8 +291,16 @@ static void stm32_rproc_mb_vq_work(struct work_struct *work)
|
|
Takashi Iwai |
be85db |
struct stm32_mbox *mb = container_of(work, struct stm32_mbox, vq_work);
|
|
Takashi Iwai |
be85db |
struct rproc *rproc = dev_get_drvdata(mb->client.dev);
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
+ mutex_lock(&rproc->lock);
|
|
Takashi Iwai |
be85db |
+
|
|
Takashi Iwai |
be85db |
+ if (rproc->state != RPROC_RUNNING)
|
|
Takashi Iwai |
be85db |
+ goto unlock_mutex;
|
|
Takashi Iwai |
be85db |
+
|
|
Takashi Iwai |
be85db |
if (rproc_vq_interrupt(rproc, mb->vq_id) == IRQ_NONE)
|
|
Takashi Iwai |
be85db |
dev_dbg(&rproc->dev, "no message found in vq%d\n", mb->vq_id);
|
|
Takashi Iwai |
be85db |
+
|
|
Takashi Iwai |
be85db |
+unlock_mutex:
|
|
Takashi Iwai |
be85db |
+ mutex_unlock(&rproc->lock);
|
|
Takashi Iwai |
be85db |
}
|
|
Takashi Iwai |
be85db |
|
|
Takashi Iwai |
be85db |
static void stm32_rproc_mb_callback(struct mbox_client *cl, void *data)
|
|
Takashi Iwai |
be85db |
--
|
|
Takashi Iwai |
be85db |
2.35.3
|
|
Takashi Iwai |
be85db |
|