From patchwork Thu Aug 4 21:40:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sonasath, Moiz" X-Patchwork-Id: 1036882 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p74LkI1a019865 for ; Thu, 4 Aug 2011 21:46:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755001Ab1HDVp6 (ORCPT ); Thu, 4 Aug 2011 17:45:58 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:53386 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755150Ab1HDVp5 (ORCPT ); Thu, 4 Aug 2011 17:45:57 -0400 Received: from dlep36.itg.ti.com ([157.170.170.91]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p74LjrFH001005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 4 Aug 2011 16:45:53 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id p74LjrIA017797; Thu, 4 Aug 2011 16:45:53 -0500 (CDT) Received: from dlee73.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p74LjqOw024636; Thu, 4 Aug 2011 16:45:52 -0500 (CDT) Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE73.ent.ti.com (157.170.170.88) with Microsoft SMTP Server id 8.3.106.1; Thu, 4 Aug 2011 16:45:52 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id p74LjqUA024752; Thu, 4 Aug 2011 16:45:52 -0500 Received: from lina0132712 (lina0132712.am.dhcp.ti.com [128.247.78.215]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id p74Ljqf08090; Thu, 4 Aug 2011 16:45:52 -0500 (CDT) Received: by lina0132712 (Postfix, from userid 1000) id C031F30034D; Thu, 4 Aug 2011 16:40:11 -0500 (CDT) From: Moiz Sonasath To: , , CC: , , Axel Haslam , Moiz Sonasath Subject: [PATCH] usb: musb: use put_sync_suspend instead of put_sync Date: Thu, 4 Aug 2011 16:40:11 -0500 Message-ID: <1312494011-18745-1-git-send-email-m-sonasath@ti.com> X-Mailer: git-send-email 1.6.0.4 MIME-Version: 1.0 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]); Thu, 04 Aug 2011 21:46:19 +0000 (UTC) From: Axel Haslam As Documented in runtime documentation, drivers can call put_sync in contexts where sleep is allowed, in contexts where sleep is not possible, the drivers need to mark these as to be made interrupt safe and also use put_sync_suspend instead of put_sync as the idle callbacks will be called with interrupt enabled - which is not a good thing to happen in isr context. BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:798 in_atomic(): 0, irqs_disabled(): 0, pid: 44, name: irq/164-fsa9480 Backtrace: [] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c) r6:de41bcd8 r5:ffff72b6 r4:ffff6f03 r3:60000113 [] (dump_stack+0x0/0x1c) from [] (__might_sleep+0x130/0x134) [] (__might_sleep+0x0/0x134) from [] (__pm_runtime_resume+0x94/0x98) r5:00000004 r4:de58a408 [] (__pm_runtime_resume+0x0/0x98) from [] (musb_otg_notifications+0x90/0x140) r7:c07c8220 r6:de41bcd8 r5:c0760494 r4:de41b000 [] (musb_otg_notifications+0x0/0x140) from [] (notifier_call_chain+0x4c/0x8c) r5:00000000 r4:ffffffff [] (notifier_call_chain+0x0/0x8c) from [] (__atomic_notifier_call_chain+0x40/0x54) r8:00000004 r7:00000001 r6:de41bcd8 r5:ffffffff r4:c078ca38 A call to pm_runtime_irq_safe, will indefently prevent the parent from sleeping by doing a call to get-sync on the parent. this is "to prevent a irq-safe child to wait for a non-irq safe parent." For this reason, the parent runtime-pm suspend is blocked, and we dont let L3 and CORE enter into low power. As a workaround, we call the parent runtime functions on the child runtime hooks, for this to work, the parent has to be set to ignere children, otherwise, even with a "timmed" autosuspend call, will return BUSY, as the child is not yet suspended. This patch is based off: https://lkml.org/lkml/2011/7/20/357 Signed-off-by: Axel Haslam Reported-by: Colin Cross Signed-off-by: Moiz Sonasath --- drivers/usb/musb/musb_core.c | 9 +++++++++ drivers/usb/musb/musb_gadget.c | 2 +- drivers/usb/musb/omap2430.c | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index c71b037..d22bc73 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1941,7 +1941,11 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) pm_runtime_use_autosuspend(musb->controller); pm_runtime_set_autosuspend_delay(musb->controller, 200); + pm_runtime_use_autosuspend(musb->controller->parent); + pm_runtime_set_autosuspend_delay(musb->controller->parent, 500); + pm_suspend_ignore_children(musb->controller->parent,true); pm_runtime_enable(musb->controller); + pm_runtime_irq_safe(musb->controller); spin_lock_init(&musb->lock); musb->board_mode = plat->mode; @@ -2375,6 +2379,9 @@ static int musb_runtime_suspend(struct device *dev) musb_save_context(musb); + pm_runtime_mark_last_busy(musb->controller->parent); + pm_runtime_put_autosuspend(musb->controller->parent); + return 0; } @@ -2392,6 +2399,8 @@ static int musb_runtime_resume(struct device *dev) * Also context restore without save does not make * any sense */ + if (pm_runtime_suspended(dev->parent)) + pm_runtime_get_sync(dev->parent); if (!first) musb_restore_context(musb); first = 0; diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 548338c..d5d8f3a 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1710,7 +1710,7 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) } spin_unlock_irqrestore(&musb->lock, flags); - pm_runtime_put(musb->controller); + pm_runtime_put_sync_suspend(musb->controller); return 0; } diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index c5d4c44..8b6888d 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -471,6 +471,7 @@ static int __init omap2430_probe(struct platform_device *pdev) } pm_runtime_enable(&pdev->dev); + pm_runtime_irq_safe(&pdev->dev); return 0; @@ -516,7 +517,8 @@ static int omap2430_runtime_resume(struct device *dev) struct musb *musb = glue_to_musb(glue); omap2430_low_level_init(musb); - otg_set_suspend(musb->xceiv, 0); + if (musb->xceiv) + otg_set_suspend(musb->xceiv, 0); return 0; }