From: Sascha Hauer <s.hauer@pengutronix.de>
To: Han Xu <xhnjupt@gmail.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Richard Weinberger <richard@nod.at>,
Esben Haabendal <esben@geanix.com>,
linux-kernel@vger.kernel.org, Shawn Guo <shawnguo@kernel.org>,
vkoul@kernel.org, Boris Brezillon <boris.brezillon@collabora.com>,
linux-mtd <linux-mtd@lists.infradead.org>,
linux-imx@nxp.com, Miquel Raynal <miquel.raynal@bootlin.com>,
dmaengine@vger.kernel.org, Han Xu <han.xu@nxp.com>,
Fabio Estevam <festevam@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/6] dmaengine: mxs: add the power management functions
Date: Fri, 17 Jan 2020 09:13:06 +0100 [thread overview]
Message-ID: <20200117081306.eeuf3fvph5rb7tjf@pengutronix.de> (raw)
In-Reply-To: <CA+EcR23TCUU83Y7BYX5LCvGAj20+s67n+rWaGR5R9BSMHUH82A@mail.gmail.com>
On Thu, Jan 16, 2020 at 10:36:33AM -0600, Han Xu wrote:
> On Wed, Jan 15, 2020 at 2:03 AM Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > On Wed, Jan 15, 2020 at 05:44:00AM +0800, Han Xu wrote:
> > > add the power management functions and leverage the runtime pm for
> > > system suspend/resume
> > >
> > > Signed-off-by: Han Xu <han.xu@nxp.com>
> > > ---
> > > drivers/dma/mxs-dma.c | 97 +++++++++++++++++++++++++++++++++++++++----
> > > 1 file changed, 90 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> > > index b458f06f9067..251492c5ea58 100644
> > > --- a/drivers/dma/mxs-dma.c
> > > +++ b/drivers/dma/mxs-dma.c
> > > @@ -25,6 +25,7 @@
> > > #include <linux/of_dma.h>
> > > #include <linux/list.h>
> > > #include <linux/dma/mxs-dma.h>
> > > +#include <linux/pm_runtime.h>
> > >
> > > #include <asm/irq.h>
> > >
> > > @@ -39,6 +40,8 @@
> > > #define dma_is_apbh(mxs_dma) ((mxs_dma)->type == MXS_DMA_APBH)
> > > #define apbh_is_old(mxs_dma) ((mxs_dma)->dev_id == IMX23_DMA)
> > >
> > > +#define MXS_DMA_RPM_TIMEOUT 50 /* ms */
> > > +
> > > #define HW_APBHX_CTRL0 0x000
> > > #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)
> > > #define BM_APBH_CTRL0_APB_BURST_EN (1 << 28)
> > > @@ -416,6 +419,7 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
> > > {
> > > struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
> > > struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
> > > + struct device *dev = &mxs_dma->pdev->dev;
> > > int ret;
> > >
> > > mxs_chan->ccw = dma_alloc_coherent(mxs_dma->dma_device.dev,
> > > @@ -431,9 +435,11 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
> > > if (ret)
> > > goto err_irq;
> > >
> > > - ret = clk_prepare_enable(mxs_dma->clk);
> > > - if (ret)
> > > + ret = pm_runtime_get_sync(dev);
> > > + if (ret < 0) {
> > > + dev_err(dev, "Failed to enable clock\n");
> > > goto err_clk;
> >
> > From looking at other DMA drivers I know we are in good company here,
> > but I think this is wrong. Doing pm_runtime_get_sync() in
> > alloc_chan_resources() and going to autosuspend in free_chan_resources()
> > effectively disables runtime_pm as clients normally acquire their
> > channels during driver probe and release them only in driver remove.
>
> Thanks for the comments.
> That's why I moved acquire_dma_resource from the probe to
> runtime_resume in the gpmi driver, this change won't disable the
> runtime_pm function and the incremental counter always balanced.
Yes, that's what I've written a few lines further down:
>
> >
> > In the next patch you release the DMA channels in the GPMI nand drivers
> > runtime_suspend hook just to somehow trigger the runtime_suspend of the
> > DMA driver.
And I consider doing this a crude hack. Here is what I suggested doing
instead:
> >
> > What you should do instead is to make sure the hook runtime_pm to the
> > DMA drivers activity phases, like for example the pl330 driver does.
> > Then you wouldn't have to care about manually putting the DMA driver into
> > suspend from the GPMI NAND driver.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-01-17 8:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 21:43 [PATCH 0/6] gpmi/mxs-dma runtime pm patch set Han Xu
2020-01-14 21:43 ` [PATCH 1/6] dmaengine: mxs: change the way to register probe function Han Xu
2020-01-14 22:13 ` Fabio Estevam
2020-01-14 21:43 ` [PATCH 2/6] dmaengine: mxs: add the remove function Han Xu
2020-01-14 21:44 ` [PATCH 3/6] dmaengine: mxs: add the power management functions Han Xu
2020-01-15 8:02 ` Sascha Hauer
2020-01-16 16:36 ` Han Xu
2020-01-17 8:13 ` Sascha Hauer [this message]
2020-01-14 21:44 ` [PATCH 4/6] dmaengine: mxs: switch from dma_coherent to dma_pool Han Xu
2020-01-15 8:14 ` Sascha Hauer
2020-01-14 21:44 ` [PATCH 5/6] mtd: rawnand: gpmi: refine the runtime pm ops Han Xu
2020-01-15 8:32 ` Sascha Hauer
2020-01-14 21:44 ` [PATCH 6/6] mtd: rawnand: gpmi: set the pinctrl state for suspend/reusme Han Xu
2020-01-17 20:15 ` Esben Haabendal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200117081306.eeuf3fvph5rb7tjf@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=boris.brezillon@collabora.com \
--cc=dmaengine@vger.kernel.org \
--cc=esben@geanix.com \
--cc=festevam@gmail.com \
--cc=han.xu@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=shawnguo@kernel.org \
--cc=vigneshr@ti.com \
--cc=vkoul@kernel.org \
--cc=xhnjupt@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).