From patchwork Wed Feb 3 15:03:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 76713 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o13F3R1e004986 for ; Wed, 3 Feb 2010 15:03:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755869Ab0BCPDn (ORCPT ); Wed, 3 Feb 2010 10:03:43 -0500 Received: from mail.gmx.net ([213.165.64.20]:56240 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754635Ab0BCPDn (ORCPT ); Wed, 3 Feb 2010 10:03:43 -0500 Received: (qmail invoked by alias); 03 Feb 2010 15:03:41 -0000 Received: from p57BD1A11.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.26.17] by mail.gmx.net (mp057) with SMTP; 03 Feb 2010 16:03:41 +0100 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX184wIZnULo4dNpD/P/qnLY3pD1AJvpO0AVyUG4yY2 qzOtw4G/QI6sbO Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1Ncglm-0004Ja-Jf; Wed, 03 Feb 2010 16:03:54 +0100 Date: Wed, 3 Feb 2010 16:03:54 +0100 (CET) From: Guennadi Liakhovetski To: "linux-sh@vger.kernel.org" cc: Dan Williams , Paul Mundt Subject: [PATCH 3/4] dmaengine: add runtime PM support to the shdma driver In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.56000000000000005 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 03 Feb 2010 15:03:44 +0000 (UTC) diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c index 3498cab..7e7ce10 100644 --- a/drivers/dma/shdma.c +++ b/drivers/dma/shdma.c @@ -24,7 +24,10 @@ #include #include #include +#include + #include + #include "shdma.h" /* DMA descriptor control */ @@ -266,6 +269,8 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) struct sh_desc *desc; struct sh_dmae_slave *param = chan->private; + pm_runtime_get_sync(sh_chan->dev); + /* * This relies on the guarantee from dmaengine that alloc_chan_resources * never runs concurrently with itself or free_chan_resources. @@ -308,6 +313,9 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) } spin_unlock_bh(&sh_chan->desc_lock); + if (!sh_chan->descs_allocated) + pm_runtime_put(sh_chan->dev); + return sh_chan->descs_allocated; } @@ -319,6 +327,7 @@ static void sh_dmae_free_chan_resources(struct dma_chan *chan) struct sh_dmae_chan *sh_chan = to_sh_chan(chan); struct sh_desc *desc, *_desc; LIST_HEAD(list); + int descs = sh_chan->descs_allocated; dmae_halt(sh_chan); @@ -339,6 +348,9 @@ static void sh_dmae_free_chan_resources(struct dma_chan *chan) spin_unlock_bh(&sh_chan->desc_lock); + if (descs > 0) + pm_runtime_put(sh_chan->dev); + list_for_each_entry_safe(desc, _desc, &list, node) kfree(desc); } @@ -920,6 +932,9 @@ static int __init sh_dmae_probe(struct platform_device *pdev) /* platform data */ shdev->pdata = pdata; + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + /* reset dma controller */ err = sh_dmae_rst(shdev); if (err) @@ -970,6 +985,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev) goto chan_probe_err; } + pm_runtime_put(&pdev->dev); + platform_set_drvdata(pdev, shdev); dma_async_device_register(&shdev->common); @@ -982,6 +999,7 @@ eirq_err: free_irq(errirq, shdev); rst_err: + pm_runtime_put(&pdev->dev); if (dmars) iounmap(shdev->dmars); emapdmars: @@ -1015,6 +1033,8 @@ static int __exit sh_dmae_remove(struct platform_device *pdev) /* channel data remove */ sh_dmae_chan_remove(shdev); + pm_runtime_disable(&pdev->dev); + if (shdev->dmars) iounmap(shdev->dmars); iounmap(shdev->chan_reg);