Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3055198rdh; Thu, 28 Sep 2023 00:45:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWXpnYC0Dr06Ey8fY/TpVSOHb+gSvHyonpS+QrJ6x0MIW1DSMuhZQFGhI7H2Pd0Q6BszOs X-Received: by 2002:a17:903:246:b0:1c0:b84d:3f73 with SMTP id j6-20020a170903024600b001c0b84d3f73mr411191plh.53.1695887107524; Thu, 28 Sep 2023 00:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695887107; cv=none; d=google.com; s=arc-20160816; b=ORpU46rDsOm8yOdr1GYQ6P7qEhVg76k1fwDttV3rylvOrU9hvlj0Vov4XvwW6ASJzK uyRM6eLLuRtdROBvbty75gCVowXrlOWGmk/mTIDcMbicigvsJzfae3nb3ZXFsDvu+Vgt lz12p5g9ownMhr/V/ZNqapctqMn6oGkWJWbSBG39QIKD/HKEs3ykE6pov2WaVZYS31Oe bNfAf0KOw2sr6FNQI+zrz8KYvNpnuFLA7jJ3d1yjGoe2xjDGHBYnjFqRAyn5kgnHSxW3 4LlZ7UlzP1e9bm5qkA45nALUDfxL7B3wzSTKrrhT8f2ZxlDZdk4locxlR52ba+VQFjiY l8RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=E2BOUKoy+nwm7d1IaJoZ8Y7eq7uVyaR5QT8EVzn8vc0=; fh=9OK0jQjNpDMmp8JU/m2bl2EUTy0tlUMtkgOIK8kJoC8=; b=R1tMTBiSzG/oarJzcW3N05EaDeqQ2+8cwcUdgUlW7wW2UvWwT1K8ohy9dhlaXjgwru LlX6FStRQRnQnqL2YA+u1mG3K56pCQqVP0KXpVPwdSh7Kzi4jd/77fAqXuYB5Q3bGi8C kZVVo6RKcMqcflEC5o1ugwrOMTPojj5u6hbeot+4UFuHGO1RVtUyBK6AbxZDasXnpt/N tfQSHpVAyvQ+Ib8+AFF90ZhFG2eWiTetmYRVnfkCumwM8hpkw8QRIYY7Z37+wlMLO7Sf XYjbY5T6ZMnnNP6noNINz/n4V+6uD1qGPWaw8EuzkhTNGgmV5MHZ8ns2yhWiga16eSxB fGaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uuibvGvN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id kr13-20020a170903080d00b001bb9533b968si16797182plb.408.2023.09.28.00.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 00:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uuibvGvN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 46BA3815839D; Thu, 28 Sep 2023 00:38:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjI1HiY (ORCPT + 99 others); Thu, 28 Sep 2023 03:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230044AbjI1HiW (ORCPT ); Thu, 28 Sep 2023 03:38:22 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DC8392; Thu, 28 Sep 2023 00:38:21 -0700 (PDT) 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230928060749.qzs6qgcesstclqqk@pengutronix.de> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 28 Sep 2023 00:38:52 -0700 (PDT) On 28-09-23, 08:07, Uwe Kleine-K?nig wrote: > [Cc += 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 double > > 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?nig | > Industrial Linux Solutions | https://www.pengutronix.de/ | -- ~Vinod