From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752774AbbDBBLh (ORCPT ); Wed, 1 Apr 2015 21:11:37 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:33497 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752091AbbDBBLf (ORCPT ); Wed, 1 Apr 2015 21:11:35 -0400 Message-ID: <551C973C.3080902@roeck-us.net> Date: Wed, 01 Apr 2015 18:11:24 -0700 From: Guenter Roeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "Fu, Borun" , "Rafael J. Wysocki" , "linux-watchdog@vger.kernel.org" CC: Linux Kernel Mailing List , Linux PM list , Wim Van Sebroeck , "Li, Aubrey" , "Wang, Frank" Subject: Re: [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend References: <2017660.nPaHVT8bW3@vostro.rjw.lan> <48A8D21F3057FE4DB59C829EB7A1638A10EA3254@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <48A8D21F3057FE4DB59C829EB7A1638A10EA3254@SHSMSX104.ccr.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-CTCH-PVer: 0000001 X-CTCH-Spam: Unknown X-CTCH-VOD: Unknown X-CTCH-Flags: 0 X-CTCH-RefID: str=0001.0A020201.551C9746.0160,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-Score: 0.001 X-CTCH-ScoreCust: 0.000 X-CTCH-Rules: C_4847, X-CTCH-SenderID: linux@roeck-us.net X-CTCH-SenderID-Flags: 0 X-CTCH-SenderID-TotalMessages: 12 X-CTCH-SenderID-TotalSpam: 0 X-CTCH-SenderID-TotalSuspected: 0 X-CTCH-SenderID-TotalConfirmed: 0 X-CTCH-SenderID-TotalBulk: 0 X-CTCH-SenderID-TotalVirus: 0 X-CTCH-SenderID-TotalRecipients: 0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: mailgid no entry from get_relayhosts_entry X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/01/2015 05:52 PM, Fu, Borun wrote: > Hi Rafael, > watchdog_active() function is not implemented in your patch. Pls. add it. > Please explain why using the standard watchdog_active() would not work here. Guenter > static int watchdog_active(struct device *dev) > { > unsigned int val; > > spin_lock(&iTCO_wdt_private.io_lock); > val = inw(TCO1_CNT); > spin_unlock(&iTCO_wdt_private.io_lock); > > /* Bit 11: TCO Timer Halt */ > if (val & 0x0800) > return 0; > else > return 1; > } > > Regards, > Borun > -----Original Message----- > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net] > Sent: Thursday, April 02, 2015 8:31 > To: linux-watchdog@vger.kernel.org > Cc: Linux Kernel Mailing List; Linux PM list; Wim Van Sebroeck; Li, Aubrey; Fu, Borun > Subject: [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend > > From: Rafael J. Wysocki > > 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�����r��y���b�X��ǧv�^�)޺{.n�+����{���\�� �{ay�ʇڙ�,j��f���h���z��w��� ���j:+v���w�j�m��������zZ+�����ݢj"��!tml= >