Message ID | 20250331112246.2407276-1-peng.fan@oss.nxp.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | remoteproc: imx_rproc: Add mutex protection for workqueue | expand |
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. Can fix wrap Same as commit 47e6ab07018e ("remoteproc: imx_dsp_rproc: Add mutex... > > Reuse the commit log from the fix to imx_dsp_rproc: This sentense look like reduntant. > > 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> Reviewed-by: Frank Li <Frank.Li@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) > + return; > + > idr_for_each(&rproc->notifyids, imx_rproc_notified_idr_cb, rproc); > } > > -- > 2.37.1 >
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 >
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) + return; + idr_for_each(&rproc->notifyids, imx_rproc_notified_idr_cb, rproc); }