From patchwork Fri Apr 29 13:17:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 740941 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3TDHlrU006377 for ; Fri, 29 Apr 2011 13:17:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756960Ab1D2NRp (ORCPT ); Fri, 29 Apr 2011 09:17:45 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:52792 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755645Ab1D2NRo (ORCPT ); Fri, 29 Apr 2011 09:17:44 -0400 Received: by eyx24 with SMTP id 24so1141815eyx.19 for ; Fri, 29 Apr 2011 06:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=2O9L6zfqQzD4z8Wz2I9zTWgIxp5L3U1PId7qxGZsdXg=; b=PWbUFgFRJAxBYTwcS4qiQq/4Q2F5ryvRBkE4ECgx/GO/B7b8cFqvdGne+vju+gq/yh g7w/e78cH0bpnJzVat72P0GdlPaP5hI4PNpt8txZPaSflKSR2VMpW4Z7z3dJxBY5gA0D cqxZ37DrYRB8eb4QHlw6UIPih6z0MyIkJkk1k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=QogbuVy+TgIdBX9COmKJJ/zo01DbPXiaS4X3Qz6XzYTJOpsxy2TkIgaqUxdCKyYwky YvZIe+dn7ukLyoacC4BOqvfiloFik44k7mGY5nM0Jt6LYiIZ9vssixz512LPXy/cZ1zQ XLyrTzm63vIL7BMF96W+nU7QDN85+LkaI0xVo= Received: by 10.14.34.143 with SMTP id s15mr2239566eea.235.1304083063162; Fri, 29 Apr 2011 06:17:43 -0700 (PDT) Received: from localhost (host-94-101-4-66.igua.fi [94.101.4.66]) by mx.google.com with ESMTPS id c14sm711023eeb.4.2011.04.29.06.17.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Apr 2011 06:17:42 -0700 (PDT) From: Jarkko Nikula To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, Felipe Balbi , Hema HK , Jarkko Nikula Subject: [PATCH] usb: musb: gadget: Fix out-of-sync runtime pm calls Date: Fri, 29 Apr 2011 16:17:35 +0300 Message-Id: <1304083055-2809-1-git-send-email-jhnikula@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Apr 2011 13:17:48 +0000 (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 --- 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(-) 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;