From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09AB0C77B60 for ; Mon, 1 May 2023 03:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=caX8H2pd75uUjyqMUkzEa6NtAtgvYLIUHKRWr6dTInw=; b=dyWLSlpfBB8nAa vDkwdJWncmIJHCEMCLpJEdWSIbR7txR3HTEzIDOsnj6WcXZdfH6GeBzpm6R2wtzLdtB5ydoyQun4L ZJkDx9QZJ+YwUsyit2ebb1hUEKlwwd6MJChCqShckFqxnHI5dnDGWWtvtZMicmSe58BLJaNN6xrJE otXGZBoHguV3taE1/eHSDGXZiNbMPbPHaKlb86gyXtWcjHZvjiP/XmlMiF6ohh++h/THMvXwzrF9j d7B8KL1xBAsQW+kfEyDAJ2re5li094uVVMoCWmHjBki8aaP9dQIz/7D+507AFMMpTJDnhnMSjGwYA tOcAh1TsPVsO5TzQQEuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ptJra-00F90B-2s; Mon, 01 May 2023 03:06:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ptJrQ-00F8tv-2Q for linux-arm-kernel@lists.infradead.org; Mon, 01 May 2023 03:05:58 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A67461765; Mon, 1 May 2023 03:05:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C05CC4339E; Mon, 1 May 2023 03:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682910355; bh=L7TaH2CVnBpQ3FgRQFzJASy56Np5ekKgT/J9X7fsE+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrknC49X/Fri5KbYQ6+XLNmQRFRUeQxFI0SwoQ/U3PKlxmObPEAlNlyA8EmYf83jV CrOwcedalcZ6t0gY1R/Wqr1Vt3dnikokSrsTTs40/LgPy5/thIwUF8gV6men4EBtOJ Nmx0ZVj5ft6r85dbwIFAc19bLWRNFGtcPc4bivDqHBv7ytSs9+DlZ7h6ZTmvqDDFCC Luq8jqKtvhLTJ6LlAbhQc4iPjWEw4Gt0nfohBXle8AnuRKd4ixkDiRHNUQnvkt2cb4 AJ8eK1YIbmlM4sw/53/EEu/ptbVfXtNrjoCt2oh0PnRK4gim5dRnK7uWbdaCFTNfkA lFy3zeg7crosA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnaud Pouliquen , Mathieu Poirier , Sasha Levin , andersson@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-remoteproc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 07/12] remoteproc: stm32_rproc: Add mutex protection for workqueue Date: Sun, 30 Apr 2023 23:05:33 -0400 Message-Id: <20230501030540.3254928-7-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501030540.3254928-1-sashal@kernel.org> References: <20230501030540.3254928-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230430_200556_834424_5AB22378 X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnaud Pouliquen [ Upstream commit 35bdafda40cc343ad2ba2cce105eba03a70241cc ] 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 Signed-off-by: Sasha Levin --- 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 d2414cc1d90d6..659b747e182d5 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -297,8 +297,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.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel