Re: [PATCHv2 00/15] Get MUSB PM runtime working again

Tony Lindgren
2016-05-18T19:12:40Z

* Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> [160518 11:47]:
> On Wed, 18 May 2016, Tony Lindgren wrote:
>
> > * Bin Liu <b-liu-l0cyMroinI0@public.gmane.org> [160518 10:37]:
> > > I think I found the problem. Before having the offending patch,
> > > musb_gadget_pullup() got called by musb_gadget_start(), then pm_suspend
> > > immediately (~2us) happens, and musb_save_context() backs up DEVCTL register
> > > which has session bit set.
> > >
> > > But with the offending patch, pm_suspend happends much later (~200ms)
> > > after musb_gadget_pullup() is called, so by this time when
> > > musb_save_context() is called, session bit is already cleared by the
> > > controller, so the backup of DEVCTL register does not have session bit
> > > set. Later when pm_resume, musb_restore_context() cleared the seesion
> > > bit.
> >
> > OK sounds like that's expected as that's the current autosuspend
> > timeout. See for example e6244deed843 ("i2c: omap: Fix PM regression
> > with deferred probe for pm_runtime_reinit") for references why
> > pm_runtime_put_sync_suspend() needs to be used if autosuspend has
> > been set.
> >
> > So you doing pm_runtime_put_sync_suspend() probably fixes your
> > issue. (Sorry I think I mentioned just pm_runtime_put_sync()
> > earlier..)
>
> Actually it may be the other way around.
> pm_runtime_put_sync_suspend() will do an immediate suspend regardless
> of the autosuspend timer, whereas pm_runtime_put_sync() will not
> suspend the device until the autosuspend timer expires.

In this case it seems that pm_runtime_put_sync_suspend() is needed
to save the DEVCTL session bit before it automagically clears..
Would probably be best to handle the session bit separately and
not rely on save/restore for setting it.

Regards,

Tony