Message ID | 20230331160634.3113031-1-arnaud.pouliquen@foss.st.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp693266vqo; Fri, 31 Mar 2023 09:38:03 -0700 (PDT) X-Google-Smtp-Source: AKy350aG2uXWyuv6ZjayufVloFZd9kLkzXhRhu+uug2B0H4WK0zcNQguMmoIgI0kxEA7NzNhyEcT X-Received: by 2002:a05:6402:1115:b0:502:32b6:6e56 with SMTP id u21-20020a056402111500b0050232b66e56mr19935191edv.37.1680280682791; Fri, 31 Mar 2023 09:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680280682; cv=none; d=google.com; s=arc-20160816; b=d4XZbqVHNIXcjo0vXr/tKod7PTIZVn8WwfF9wGn3FkKD0oeYajgTkX7DXoO9rriCT1 vKx41StZiauhCEORHP9rt4VT9kj2LMfQC7j4rPj9SbbG1hkh6S9c2eT+9DJIJCAdW+Np Da+kTJe5zMc+Ac2maXBqJCL0PP7XFPVyAQngi5ehoWxeIEOjbmI+xjN44DKm5sXob8+5 oh0NJMihhmqhMWgw4HACbU0rI/45l82BPQzaRe+8/avbLMkLU60m2C8R4S2lzRuzHCEX 8I8psNU9L5lpgDPs9YD7FyS6F9seto1o+5HGPd6y3wD1s9lkhCRrrpHePZgEac2We19i 7zTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ac3ViCSx4VTlv+LCUqAH7E7aEYqOJVCoIrcTZkiflLc=; b=UfNjok2FqVB47S7jPjQJS3qZj2CFrj5kGPrXZShfQbPn+h/0xXRHgJRq+K2jh3uK/h 2NVJCsMBxL7VlYN90B0aZiahJpFOCX4Who2NAcoHRaKCsI8lF3egX85ZUT1yHolH9uIW yP3bh0V9db/b4j94OIsoBgub9i0K2Luz0gC/b4KA6ycwiGu1P1QIgrHaBTWYLFEOwB9E xpK6E+7OkMz5cHldULrGJPr40MhkNex/HFu5lUfM267Ysu33TasbdZFsa/OLYfo/enoF 2TGYOtFkUhHHw1QU1WLw1Y/Hd8YlrPfqG1+q6zoVOfRBnqCzR+yq+dOwGxndNmPcUL+s VZ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=DAqWhPxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7-20020aa7d407000000b005021f0d5763si2116417edq.682.2023.03.31.09.37.38; Fri, 31 Mar 2023 09:38:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=DAqWhPxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbjCaQHA (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Fri, 31 Mar 2023 12:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjCaQG6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 31 Mar 2023 12:06:58 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14061EA38; Fri, 31 Mar 2023 09:06:56 -0700 (PDT) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32VDr4TF010311; Fri, 31 Mar 2023 18:06:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=selector1; bh=Ac3ViCSx4VTlv+LCUqAH7E7aEYqOJVCoIrcTZkiflLc=; b=DAqWhPxO9f0x4XYX/WTjp22Ou8QoEFOwd4cF6wTMoplIcxfg29fgVidw6j6pm7OaAWlj V6AaPUVl/HSwqaTriFbK2lwq7EYvJaWWU11LCD3wLNJpUYH9NTIiPWX/pE9z7JPMOxLk KRR0PmPUruP+EIJnUZyLumt5M17wXcaRvZEwOBwlUbtPn2kIHEsnDP/DOv67leYw2AXC WvLtyZQnM2jsSItfEyU626TpYI56c/UYAo1p3aDd944l4VVDqpr5AUBa1pwF5K7thwBD GgNyuEUMdmsiNKLHyH/BTSrtvcLu1vNotTa8G66ku0ePySujAIIqxKZkf2AafqQLPIGt oA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3pnw9c27um-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Mar 2023 18:06:48 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E790710002A; Fri, 31 Mar 2023 18:06:41 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DDF282248BA; Fri, 31 Mar 2023 18:06:41 +0200 (CEST) Received: from localhost (10.201.21.178) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 31 Mar 2023 18:06:41 +0200 From: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> To: Bjorn Andersson <andersson@kernel.org>, Mathieu Poirier <mathieu.poirier@linaro.org> CC: <linux-remoteproc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-stm32@st-md-mailman.stormreply.com>, <arnaud.pouliquen@foss.st.com> Subject: [PATCH] remoteproc: stm32_rproc: Add mutex protection for workqueue Date: Fri, 31 Mar 2023 18:06:34 +0200 Message-ID: <20230331160634.3113031-1-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.201.21.178] X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-31_07,2023-03-31_01,2023-02-09_01 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761901997155351991?= X-GMAIL-MSGID: =?utf-8?q?1761901997155351991?= |
Series |
remoteproc: stm32_rproc: Add mutex protection for workqueue
|
|
Commit Message
Arnaud POULIQUEN
March 31, 2023, 4:06 p.m. UTC
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_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 <mathieu.poirier@linaro.org>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
This patch is similar to the issue fixed in
commit 47e6ab07018e ("remoteproc: imx_dsp_rproc: Add mutex protection for workqueue")
---
drivers/remoteproc/stm32_rproc.c | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
On Fri, Mar 31, 2023 at 06:06:34PM +0200, Arnaud Pouliquen wrote: > 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_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 <mathieu.poirier@linaro.org> > Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> > I had forgotten about this issue - applied. > --- > This patch is similar to the issue fixed in > commit 47e6ab07018e ("remoteproc: imx_dsp_rproc: Add mutex protection for workqueue") > --- > 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 7d782ed9e589..f618405cf420 100644 > --- a/drivers/remoteproc/stm32_rproc.c > +++ b/drivers/remoteproc/stm32_rproc.c > @@ -287,8 +287,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.25.1 >
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 7d782ed9e589..f618405cf420 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -287,8 +287,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)