diff mbox

usb: musb: gadget: Fix out-of-sync runtime pm calls

Message ID 1304083055-2809-1-git-send-email-jhnikula@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jarkko Nikula April 29, 2011, 1:17 p.m. UTC
If cable is not connected to peripheral only board when initializing the
gadget driver, then runtime pm calls are out-of-sync and the musb cannot
idle with omap2430.c. This was noted on Nokia N900 where musb prevented the
CPU to be able to enter deeper retention idle state.

This was working in 2.6.38 before runtime pm conversions but there musb
smart standby/idle modes were configured statically where they are now
updated runtime depending on use and cable status.

Reason for out-of-sync is that runtime pm is activated in function
musb_gadget.c: usb_gadget_probe_driver but suspended only in OTG mode if
cable is not connected when initializing. In peripheral only mode this leads
to out-of-sync runtime pm since runtime pm remain active and is activated
another time in omap2430.c: musb_otg_notifications for VBUS Connect event
and thus cannot suspend for VBUS Disconnect event since the use count remains
active.

Fix this by moving cable status check and pm_runtime_put call in
usb_gadget_probe_driver out of is_otg_enabled block.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
---
IMHO this is for 2.6.39 as this fixes PM regression on OMAP2+ boards that use
musb in peripheral mode.
---
 drivers/usb/musb/musb_gadget.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

Felipe Balbi May 2, 2011, 9:30 a.m. UTC | #1
On Fri, Apr 29, 2011 at 04:17:35PM +0300, Jarkko Nikula wrote:
> If cable is not connected to peripheral only board when initializing the
> gadget driver, then runtime pm calls are out-of-sync and the musb cannot
> idle with omap2430.c. This was noted on Nokia N900 where musb prevented the
> CPU to be able to enter deeper retention idle state.
> 
> This was working in 2.6.38 before runtime pm conversions but there musb
> smart standby/idle modes were configured statically where they are now
> updated runtime depending on use and cable status.
> 
> Reason for out-of-sync is that runtime pm is activated in function
> musb_gadget.c: usb_gadget_probe_driver but suspended only in OTG mode if
> cable is not connected when initializing. In peripheral only mode this leads
> to out-of-sync runtime pm since runtime pm remain active and is activated
> another time in omap2430.c: musb_otg_notifications for VBUS Connect event
> and thus cannot suspend for VBUS Disconnect event since the use count remains
> active.
> 
> Fix this by moving cable status check and pm_runtime_put call in
> usb_gadget_probe_driver out of is_otg_enabled block.
> 
> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>

applied, thanks
diff mbox

Patch

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 6dfbf9f..f47c201 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1887,11 +1887,9 @@  int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
 			otg_set_vbus(musb->xceiv, 1);
 
 		hcd->self.uses_pio_for_control = 1;
-
-		if (musb->xceiv->last_event == USB_EVENT_NONE)
-			pm_runtime_put(musb->controller);
-
 	}
+	if (musb->xceiv->last_event == USB_EVENT_NONE)
+		pm_runtime_put(musb->controller);
 
 	return 0;