Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] usb: musb: fix idling for suspend after disconnect interrupt
@ 2019-11-26  3:41 Tony Lindgren
  2019-11-26 10:20 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2019-11-26  3:41 UTC (permalink / raw)
  To: Bin Liu
  Cc: Greg Kroah-Hartman, linux-usb, linux-omap, Merlijn Wajer,
	Pavel Machek, Sebastian Reichel

When disconnected as USB B-device, we sometimes get a suspend interrupt
after disconnect interrupt. In that case we have devctl set to 99 with
VBUS still valid and musb_pm_runtime_check_session() wrongly things we
have an active session. We have no other interrupts after disconnect
coming in this case at least with the omap2430 glue.

Let's fix the issue by checking the interrupt status again with
delayed work for the devctl 99 case. In the suspend after disconnect
case the devctl session bit has cleared by then and musb can idle.
For a typical USB B-device connect case we just continue with normal
interrupts.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/usb/musb/musb_core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1943,6 +1943,9 @@ ATTRIBUTE_GROUPS(musb);
 #define MUSB_QUIRK_B_INVALID_VBUS_91	(MUSB_DEVCTL_BDEVICE | \
 					 (2 << MUSB_DEVCTL_VBUS_SHIFT) | \
 					 MUSB_DEVCTL_SESSION)
+#define MUSB_QUIRK_B_DISCONNECT_99	(MUSB_DEVCTL_BDEVICE | \
+					 (3 << MUSB_DEVCTL_VBUS_SHIFT) | \
+					 MUSB_DEVCTL_SESSION)
 #define MUSB_QUIRK_A_DISCONNECT_19	((3 << MUSB_DEVCTL_VBUS_SHIFT) | \
 					 MUSB_DEVCTL_SESSION)
 
@@ -1965,6 +1968,11 @@ static void musb_pm_runtime_check_session(struct musb *musb)
 	s = MUSB_DEVCTL_FSDEV | MUSB_DEVCTL_LSDEV |
 		MUSB_DEVCTL_HR;
 	switch (devctl & ~s) {
+	case MUSB_QUIRK_B_DISCONNECT_99:
+		musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n");
+		schedule_delayed_work(&musb->irq_work,
+				      msecs_to_jiffies(1000));
+		break;
 	case MUSB_QUIRK_B_INVALID_VBUS_91:
 		if (musb->quirk_retries && !musb->flush_irq_work) {
 			musb_dbg(musb,
-- 
2.24.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: musb: fix idling for suspend after disconnect interrupt
  2019-11-26  3:41 [PATCH] usb: musb: fix idling for suspend after disconnect interrupt Tony Lindgren
@ 2019-11-26 10:20 ` Sergei Shtylyov
  2019-11-26 17:45   ` Tony Lindgren
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2019-11-26 10:20 UTC (permalink / raw)
  To: Tony Lindgren, Bin Liu
  Cc: Greg Kroah-Hartman, linux-usb, linux-omap, Merlijn Wajer,
	Pavel Machek, Sebastian Reichel

Hello!

On 26.11.2019 6:41, Tony Lindgren wrote:

> When disconnected as USB B-device, we sometimes get a suspend interrupt
> after disconnect interrupt. In that case we have devctl set to 99 with
> VBUS still valid and musb_pm_runtime_check_session() wrongly things we

     Thinks?

> have an active session. We have no other interrupts after disconnect
> coming in this case at least with the omap2430 glue.
> 
> Let's fix the issue by checking the interrupt status again with
> delayed work for the devctl 99 case. In the suspend after disconnect
> case the devctl session bit has cleared by then and musb can idle.
> For a typical USB B-device connect case we just continue with normal
> interrupts.
> 
> Cc: Merlijn Wajer <merlijn@wizzup.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: musb: fix idling for suspend after disconnect interrupt
  2019-11-26 10:20 ` Sergei Shtylyov
@ 2019-11-26 17:45   ` Tony Lindgren
  0 siblings, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2019-11-26 17:45 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Bin Liu, Greg Kroah-Hartman, linux-usb, linux-omap,
	Merlijn Wajer, Pavel Machek, Sebastian Reichel

* Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> [191126 10:21]:
> Hello!
> 
> On 26.11.2019 6:41, Tony Lindgren wrote:
> 
> > When disconnected as USB B-device, we sometimes get a suspend interrupt
> > after disconnect interrupt. In that case we have devctl set to 99 with
> > VBUS still valid and musb_pm_runtime_check_session() wrongly things we
> 
>     Thinks?

Thanks will fix.

Tony

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26  3:41 [PATCH] usb: musb: fix idling for suspend after disconnect interrupt Tony Lindgren
2019-11-26 10:20 ` Sergei Shtylyov
2019-11-26 17:45   ` Tony Lindgren

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git