All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Few PM fixes for MUSB for v4.9 merge window
@ 2016-09-15 16:29 Tony Lindgren
       [not found] ` <20160915162914.8164-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2016-09-15 16:29 UTC (permalink / raw)
  To: Bin Liu
  Cc: Greg Kroah-Hartman, Andreas Kemnade, Felipe Balbi,
	George Cherian, Kishon Vijay Abraham I, Ivaylo Dimitrov,
	Ladislav Michl, Sergei Shtylyov,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

Hi,

I noticed few corner cases we're not handling properly with the
musb hardware session bit based PM runtime heading for v4.9.

Probably the disconnect after unconfigure PM issue has always
been there, but fixing it without the session bit based PM
runtime would be a mess.

Regards,

Tony

Tony Lindgren (2):
  usb: musb: Fix PM runtime for disconnect after unconfigure
  usb: musb: Fix session based PM for first invalid VBUS

 drivers/usb/musb/musb_core.c   | 13 ++++++++-----
 drivers/usb/musb/musb_core.h   |  1 +
 drivers/usb/musb/musb_gadget.c |  3 +++
 3 files changed, 12 insertions(+), 5 deletions(-)

-- 
2.9.3
--
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

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

* [PATCH 1/2] usb: musb: Fix PM runtime for disconnect after unconfigure
       [not found] ` <20160915162914.8164-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2016-09-15 16:29   ` Tony Lindgren
  2016-09-15 16:29   ` [PATCH 2/2] usb: musb: Fix session based PM for first invalid VBUS Tony Lindgren
  2016-09-21 20:08   ` [PATCH 0/2] Few PM fixes for MUSB for v4.9 merge window Bin Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2016-09-15 16:29 UTC (permalink / raw)
  To: Bin Liu
  Cc: Greg Kroah-Hartman, Andreas Kemnade, Felipe Balbi,
	George Cherian, Kishon Vijay Abraham I, Ivaylo Dimitrov,
	Ladislav Michl, Sergei Shtylyov,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

If we unconfigure musb as a USB peripheral with cable connected,
and then remove the cable, no interrupts will happen. And musb
thinks we're still connected keeping the device active.

Now with the session bit based PM runtime working for musb, we
can fix this issue by calling musb irq_work. That rechecks the
devctl register and reconfigures PM runtime based on the devctl.

Fixes: 467d5c980709 ("usb: musb: Implement session bit based
runtime PM for musb-core")
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
---
 drivers/usb/musb/musb_gadget.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1964,6 +1964,9 @@ static int musb_gadget_stop(struct usb_gadget *g)
 	 * that currently misbehaves.
 	 */
 
+	/* Force check of devctl register for PM runtime */
+	schedule_work(&musb->irq_work);
+
 	pm_runtime_mark_last_busy(musb->controller);
 	pm_runtime_put_autosuspend(musb->controller);
 
-- 
2.9.3
--
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

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

* [PATCH 2/2] usb: musb: Fix session based PM for first invalid VBUS
       [not found] ` <20160915162914.8164-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2016-09-15 16:29   ` [PATCH 1/2] usb: musb: Fix PM runtime for disconnect after unconfigure Tony Lindgren
@ 2016-09-15 16:29   ` Tony Lindgren
  2016-09-21 20:08   ` [PATCH 0/2] Few PM fixes for MUSB for v4.9 merge window Bin Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2016-09-15 16:29 UTC (permalink / raw)
  To: Bin Liu
  Cc: Greg Kroah-Hartman, Andreas Kemnade, Felipe Balbi,
	George Cherian, Kishon Vijay Abraham I, Ivaylo Dimitrov,
	Ladislav Michl, Sergei Shtylyov,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

With the session bit based PM runtime working on musb, we've
implemented few quirks to attempt to detect the current state of
the hardware. One of the quirks is for invalid VBUS as peripheral,
but it is not working in all cases.

If we start musb on dm3730 as a peripheral with no cable connected,
we will get the devctl 91 state once and will never idle as there
are not further interrupts from musb. So we need to ignore the first
devctl 91 state as there will be more interrupts if we're connected.

The invalid VBUS state also can happen always when connected to
certain USB hubs. Looks like musb on dm3730 can claim invalid VBUS
with some hubs while 3717-evm and BeagleBone don't. This causes
session as peripheral to fail for dm3730 with some hubs.

This too is fixed by ignoring only the first invalid VBUS. When
connected, we can just look at the session bit as that will clear
automatically when the session ends.

Fixes: 467d5c980709 ("usb: musb: Implement session bit based
runtime PM for musb-core")
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
---
 drivers/usb/musb/musb_core.c | 13 ++++++++-----
 drivers/usb/musb/musb_core.h |  1 +
 2 files changed, 9 insertions(+), 5 deletions(-)

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
@@ -1855,11 +1855,13 @@ 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->session)
-			break;
-		musb_dbg(musb, "Allow PM as device with invalid vbus: %02x",
-			devctl);
-		return;
+		if (!musb->session && !musb->quirk_invalid_vbus) {
+			musb->quirk_invalid_vbus = true;
+			musb_dbg(musb,
+				 "First invalid vbus, assume no session");
+			return;
+		}
+		break;
 	case MUSB_QUIRK_A_DISCONNECT_19:
 		if (!musb->session)
 			break;
@@ -1886,6 +1888,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
 				error);
 	} else {
 		musb_dbg(musb, "Allow PM with no session: %02x", devctl);
+		musb->quirk_invalid_vbus = false;
 		pm_runtime_mark_last_busy(musb->controller);
 		pm_runtime_put_autosuspend(musb->controller);
 	}
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -379,6 +379,7 @@ struct musb {
 
 	int			port_mode;	/* MUSB_PORT_MODE_* */
 	bool			session;
+	bool			quirk_invalid_vbus;
 	bool			is_host;
 
 	int			a_wait_bcon;	/* VBUS timeout in msecs */
-- 
2.9.3
--
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

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

* Re: [PATCH 0/2] Few PM fixes for MUSB for v4.9 merge window
       [not found] ` <20160915162914.8164-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2016-09-15 16:29   ` [PATCH 1/2] usb: musb: Fix PM runtime for disconnect after unconfigure Tony Lindgren
  2016-09-15 16:29   ` [PATCH 2/2] usb: musb: Fix session based PM for first invalid VBUS Tony Lindgren
@ 2016-09-21 20:08   ` Bin Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Bin Liu @ 2016-09-21 20:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, Andreas Kemnade, Felipe Balbi,
	Kishon Vijay Abraham I, Ivaylo Dimitrov, Ladislav Michl,
	Sergei Shtylyov, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

Hi,

On Thu, Sep 15, 2016 at 09:29:12AM -0700, Tony Lindgren wrote:
> Hi,
> 
> I noticed few corner cases we're not handling properly with the
> musb hardware session bit based PM runtime heading for v4.9.
> 
> Probably the disconnect after unconfigure PM issue has always
> been there, but fixing it without the session bit based PM
> runtime would be a mess.
> 
> Regards,
> 
> Tony
> 
> Tony Lindgren (2):
>   usb: musb: Fix PM runtime for disconnect after unconfigure
>   usb: musb: Fix session based PM for first invalid VBUS
> 
>  drivers/usb/musb/musb_core.c   | 13 ++++++++-----
>  drivers/usb/musb/musb_core.h   |  1 +
>  drivers/usb/musb/musb_gadget.c |  3 +++
>  3 files changed, 12 insertions(+), 5 deletions(-)

Applied. Thanks.

Regards,
-Bin.
--
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

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

end of thread, other threads:[~2016-09-21 20:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 16:29 [PATCH 0/2] Few PM fixes for MUSB for v4.9 merge window Tony Lindgren
     [not found] ` <20160915162914.8164-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-09-15 16:29   ` [PATCH 1/2] usb: musb: Fix PM runtime for disconnect after unconfigure Tony Lindgren
2016-09-15 16:29   ` [PATCH 2/2] usb: musb: Fix session based PM for first invalid VBUS Tony Lindgren
2016-09-21 20:08   ` [PATCH 0/2] Few PM fixes for MUSB for v4.9 merge window Bin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.