From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752874AbbDCCxo (ORCPT ); Thu, 2 Apr 2015 22:53:44 -0400 Received: from mga14.intel.com ([192.55.52.115]:36585 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbbDCCxk (ORCPT ); Thu, 2 Apr 2015 22:53:40 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,515,1422950400"; d="scan'208";a="674671310" From: "Fu, Borun" To: "Rafael J. Wysocki" , Guenter Roeck CC: "linux-watchdog@vger.kernel.org" , "Linux Kernel Mailing List" , Linux PM list , Wim Van Sebroeck , "Li, Aubrey" Subject: RE: [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend Thread-Topic: [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend Thread-Index: AQHQbNjrdUT/1ElQm0OEK2zQYFw3/J04Zu8AgAFbHQCAANbh8A== Date: Fri, 3 Apr 2015 02:53:35 +0000 Message-ID: <48A8D21F3057FE4DB59C829EB7A1638A10EA487C@SHSMSX104.ccr.corp.intel.com> References: <2017660.nPaHVT8bW3@vostro.rjw.lan> <551C99A4.40608@roeck-us.net> <2928815.XiLbVYtUVn@vostro.rjw.lan> In-Reply-To: <2928815.XiLbVYtUVn@vostro.rjw.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t332s1NK014134 On Apr 3, 2015 06:04, Rafael J. Wysocki wrote: > On Wednesday, April 01, 2015 06:21:40 PM Guenter Roeck wrote: >> On 04/01/2015 05:31 PM, Rafael J. Wysocki wrote: >>> From: Rafael J. Wysocki > > [cut] > >> Hi Rafael, >> >> This only covers suspend and resume, but not any of the other >> sleep operations (like SIMPLE_DEV_PM_OPS would do). >> Is that intentional ? > > Yes, it is: > (1) The problemm at hand is strictly specific to system suspend. > (2) The SIMPLE_DEV_PM_OPS etc macros don't cover the _noirq callback > variants > (and we want to use the _noirq variants, because we want the > watchdog to be stopped as late and restarted as early as reasonably > possible). (3) I'm not even sure if adding runtime PM support to > this driver would make any sense. :-) >> >>> +}; >>> + >>> +#define ITCO_WDT_PM_OPS &iTCO_wdt_pm >> >> Checkpatch wants to see (&iTCO_wdt_pm). >> >> ERROR: Macros with complex values should be enclosed in parentheses > > Please find an updated patch below. > > Rafael > > Tested-by: Borun Fu Borun > --- > From: Rafael J. Wysocki > Subject: PM / watchdog: iTCO: stop watchdog during system suspend > > If the target sleep state of the system is not an ACPI sleep state > (S1, S2 or S3), the TCO watchdog needs to be stopped during system > suspend, because it may not be possible to ping it any more after > timekeeping has been suspended (suspend-to-idle does that for > one example). > > For this reason, provide ->suspend_noirq and ->resume_noirq > callbacks for the iTCO watchdog driver and use them to stop > and restart the watchdog during system suspend and resume, > respectively, if the system is not going to enter an ACPI > sleep state (in which case the watchdog will be stopped > by the platform firmware before the state is entered). > > Reported-by: Borun Fu > Signed-off-by: Rafael J. Wysocki > --- > drivers/watchdog/iTCO_wdt.c | 51 > ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 > insertions(+) > Index: linux-pm/drivers/watchdog/iTCO_wdt.c > ================================================================ === --- > linux-pm.orig/drivers/watchdog/iTCO_wdt.c +++ > linux-pm/drivers/watchdog/iTCO_wdt.c @@ -51,6 +51,7 @@ > #define DRV_VERSION "1.11" > > /* Includes */ +#include /* For ACPI support */ > #include /* For module specific items */ #include > /* For new moduleparam's */ #include > /* For standard types (like size_t) */ @@ -103,6 > +104,8 @@ static struct { /* this is private data struct > platform_device *dev; /* the PCI-device */ struct pci_dev *pdev; > + /* whether or not the watchdog has been suspended */ > + bool suspended; > } iTCO_wdt_private; > > /* module parameters */ @@ -571,12 +574,60 @@ static void > iTCO_wdt_shutdown(struct pla iTCO_wdt_stop(NULL); } > +#ifdef CONFIG_PM_SLEEP +/* + * Suspend-to-idle requires this, because > it stops the ticks and timekeeping, so + * the watchdog cannot be pinged > while in that state. In ACPI sleep states the + * watchdog is stopped > by the platform firmware. + */ + +#ifdef CONFIG_ACPI +static inline bool > need_suspend(void) +{ + return acpi_target_system_state() == > ACPI_STATE_S0; +} +#else +static inline bool need_suspend(void) { return > true; } +#endif + +static int iTCO_wdt_suspend_noirq(struct device *dev) > +{ + int ret = 0; + + iTCO_wdt_private.suspended = false; + if > (watchdog_active(&iTCO_wdt_watchdog_dev) && need_suspend()) { + ret = > iTCO_wdt_stop(&iTCO_wdt_watchdog_dev); + if (!ret) > + iTCO_wdt_private.suspended = true; + } + return ret; +} + +static > int iTCO_wdt_resume_noirq(struct device *dev) +{ + if > (iTCO_wdt_private.suspended) + iTCO_wdt_start(&iTCO_wdt_watchdog_dev); > + + return 0; +} + +struct dev_pm_ops iTCO_wdt_pm = { + .suspend_noirq = > iTCO_wdt_suspend_noirq, + .resume_noirq = iTCO_wdt_resume_noirq, +}; + > +#define ITCO_WDT_PM_OPS (&iTCO_wdt_pm) +#else +#define > ITCO_WDT_PM_OPS NULL +#endif /* CONFIG_PM_SLEEP */ + > static struct platform_driver iTCO_wdt_driver = { .probe = > iTCO_wdt_probe, .remove = iTCO_wdt_remove, .shutdown = > iTCO_wdt_shutdown, .driver = { .name = DRV_NAME, + .pm > = ITCO_WDT_PM_OPS, }, }; {.n++%ݶw{.n+{G{ayʇڙ,jfhz_(階ݢj"mG?&~iOzv^m ?I