linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Bin Liu <b-liu-l0cyMroinI0@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: musb RPM sleep-while-atomic in 4.9-rc1
Date: Wed, 26 Oct 2016 16:20:50 +0200	[thread overview]
Message-ID: <20161026142050.GK12024@localhost> (raw)
In-Reply-To: <20161025151110.vih52s47a2g2col5-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>

On Tue, Oct 25, 2016 at 08:11:10AM -0700, Tony Lindgren wrote:
> * Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> [161025 01:33]:
> > On Mon, Oct 24, 2016 at 10:35:38AM -0700, Tony Lindgren wrote:
> > 
> > > From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> > > Date: Mon, 24 Oct 2016 09:18:02 -0700
> > > Subject: [PATCH] usb: musb: Fix sleeping function called from invalid
> > >  context for hdrc glue
> > > 
> > > Commit 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS
> > > glue layer") wrongly added a call for pm_runtime_get_sync to otg_timer
> > > that runs in softirq context. That causes a "BUG: sleeping function called
> > > from invalid context" every time when polling the cable status:
> > > 
> > > [<c015ebb4>] (__might_sleep) from [<c0413d60>] (__pm_runtime_resume+0x9c/0xa0)
> > > [<c0413d60>] (__pm_runtime_resume) from [<c04d0bc4>] (otg_timer+0x3c/0x254)
> > > [<c04d0bc4>] (otg_timer) from [<c0191180>] (call_timer_fn+0xfc/0x41c)
> > > [<c0191180>] (call_timer_fn) from [<c01915c0>] (expire_timers+0x120/0x210)
> > > [<c01915c0>] (expire_timers) from [<c0191acc>] (run_timer_softirq+0xa4/0xdc)
> > > [<c0191acc>] (run_timer_softirq) from [<c010168c>] (__do_softirq+0x12c/0x594)
> > > 
> > > I did not notice that as I did not have CONFIG_DEBUG_ATOMIC_SLEEP enabled.
> > > 
> > > Let's fix the issue by adding dsps_check_status() and dsps_runtime_resume()
> > > functions. And let's have otg_timer() check for the PM runtime status, and
> > > if not already enabled, have dsps_runtime_resume() call dsps_check_status()
> > > directly.
> > 
> > While this makes the sleeping-while-atomic warning go away, it does not
> > seem correct. In case we were suspended, the glue layer will now call
> > dsps_check_status while the controller (child) is still suspended:
> > 
> > [    8.577538] musb-hdrc musb-hdrc.0.auto: otg_timer
> > [    8.582642] musb-dsps 47401400.usb: dsps_runtime_resume
> > [    8.600651] musb-hdrc musb-hdrc.0.auto: dsps_check_status
> > [    8.630617] musb-hdrc musb-hdrc.0.auto: musb_runtime_resume
> 
> Hmm that's a good point yeah. If we start doing something generic in
> musb-core.c musb_runtime_resume, things could go wrong in the future.
> 
> With this particular hardware musb registers are always accessible
> though when the parent of the two musb instances musb_am335x is done.
> 
> We could just reprogam the otg timer if !pm_runtime_active(dev). But
> the sucky things with that approach is that when idle we have two
> timers, one to wake-up, then another one to check the status.

Maybe add another callback from musb_runtime_resume that can be used for
such deferred work instead?

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-10-26 14:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 15:37 musb RPM sleep-while-atomic in 4.9-rc1 Johan Hovold
2016-10-21  7:08 ` Tony Lindgren
     [not found]   ` <20161021070848.rum7wrlihjayqdbh-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-21  9:25     ` Johan Hovold
2016-10-21  9:49       ` Tony Lindgren
     [not found]         ` <20161021094904.q66kjsl33yzf2kir-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-21 11:07           ` Johan Hovold
2016-10-21 11:27             ` Tony Lindgren
     [not found]               ` <20161021112745.lancojpgv4h6aqpw-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-24 17:35                 ` Tony Lindgren
     [not found]                   ` <20161024173538.26xvlitxiwjmh4fx-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-25  8:32                     ` Johan Hovold
2016-10-25 15:11                       ` Tony Lindgren
     [not found]                         ` <20161025151110.vih52s47a2g2col5-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-26 14:20                           ` Johan Hovold [this message]
2016-10-26 14:31                             ` Tony Lindgren
     [not found]                               ` <20161026143100.rg4pse6mjyq32hxm-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-27 15:14                                 ` Tony Lindgren
     [not found]                                   ` <20161027151446.ffj6w2tydf6ymv7c-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-27 16:44                                     ` Johan Hovold
2016-10-27 17:40                                       ` Tony Lindgren
     [not found]                                         ` <20161027174016.43twztwekvb3b25t-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-27 18:45                                           ` Johan Hovold
2016-10-27 19:15                                             ` Tony Lindgren
     [not found]                                               ` <20161027191552.tuutyslp5qtu2b4f-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-28  9:44                                                 ` Johan Hovold
2016-10-28 18:13                                                   ` Tony Lindgren
     [not found]                                                     ` <20161028181318.umwn3rx55pg2cvwd-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-10-31 11:49                                                       ` Johan Hovold
2016-11-03 21:26                                                         ` Tony Lindgren
     [not found]                                                           ` <20161103212635.GC21430-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-11-03 22:01                                                             ` Ladislav Michl
2016-11-04 14:16                                                             ` Johan Hovold
2016-11-04 15:13                                                               ` Tony Lindgren
2016-11-07 18:28                                                               ` Tony Lindgren

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=20161026142050.GK12024@localhost \
    --to=johan-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=b-liu-l0cyMroinI0@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    /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).