diff mbox

[7/7] usb: dwc3: exynos: add pm_runtime support

Message ID 20131213195618.GG5292@saruman.home (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi Dec. 13, 2013, 7:56 p.m. UTC
On Fri, Dec 13, 2013 at 02:01:32PM +0900, Anton Tikhomirov wrote:
> Hi Felipe,
> 
> > -static int dwc3_exynos_suspend(struct device *dev)
> > +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos)
> >  {
> > -	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > -
> >  	clk_disable(exynos->clk);
> > 
> >  	return 0;
> >  }
> > 
> > +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos)
> > +{
> > +	return clk_enable(exynos->clk);
> > +}
> > +
> > +static int dwc3_exynos_suspend(struct device *dev)
> > +{
> > +	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > +
> > +	return __dwc3_exynos_suspend(exynos);
> 
> If dwc3-exynos is runtime suspended, the clock will be disabled
> second time here (unbalanced clk_enable/clk_disable).

I don't get what you mean but there is something that probably needs
fixing, I guess below makes it better:


Is that what you meant ?

Comments

Felipe Balbi Dec. 13, 2013, 8:18 p.m. UTC | #1
On Fri, Dec 13, 2013 at 01:56:18PM -0600, Felipe Balbi wrote:
> On Fri, Dec 13, 2013 at 02:01:32PM +0900, Anton Tikhomirov wrote:
> > Hi Felipe,
> > 
> > > -static int dwc3_exynos_suspend(struct device *dev)
> > > +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos)
> > >  {
> > > -	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > > -
> > >  	clk_disable(exynos->clk);
> > > 
> > >  	return 0;
> > >  }
> > > 
> > > +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos)
> > > +{
> > > +	return clk_enable(exynos->clk);
> > > +}
> > > +
> > > +static int dwc3_exynos_suspend(struct device *dev)
> > > +{
> > > +	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > > +
> > > +	return __dwc3_exynos_suspend(exynos);
> > 
> > If dwc3-exynos is runtime suspended, the clock will be disabled
> > second time here (unbalanced clk_enable/clk_disable).
> 
> I don't get what you mean but there is something that probably needs
> fixing, I guess below makes it better:
> 
> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
> index c93919a..1e5720a 100644
> --- a/drivers/usb/dwc3/dwc3-exynos.c
> +++ b/drivers/usb/dwc3/dwc3-exynos.c
> @@ -218,6 +218,9 @@ static int dwc3_exynos_suspend(struct device *dev)
>  {
>  	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
>  
> +	if (pm_runtime_suspended(dev))
> +		return 0;
> +
>  	return __dwc3_exynos_suspend(exynos);
>  }
>  
> 
> Is that what you meant ?

note, however, that this is *not* a case where we would fall today. See
that we pm_runtime_get() in probe and only pm_runtime_put() during
remove. So there would never be a case where we would try system suspend
while device was already runtime suspended.

I have fixed all patches in my testing/next branch anyway, just to make
sure we're "idiot-proof" when it comes to implementing real runtime pm
later on :-)

cheers
Anton Tikhomirov Dec. 16, 2013, 2:31 a.m. UTC | #2
Hi Felipe,

> On Fri, Dec 13, 2013 at 02:01:32PM +0900, Anton Tikhomirov wrote:
> > Hi Felipe,
> >
> > > -static int dwc3_exynos_suspend(struct device *dev)
> > > +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos)
> > >  {
> > > -	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > > -
> > >  	clk_disable(exynos->clk);
> > >
> > >  	return 0;
> > >  }
> > >
> > > +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos)
> > > +{
> > > +	return clk_enable(exynos->clk);
> > > +}
> > > +
> > > +static int dwc3_exynos_suspend(struct device *dev)
> > > +{
> > > +	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > > +
> > > +	return __dwc3_exynos_suspend(exynos);
> >
> > If dwc3-exynos is runtime suspended, the clock will be disabled
> > second time here (unbalanced clk_enable/clk_disable).
> 
> I don't get what you mean but there is something that probably needs
> fixing, I guess below makes it better:
> 
> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-
> exynos.c
> index c93919a..1e5720a 100644
> --- a/drivers/usb/dwc3/dwc3-exynos.c
> +++ b/drivers/usb/dwc3/dwc3-exynos.c
> @@ -218,6 +218,9 @@ static int dwc3_exynos_suspend(struct device *dev)
>  {
>  	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> 
> +	if (pm_runtime_suspended(dev))
> +		return 0;
> +
>  	return __dwc3_exynos_suspend(exynos);
>  }
> 
> 
> Is that what you meant ?

Yes, this is exactly what I meant.

Thanks.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Anton Tikhomirov Dec. 16, 2013, 2:47 a.m. UTC | #3
Hi Felipe,

> On Fri, Dec 13, 2013 at 01:56:18PM -0600, Felipe Balbi wrote:
> > On Fri, Dec 13, 2013 at 02:01:32PM +0900, Anton Tikhomirov wrote:
> > > Hi Felipe,
> > >
> > > > -static int dwc3_exynos_suspend(struct device *dev)
> > > > +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos)
> > > >  {
> > > > -	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > > > -
> > > >  	clk_disable(exynos->clk);
> > > >
> > > >  	return 0;
> > > >  }
> > > >
> > > > +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos)
> > > > +{
> > > > +	return clk_enable(exynos->clk);
> > > > +}
> > > > +
> > > > +static int dwc3_exynos_suspend(struct device *dev)
> > > > +{
> > > > +	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> > > > +
> > > > +	return __dwc3_exynos_suspend(exynos);
> > >
> > > If dwc3-exynos is runtime suspended, the clock will be disabled
> > > second time here (unbalanced clk_enable/clk_disable).
> >
> > I don't get what you mean but there is something that probably needs
> > fixing, I guess below makes it better:
> >
> > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-
> exynos.c
> > index c93919a..1e5720a 100644
> > --- a/drivers/usb/dwc3/dwc3-exynos.c
> > +++ b/drivers/usb/dwc3/dwc3-exynos.c
> > @@ -218,6 +218,9 @@ static int dwc3_exynos_suspend(struct device *dev)
> >  {
> >  	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
> >
> > +	if (pm_runtime_suspended(dev))
> > +		return 0;
> > +
> >  	return __dwc3_exynos_suspend(exynos);
> >  }
> >
> >
> > Is that what you meant ?
> 
> note, however, that this is *not* a case where we would fall today. See
> that we pm_runtime_get() in probe and only pm_runtime_put() during
> remove. So there would never be a case where we would try system
> suspend 
> while device was already runtime suspended.

You are right, while runtime PM is blocked by get_sync() in probe, this
check
doesn't matter.

> 
> I have fixed all patches in my testing/next branch anyway, just to make
> sure we're "idiot-proof" when it comes to implementing real runtime pm
> later on :-)
> 
> cheers
> 
> --
> balbi

Thank you

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index c93919a..1e5720a 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -218,6 +218,9 @@  static int dwc3_exynos_suspend(struct device *dev)
 {
 	struct dwc3_exynos *exynos = dev_get_drvdata(dev);
 
+	if (pm_runtime_suspended(dev))
+		return 0;
+
 	return __dwc3_exynos_suspend(exynos);
 }