Skip to contentSkip to conversation

usb: musb: Fix trying to suspend while active for OTG configurations

PATCH Applied Tony Lindgren 3 participants 3 messages Apr 7, 2017 – May 1, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: musb: Fix trying to suspend while active for OTG configurations

Commit d8e5f0eca1e8 ("usb: musb: Fix hardirq-safe hardirq-unsafe lock order error") caused a regression where musb keeps trying to enable host mode with no cable connected. This seems to be caused by the fact that now phy is enabled earlier, and we are wrongly trying to force USB host mode on an OTG port. The errors we are getting are "trying to suspend as a_idle while active".

For ports configured as OTG, we should not need to do anything to try to force USB host mode on it's OTG port. Trying to force host mode in this case just seems to completely confuse the musb state machine.

Let's fix the issue by making musb_host_setup() attempt to force the mode only if port_mode is configured for host mode.

Fixes d8e5f0eca1e8 ("usb: musb: Fix hardirq-safe hardirq-unsafe

lock order error")

---
 drivers/usb/musb/musb_host.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/musb/musb_host.c +0 -3
@@ -2780,10 +2780,11 @@ int musb_host_setup(struct musb *musb, int power_budget)
 	int ret;
 	struct usb_hcd *hcd = musb->hcd;
 
-	MUSB_HST_MODE(musb);
-	musb->xceiv->otg->default_a = 1;
-	musb->xceiv->otg->state = OTG_STATE_A_IDLE;

A message that is not in the archive (sent off-list or not yet received): 20170407143528.4753-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org

Tested-by
#2 lore raw
Quoted 7 lines · Tony Lindgren

Commit d8e5f0eca1e8 ("usb: musb: Fix hardirq-safe hardirq-unsafe lock order error") caused a regression where musb keeps trying to enable host mode with no cable connected. This seems to be caused by the fact that now phy is enabled earlier, and we are wrongly trying to force USB host mode on an OTG port. The errors we are getting are "trying to suspend as a_idle while active".

Quoted 7 lines

For ports configured as OTG, we should not need to do anything to try to force USB host mode on it's OTG port. Trying to force host mode in this case just seems to completely confuse the musb state machine.

Let's fix the issue by making musb_host_setup() attempt to force the mode only if port_mode is configured for host mode.

Quoted 22 lines
Fixes d8e5f0eca1e8 ("usb: musb: Fix hardirq-safe hardirq-unsafe

lock order error")

---
 drivers/usb/musb/musb_host.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/musb/musb_host.c +0 -2
@@ -2780,10 +2780,11 @@ int musb_host_setup(struct musb *musb, int power_budget)
 	int ret;
 	struct usb_hcd *hcd = musb->hcd;
 
-	MUSB_HST_MODE(musb);
-	musb->xceiv->otg->default_a = 1;

drivers/usb/musb/musb_host.c int musb_host_setup(struct musb *musb, int power_budget) · line 2790

Quoted 10 lines
drivers/usb/musb/musb_host.c +5 -2
-	musb->xceiv->otg->state = OTG_STATE_A_IDLE;
-
+	if (musb->port_mode == MUSB_PORT_MODE_HOST) {
+		MUSB_HST_MODE(musb);
+		musb->xceiv->otg->default_a = 1;
+		musb->xceiv->otg->state = OTG_STATE_A_IDLE;
+	}
 	otg_set_host(musb->xceiv->otg, &hcd->self);
 	hcd->self.otg_port = 1;
 	musb->xceiv->otg->host = &hcd->self;

- Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 786d8296-e7b0-b8c7-fa5f-d9d34633ae04-l0cyMroinI0@public.gmane.org

Applied
#4 lore raw
Quoted 15 lines · Peter Ujfalusi
Quoted 12 lines · Tony Lindgren

Commit d8e5f0eca1e8 ("usb: musb: Fix hardirq-safe hardirq-unsafe lock order error") caused a regression where musb keeps trying to enable host mode with no cable connected. This seems to be caused by the fact that now phy is enabled earlier, and we are wrongly trying to force USB host mode on an OTG port. The errors we are getting are "trying to suspend as a_idle while active".

For ports configured as OTG, we should not need to do anything to try to force USB host mode on it's OTG port. Trying to force host mode in this case just seems to completely confuse the musb state machine.

Quoted 13 lines
Quoted 2 lines

Let's fix the issue by making musb_host_setup() attempt to force the mode only if port_mode is configured for host mode.

Quoted 8 lines
Fixes d8e5f0eca1e8 ("usb: musb: Fix hardirq-safe hardirq-unsafe

lock order error")

Applied. Thanks.
-Bin.

Quoted 11 lines
Quoted 11 lines

---
drivers/usb/musb/musb_host.c | 9 +++++----

1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/musb/musb_host.c +0 -0
@@ -2780,10 +2780,11 @@ int musb_host_setup(struct musb *musb, int power_budget)
 	int ret;
 	struct usb_hcd *hcd = musb->hcd;
 
Quoted 15 lines

drivers/usb/musb/musb_host.c int musb_host_setup(struct musb *musb, int power_budget) · line 2790

Quoted 13 lines
drivers/usb/musb/musb_host.c +5 -4
-	MUSB_HST_MODE(musb);
-	musb->xceiv->otg->default_a = 1;
-	musb->xceiv->otg->state = OTG_STATE_A_IDLE;
-
+	if (musb->port_mode == MUSB_PORT_MODE_HOST) {
+		MUSB_HST_MODE(musb);
+		musb->xceiv->otg->default_a = 1;
+		musb->xceiv->otg->state = OTG_STATE_A_IDLE;
+	}
 	otg_set_host(musb->xceiv->otg, &hcd->self);
 	hcd->self.otg_port = 1;
 	musb->xceiv->otg->host = &hcd->self;

- Péter

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html