From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422853AbbENV73 (ORCPT ); Thu, 14 May 2015 17:59:29 -0400 Received: from muru.com ([72.249.23.125]:51061 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422827AbbENV7Z (ORCPT ); Thu, 14 May 2015 17:59:25 -0400 Date: Thu, 14 May 2015 14:59:21 -0700 From: Tony Lindgren To: "Rafael J. Wysocki" Cc: Felipe Balbi , "Rafael J. Wysocki" , Alan Stern , Andreas Fenkart , Greg Kroah-Hartman , Huiquan Zhong , Kevin Hilman , NeilBrown , Mika Westerberg , Nishanth Menon , Peter Hurley , Sebastian Andrzej Siewior , Ulf Hansson , Thomas Gleixner , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-omap@vger.kernel.org Subject: Re: [PATCH 2/5] PM / Wakeirq: Add automated device wake IRQ handling Message-ID: <20150514215921.GQ15563@atomide.com> References: <1431560196-5722-1-git-send-email-tony@atomide.com> <20150514155945.GL15563@atomide.com> <20150514211501.GO15563@atomide.com> <3499196.MCAcS31ICO@vostro.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3499196.MCAcS31ICO@vostro.rjw.lan> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Rafael J. Wysocki [150514 14:36]: > On Thursday, May 14, 2015 02:15:01 PM Tony Lindgren wrote: > > * Tony Lindgren [150514 09:01]: > > > * Felipe Balbi [150513 19:09]: > > > > > +void dev_pm_enable_wake_irq(struct device *dev) > > > > > +{ > > > > > + struct wake_irq *wirq = dev->power.wakeirq; > > > > > + > > > > > + if (wirq && wirq->manage_irq) > > > > > + enable_irq(wirq->irq); > > > > > +} > > > > > +EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq); > > > > > > > > you probably want to enable dev_pm_enable_wake_irq() automatically for > > > > from rpm_suspend(). According to runtime_pm documentation, wakeup should > > > > always be enabled for runtime suspended devices. I didn't really look > > > > through the whole thing yet to know if you did call it or not. > > > > > > Yes I think we can also automate that part, I've been playing with an > > > additional patch doing that for pm runtime. Been still thinking if > > > there's any need to manage that in the consomer driver, I guess not. > > > > Here's what that would roughly look and now I also remember why > > I did not include it. It adds currently extra checks also for > > devices not using dedicated wakeirqs. But basically this would > > allow leaving out the enable/disable PM runtime calls from drivers. ... > > @@ -1427,6 +1432,7 @@ int pm_runtime_force_suspend(struct device *dev) > > goto err; > > } > > > > + dev_pm_enable_wake_irq(dev); > > Why here? This is for system suspend. > > > ret = callback(dev); > > if (ret) > > goto err; > > @@ -1434,6 +1440,7 @@ int pm_runtime_force_suspend(struct device *dev) > > pm_runtime_set_suspended(dev); > > return 0; > > err: > > + dev_pm_disable_wake_irq(dev); > > pm_runtime_enable(dev); > > return ret; > > } > > @@ -1463,6 +1470,7 @@ int pm_runtime_force_resume(struct device *dev) > > goto out; > > } > > > > + dev_pm_disable_wake_irq(dev); > > This one too. Oh you're right, seems to work fine for me without those. So it would be the following additional patch then (only quickly tested). Regards, Tony 8< ---------------- --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "power.h" @@ -514,6 +515,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) callback = RPM_GET_CALLBACK(dev, runtime_suspend); + dev_pm_enable_wake_irq(dev); retval = rpm_callback(callback, dev); if (retval) goto fail; @@ -552,6 +554,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) return retval; fail: + dev_pm_disable_wake_irq(dev); __update_runtime_status(dev, RPM_ACTIVE); dev->power.deferred_resume = false; wake_up_all(&dev->power.wait_queue); @@ -734,10 +737,12 @@ static int rpm_resume(struct device *dev, int rpmflags) callback = RPM_GET_CALLBACK(dev, runtime_resume); + dev_pm_disable_wake_irq(dev); retval = rpm_callback(callback, dev); if (retval) { __update_runtime_status(dev, RPM_SUSPENDED); pm_runtime_cancel_pending(dev); + dev_pm_enable_wake_irq(dev); } else { no_callback: __update_runtime_status(dev, RPM_ACTIVE);