From: Guenter Roeck <linux@roeck-us.net>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>, linux-watchdog@vger.kernel.org
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux PM list <linux-pm@vger.kernel.org>,
Wim Van Sebroeck <wim@iguana.be>, Aubrey Li <aubrey.li@intel.com>,
Borun Fu <borun.fu@intel.com>
Subject: Re: [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend
Date: Wed, 01 Apr 2015 18:21:40 -0700 [thread overview]
Message-ID: <551C99A4.40608@roeck-us.net> (raw)
In-Reply-To: <2017660.nPaHVT8bW3@vostro.rjw.lan>
On 04/01/2015 05:31 PM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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 <borun.fu@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> 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 <linux/acpi.h> /* For ACPI support */
> #include <linux/module.h> /* For module specific items */
> #include <linux/moduleparam.h> /* For new moduleparam's */
> #include <linux/types.h> /* 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,
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 ?
> +};
> +
> +#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
Thanks,
Guenter
next prev parent reply other threads:[~2015-04-02 1:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-02 0:31 [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend Rafael J. Wysocki
2015-04-02 0:52 ` Fu, Borun
2015-04-02 0:52 ` Fu, Borun
2015-04-02 1:11 ` Guenter Roeck
2015-04-02 1:11 ` Guenter Roeck
2015-04-02 2:13 ` Fu, Borun
2015-04-02 2:13 ` Fu, Borun
2015-04-02 2:13 ` Fu, Borun
2015-04-02 1:21 ` Guenter Roeck [this message]
[not found] ` <551C99A4.40608-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2015-04-02 22:04 ` Rafael J. Wysocki
2015-04-02 22:04 ` Rafael J. Wysocki
2015-04-03 2:53 ` Fu, Borun
2015-04-03 2:53 ` Fu, Borun
2015-04-03 5:48 ` Guenter Roeck
2015-04-03 11:04 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=551C99A4.40608@roeck-us.net \
--to=linux@roeck-us.net \
--cc=aubrey.li@intel.com \
--cc=borun.fu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.