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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF169C49EA5 for ; Thu, 24 Jun 2021 15:36:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CFBA613EB for ; Thu, 24 Jun 2021 15:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232399AbhFXPi0 (ORCPT ); Thu, 24 Jun 2021 11:38:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232398AbhFXPi0 (ORCPT ); Thu, 24 Jun 2021 11:38:26 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66561C061574 for ; Thu, 24 Jun 2021 08:36:06 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwROe-0005zk-Uh; Thu, 24 Jun 2021 17:36:04 +0200 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lwROe-0006MU-3W; Thu, 24 Jun 2021 17:36:04 +0200 Date: Thu, 24 Jun 2021 17:36:04 +0200 From: Michael Tretter To: dmaengine@vger.kernel.org, vkoul@kernel.org Cc: michal.simek@xilinx.com, appanad@xilinx.com, linux-arm-kernel@lists.infradead.org Subject: Re: dmaengine: zynqmp_dma: lockdep warning Message-ID: <20210624153604.GA24339@pengutronix.de> References: <20210601130108.GA12967@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210601130108.GA12967@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 17:35:24 up 126 days, 18:59, 125 users, load average: 0.02, 0.07, 0.12 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dmaengine@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org On Tue, 01 Jun 2021 15:01:08 +0200, Michael Tretter wrote: > I get a lockdep warning in the zynqmp dma driver and I am not entirely sure > how to fix it. > > The code in drivers/dma/xilinx/zynqmp_dma.c looks as follows: > > 604 static void zynqmp_dma_chan_desc_cleanup(struct zynqmp_dma_chan *chan) > 605 { > [...] > 612 callback = desc->async_tx.callback; > 613 callback_param = desc->async_tx.callback_param; > 614 if (callback) { > 615 spin_unlock(&chan->lock); > 616 callback(callback_param); > 617 spin_lock(&chan->lock); > 618 } > [...] > 626 } > [...] > 747 static void zynqmp_dma_do_tasklet(struct tasklet_struct *t) > 748 { > [...] > 753 spin_lock_irqsave(&chan->lock, irqflags); > [...] > 763 while (count) { > 764 zynqmp_dma_complete_descriptor(chan); > 765 zynqmp_dma_chan_desc_cleanup(chan); > 766 count--; > 767 } > [...] > 773 spin_unlock_irqrestore(&chan->lock, irqflags); > 774 } > > Lockdep reports that in line 617 spin_lock() is called from a non-hardirq > context, while the same lock is used from a hardirq context. During runtime, > the sequence is as follows: > > line 753: acquire lock and disable interrupts > line 615: release lock without enabling interrupts > line 617: re-acquire lock with still disabled interrupts > line 773: released lock and re-enable interrupts > > Is this a false positive of lockdep, because it does not know that the irqs > are still disabled in line 617? Is it actually OK to leave interrupts disabled > over a spin_unlock() -> spin_lock() sequence or is this a problem? > > Additionally, the lock is held for the entire tasklet that handles the > finished dma transfer. This is conflict to the rule that spin locks should be > held only for a short time. Is it necessary to hold the lock that long? I > understand that the lock is only used to protect the descriptor lists and it > would be better to only get the lock when descriptors are moved between lists. > > Any guidance would be helpful. Gentle ping. Michael 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 X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24A31C49EA5 for ; Thu, 24 Jun 2021 15:37:37 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E935D613DA for ; Thu, 24 Jun 2021 15:37:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E935D613DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=7cYLxVNi4kASYtwEyOVMF2rQoVWsrg+H5wpG0aPD9rQ=; b=VrxT1mm7BZshnA l1j+sYj3CV105xPzvnBuvc9/YVRngmCmsDjf/I6dFMiGKqlZky2XJE3OdN/prc7XTfSBDvyiHJ8bb eiw3WpqZQk3oDsdzSfyH7nN9Glj2rJB/mZlTJPwOlqtxQAs/XWnXYdCQLe9XwR8skxaqy8pvKbgSK QPxERn0jracJMaEeyNARwVHq8nsfKiswKZ+Oh6pjAIioHaSLSzQnjgOevaAx29TVTeoRA9xNOKyTh WxxvLCxLHuD54lmjX9OpccDym4JRwiYm5lV7PtKlCBVRREC76gyRMcnn0vX1rP2sPH9skyiUepHWY 68EJnglQ3S70fJx/7gVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwROn-00FH5X-DA; Thu, 24 Jun 2021 15:36:13 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwROj-00FH19-Pl for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 15:36:11 +0000 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwROe-0005zk-Uh; Thu, 24 Jun 2021 17:36:04 +0200 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lwROe-0006MU-3W; Thu, 24 Jun 2021 17:36:04 +0200 Date: Thu, 24 Jun 2021 17:36:04 +0200 From: Michael Tretter To: dmaengine@vger.kernel.org, vkoul@kernel.org Cc: michal.simek@xilinx.com, appanad@xilinx.com, linux-arm-kernel@lists.infradead.org Subject: Re: dmaengine: zynqmp_dma: lockdep warning Message-ID: <20210624153604.GA24339@pengutronix.de> References: <20210601130108.GA12967@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210601130108.GA12967@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 17:35:24 up 126 days, 18:59, 125 users, load average: 0.02, 0.07, 0.12 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_083609_879683_8912CB39 X-CRM114-Status: GOOD ( 25.43 ) 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 On Tue, 01 Jun 2021 15:01:08 +0200, Michael Tretter wrote: > I get a lockdep warning in the zynqmp dma driver and I am not entirely sure > how to fix it. > > The code in drivers/dma/xilinx/zynqmp_dma.c looks as follows: > > 604 static void zynqmp_dma_chan_desc_cleanup(struct zynqmp_dma_chan *chan) > 605 { > [...] > 612 callback = desc->async_tx.callback; > 613 callback_param = desc->async_tx.callback_param; > 614 if (callback) { > 615 spin_unlock(&chan->lock); > 616 callback(callback_param); > 617 spin_lock(&chan->lock); > 618 } > [...] > 626 } > [...] > 747 static void zynqmp_dma_do_tasklet(struct tasklet_struct *t) > 748 { > [...] > 753 spin_lock_irqsave(&chan->lock, irqflags); > [...] > 763 while (count) { > 764 zynqmp_dma_complete_descriptor(chan); > 765 zynqmp_dma_chan_desc_cleanup(chan); > 766 count--; > 767 } > [...] > 773 spin_unlock_irqrestore(&chan->lock, irqflags); > 774 } > > Lockdep reports that in line 617 spin_lock() is called from a non-hardirq > context, while the same lock is used from a hardirq context. During runtime, > the sequence is as follows: > > line 753: acquire lock and disable interrupts > line 615: release lock without enabling interrupts > line 617: re-acquire lock with still disabled interrupts > line 773: released lock and re-enable interrupts > > Is this a false positive of lockdep, because it does not know that the irqs > are still disabled in line 617? Is it actually OK to leave interrupts disabled > over a spin_unlock() -> spin_lock() sequence or is this a problem? > > Additionally, the lock is held for the entire tasklet that handles the > finished dma transfer. This is conflict to the rule that spin locks should be > held only for a short time. Is it necessary to hold the lock that long? I > understand that the lock is only used to protect the descriptor lists and it > would be better to only get the lock when descriptors are moved between lists. > > Any guidance would be helpful. Gentle ping. Michael _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel