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 01916CE7B08 for ; Thu, 28 Sep 2023 07:38:48 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YomWGI4BQbT21t6tTcS7YU7G/iISrrbdkkXTBeND6vo=; b=jXHP0PXpzKR4UY 4Y0vdeitYQCZgsGOAlXdgFgl52gWmCefp9ZkGVwfHnG8Yvedh9eyaLmwjSrLT/ymAsWKPb8EUHXRk TJ5lQ1JPzqAL/ml96OXrfg2gJoSKs4nPsfQDzTZiFMlVsGHpB7RPUQ7juwnMU1KEWXRYiMPV0ACb9 7ggk8qJvpUtQK0bBe6Zb6FrgrN+ljGwwgf+9n0xLvLkveyOWytfWNDw1JoZOIFdpLyH46hpMII3kG b5f8Cw0s7Ul5KbG0NQJeeFrqkZxr3AhUD9InMQbVYdx2uaHWt+zBCyRRQQkl0Py9Csd5FOd/m8bSq 1r8yuUZww1t4XoOmt3QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qllbM-002Xbf-2J; Thu, 28 Sep 2023 07:38:24 +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 1qllbJ-002Xak-36 for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 07:38:23 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DE30161B89; Thu, 28 Sep 2023 07:38:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE061C433C8; Thu, 28 Sep 2023 07:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695886700; bh=UhY6cOElhzlwnHpIfwIH6wNFErVALugCIYKMSXrO0/A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uuibvGvND9tKZ81BkY98N7O4z1zCNQv6dU+vJh1VbcTuQ5wBh5PEzyAVy436X0Wki alF66Xe+im1N9jdkv85eRv55IxRzrPQ62uqCgdUqZvpOgNItpyH3JDkYVeknYoh8eB MZXCv52p5qwk2D6CBopufN+ctKHtNk6LP4YIuI6r8IYGr0xjbXbpD4/xrmuxfXZxV4 UKR5c3VWYVowrJeTJaGHDONT5FVVNuxYyztWLT6AA0ejYs8n0rlPTrvhYcO7fE0JH8 X4eM6kaDCPqKHDSaCcPPBrNtx20FNqhE3xyRzgnjoDSmPM5npWIZsTJStt5WXdKTPA AjZ8PhBnZ5wFw== Date: Thu, 28 Sep 2023 13:08:15 +0530 From: Vinod Koul To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Chengfeng Ye , gregkh@linuxfoundation.org, jirislaby@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, sorganov@gmail.com, festevam@gmail.com, ilpo.jarvinen@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, dmaengine@vger.kernel.org Subject: Re: [PATCH RESEND] serial: imx: Fix potential deadlock on sport->port.lock Message-ID: References: <20230927181939.60554-1-dg573847474@gmail.com> <20230928060749.qzs6qgcesstclqqk@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230928060749.qzs6qgcesstclqqk@pengutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_003822_040295_CF61FF57 X-CRM114-Status: GOOD ( 24.06 ) 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 28-09-23, 08:07, Uwe Kleine-K=F6nig wrote: > [Cc +=3D Vinod Koul, dmaengine@vger.kernel.org] > = > Hello, > = > On Wed, Sep 27, 2023 at 06:19:39PM +0000, Chengfeng Ye wrote: > > As &sport->port.lock is acquired under irq context along the following > > call chain from imx_uart_rtsint(), other acquisition of the same lock > > inside process context or softirq context should disable irq avoid doub= le > > lock. > > = > > > > = > > imx_uart_dma_rx_callback() > > --> spin_lock(&sport->port.lock) > > > > --> imx_uart_rtsint() > > --> spin_lock(&sport->port.lock) > > = > > This flaw was found by an experimental static analysis tool I am > > developing for irq-related deadlock. > = > Ah, I understood before that you really experienced that deadlock (or a > lockdep splat). I didn't test anything, but I think the > imx_uart_dma_rx_callback() is called indirectly by > sdma_update_channel_loop() which is called in irq context. I don't know > if this is the case for all dma drivers?! > = > @Vinod: Maybe you can chime in here: Is a dma callback always called in > irq context? Not in callback but a tasklet context. The DMA irq handler is supposed to use a tasklet for invoking the callback > If yes, this patch isn't needed. Otherwise it might be a good idea to > not use the special knowledge and switch to spin_lock_irqsave() as > suggested. > = > > To prevent the potential deadlock, the patch uses spin_lock_irqsave() > > on the &sport->port.lock inside imx_uart_dma_rx_callback() to prevent > > the possible deadlock scenario. > > = > > Signed-off-by: Chengfeng Ye > = > If we agree this patch is a good idea, we can add: > = > Fixes: 496a4471b7c3 ("serial: imx: work-around for hardware RX flood") > = > Thanks > Uwe > = > -- = > Pengutronix e.K. | Uwe Kleine-K=F6nig = | > Industrial Linux Solutions | https://www.pengutronix.de/ | -- = ~Vinod _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel