From patchwork Tue Sep 26 12:40:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Lesne X-Patchwork-Id: 9971933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4608560365 for ; Tue, 26 Sep 2017 12:41:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE3E828F96 for ; Tue, 26 Sep 2017 12:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F19C28FA0; Tue, 26 Sep 2017 12:41:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE58C28FAC for ; Tue, 26 Sep 2017 12:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934771AbdIZMlH (ORCPT ); Tue, 26 Sep 2017 08:41:07 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:65153 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936671AbdIZMlF (ORCPT ); Tue, 26 Sep 2017 08:41:05 -0400 Received: from localhost.localdomain ([109.190.217.251]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.168]) with ESMTPSA (Nemesis) id 0MhPvC-1dj1NA0zMA-00Ma2n; Tue, 26 Sep 2017 14:40:58 +0200 From: Sylvain Lesne To: dmaengine@vger.kernel.org Cc: vinod.koul@intel.com, sr@denx.de Subject: [PATCH] dmaengine: altera: submit descriptors in tasklet Date: Tue, 26 Sep 2017 14:40:57 +0200 Message-Id: <1506429657-26048-1-git-send-email-lesne@alse-fr.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-Provags-ID: V03:K0:pl5WCNKH+tCZrpqOhYbvSri6cCID6z8TlhpQa+AayEEzOvouvDE oFohcJ7gtVDWmFtANIq3UqRNtkOiTBBvJnypwV7NwwNxBaECFz/JwjBNWBxV7+83XCVXox+ 5V5PpmkClzloa9NPS//cinW12r2KmVEi6x2bVOJKTS/B1hcWCC+TNmnStKh42sfMPUV2wje pn7VWKxslP4hoS6BQ7VWw== X-UI-Out-Filterresults: notjunk:1; V01:K0:xtHjJWgshxE=:ut+8D8azf10c0rS6g0gnam xnmngYS9Ktm4Er/MEjPdDAORLXSAqL1NdzyD8GA9K/O6LHCBVwYfaPZbzo3KBUXPSf/giSl3O glo6BAWx9TFKpTqEsILb2cBgaO4lQxEJ55p8eXpUMuZOQPAc7CfkgnGU6WZZQKdaQ7IHo3Bo+ 9TWxf3rJOeNcXT9S1nF7J7rx9RsVG040U07ZxXWEkDC9FSB55dVrlEpT7CTrRZoiSU/HAITHB qpTEi+Ac/f/8soVWtzJjmokNBFEs2EepxUaM5D3KtREE8cLjM5ywawIK+ttyK0rFAdTF5llIQ m+C/jtIQdAIED4haxemXDOimD+ofaYzyB7ezFS3EpuCMfmq8LQoU/9BrfBF2YCtK8nV1PyURg 0UQX7ZEBs/OPprs50+wPHK2DzzcVHnGgmEZqispK7NgcCrB2iLJ3bk/hp791li+0rJRV2FZRA 4CX337pUJ+l4Gcq1vTdm2YNhuOMlDKRaFby8v6DmaPIJHnGxyZBUOuX2VM4kI4Qj2MC0Qmqoj onszMYEeUXwmCw/Jc4erff+AONzS5CdOBL0mo+3vngxmQKAvMwuxuEHAGCHSdrhqtBSgTsEiH VQiE6JEziSLmdGCEdxf6z55FkBfu32HO5wl8gQgOq2w+4Lc75m7dYpJKEarKc3sCcl4AHHHbD a/2ze18M1adEKSswrhGKEzoOSs/jpqJQJl1CjzMHdKNF/9gqouG6Jn8FKjIvOTsIu6bAXbzKI oVf5Mpq6lwQZvJ30KDa06z4CKUN/kMjIqwOn1g== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Submitting new descriptors in the IRQ handler requires the lock to be held, which in turn should require interrupts to be disabled each time this lock is acquired in process context, which is not currently done. To reduce lock complexity and avoid deadlocks, move the new descriptor submission in the tasklet. Signed-off-by: Sylvain Lesne --- Hi Stefan, here is a patch to do that. I tested it on my setup, and can confirm that I cannot reproduce the deadlock anymore! Since it's just reverting to code from your v2, I think I should add your signed-off-by as well, right? --- drivers/dma/altera-msgdma.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c index 35cbf2365f68..615333cf6abd 100644 --- a/drivers/dma/altera-msgdma.c +++ b/drivers/dma/altera-msgdma.c @@ -704,6 +704,10 @@ static void msgdma_tasklet(unsigned long data) msgdma_chan_desc_cleanup(mdev); } + /* Start next transfer if the DMA controller is idle */ + if (mdev->idle) + msgdma_start_transfer(mdev); + spin_unlock(&mdev->lock); } @@ -720,13 +724,8 @@ static irqreturn_t msgdma_irq_handler(int irq, void *data) u32 status; status = ioread32(mdev->csr + MSGDMA_CSR_STATUS); - if ((status & MSGDMA_CSR_STAT_BUSY) == 0) { - /* Start next transfer if the DMA controller is idle */ - spin_lock(&mdev->lock); + if ((status & MSGDMA_CSR_STAT_BUSY) == 0) mdev->idle = true; - msgdma_start_transfer(mdev); - spin_unlock(&mdev->lock); - } tasklet_schedule(&mdev->irq_tasklet);