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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 287AFC04A94 for ; Wed, 26 Jul 2023 15:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234500AbjGZP5Z (ORCPT ); Wed, 26 Jul 2023 11:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233264AbjGZP5X (ORCPT ); Wed, 26 Jul 2023 11:57:23 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E90A4100 for ; Wed, 26 Jul 2023 08:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:From:References:Cc:To: MIME-Version:Date:Message-ID:content-disposition; bh=4QVwg/3buKSKa87Kcb2VqaMkmqvy97Dgt5k/CEvT8aQ=; b=heBCf9Bwkfy9wEwW2XMdjOiYW5 zLEwoiA+XKTBS9uzuU2MaAA/esjk7A5WciR4XIjg20XBNfvqswFXaY8N+KiFjo1TW6XdQDwSEWvGl 1ZC70U/NnmlNfFql1lJ92MS1Fjae6kjsIG8V01ayjngNsvoljymDw39ZBXuPTDLg/OYD3J7INrQ5p lGoI48P+v7yQbUCa2jKAwbWBedwKXXly6pslTWyCAZayqtBthXYaKxlOjJ/GtJ4cmNf6C6il3mRVD B+2TRn0lysrZP8Em/dpRF08Ik7INqpgJ7FCvsuSfbuJG+BuKj/FczJq7AD/LLq8Y2WohlEFJ3/kbc Sx9i2jTw==; Received: from d75-158-34-12.abhsia.telus.net ([75.158.34.12] helo=[192.168.11.155]) by ale.deltatee.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qOgt3-00B3w0-6K; Wed, 26 Jul 2023 09:57:18 -0600 Message-ID: <9378e69f-2bd4-9d8d-c736-b8799f6ebecc@deltatee.com> Date: Wed, 26 Jul 2023 09:57:16 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Chengfeng Ye , vkoul@kernel.org Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230726104827.60382-1-dg573847474@gmail.com> From: Logan Gunthorpe In-Reply-To: <20230726104827.60382-1-dg573847474@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 75.158.34.12 X-SA-Exim-Rcpt-To: dg573847474@gmail.com, vkoul@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH] dmaengine: plx_dma: Fix potential deadlock on &plxdev->ring_lock X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-07-26 04:48, Chengfeng Ye wrote: > As plx_dma_process_desc() is invoked by both tasklet plx_dma_desc_task() > under softirq context and plx_dma_tx_status() callback that executed under > process context, the lock aquicision of &plxdev->ring_lock inside > plx_dma_process_desc() should disable irq otherwise deadlock could happen > if the irq preempts the execution of process context code while the lock > is held in process context on the same CPU. > > Possible deadlock scenario: > plx_dma_tx_status() > -> plx_dma_process_desc() > -> spin_lock(&plxdev->ring_lock) > > -> plx_dma_desc_task() > -> plx_dma_process_desc() > -> spin_lock(&plxdev->ring_lock) (deadlock here) > > This flaw was found by an experimental static analysis tool I am developing > for irq-related deadlock. > > The tentative patch fixes the potential deadlock by spin_lock_irqsave() in > plx_dma_process_desc() to disable irq while lock is held. > > Signed-off-by: Chengfeng Ye Makes sense. Thanks! Reviewed-by: Logan Gunthorpe Logan