Re: [PATCH 1/1] usb: host: xhci-plat: keep runtime active when remove host

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

 



On Wed, May 13, 2020 at 11:08:13AM +0000, Peter Chen wrote:
>  
>  
> > > diff --git a/drivers/usb/host/xhci-plat.c
> > > b/drivers/usb/host/xhci-plat.c index 1d4f6f85f0fe..f38d53528c96 100644
> > > --- a/drivers/usb/host/xhci-plat.c
> > > +++ b/drivers/usb/host/xhci-plat.c
> > > @@ -362,6 +362,7 @@ static int xhci_plat_remove(struct platform_device *dev)
> > >  	struct clk *reg_clk = xhci->reg_clk;
> > >  	struct usb_hcd *shared_hcd = xhci->shared_hcd;
> > >
> > > +	pm_runtime_get_sync(&dev->dev);
> > >  	xhci->xhc_state |= XHCI_STATE_REMOVING;
> > >
> > >  	usb_remove_hcd(shared_hcd);
> > 
> > You mustn't add a pm_runtime_get call without a corresponding pm_runtime_put
> > call.
> > 
> > With just this one call, if the role switched from host to device and then back to host,
> > then the host would never be able to go into runtime suspend.
> > 
> 
> I may not consider carefully for other cases, for my case, the xhci-plat device
> will be removed, and re-created. But if we remove the driver using modprobe,
> it may have issues.
> 
> > In this case the correspondence between the get's and the put's will probably be
> > obscure; some comments would help.
> > 
> 
> I explained at the reply for Mathias's, but I am not 100% it is the root cause.

Okay, but there's something you may not know: pm_runtime_set_suspended() 
should be called _after_ pm_runtime_disable().  If you try to set the 
state to "suspended" while the device is enabled for runtime PM, the 
call may very well fail.

In this case, if all you want to do is block callbacks to the xHCI 
suspend routine, pm_runtime_disable() is probably all you need.

Alan Stern



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux