* [PATCH 1/2] USB: musb: fix late external abort on suspend
[not found] <20170905142112.28158-1-johan@kernel.org>
@ 2017-09-05 14:21 ` Johan Hovold
2017-09-05 14:21 ` [PATCH 2/2] USB: musb: fix session-bit runtime-PM quirk Johan Hovold
1 sibling, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2017-09-05 14:21 UTC (permalink / raw)
To: Bin Liu
Cc: Tony Lindgren, Greg Kroah-Hartman, linux-usb, Johan Hovold,
stable, Felipe Balbi
The musb delayed irq work was never flushed on suspend, something which
since 4.9 can lead to an external abort if the work is scheduled after
the grandparent's clock has been disabled:
PM: Suspending system (mem)
PM: suspend of devices complete after 125.224 msecs
PM: suspend devices took 0.132 seconds
PM: late suspend of devices complete after 7.423 msecs
PM: noirq suspend of devices complete after 7.083 msecs
suspend debug: Waiting for 5 second(s).
Unhandled fault: external abort on non-linefetch (0x1008) at 0xd0262c60
...
[<c054880c>] (musb_default_readb) from [<c0547b5c>] (musb_irq_work+0x48/0x220)
[<c0547b5c>] (musb_irq_work) from [<c014f8a4>] (process_one_work+0x1f4/0x758)
[<c014f8a4>] (process_one_work) from [<c014fe5c>] (worker_thread+0x54/0x514)
[<c014fe5c>] (worker_thread) from [<c015704c>] (kthread+0x128/0x158)
[<c015704c>] (kthread) from [<c0109330>] (ret_from_fork+0x14/0x24)
Commit 2bff3916fda9 ("usb: musb: Fix PM for hub disconnect") started
scheduling musb_irq_work with a delay of up to a second and with
retries thereby making this easy to trigger, for example, by suspending
shortly after a disconnect.
Note that the session flag is cleared and runtime-PM usage count
balanced after having cancelled the irq work instead of always
rescheduling on resume as the latter would have broken PM for host mode,
which always has the session bit set.
Fixes: 550a7375fe72 ("USB: Add MUSB and TUSB support")
Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core")
Fixes: 2bff3916fda9 ("usb: musb: Fix PM for hub disconnect")
Cc: stable <stable@vger.kernel.org> # 4.9
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/musb/musb_core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b67692857daf..8645432337cb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2681,8 +2681,18 @@ static int musb_suspend(struct device *dev)
musb_platform_disable(musb);
musb_disable_interrupts(musb);
- if (!(musb->io.quirks & MUSB_PRESERVE_SESSION))
+
+ cancel_delayed_work_sync(&musb->irq_work);
+
+ if (!(musb->io.quirks & MUSB_PRESERVE_SESSION)) {
musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+
+ if (musb->session) {
+ musb->session = false;
+ pm_runtime_put_noidle(musb->controller);
+ }
+ }
+
WARN_ON(!list_empty(&musb->pending_list));
spin_lock_irqsave(&musb->lock, flags);
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 2/2] USB: musb: fix session-bit runtime-PM quirk
[not found] <20170905142112.28158-1-johan@kernel.org>
2017-09-05 14:21 ` [PATCH 1/2] USB: musb: fix late external abort on suspend Johan Hovold
@ 2017-09-05 14:21 ` Johan Hovold
1 sibling, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2017-09-05 14:21 UTC (permalink / raw)
To: Bin Liu; +Cc: Tony Lindgren, Greg Kroah-Hartman, linux-usb, Johan Hovold,
stable
The current session-bit quirk implementation does not prevent the retry
counter from underflowing, something which could break runtime PM and
keep the device active for a very long time (about 2^32 seconds) after a
disconnect.
This notably breaks the B-device timeout case, but could potentially
cause problems also when the controller is operating as an A-device.
Fixes: 2bff3916fda9 ("usb: musb: Fix PM for hub disconnect")
Cc: stable <stable@vger.kernel.org> # 4.9
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/musb/musb_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 8645432337cb..8c40fc555eb0 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1861,22 +1861,22 @@ static void musb_pm_runtime_check_session(struct musb *musb)
MUSB_DEVCTL_HR;
switch (devctl & ~s) {
case MUSB_QUIRK_B_INVALID_VBUS_91:
- if (musb->quirk_retries--) {
+ if (musb->quirk_retries) {
musb_dbg(musb,
"Poll devctl on invalid vbus, assume no session");
schedule_delayed_work(&musb->irq_work,
msecs_to_jiffies(1000));
-
+ musb->quirk_retries--;
return;
}
/* fall through */
case MUSB_QUIRK_A_DISCONNECT_19:
- if (musb->quirk_retries--) {
+ if (musb->quirk_retries) {
musb_dbg(musb,
"Poll devctl on possible host mode disconnect");
schedule_delayed_work(&musb->irq_work,
msecs_to_jiffies(1000));
-
+ musb->quirk_retries--;
return;
}
if (!musb->session)
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread