From patchwork Fri Oct 28 12:37:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4873 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2809B23E0B for ; Fri, 28 Oct 2011 12:37:53 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 0620EA18631 for ; Fri, 28 Oct 2011 12:37:53 +0000 (UTC) Received: by faan26 with SMTP id n26so5330561faa.11 for ; Fri, 28 Oct 2011 05:37:52 -0700 (PDT) Received: by 10.223.76.27 with SMTP id a27mr5356737fak.12.1319805472797; Fri, 28 Oct 2011 05:37:52 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.1.71 with SMTP id 7cs9684lak; Fri, 28 Oct 2011 05:37:52 -0700 (PDT) Received: by 10.14.23.194 with SMTP id v42mr237772eev.174.1319805471032; Fri, 28 Oct 2011 05:37:51 -0700 (PDT) Received: from eu1sys200aog108.obsmtp.com (eu1sys200aog108.obsmtp.com. [207.126.144.125]) by mx.google.com with SMTP id e14si2861550eec.50.2011.10.28.05.37.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Oct 2011 05:37:51 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP; Fri, 28 Oct 2011 12:37:50 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 2C0545A; Fri, 28 Oct 2011 12:37:23 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 2132654; Fri, 28 Oct 2011 12:37:23 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id EA5AF24C2E5; Fri, 28 Oct 2011 14:37:15 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 28 Oct 2011 14:37:22 +0200 From: Ulf Hansson To: Russell King , Cc: , "Rafael J. Wysocki" , Magnus Damm , Ulf Hansson Subject: [PATCH V2] AMBA: Use suspend_noriq to force devices into runtime suspend Date: Fri, 28 Oct 2011 14:37:18 +0200 Message-ID: <1319805438-25004-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 To be able to make sure devices are put into runtime suspend after a suspend sequence, the suspend_noirq callback is used. Previously it was was possible for drivers doing pm_runtime_suspend and pm_runtime_put_sync directly from it's suspend callbacks. This is now not possible due to the following commit, which solved a race issue: PM: Limit race conditions between runtime PM and system sleep (v2) If an AMBA device is used as wakeup device, the driver shall configure the device as such. This will prevent the AMBA bus from forcing it into runtime suspend state when executing the suspend_noirq callback. Signed-off-by: Ulf Hansson --- Changes in v2: - Integrated code directly into suspend|resume_noirq and get rid of not needed ifdefs. - Prevent runtime suspend if device is configured as wakeup. --- drivers/amba/bus.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index bd230e8..97ca9a9 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -158,6 +159,7 @@ static int amba_pm_suspend(struct device *dev) static int amba_pm_suspend_noirq(struct device *dev) { struct device_driver *drv = dev->driver; + bool is_suspended = pm_runtime_status_suspended(dev); int ret = 0; if (!drv) @@ -168,6 +170,14 @@ static int amba_pm_suspend_noirq(struct device *dev) ret = drv->pm->suspend_noirq(dev); } + /* + * If the amba device is not already runtime suspended, + * check if we can force it into this state to save power. + */ + if (!ret && !is_suspended && !device_may_wakeup(dev)) + if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_suspend) + ret = dev->bus->pm->runtime_suspend(dev); + return ret; } @@ -192,6 +202,7 @@ static int amba_pm_resume(struct device *dev) static int amba_pm_resume_noirq(struct device *dev) { struct device_driver *drv = dev->driver; + bool is_suspended = pm_runtime_status_suspended(dev); int ret = 0; if (!drv) @@ -202,6 +213,14 @@ static int amba_pm_resume_noirq(struct device *dev) ret = drv->pm->resume_noirq(dev); } + /* + * If the amba device was forced into runtime suspend state + * from suspend_noirq, make sure we restore the state. + */ + if (!ret && !is_suspended && !device_may_wakeup(dev)) + if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_resume) + ret = dev->bus->pm->runtime_resume(dev); + return ret; }