Re: [PATCH v2 06/10] usb: xhci: Enable runtime pm in xhci-plat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sat, Mar 02, 2013 at 10:53:16AM -0500, Alan Stern wrote:
> On Sat, 2 Mar 2013, Vivek Gautam wrote:
> 
> > By enabling runtime pm in this driver allows users of
> > xhci-plat to enter into runtime pm. This is not full
> > runtime pm support (AKA xhci-plat doesn't actually power
> > anything off when in runtime suspend mode) but,
> > just basic enablement.
> > 
> > Signed-off-by: Vivek Gautam <gautam.vivek@xxxxxxxxxxx>
> > CC: Doug Anderson <dianders@xxxxxxxxxxxx>
> > ---
> >  drivers/usb/host/xhci-plat.c |    7 +++++++
> >  1 files changed, 7 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index c9c7e13..595cb52 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> > @@ -12,6 +12,7 @@
> >   */
> >  
> >  #include <linux/platform_device.h>
> > +#include <linux/pm_runtime.h>
> >  #include <linux/module.h>
> >  #include <linux/slab.h>
> >  
> > @@ -149,6 +150,8 @@ static int xhci_plat_probe(struct platform_device *pdev)
> >  	if (ret)
> >  		goto put_usb3_hcd;
> >  
> > +	pm_runtime_enable(&pdev->dev);
> 
> This is generally not a good idea.  You shouldn't enable a device for 
> runtime PM without first telling the PM core what state it is in.
> 
> > @@ -174,6 +177,10 @@ static int xhci_plat_remove(struct platform_device *dev)
> >  	struct usb_hcd	*hcd = platform_get_drvdata(dev);
> >  	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
> >  
> > +	if (!pm_runtime_suspended(&dev->dev))
> > +		pm_runtime_put(&dev->dev);
> > +	pm_runtime_disable(&dev->dev);
> > +
> >  	usb_remove_hcd(xhci->shared_hcd);
> >  	usb_put_hcd(xhci->shared_hcd);
> 
> This is very strange.  Why have a pm_runtime_put with no balancing 
> pm_runtime_get?

this is good point and, in fact, a doubt I have myself. How are we
supposed to check if device is suspended ? In case it _is_ suspended we
might not be able to read device's registers due to clocks possibly
being gated.

Also, considering that some drivers are used in multiple platforms and
those might behave differently when it comes to clock handling, how do
we do that ? Should we require drivers to explicitly clk_get();
clk_prepare_enable(); pm_runtime_set_active(); pm_runtime_enable() ?

While that's doable, I don't see how that'd be doable for OMAP since
they want to hide clock handling from drivers.

Any tips ?

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux