Linux-Watchdog Archive on lore.kernel.org
 help / Atom feed
* [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations
@ 2019-05-17 20:59 Jerry Hoemann
  2019-05-17 20:59 ` [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister Jerry Hoemann
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

First two changes makes hpwdt more generic.
Next two changes make hpwdt work better with kdump.


Jerry Hoemann (6):
  watchdog/hpwdt: Stop hpwdt on unregister.
  watchdog/hpwdt: Advertize max_hw_heartbeat_ms
  watchdog/hpwdt: Have core ping watchdog.
  watchdog/hpwdt: Add module parameter kdumptimeout.
  watchdog/hpwdt: Update documentation
  watchdog/hpwdt: Reflect changes

 Documentation/watchdog/hpwdt.txt |  4 +++
 drivers/watchdog/hpwdt.c         | 55 ++++++++++++++++++++++++++++++----------
 2 files changed, 45 insertions(+), 14 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister.
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
@ 2019-05-17 20:59 ` Jerry Hoemann
  2019-06-06 21:14   ` Guenter Roeck
  2019-05-17 20:59 ` [PATCH 2/6] watchdog/hpwdt: Advertize max_hw_heartbeat_ms Jerry Hoemann
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

Have the WD core stop the watchdog on unregister instead of explicitly
calling hpwdt_stop() in hpwdt_exit().

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 drivers/watchdog/hpwdt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index ef30c7e..8c49f13 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -310,6 +310,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
 	if (retval != 0)
 		goto error_init_nmi_decoding;
 
+	watchdog_stop_on_unregister(&hpwdt_dev);
 	watchdog_set_nowayout(&hpwdt_dev, nowayout);
 	if (watchdog_init_timeout(&hpwdt_dev, soft_margin, NULL))
 		dev_warn(&dev->dev, "Invalid soft_margin: %d.\n", soft_margin);
@@ -350,9 +351,6 @@ static int hpwdt_init_one(struct pci_dev *dev,
 
 static void hpwdt_exit(struct pci_dev *dev)
 {
-	if (!nowayout)
-		hpwdt_stop();
-
 	watchdog_unregister_device(&hpwdt_dev);
 	hpwdt_exit_nmi_decoding();
 	pci_iounmap(dev, pci_mem_addr);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/6] watchdog/hpwdt: Advertize max_hw_heartbeat_ms
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
  2019-05-17 20:59 ` [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister Jerry Hoemann
@ 2019-05-17 20:59 ` Jerry Hoemann
  2019-06-06 21:17   ` Guenter Roeck
  2019-05-17 20:59 ` [PATCH 3/6] watchdog/hpwdt: Have core ping watchdog Jerry Hoemann
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

Set max_hw_heartbeat_ms instead of max_timeout so that user client can
set timeout range in excess of what the underlying hardware supports.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 drivers/watchdog/hpwdt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 8c49f13..9f7a370 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -62,9 +62,9 @@
 static int hpwdt_start(struct watchdog_device *wdd)
 {
 	int control = 0x81 | (pretimeout ? 0x4 : 0);
-	int reload = SECS_TO_TICKS(wdd->timeout);
+	int reload = SECS_TO_TICKS(min(wdd->timeout, wdd->max_hw_heartbeat_ms/1000));
 
-	dev_dbg(wdd->parent, "start watchdog 0x%08x:0x%02x\n", reload, control);
+	dev_dbg(wdd->parent, "start watchdog 0x%08x:0x%08x:0x%02x\n", wdd->timeout, reload, control);
 	iowrite16(reload, hpwdt_timer_reg);
 	iowrite8(control, hpwdt_timer_con);
 
@@ -91,9 +91,9 @@ static int hpwdt_stop_core(struct watchdog_device *wdd)
 
 static int hpwdt_ping(struct watchdog_device *wdd)
 {
-	int reload = SECS_TO_TICKS(wdd->timeout);
+	int reload = SECS_TO_TICKS(min(wdd->timeout, wdd->max_hw_heartbeat_ms/1000));
 
-	dev_dbg(wdd->parent, "ping  watchdog 0x%08x\n", reload);
+	dev_dbg(wdd->parent, "ping  watchdog 0x%08x:0x%08x\n", wdd->timeout, reload);
 	iowrite16(reload, hpwdt_timer_reg);
 
 	return 0;
@@ -208,9 +208,9 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
 	.info		= &ident,
 	.ops		= &hpwdt_ops,
 	.min_timeout	= 1,
-	.max_timeout	= HPWDT_MAX_TIMER,
 	.timeout	= DEFAULT_MARGIN,
 	.pretimeout	= PRETIMEOUT_SEC,
+	.max_hw_heartbeat_ms	= HPWDT_MAX_TIMER * 1000,
 };
 
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/6] watchdog/hpwdt: Have core ping watchdog.
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
  2019-05-17 20:59 ` [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister Jerry Hoemann
  2019-05-17 20:59 ` [PATCH 2/6] watchdog/hpwdt: Advertize max_hw_heartbeat_ms Jerry Hoemann
@ 2019-05-17 20:59 ` Jerry Hoemann
  2019-06-06 21:18   ` Guenter Roeck
  2019-05-17 20:59 ` [PATCH 4/6] watchdog/hpwdt: Add module parameter kdumptimeout Jerry Hoemann
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

Instead of stopping the hw timer during probe, have the core update
the timer if the timer is already running.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 drivers/watchdog/hpwdt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 9f7a370..aa4101c 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -59,6 +59,11 @@
 /*
  *	Watchdog operations
  */
+static int hpwdt_hw_is_running(void)
+{
+	return ioread8(hpwdt_timer_con) & 0x01;
+}
+
 static int hpwdt_start(struct watchdog_device *wdd)
 {
 	int control = 0x81 | (pretimeout ? 0x4 : 0);
@@ -302,8 +307,11 @@ static int hpwdt_init_one(struct pci_dev *dev,
 	hpwdt_timer_reg = pci_mem_addr + 0x70;
 	hpwdt_timer_con = pci_mem_addr + 0x72;
 
-	/* Make sure that timer is disabled until /dev/watchdog is opened */
-	hpwdt_stop();
+	/* Have the core update running timer until user space is ready */
+	if (hpwdt_hw_is_running()) {
+		dev_info(&dev->dev, "timer is running\n");
+		set_bit(WDOG_HW_RUNNING, &hpwdt_dev.status);
+	}
 
 	/* Initialize NMI Decoding functionality */
 	retval = hpwdt_init_nmi_decoding(dev);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/6] watchdog/hpwdt: Add module parameter kdumptimeout.
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
                   ` (2 preceding siblings ...)
  2019-05-17 20:59 ` [PATCH 3/6] watchdog/hpwdt: Have core ping watchdog Jerry Hoemann
@ 2019-05-17 20:59 ` Jerry Hoemann
  2019-06-06 21:19   ` Guenter Roeck
  2019-05-17 20:59 ` [PATCH 5/6] watchdog/hpwdt: Update documentation Jerry Hoemann
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

Instead of unconditionally stopping the watchdog timer after receipt of
a pretimeout NMI, reprogram the timeout based upon module parameter
kdumptimeout.

The provides a more flexible override than the depricated allow_kdump.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 drivers/watchdog/hpwdt.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index aa4101c..dc65006 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -29,7 +29,8 @@
 #define HPWDT_VERSION			"2.0.2"
 #define SECS_TO_TICKS(secs)		((secs) * 1000 / 128)
 #define TICKS_TO_SECS(ticks)		((ticks) * 128 / 1000)
-#define HPWDT_MAX_TIMER			TICKS_TO_SECS(65535)
+#define HPWDT_MAX_TICKS			65535
+#define HPWDT_MAX_TIMER			TICKS_TO_SECS(HPWDT_MAX_TICKS)
 #define DEFAULT_MARGIN			30
 #define PRETIMEOUT_SEC			9
 
@@ -37,6 +38,7 @@
 static unsigned int soft_margin = DEFAULT_MARGIN;	/* in seconds */
 static bool nowayout = WATCHDOG_NOWAYOUT;
 static bool pretimeout = IS_ENABLED(CONFIG_HPWDT_NMI_DECODING);
+static int kdumptimeout = -1;
 
 static void __iomem *pci_mem_addr;		/* the PCI-memory address */
 static unsigned long __iomem *hpwdt_nmistat;
@@ -56,6 +58,7 @@
 	{0},			/* terminate list */
 };
 
+static struct watchdog_device hpwdt_dev;
 /*
  *	Watchdog operations
  */
@@ -94,12 +97,18 @@ static int hpwdt_stop_core(struct watchdog_device *wdd)
 	return 0;
 }
 
+static void hpwdt_ping_ticks(int val)
+{
+	val = min(val, HPWDT_MAX_TICKS);
+	iowrite16(val, hpwdt_timer_reg);
+}
+
 static int hpwdt_ping(struct watchdog_device *wdd)
 {
 	int reload = SECS_TO_TICKS(min(wdd->timeout, wdd->max_hw_heartbeat_ms/1000));
 
 	dev_dbg(wdd->parent, "ping  watchdog 0x%08x:0x%08x\n", wdd->timeout, reload);
-	iowrite16(reload, hpwdt_timer_reg);
+	hpwdt_ping_ticks(reload);
 
 	return 0;
 }
@@ -175,7 +184,14 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
 	if (ilo5 && !pretimeout && !mynmi)
 		return NMI_DONE;
 
-	hpwdt_stop();
+	if (kdumptimeout < 0)
+		hpwdt_stop();
+	else if (kdumptimeout == 0)
+		;
+	else {
+		unsigned int val = max((unsigned int)kdumptimeout, hpwdt_dev.timeout);
+		hpwdt_ping_ticks(SECS_TO_TICKS(val));
+	}
 
 	hex_byte_pack(panic_msg, mynmi);
 	nmi_panic(regs, panic_msg);
@@ -328,6 +344,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
 		pretimeout = 0;
 	}
 	hpwdt_dev.pretimeout = pretimeout ? PRETIMEOUT_SEC : 0;
+	kdumptimeout = min(kdumptimeout, HPWDT_MAX_TIMER);
 
 	hpwdt_dev.parent = &dev->dev;
 	retval = watchdog_register_device(&hpwdt_dev);
@@ -342,6 +359,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
 				hpwdt_dev.timeout, nowayout);
 	dev_info(&dev->dev, "pretimeout: %s.\n",
 				pretimeout ? "on" : "off");
+	dev_info(&dev->dev, "kdumptimeout: %d.\n", kdumptimeout);
 
 	if (dev->subsystem_vendor == PCI_VENDOR_ID_HP_3PAR)
 		ilo5 = true;
@@ -387,6 +405,9 @@ static void hpwdt_exit(struct pci_dev *dev)
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
 		__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
+module_param(kdumptimeout, int, 0444);
+MODULE_PARM_DESC(kdumptimeout, "Timeout applied for crash kernel transition in seconds");
+
 #ifdef CONFIG_HPWDT_NMI_DECODING
 module_param(pretimeout, bool, 0);
 MODULE_PARM_DESC(pretimeout, "Watchdog pretimeout enabled");
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/6] watchdog/hpwdt: Update documentation
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
                   ` (3 preceding siblings ...)
  2019-05-17 20:59 ` [PATCH 4/6] watchdog/hpwdt: Add module parameter kdumptimeout Jerry Hoemann
@ 2019-05-17 20:59 ` Jerry Hoemann
  2019-06-06 21:19   ` Guenter Roeck
  2019-05-17 20:59 ` [PATCH 6/6] watchdog/hpwdt: Reflect changes Jerry Hoemann
  2019-06-05 22:31 ` [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

Update documentation to explain new module parameter kdumptimeout.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 Documentation/watchdog/hpwdt.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/watchdog/hpwdt.txt b/Documentation/watchdog/hpwdt.txt
index 55df692..35da141 100644
--- a/Documentation/watchdog/hpwdt.txt
+++ b/Documentation/watchdog/hpwdt.txt
@@ -33,6 +33,10 @@ Last reviewed: 08/20/2018
                Default value is set when compiling the kernel. If it is set
                to "Y", then there is no way of disabling the watchdog once
                it has been started.
+ kdumptimeout  Minimum timeout in seconds to apply upon receipt of an NMI
+               before calling panic. (-1) disables the watchdog.  When value
+               is > 0, the timer is reprogrammed with the greater of
+               value or current timeout value.
 
  NOTE: More information about watchdog drivers in general, including the ioctl
        interface to /dev/watchdog can be found in
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/6] watchdog/hpwdt: Reflect changes
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
                   ` (4 preceding siblings ...)
  2019-05-17 20:59 ` [PATCH 5/6] watchdog/hpwdt: Update documentation Jerry Hoemann
@ 2019-05-17 20:59 ` Jerry Hoemann
  2019-06-06 21:20   ` Guenter Roeck
  2019-06-05 22:31 ` [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-05-17 20:59 UTC (permalink / raw)
  To: linux, wim, linux-watchdog
  Cc: linux-kernel, mironov.ivan, rasmus.villemoes, jerry.hoemann

Bump driver number to reflect recent changes.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 drivers/watchdog/hpwdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index dc65006..9e02f88 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -26,7 +26,7 @@
 #include <linux/watchdog.h>
 #include <asm/nmi.h>
 
-#define HPWDT_VERSION			"2.0.2"
+#define HPWDT_VERSION			"2.0.3"
 #define SECS_TO_TICKS(secs)		((secs) * 1000 / 128)
 #define TICKS_TO_SECS(ticks)		((ticks) * 128 / 1000)
 #define HPWDT_MAX_TICKS			65535
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations
  2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
                   ` (5 preceding siblings ...)
  2019-05-17 20:59 ` [PATCH 6/6] watchdog/hpwdt: Reflect changes Jerry Hoemann
@ 2019-06-05 22:31 ` Jerry Hoemann
  2019-06-05 22:51   ` Guenter Roeck
  6 siblings, 1 reply; 15+ messages in thread
From: Jerry Hoemann @ 2019-06-05 22:31 UTC (permalink / raw)
  To: linux, wim, linux-watchdog; +Cc: linux-kernel

On Fri, May 17, 2019 at 02:59:37PM -0600, Jerry Hoemann wrote:
> First two changes makes hpwdt more generic.
> Next two changes make hpwdt work better with kdump.
> 

Hi Guenter,

Did you have feedback on this patch set?

Thanks

Jerry


> 
> Jerry Hoemann (6):
>   watchdog/hpwdt: Stop hpwdt on unregister.
>   watchdog/hpwdt: Advertize max_hw_heartbeat_ms
>   watchdog/hpwdt: Have core ping watchdog.
>   watchdog/hpwdt: Add module parameter kdumptimeout.
>   watchdog/hpwdt: Update documentation
>   watchdog/hpwdt: Reflect changes
> 
>  Documentation/watchdog/hpwdt.txt |  4 +++
>  drivers/watchdog/hpwdt.c         | 55 ++++++++++++++++++++++++++++++----------
>  2 files changed, 45 insertions(+), 14 deletions(-)
> 
> -- 
> 1.8.3.1

-- 

-----------------------------------------------------------------------------
Jerry Hoemann                  Software Engineer   Hewlett Packard Enterprise
-----------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations
  2019-06-05 22:31 ` [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
@ 2019-06-05 22:51   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-05 22:51 UTC (permalink / raw)
  To: Jerry Hoemann; +Cc: wim, linux-watchdog, linux-kernel

On Wed, Jun 05, 2019 at 04:31:03PM -0600, Jerry Hoemann wrote:
> On Fri, May 17, 2019 at 02:59:37PM -0600, Jerry Hoemann wrote:
> > First two changes makes hpwdt more generic.
> > Next two changes make hpwdt work better with kdump.
> > 
> 
> Hi Guenter,
> 
> Did you have feedback on this patch set?
> 
I have been out on vacation, and I am still digging myself out of a big hole.

Guenter

> Thanks
> 
> Jerry
> 
> 
> > 
> > Jerry Hoemann (6):
> >   watchdog/hpwdt: Stop hpwdt on unregister.
> >   watchdog/hpwdt: Advertize max_hw_heartbeat_ms
> >   watchdog/hpwdt: Have core ping watchdog.
> >   watchdog/hpwdt: Add module parameter kdumptimeout.
> >   watchdog/hpwdt: Update documentation
> >   watchdog/hpwdt: Reflect changes
> > 
> >  Documentation/watchdog/hpwdt.txt |  4 +++
> >  drivers/watchdog/hpwdt.c         | 55 ++++++++++++++++++++++++++++++----------
> >  2 files changed, 45 insertions(+), 14 deletions(-)
> > 
> > -- 
> > 1.8.3.1
> 
> -- 
> 
> -----------------------------------------------------------------------------
> Jerry Hoemann                  Software Engineer   Hewlett Packard Enterprise
> -----------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister.
  2019-05-17 20:59 ` [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister Jerry Hoemann
@ 2019-06-06 21:14   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-06 21:14 UTC (permalink / raw)
  To: Jerry Hoemann
  Cc: wim, linux-watchdog, linux-kernel, mironov.ivan, rasmus.villemoes

On Fri, May 17, 2019 at 02:59:38PM -0600, Jerry Hoemann wrote:
> Have the WD core stop the watchdog on unregister instead of explicitly
> calling hpwdt_stop() in hpwdt_exit().
> 
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/hpwdt.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index ef30c7e..8c49f13 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -310,6 +310,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
>  	if (retval != 0)
>  		goto error_init_nmi_decoding;
>  
> +	watchdog_stop_on_unregister(&hpwdt_dev);
>  	watchdog_set_nowayout(&hpwdt_dev, nowayout);
>  	if (watchdog_init_timeout(&hpwdt_dev, soft_margin, NULL))
>  		dev_warn(&dev->dev, "Invalid soft_margin: %d.\n", soft_margin);
> @@ -350,9 +351,6 @@ static int hpwdt_init_one(struct pci_dev *dev,
>  
>  static void hpwdt_exit(struct pci_dev *dev)
>  {
> -	if (!nowayout)
> -		hpwdt_stop();
> -
>  	watchdog_unregister_device(&hpwdt_dev);
>  	hpwdt_exit_nmi_decoding();
>  	pci_iounmap(dev, pci_mem_addr);

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/6] watchdog/hpwdt: Advertize max_hw_heartbeat_ms
  2019-05-17 20:59 ` [PATCH 2/6] watchdog/hpwdt: Advertize max_hw_heartbeat_ms Jerry Hoemann
@ 2019-06-06 21:17   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-06 21:17 UTC (permalink / raw)
  To: Jerry Hoemann
  Cc: wim, linux-watchdog, linux-kernel, mironov.ivan, rasmus.villemoes

On Fri, May 17, 2019 at 02:59:39PM -0600, Jerry Hoemann wrote:
> Set max_hw_heartbeat_ms instead of max_timeout so that user client can
> set timeout range in excess of what the underlying hardware supports.
> 
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/hpwdt.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index 8c49f13..9f7a370 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -62,9 +62,9 @@
>  static int hpwdt_start(struct watchdog_device *wdd)
>  {
>  	int control = 0x81 | (pretimeout ? 0x4 : 0);
> -	int reload = SECS_TO_TICKS(wdd->timeout);
> +	int reload = SECS_TO_TICKS(min(wdd->timeout, wdd->max_hw_heartbeat_ms/1000));
>  
> -	dev_dbg(wdd->parent, "start watchdog 0x%08x:0x%02x\n", reload, control);
> +	dev_dbg(wdd->parent, "start watchdog 0x%08x:0x%08x:0x%02x\n", wdd->timeout, reload, control);
>  	iowrite16(reload, hpwdt_timer_reg);
>  	iowrite8(control, hpwdt_timer_con);
>  
> @@ -91,9 +91,9 @@ static int hpwdt_stop_core(struct watchdog_device *wdd)
>  
>  static int hpwdt_ping(struct watchdog_device *wdd)
>  {
> -	int reload = SECS_TO_TICKS(wdd->timeout);
> +	int reload = SECS_TO_TICKS(min(wdd->timeout, wdd->max_hw_heartbeat_ms/1000));
>  
> -	dev_dbg(wdd->parent, "ping  watchdog 0x%08x\n", reload);
> +	dev_dbg(wdd->parent, "ping  watchdog 0x%08x:0x%08x\n", wdd->timeout, reload);
>  	iowrite16(reload, hpwdt_timer_reg);
>  
>  	return 0;
> @@ -208,9 +208,9 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
>  	.info		= &ident,
>  	.ops		= &hpwdt_ops,
>  	.min_timeout	= 1,
> -	.max_timeout	= HPWDT_MAX_TIMER,
>  	.timeout	= DEFAULT_MARGIN,
>  	.pretimeout	= PRETIMEOUT_SEC,
> +	.max_hw_heartbeat_ms	= HPWDT_MAX_TIMER * 1000,
>  };
>  
>  

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/6] watchdog/hpwdt: Have core ping watchdog.
  2019-05-17 20:59 ` [PATCH 3/6] watchdog/hpwdt: Have core ping watchdog Jerry Hoemann
@ 2019-06-06 21:18   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-06 21:18 UTC (permalink / raw)
  To: Jerry Hoemann
  Cc: wim, linux-watchdog, linux-kernel, mironov.ivan, rasmus.villemoes

On Fri, May 17, 2019 at 02:59:40PM -0600, Jerry Hoemann wrote:
> Instead of stopping the hw timer during probe, have the core update
> the timer if the timer is already running.
> 
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/hpwdt.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index 9f7a370..aa4101c 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -59,6 +59,11 @@
>  /*
>   *	Watchdog operations
>   */
> +static int hpwdt_hw_is_running(void)
> +{
> +	return ioread8(hpwdt_timer_con) & 0x01;
> +}
> +
>  static int hpwdt_start(struct watchdog_device *wdd)
>  {
>  	int control = 0x81 | (pretimeout ? 0x4 : 0);
> @@ -302,8 +307,11 @@ static int hpwdt_init_one(struct pci_dev *dev,
>  	hpwdt_timer_reg = pci_mem_addr + 0x70;
>  	hpwdt_timer_con = pci_mem_addr + 0x72;
>  
> -	/* Make sure that timer is disabled until /dev/watchdog is opened */
> -	hpwdt_stop();
> +	/* Have the core update running timer until user space is ready */
> +	if (hpwdt_hw_is_running()) {
> +		dev_info(&dev->dev, "timer is running\n");
> +		set_bit(WDOG_HW_RUNNING, &hpwdt_dev.status);
> +	}
>  
>  	/* Initialize NMI Decoding functionality */
>  	retval = hpwdt_init_nmi_decoding(dev);

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/6] watchdog/hpwdt: Add module parameter kdumptimeout.
  2019-05-17 20:59 ` [PATCH 4/6] watchdog/hpwdt: Add module parameter kdumptimeout Jerry Hoemann
@ 2019-06-06 21:19   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-06 21:19 UTC (permalink / raw)
  To: Jerry Hoemann
  Cc: wim, linux-watchdog, linux-kernel, mironov.ivan, rasmus.villemoes

On Fri, May 17, 2019 at 02:59:41PM -0600, Jerry Hoemann wrote:
> Instead of unconditionally stopping the watchdog timer after receipt of
> a pretimeout NMI, reprogram the timeout based upon module parameter
> kdumptimeout.
> 
> The provides a more flexible override than the depricated allow_kdump.
> 
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/hpwdt.c | 27 ++++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index aa4101c..dc65006 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -29,7 +29,8 @@
>  #define HPWDT_VERSION			"2.0.2"
>  #define SECS_TO_TICKS(secs)		((secs) * 1000 / 128)
>  #define TICKS_TO_SECS(ticks)		((ticks) * 128 / 1000)
> -#define HPWDT_MAX_TIMER			TICKS_TO_SECS(65535)
> +#define HPWDT_MAX_TICKS			65535
> +#define HPWDT_MAX_TIMER			TICKS_TO_SECS(HPWDT_MAX_TICKS)
>  #define DEFAULT_MARGIN			30
>  #define PRETIMEOUT_SEC			9
>  
> @@ -37,6 +38,7 @@
>  static unsigned int soft_margin = DEFAULT_MARGIN;	/* in seconds */
>  static bool nowayout = WATCHDOG_NOWAYOUT;
>  static bool pretimeout = IS_ENABLED(CONFIG_HPWDT_NMI_DECODING);
> +static int kdumptimeout = -1;
>  
>  static void __iomem *pci_mem_addr;		/* the PCI-memory address */
>  static unsigned long __iomem *hpwdt_nmistat;
> @@ -56,6 +58,7 @@
>  	{0},			/* terminate list */
>  };
>  
> +static struct watchdog_device hpwdt_dev;
>  /*
>   *	Watchdog operations
>   */
> @@ -94,12 +97,18 @@ static int hpwdt_stop_core(struct watchdog_device *wdd)
>  	return 0;
>  }
>  
> +static void hpwdt_ping_ticks(int val)
> +{
> +	val = min(val, HPWDT_MAX_TICKS);
> +	iowrite16(val, hpwdt_timer_reg);
> +}
> +
>  static int hpwdt_ping(struct watchdog_device *wdd)
>  {
>  	int reload = SECS_TO_TICKS(min(wdd->timeout, wdd->max_hw_heartbeat_ms/1000));
>  
>  	dev_dbg(wdd->parent, "ping  watchdog 0x%08x:0x%08x\n", wdd->timeout, reload);
> -	iowrite16(reload, hpwdt_timer_reg);
> +	hpwdt_ping_ticks(reload);
>  
>  	return 0;
>  }
> @@ -175,7 +184,14 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
>  	if (ilo5 && !pretimeout && !mynmi)
>  		return NMI_DONE;
>  
> -	hpwdt_stop();
> +	if (kdumptimeout < 0)
> +		hpwdt_stop();
> +	else if (kdumptimeout == 0)
> +		;
> +	else {
> +		unsigned int val = max((unsigned int)kdumptimeout, hpwdt_dev.timeout);
> +		hpwdt_ping_ticks(SECS_TO_TICKS(val));
> +	}
>  
>  	hex_byte_pack(panic_msg, mynmi);
>  	nmi_panic(regs, panic_msg);
> @@ -328,6 +344,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
>  		pretimeout = 0;
>  	}
>  	hpwdt_dev.pretimeout = pretimeout ? PRETIMEOUT_SEC : 0;
> +	kdumptimeout = min(kdumptimeout, HPWDT_MAX_TIMER);
>  
>  	hpwdt_dev.parent = &dev->dev;
>  	retval = watchdog_register_device(&hpwdt_dev);
> @@ -342,6 +359,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
>  				hpwdt_dev.timeout, nowayout);
>  	dev_info(&dev->dev, "pretimeout: %s.\n",
>  				pretimeout ? "on" : "off");
> +	dev_info(&dev->dev, "kdumptimeout: %d.\n", kdumptimeout);
>  
>  	if (dev->subsystem_vendor == PCI_VENDOR_ID_HP_3PAR)
>  		ilo5 = true;
> @@ -387,6 +405,9 @@ static void hpwdt_exit(struct pci_dev *dev)
>  MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
>  		__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
>  
> +module_param(kdumptimeout, int, 0444);
> +MODULE_PARM_DESC(kdumptimeout, "Timeout applied for crash kernel transition in seconds");
> +
>  #ifdef CONFIG_HPWDT_NMI_DECODING
>  module_param(pretimeout, bool, 0);
>  MODULE_PARM_DESC(pretimeout, "Watchdog pretimeout enabled");

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/6] watchdog/hpwdt: Update documentation
  2019-05-17 20:59 ` [PATCH 5/6] watchdog/hpwdt: Update documentation Jerry Hoemann
@ 2019-06-06 21:19   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-06 21:19 UTC (permalink / raw)
  To: Jerry Hoemann
  Cc: wim, linux-watchdog, linux-kernel, mironov.ivan, rasmus.villemoes

On Fri, May 17, 2019 at 02:59:42PM -0600, Jerry Hoemann wrote:
> Update documentation to explain new module parameter kdumptimeout.
> 
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  Documentation/watchdog/hpwdt.txt | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/watchdog/hpwdt.txt b/Documentation/watchdog/hpwdt.txt
> index 55df692..35da141 100644
> --- a/Documentation/watchdog/hpwdt.txt
> +++ b/Documentation/watchdog/hpwdt.txt
> @@ -33,6 +33,10 @@ Last reviewed: 08/20/2018
>                 Default value is set when compiling the kernel. If it is set
>                 to "Y", then there is no way of disabling the watchdog once
>                 it has been started.
> + kdumptimeout  Minimum timeout in seconds to apply upon receipt of an NMI
> +               before calling panic. (-1) disables the watchdog.  When value
> +               is > 0, the timer is reprogrammed with the greater of
> +               value or current timeout value.
>  
>   NOTE: More information about watchdog drivers in general, including the ioctl
>         interface to /dev/watchdog can be found in

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/6] watchdog/hpwdt: Reflect changes
  2019-05-17 20:59 ` [PATCH 6/6] watchdog/hpwdt: Reflect changes Jerry Hoemann
@ 2019-06-06 21:20   ` Guenter Roeck
  0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2019-06-06 21:20 UTC (permalink / raw)
  To: Jerry Hoemann
  Cc: wim, linux-watchdog, linux-kernel, mironov.ivan, rasmus.villemoes

On Fri, May 17, 2019 at 02:59:43PM -0600, Jerry Hoemann wrote:
> Bump driver number to reflect recent changes.
> 
> Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/hpwdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index dc65006..9e02f88 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -26,7 +26,7 @@
>  #include <linux/watchdog.h>
>  #include <asm/nmi.h>
>  
> -#define HPWDT_VERSION			"2.0.2"
> +#define HPWDT_VERSION			"2.0.3"
>  #define SECS_TO_TICKS(secs)		((secs) * 1000 / 128)
>  #define TICKS_TO_SECS(ticks)		((ticks) * 128 / 1000)
>  #define HPWDT_MAX_TICKS			65535

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 20:59 [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
2019-05-17 20:59 ` [PATCH 1/6] watchdog/hpwdt: Stop hpwdt on unregister Jerry Hoemann
2019-06-06 21:14   ` Guenter Roeck
2019-05-17 20:59 ` [PATCH 2/6] watchdog/hpwdt: Advertize max_hw_heartbeat_ms Jerry Hoemann
2019-06-06 21:17   ` Guenter Roeck
2019-05-17 20:59 ` [PATCH 3/6] watchdog/hpwdt: Have core ping watchdog Jerry Hoemann
2019-06-06 21:18   ` Guenter Roeck
2019-05-17 20:59 ` [PATCH 4/6] watchdog/hpwdt: Add module parameter kdumptimeout Jerry Hoemann
2019-06-06 21:19   ` Guenter Roeck
2019-05-17 20:59 ` [PATCH 5/6] watchdog/hpwdt: Update documentation Jerry Hoemann
2019-06-06 21:19   ` Guenter Roeck
2019-05-17 20:59 ` [PATCH 6/6] watchdog/hpwdt: Reflect changes Jerry Hoemann
2019-06-06 21:20   ` Guenter Roeck
2019-06-05 22:31 ` [PATCH 0/6] watchdog/hpwdt: cleanups and kdump accommodations Jerry Hoemann
2019-06-05 22:51   ` Guenter Roeck

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org linux-watchdog@archiver.kernel.org
	public-inbox-index linux-watchdog


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/ public-inbox