From patchwork Sat Aug 20 19:32:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 1082962 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7KJck83015579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 20 Aug 2011 19:39:12 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7KJaGt0025531; Sat, 20 Aug 2011 12:36:46 -0700 Received: from ogre.sisk.pl (ogre.sisk.pl [217.79.144.158]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7KJVbeW025004 for ; Sat, 20 Aug 2011 12:31:39 -0700 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 2C8EB1B97D8; Sat, 20 Aug 2011 20:51:47 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18754-02; Sat, 20 Aug 2011 20:51:33 +0200 (CEST) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 57D691B97F4; Sat, 20 Aug 2011 20:51:33 +0200 (CEST) From: "Rafael J. Wysocki" To: linux-sh@vger.kernel.org Date: Sat, 20 Aug 2011 21:32:13 +0200 User-Agent: KMail/1.13.6 (Linux/3.1.0-rc2+; KDE/4.6.0; x86_64; ; ) References: <201108202131.19479.rjw@sisk.pl> In-Reply-To: <201108202131.19479.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <201108202132.13304.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-3.932 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: Linux PM mailing list , LKML Subject: [linux-pm] [PATCH 1/2] PM / Runtime: Introduce pm_runtime_irq_unsafe() X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 20 Aug 2011 19:39:12 +0000 (UTC) From: Rafael J. Wysocki Add a helper function allowing drivers and subsystems to clear the power.irq_safe device flag. Signed-off-by: Rafael J. Wysocki --- Documentation/power/runtime_pm.txt | 4 ++++ drivers/base/power/runtime.c | 9 +++++---- include/linux/pm_runtime.h | 13 ++++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) Index: linux/include/linux/pm_runtime.h =================================================================== --- linux.orig/include/linux/pm_runtime.h +++ linux/include/linux/pm_runtime.h @@ -40,7 +40,7 @@ extern int pm_generic_runtime_idle(struc extern int pm_generic_runtime_suspend(struct device *dev); extern int pm_generic_runtime_resume(struct device *dev); extern void pm_runtime_no_callbacks(struct device *dev); -extern void pm_runtime_irq_safe(struct device *dev); +extern void __pm_runtime_irq_safe(struct device *dev, bool irq_safe); extern void __pm_runtime_use_autosuspend(struct device *dev, bool use); extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay); extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev); @@ -102,6 +102,16 @@ static inline void pm_runtime_mark_last_ ACCESS_ONCE(dev->power.last_busy) = jiffies; } +static inline void pm_runtime_irq_safe(struct device *dev) +{ + __pm_runtime_irq_safe(dev, true); +} + +static inline void pm_runtime_irq_unsafe(struct device *dev) +{ + __pm_runtime_irq_safe(dev, false); +} + #else /* !CONFIG_PM_RUNTIME */ static inline int __pm_runtime_idle(struct device *dev, int rpmflags) @@ -143,6 +153,7 @@ static inline int pm_generic_runtime_sus static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } static inline void pm_runtime_no_callbacks(struct device *dev) {} static inline void pm_runtime_irq_safe(struct device *dev) {} +static inline void pm_runtime_irq_unsafe(struct device *dev) {} static inline bool pm_runtime_callbacks_present(struct device *dev) { return false; } static inline void pm_runtime_mark_last_busy(struct device *dev) {} Index: linux/drivers/base/power/runtime.c =================================================================== --- linux.orig/drivers/base/power/runtime.c +++ linux/drivers/base/power/runtime.c @@ -1109,22 +1109,23 @@ void pm_runtime_no_callbacks(struct devi EXPORT_SYMBOL_GPL(pm_runtime_no_callbacks); /** - * pm_runtime_irq_safe - Leave interrupts disabled during callbacks. + * __pm_runtime_irq_safe - Manipulate a device's power.irq_safe flag. * @dev: Device to handle + * @irq_safe: Whether or not to leave interrupts disabled during callbacks. * - * Set the power.irq_safe flag, which tells the PM core that the + * Set or unset the power.irq_safe flag, which tells the PM core that the * ->runtime_suspend() and ->runtime_resume() callbacks for this device should * always be invoked with the spinlock held and interrupts disabled. It also * causes the parent's usage counter to be permanently incremented, preventing * the parent from runtime suspending -- otherwise an irq-safe child might have * to wait for a non-irq-safe parent. */ -void pm_runtime_irq_safe(struct device *dev) +void __pm_runtime_irq_safe(struct device *dev, bool irq_safe) { if (dev->parent) pm_runtime_get_sync(dev->parent); spin_lock_irq(&dev->power.lock); - dev->power.irq_safe = 1; + dev->power.irq_safe = irq_safe; spin_unlock_irq(&dev->power.lock); } EXPORT_SYMBOL_GPL(pm_runtime_irq_safe); Index: linux/Documentation/power/runtime_pm.txt =================================================================== --- linux.orig/Documentation/power/runtime_pm.txt +++ linux/Documentation/power/runtime_pm.txt @@ -434,6 +434,10 @@ drivers/base/power/runtime.c and include suspend and resume callbacks (but not the idle callback) to be invoked with interrupts disabled + void pm_runtime_irq_unsafe(struct device *dev); + - clear the power.irq_safe flag for the device, causing the runtime-PM + callbacks to be invoked with interrupts enabled + void pm_runtime_mark_last_busy(struct device *dev); - set the power.last_busy field to the current time