From patchwork Fri Jul 8 08:48:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 9220151 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 8C0DE607D9 for ; Fri, 8 Jul 2016 08:41:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79BF2285C7 for ; Fri, 8 Jul 2016 08:41:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E287285CA; Fri, 8 Jul 2016 08:41:19 +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 03C0B285C7 for ; Fri, 8 Jul 2016 08:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753694AbcGHIlS (ORCPT ); Fri, 8 Jul 2016 04:41:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:31305 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751550AbcGHIlQ (ORCPT ); Fri, 8 Jul 2016 04:41:16 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 08 Jul 2016 01:41:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,328,1464678000"; d="scan'208";a="1013022815" Received: from vkoul-udesk7.iind.intel.com (HELO localhost) ([10.223.84.143]) by orsmga002.jf.intel.com with ESMTP; 08 Jul 2016 01:41:13 -0700 Date: Fri, 8 Jul 2016 14:18:24 +0530 From: Vinod Koul To: Zhangfei Gao Cc: "dmaengine@vger.kernel.org" , Daniel Mack Subject: Re: [PATCH 16/32] dmaengine: mmp_pdma: explicitly freeup irq Message-ID: <20160708084823.GS12591@localhost> References: <1467730478-9696-1-git-send-email-vinod.koul@intel.com> <1467730478-9696-17-git-send-email-vinod.koul@intel.com> <20160708035141.GJ12591@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Jul 08, 2016 at 11:54:17AM +0800, Zhangfei Gao wrote: > On 8 July 2016 at 11:51, Vinod Koul wrote: > > On Fri, Jul 08, 2016 at 10:40:42AM +0800, Zhangfei Gao wrote: > >> Dear Vinod > >> > >> On 5 July 2016 at 22:54, Vinod Koul wrote: > >> > dmaengine device should explicitly call devm_free_irq() when using > >> > devm_reqister_irq(). > >> > > >> > The irq is still ON when devices remove is executed and irq should be > >> > quiesced before remove is completed. > >> > > >> > Signed-off-by: Vinod Koul > >> > Cc: Zhangfei Gao > >> > Cc: Daniel Mack > >> > --- > >> > drivers/dma/mmp_pdma.c | 17 +++++++++++++++++ > >> > 1 file changed, 17 insertions(+) > >> > > >> > diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c > >> > index 56f1fd68b620..975bc4bf525b 100644 > >> > --- a/drivers/dma/mmp_pdma.c > >> > +++ b/drivers/dma/mmp_pdma.c > >> > @@ -931,6 +931,23 @@ static void dma_do_tasklet(unsigned long data) > >> > static int mmp_pdma_remove(struct platform_device *op) > >> > { > >> > struct mmp_pdma_device *pdev = platform_get_drvdata(op); > >> > + struct mmp_pdma_phy *phy; > >> > + int i, irq = 0, irq_num = 0; > >> > + > >> > + > >> > + irq = platform_get_irq(op, 0); > >> > + devm_free_irq(&op->dev, irq, pdev); > >> > + > >> > + for (i = 0; i < pdev->dma_channels; i++) { > >> > + if (platform_get_irq(op, i) > 0) > >> > + irq_num++; > >> > + } > >> > + > >> > + for (i = 0; i < pdev->dma_channels; i++) { > >> > + phy = &pdev->phy[i]; > >> > + irq = (irq_num != pdev->dma_channels) ? 0 : platform_get_irq(op, i); > >> > + devm_free_irq(&op->dev, irq, phy); > >> > + } > >> > > >> Is it possible irq=0 is freed twice? > > > > Yes I see the point, we should do: > > > > for (i = 0; i < pdev->dma_channels; i++) { > > if (platform_get_irq(op, i) > 0) > > irq_num++; > > } > > > > if (irq_num != pdev->dma_channels) { > > irq = platform_get_irq(op, 0); > > devm_free_irq(&op->dev, irq, pdev); > > } > > else { > > for (i = 0; i < pdev->dma_channels; i++) { > > phy = &pdev->phy[i]; > > irq = (irq_num != pdev->dma_channels) ? 0 : platform_get_irq(op, i); > > here irq = platform_get_irq(op, i); > should be OK. sounds good to me comitting this now: -- >8 -- the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Zhangfei Gao diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c index 56f1fd68b620..f4b25fb0d040 100644 --- a/drivers/dma/mmp_pdma.c +++ b/drivers/dma/mmp_pdma.c @@ -931,6 +931,25 @@ static void dma_do_tasklet(unsigned long data) static int mmp_pdma_remove(struct platform_device *op) { struct mmp_pdma_device *pdev = platform_get_drvdata(op); + struct mmp_pdma_phy *phy; + int i, irq = 0, irq_num = 0; + + + for (i = 0; i < pdev->dma_channels; i++) { + if (platform_get_irq(op, i) > 0) + irq_num++; + } + + if (irq_num != pdev->dma_channels) { + irq = platform_get_irq(op, 0); + devm_free_irq(&op->dev, irq, pdev); + } else { + for (i = 0; i < pdev->dma_channels; i++) { + phy = &pdev->phy[i]; + irq = platform_get_irq(op, i); + devm_free_irq(&op->dev, irq, phy); + } + } -- ~Vinod -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in