From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Jerry Hoemann <jerry.hoemann@hpe.com>
Cc: wim@linux-watchdog.org, linux@roeck-us.net,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
rwright@hpe.com, maurice.a.saldivar@hpe.com
Subject: Re: [PATCH v2 08/11] watchdog/hpwdt: Programable Pretimeout NMI
Date: Mon, 12 Feb 2018 10:09:06 +0100 [thread overview]
Message-ID: <20180212090906.GB4513@gmail.com> (raw)
In-Reply-To: <20180212052111.12010-9-jerry.hoemann@hpe.com>
[-- Attachment #1: Type: text/plain, Size: 5349 bytes --]
Hi Jerry,
On Sun, Feb 11, 2018 at 10:21:08PM -0700, Jerry Hoemann wrote:
> Make whether or not the hpwdt watchdog delivers a pretimeout NMI
> programable by the user.
>
> The underlying iLO hardware is programmable as to whether or not
> a pre-timeout NMI is delivered to the system before the iLO resets
> the system. However, the iLO does not allow for programming the
> length of time that NMI is delivered before the system is reset.
>
> Hence, in hpwdt_set_pretimeout, val == 0 disables the NMI. Any
> non-zero value sets the pretimeout length to what the hardware
> supports.
>
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
> ---
> drivers/watchdog/hpwdt.c | 42 ++++++++++++++++++++++++++++++++++++------
> 1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index 740d0c633204..e7355f72d883 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -28,12 +28,15 @@
> #define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
> #define HPWDT_MAX_TIMER TICKS_TO_SECS(65535)
> #define DEFAULT_MARGIN 30
> +#define PRETIMEOUT_SEC 9
>
> static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */
> -static unsigned int reload; /* the computed soft_margin */
> static bool nowayout = WATCHDOG_NOWAYOUT;
> #ifdef CONFIG_HPWDT_NMI_DECODING
> static unsigned int allow_kdump = 1;
> +static bool pretimeout = 1;
> +#else
> +static bool pretimeout;
> #endif
>
> static void __iomem *pci_mem_addr; /* the PCI-memory address */
> @@ -55,10 +58,12 @@ static struct watchdog_device hpwdt_dev;
> */
> static int hpwdt_start(struct watchdog_device *dev)
> {
> - reload = SECS_TO_TICKS(dev->timeout);
> + int control = 0x81 | (pretimeout ? 0x4 : 0);
> + int reload = SECS_TO_TICKS(dev->timeout);
>
> + pr_debug("start watchdog 0x%08x:0x%02x\n", reload, control);
dev_dbg()
Even here, I think we should use
dev_emerg()
dev_crit()
dev_alert()
dev_err()
dev_warn()
dev_notice()
instead of pr_* functions now when we have a device to use.
> iowrite16(reload, hpwdt_timer_reg);
> - iowrite8(0x85, hpwdt_timer_con);
> + iowrite8(control, hpwdt_timer_con);
>
> return 0;
> }
> @@ -67,6 +72,8 @@ static int hpwdt_stop(struct watchdog_device *dev)
> {
> unsigned long data;
>
> + pr_debug("stop watchdog\n");
dev_dbg()
> +
> data = ioread8(hpwdt_timer_con);
> data &= 0xFE;
> iowrite8(data, hpwdt_timer_con);
> @@ -75,8 +82,9 @@ static int hpwdt_stop(struct watchdog_device *dev)
>
> static int hpwdt_ping(struct watchdog_device *dev)
> {
> - reload = SECS_TO_TICKS(dev->timeout);
> + int reload = SECS_TO_TICKS(dev->timeout);
>
> + pr_debug("ping watchdog 0x%08x\n", reload);
> iowrite16(reload, hpwdt_timer_reg);
>
> return 0;
> @@ -98,6 +106,16 @@ static int hpwdt_settimeout(struct watchdog_device *dev, unsigned int val)
> }
>
> #ifdef CONFIG_HPWDT_NMI_DECODING /* { */
> +static int hpwdt_set_pretimeout(struct watchdog_device *dev, unsigned int val)
> +{
> + if (val && (val != PRETIMEOUT_SEC)) {
> + pr_info("Setting pretimeout to %d\n", PRETIMEOUT_SEC);
dev_info()
> + val = PRETIMEOUT_SEC;
> + }
> + dev->pretimeout = val;
> + pretimeout = val ? 1 : 0;
> + return 0;
> +}
>
> static unsigned int hpwdt_my_nmi(void)
> {
> @@ -108,7 +126,6 @@ static inline int hexdigit(int v)
> {
> return (v > 9) ? (v-9+'A') : (v+'0');
> }
> -
> /*
> * NMI Handler
> */
> @@ -128,6 +145,9 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
>
> pr_debug("nmi: ulReason=%d, mynmi=0x%0x\n", ulReason, mynmi);
>
> + if (!pretimeout)
> + return NMI_DONE;
> +
> if (allow_kdump)
> hpwdt_stop(&hpwdt_dev);
>
> @@ -144,7 +164,8 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
> static const struct watchdog_info hpwdt_info = {
> .options = WDIOF_SETTIMEOUT |
> WDIOF_KEEPALIVEPING |
> - WDIOF_MAGICCLOSE,
> + WDIOF_MAGICCLOSE |
> + WDIOF_PRETIMEOUT,
> .identity = "HPE iLO2+ HW Watchdog Timer",
> };
>
> @@ -296,6 +317,9 @@ static const struct watchdog_ops hpwdt_ops = {
> .ping = hpwdt_ping,
> .set_timeout = hpwdt_settimeout,
> .get_timeleft = hpwdt_gettimeleft,
> +#ifdef CONFIG_HPWDT_NMI_DECODING /* { */
> + .set_pretimeout = hpwdt_set_pretimeout,
> +#endif /* } */
> };
>
> static struct watchdog_device hpwdt_dev = {
> @@ -304,6 +328,9 @@ static struct watchdog_device hpwdt_dev = {
> .min_timeout = 1,
> .max_timeout = HPWDT_MAX_TIMER,
> .timeout = DEFAULT_MARGIN,
> +#ifdef CONFIG_HPWDT_NMI_DECODING /* { */
> + .pretimeout = PRETIMEOUT_SEC,
> +#endif /* } */
> };
>
>
> @@ -322,6 +349,9 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
> #ifdef CONFIG_HPWDT_NMI_DECODING /* { */
> module_param(allow_kdump, int, 0444);
> MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs");
> +
> +module_param(pretimeout, bool, 0444);
> +MODULE_PARM_DESC(pretimeout, "Watchdog pretimeout enabled");
> #endif /* } */
>
> module_pci_driver(hpwdt_driver);
> --
> 2.13.6
Best regards
Marcus Folkesson
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-02-12 9:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-12 5:21 [PATCH v2 00/11] watchdog/hpwdt: Update driver to use watchdog core Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 01/11] watchdog/hpwdt: Remove legacy NMI sourcing Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 02/11] watchdog/hpwdt: remove include files no longer needed Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 03/11] watchdog/hpwdt: Update nmi_panic message Jerry Hoemann
2018-02-13 17:41 ` Guenter Roeck
2018-02-13 21:59 ` Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 04/11] watchdog/hpwdt: white space changes Jerry Hoemann
2018-02-12 9:35 ` Philippe Ombredanne
2018-02-13 17:44 ` Guenter Roeck
2018-02-12 5:21 ` [PATCH v2 05/11] watchdog/hpwdt: Update Module info Jerry Hoemann
2018-02-13 17:49 ` Guenter Roeck
2018-02-14 0:01 ` Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 06/11] watchdog/hpwdt: Modify to use watchdog core Jerry Hoemann
2018-02-12 9:06 ` Marcus Folkesson
2018-02-13 18:05 ` Guenter Roeck
2018-02-13 21:36 ` Jerry Hoemann
2018-02-13 21:55 ` Guenter Roeck
2018-02-13 23:54 ` Jerry Hoemann
2018-02-14 20:53 ` Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 07/11] watchdog/hpwdt: Select WATCHDOG_CORE Jerry Hoemann
2018-02-13 18:04 ` Guenter Roeck
2018-02-12 5:21 ` [PATCH v2 08/11] watchdog/hpwdt: Programable Pretimeout NMI Jerry Hoemann
2018-02-12 9:09 ` Marcus Folkesson [this message]
2018-02-12 5:21 ` [PATCH v2 09/11] watchdog/hpwdt: condition early return of NMI handler on iLO5 Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 10/11] watchdog/hpwdt: remove allow_kdump module parameter Jerry Hoemann
2018-02-13 18:20 ` Guenter Roeck
2018-02-13 23:10 ` Jerry Hoemann
2018-02-12 5:21 ` [PATCH v2 11/11] watchdog/hpwdt: Update driver version Jerry Hoemann
2018-02-13 17:07 ` Guenter Roeck
2018-02-14 0:21 ` Jerry Hoemann
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=20180212090906.GB4513@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=jerry.hoemann@hpe.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=maurice.a.saldivar@hpe.com \
--cc=rwright@hpe.com \
--cc=wim@linux-watchdog.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).