public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	"open list:REMOTE PROCESSOR (REMOTEPROC) SUBSYSTEM"
	<linux-remoteproc@vger.kernel.org>,
	"open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
	<imx@lists.linux.dev>,
	"moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
	<linux-arm-kernel@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH] remoteproc: imx_rproc: Add mutex protection for workqueue
Date: Mon, 31 Mar 2025 23:16:56 +0800	[thread overview]
Message-ID: <20250331151656.GA15525@nxa18884-linux> (raw)
In-Reply-To: <20250331112246.2407276-1-peng.fan@oss.nxp.com>

On Mon, Mar 31, 2025 at 07:22:45PM +0800, Peng Fan (OSS) wrote:
>From: Peng Fan <peng.fan@nxp.com>
>
>Same as
>commit 47e6ab07018e ("remoteproc: imx_dsp_rproc: Add mutex
>protection for workqueue") and commit 35bdafda40cc ("remoteproc:
>stm32_rproc: Add mutex protection for workqueue"), imx_rproc driver
>also has similar issue, although no issue reported until now.
>
>Reuse the commit log from the fix to imx_dsp_rproc:
>
>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 kennel dump.
>
>Call trace:
> virtqueue_add_split
> virtqueue_add_inbuf
> rpmsg_recv_done
> vring_interrupt
> rproc_vq_interrupt
> imx_rproc_vq_work
> process_one_work
> worker_thread
> kthread
> ret_from_fork
>
>Signed-off-by: Peng Fan <peng.fan@nxp.com>
>---
> drivers/remoteproc/imx_rproc.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
>index 74299af1d7f1..f933c8f4fc8b 100644
>--- a/drivers/remoteproc/imx_rproc.c
>+++ b/drivers/remoteproc/imx_rproc.c
>@@ -5,6 +5,7 @@
> 
> #include <dt-bindings/firmware/imx/rsrc.h>
> #include <linux/arm-smccc.h>
>+#include <linux/cleanup.h>
> #include <linux/clk.h>
> #include <linux/err.h>
> #include <linux/firmware/imx/sci.h>
>@@ -785,6 +786,11 @@ static void imx_rproc_vq_work(struct work_struct *work)
> 					      rproc_work);
> 	struct rproc *rproc = priv->rproc;
> 
>+	guard(mutex)(&rproc->lock);
>+
>+	if (rproc->state != RPROC_RUNNING)

Rethink this, I may need update this to
"if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED)"
same as stm32_rproc.c.

Thanks,
Peng

>+		return;
>+
> 	idr_for_each(&rproc->notifyids, imx_rproc_notified_idr_cb, rproc);
> }
> 
>-- 
>2.37.1
>


      parent reply	other threads:[~2025-03-31 14:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 11:22 [PATCH] remoteproc: imx_rproc: Add mutex protection for workqueue Peng Fan (OSS)
2025-03-31 14:16 ` Frank Li
2025-03-31 15:16 ` Peng Fan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250331151656.GA15525@nxa18884-linux \
    --to=peng.fan@oss.nxp.com \
    --cc=andersson@kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox