* [PATCH v2 0/5] watchdog: Add reboot API
@ 2014-05-10 0:31 Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 1/5] watchdog: Add API to trigger reboots Guenter Roeck
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:31 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel, Guenter Roeck
Some hardware implements reboot through its watchdog hardware, for example
by triggering a watchdog timeout or by writing into its watchdog register
set. Platform specific code starts to spread into watchdog drivers,
typically by setting pointers to a callback function which is then called
from the architecture's reset handler.
While global and exported callback function pointers (such as arm_pm_restart)
may be acceptable as long as they are used from platform and/or architecture
code, using such a mechanism across subsystems and drivers is less than
desirable. Ultimately, we'll need a better solution.
This patch series provides such a solution. It extends the watchdog
subsystem to support reboot functionality, provides an API function
call to trigger reboots, adds support for the new API to arm and arm64,
and converts the drivers providing reboot functionality to use the new
infrastructure.
The first patch in the series implements the new API. The second and third
patch modify the arm and arm64 architecture reset handlers to call the
added API function. The final two patches register the reboot handlers
in the sunxi and moxart watchdog drivers with the watchdog subsystem.
The sunxi patch depends on the most recent patch series sumitted by
Maxime Ripard.
Note that I did not address the comments asking for support of multiple
watchdogs with reset handlers, nor the request to add a flag to provide
'preferential' treatment for one of those watchdogs. This will require
additional discussion and needs to be addressed with a later patch if needed.
Key questions are how to add such support for non-DT systems, and if the
scope of restart handling is a function of the driver or of the system.
Also, if one of the watchdogs does not result in a complete system reset
but another one does, it is not clear to me why the less-than-perfect
watchdog would be configured in the first place (or how this situation
would be handled today).
Compile tested only for arm64. Tested on arm/moxart by Jonas Jensen.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/5] watchdog: Add API to trigger reboots
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
@ 2014-05-10 0:31 ` Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem Guenter Roeck
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:31 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel, Guenter Roeck
Some hardware implements reboot through its watchdog hardware,
for example by triggering a watchdog timeout. Platform specific
code starts to spread into watchdog drivers, typically by setting
pointers to a callback functions which is then called from the
platform reset handler.
To simplify code and provide a unified API to trigger reboots by
watchdog drivers, provide a single API to trigger such reboots
through the watchdog subsystem.
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Jonas Jensen <jonas.jensen@gmail.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Remove unnecessary check for ops in reboot function
drivers/watchdog/watchdog_core.c | 15 +++++++++++++++
include/linux/watchdog.h | 11 +++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index cec9b55..edfd9c5 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -43,6 +43,15 @@
static DEFINE_IDA(watchdog_ida);
static struct class *watchdog_class;
+static struct watchdog_device *wdd_reboot_dev;
+
+void watchdog_do_reboot(enum reboot_mode mode, const char *cmd)
+{
+ if (wdd_reboot_dev)
+ wdd_reboot_dev->ops->reboot(wdd_reboot_dev, mode, cmd);
+}
+EXPORT_SYMBOL(watchdog_do_reboot);
+
static void watchdog_check_min_max_timeout(struct watchdog_device *wdd)
{
/*
@@ -162,6 +171,9 @@ int watchdog_register_device(struct watchdog_device *wdd)
return ret;
}
+ if (wdd->ops->reboot)
+ wdd_reboot_dev = wdd;
+
return 0;
}
EXPORT_SYMBOL_GPL(watchdog_register_device);
@@ -181,6 +193,9 @@ void watchdog_unregister_device(struct watchdog_device *wdd)
if (wdd == NULL)
return;
+ if (wdd == wdd_reboot_dev)
+ wdd_reboot_dev = NULL;
+
devno = wdd->cdev.dev;
ret = watchdog_dev_unregister(wdd);
if (ret)
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 2a3038e..0d204af 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -12,6 +12,7 @@
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/cdev.h>
+#include <linux/reboot.h>
#include <uapi/linux/watchdog.h>
struct watchdog_ops;
@@ -23,6 +24,7 @@ struct watchdog_device;
* @start: The routine for starting the watchdog device.
* @stop: The routine for stopping the watchdog device.
* @ping: The routine that sends a keepalive ping to the watchdog device.
+ * @reboot: The routine for rebooting the system
* @status: The routine that shows the status of the watchdog device.
* @set_timeout:The routine for setting the watchdog devices timeout value.
* @get_timeleft:The routine that get's the time that's left before a reset.
@@ -42,6 +44,8 @@ struct watchdog_ops {
int (*stop)(struct watchdog_device *);
/* optional operations */
int (*ping)(struct watchdog_device *);
+ void (*reboot)(struct watchdog_device *, enum reboot_mode,
+ const char *);
unsigned int (*status)(struct watchdog_device *);
int (*set_timeout)(struct watchdog_device *, unsigned int);
unsigned int (*get_timeleft)(struct watchdog_device *);
@@ -142,4 +146,11 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd,
extern int watchdog_register_device(struct watchdog_device *);
extern void watchdog_unregister_device(struct watchdog_device *);
+#ifdef CONFIG_WATCHDOG_CORE
+extern void watchdog_do_reboot(enum reboot_mode mode, const char *cmd);
+#else
+static inline void watchdog_do_reboot(enum reboot_mode mode,
+ const char *cmd) { }
+#endif
+
#endif /* ifndef _LINUX_WATCHDOG_H */
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 1/5] watchdog: Add API to trigger reboots Guenter Roeck
@ 2014-05-10 0:31 ` Guenter Roeck
2014-05-15 1:37 ` Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 3/5] arm: " Guenter Roeck
` (3 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:31 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel, Guenter Roeck
The watchdog subsystem provides an API to perform a system reboot.
Use it.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: No change
arch/arm64/kernel/process.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 6391485..29c2bc0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -42,6 +42,7 @@
#include <linux/hw_breakpoint.h>
#include <linux/personality.h>
#include <linux/notifier.h>
+#include <linux/watchdog.h>
#include <asm/compat.h>
#include <asm/cacheflush.h>
@@ -144,6 +145,8 @@ void machine_restart(char *cmd)
if (arm_pm_restart)
arm_pm_restart(reboot_mode, cmd);
+ watchdog_do_reboot(reboot_mode, cmd);
+
/*
* Whoops - the architecture was unable to reboot.
*/
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 3/5] arm: Support reboot through watchdog subsystem
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 1/5] watchdog: Add API to trigger reboots Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem Guenter Roeck
@ 2014-05-10 0:31 ` Guenter Roeck
2014-05-15 1:37 ` Guenter Roeck
2014-05-10 0:31 ` [PATCH 4/5] watchdog: moxart: Register reboot handler with " Guenter Roeck
` (2 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:31 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel, Guenter Roeck
The watchdog subsystem provides an API to perform a system reboot.
Use it.
With this change, the arm_pm_restart callback is now optional,
so check if it is set before calling it.
Tested-by: Jonas Jensen <jonas.jensen@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: No change
arch/arm/kernel/process.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 81ef686..c3b7b5e 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -32,6 +32,7 @@
#include <linux/hw_breakpoint.h>
#include <linux/leds.h>
#include <linux/reboot.h>
+#include <linux/watchdog.h>
#include <asm/cacheflush.h>
#include <asm/idmap.h>
@@ -230,7 +231,10 @@ void machine_restart(char *cmd)
local_irq_disable();
smp_send_stop();
- arm_pm_restart(reboot_mode, cmd);
+ if (arm_pm_restart)
+ arm_pm_restart(reboot_mode, cmd);
+
+ watchdog_do_reboot(reboot_mode, cmd);
/* Give a grace period for failure to restart of 1s */
mdelay(1000);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/5] watchdog: moxart: Register reboot handler with watchdog subsystem
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
` (2 preceding siblings ...)
2014-05-10 0:31 ` [PATCH v2 3/5] arm: " Guenter Roeck
@ 2014-05-10 0:31 ` Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 5/5] watchdog: sunxi: " Guenter Roeck
2014-05-10 0:37 ` [PATCH v2 0/5] watchdog: Add reboot API Randy Dunlap
5 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:31 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel, Guenter Roeck
The watchdog subsystem now provides an API to trigger a system reboot.
Register with it.
Tested-by: Jonas Jensen <jonas.jensen@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: No change
drivers/watchdog/moxart_wdt.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c
index 4aa3a8a..b83646b 100644
--- a/drivers/watchdog/moxart_wdt.c
+++ b/drivers/watchdog/moxart_wdt.c
@@ -19,8 +19,6 @@
#include <linux/watchdog.h>
#include <linux/moduleparam.h>
-#include <asm/system_misc.h>
-
#define REG_COUNT 0x4
#define REG_MODE 0x8
#define REG_ENABLE 0xC
@@ -31,15 +29,16 @@ struct moxart_wdt_dev {
unsigned int clock_frequency;
};
-static struct moxart_wdt_dev *moxart_restart_ctx;
-
static int heartbeat;
-static void moxart_wdt_restart(enum reboot_mode reboot_mode, const char *cmd)
+static void moxart_wdt_reboot(struct watchdog_device *wdt_dev,
+ enum reboot_mode mode, const char *cmd)
{
- writel(1, moxart_restart_ctx->base + REG_COUNT);
- writel(0x5ab9, moxart_restart_ctx->base + REG_MODE);
- writel(0x03, moxart_restart_ctx->base + REG_ENABLE);
+ struct moxart_wdt_dev *moxart_wdt = watchdog_get_drvdata(wdt_dev);
+
+ writel(1, moxart_wdt->base + REG_COUNT);
+ writel(0x5ab9, moxart_wdt->base + REG_MODE);
+ writel(0x03, moxart_wdt->base + REG_ENABLE);
}
static int moxart_wdt_stop(struct watchdog_device *wdt_dev)
@@ -81,6 +80,7 @@ static const struct watchdog_ops moxart_wdt_ops = {
.owner = THIS_MODULE,
.start = moxart_wdt_start,
.stop = moxart_wdt_stop,
+ .reboot = moxart_wdt_reboot,
.set_timeout = moxart_wdt_set_timeout,
};
@@ -136,9 +136,6 @@ static int moxart_wdt_probe(struct platform_device *pdev)
if (err)
return err;
- moxart_restart_ctx = moxart_wdt;
- arm_pm_restart = moxart_wdt_restart;
-
dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n",
moxart_wdt->dev.timeout, nowayout);
@@ -149,7 +146,6 @@ static int moxart_wdt_remove(struct platform_device *pdev)
{
struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev);
- arm_pm_restart = NULL;
moxart_wdt_stop(&moxart_wdt->dev);
watchdog_unregister_device(&moxart_wdt->dev);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 5/5] watchdog: sunxi: Register reboot handler with watchdog subsystem
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
` (3 preceding siblings ...)
2014-05-10 0:31 ` [PATCH 4/5] watchdog: moxart: Register reboot handler with " Guenter Roeck
@ 2014-05-10 0:31 ` Guenter Roeck
2014-05-10 0:37 ` [PATCH v2 0/5] watchdog: Add reboot API Randy Dunlap
5 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:31 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel, Guenter Roeck
The watchdog subsystem now provides an API to trigger a system reboot.
Register with it.
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v2 of Maxime's patch adding reboot support
to the sunxi watchdog driver.
drivers/watchdog/sunxi_wdt.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
index 60deb9d..744b6f5 100644
--- a/drivers/watchdog/sunxi_wdt.c
+++ b/drivers/watchdog/sunxi_wdt.c
@@ -27,8 +27,6 @@
#include <linux/types.h>
#include <linux/watchdog.h>
-#include <asm/system_misc.h>
-
#define WDT_MAX_TIMEOUT 16
#define WDT_MIN_TIMEOUT 1
#define WDT_MODE_TIMEOUT(n) ((n) << 3)
@@ -74,23 +72,25 @@ static const int wdt_timeout_map[] = {
[16] = 0xB, /* 16s */
};
-static void __iomem *reboot_wdt_base;
-
-static void sun4i_wdt_restart(enum reboot_mode mode, const char *cmd)
+static void sunxi_wdt_reboot(struct watchdog_device *wdt_dev,
+ enum reboot_mode mode, const char *cmd)
{
+ struct sunxi_wdt_dev *sunxi_wdt = watchdog_get_drvdata(wdt_dev);
+
/* Enable timer and set reset bit in the watchdog */
- writel(WDT_MODE_EN | WDT_MODE_RST_EN, reboot_wdt_base + WDT_MODE);
+ writel(WDT_MODE_EN | WDT_MODE_RST_EN,
+ sunxi_wdt->wdt_base + WDT_MODE);
/*
* Restart the watchdog. The default (and lowest) interval
* value for the watchdog is 0.5s.
*/
- writel(WDT_CTRL_RELOAD, reboot_wdt_base + WDT_CTRL);
+ writel(WDT_CTRL_RELOAD, sunxi_wdt->wdt_base + WDT_CTRL);
while (1) {
mdelay(5);
writel(WDT_MODE_EN | WDT_MODE_RST_EN,
- reboot_wdt_base + WDT_MODE);
+ sunxi_wdt->wdt_base + WDT_MODE);
}
}
@@ -167,6 +167,7 @@ static const struct watchdog_ops sunxi_wdt_ops = {
.start = sunxi_wdt_start,
.stop = sunxi_wdt_stop,
.ping = sunxi_wdt_ping,
+ .reboot = sunxi_wdt_reboot,
.set_timeout = sunxi_wdt_set_timeout,
};
@@ -205,9 +206,6 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
if (unlikely(err))
return err;
- reboot_wdt_base = sunxi_wdt->wdt_base;
- arm_pm_restart = sun4i_wdt_restart;
-
dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
sunxi_wdt->wdt_dev.timeout, nowayout);
@@ -218,8 +216,6 @@ static int sunxi_wdt_remove(struct platform_device *pdev)
{
struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev);
- arm_pm_restart = NULL;
-
watchdog_unregister_device(&sunxi_wdt->wdt_dev);
watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/5] watchdog: Add reboot API
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
` (4 preceding siblings ...)
2014-05-10 0:31 ` [PATCH v2 5/5] watchdog: sunxi: " Guenter Roeck
@ 2014-05-10 0:37 ` Randy Dunlap
2014-05-10 0:53 ` Guenter Roeck
2014-05-10 16:23 ` [PATCH 6/5] watchdog: Document " Guenter Roeck
5 siblings, 2 replies; 14+ messages in thread
From: Randy Dunlap @ 2014-05-10 0:37 UTC (permalink / raw)
To: Guenter Roeck, linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel
On 05/09/2014 05:31 PM, Guenter Roeck wrote:
> Some hardware implements reboot through its watchdog hardware, for example
> by triggering a watchdog timeout or by writing into its watchdog register
> set. Platform specific code starts to spread into watchdog drivers,
> typically by setting pointers to a callback function which is then called
> from the architecture's reset handler.
No updates to Documentation/watchdog/ ?
--
~Randy
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/5] watchdog: Add reboot API
2014-05-10 0:37 ` [PATCH v2 0/5] watchdog: Add reboot API Randy Dunlap
@ 2014-05-10 0:53 ` Guenter Roeck
2014-05-10 16:23 ` [PATCH 6/5] watchdog: Document " Guenter Roeck
1 sibling, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 0:53 UTC (permalink / raw)
To: Randy Dunlap
Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
Catalin Marinas, Maxime Ripard, Will Deacon, Arnd Bergmann,
Heiko Stuebner, Russell King, Jonas Jensen, linux-kernel
On Fri, May 09, 2014 at 05:37:55PM -0700, Randy Dunlap wrote:
> On 05/09/2014 05:31 PM, Guenter Roeck wrote:
> > Some hardware implements reboot through its watchdog hardware, for example
> > by triggering a watchdog timeout or by writing into its watchdog register
> > set. Platform specific code starts to spread into watchdog drivers,
> > typically by setting pointers to a callback function which is then called
> > from the architecture's reset handler.
>
> No updates to Documentation/watchdog/ ?
>
You are absolutely right, I missed that completely.
Will follow in v3.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/5] watchdog: Document reboot API
2014-05-10 0:37 ` [PATCH v2 0/5] watchdog: Add reboot API Randy Dunlap
2014-05-10 0:53 ` Guenter Roeck
@ 2014-05-10 16:23 ` Guenter Roeck
2014-05-10 21:01 ` Randy Dunlap
1 sibling, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2014-05-10 16:23 UTC (permalink / raw)
To: Randy Dunlap
Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
Catalin Marinas, Maxime Ripard, Will Deacon, Arnd Bergmann,
Heiko Stuebner, Russell King, Jonas Jensen, linux-kernel,
linux-doc
Document the new reboot API functionality.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
Documentation/watchdog/watchdog-kernel-api.txt | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt
index a0438f3..f8f0f18 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -90,6 +90,8 @@ struct watchdog_ops {
int (*stop)(struct watchdog_device *);
/* optional operations */
int (*ping)(struct watchdog_device *);
+ void (*reboot)(struct watchdog_device *, enum reboot_mode,
+ const char *);
unsigned int (*status)(struct watchdog_device *);
int (*set_timeout)(struct watchdog_device *, unsigned int);
unsigned int (*get_timeleft)(struct watchdog_device *);
@@ -148,6 +150,10 @@ they are supported. These optional routines/operations are:
info structure).
* status: this routine checks the status of the watchdog timer device. The
status of the device is reported with watchdog WDIOF_* status flags/bits.
+* reboot: if this routine is present, it may be called to reboot the system.
+ Parameters are the pointer to the watchdog device, the reboot mode, and a
+ command string. The latter two parameters are the system reboot mode
+ and the cmd parameter passed to machine_restart().
* set_timeout: this routine checks and changes the timeout of the watchdog
timer device. It returns 0 on success, -EINVAL for "parameter out of range"
and -EIO for "could not write value to the watchdog". On success this
@@ -224,3 +230,11 @@ the device tree (if the module timeout parameter is invalid). Best practice is
to set the default timeout value as timeout value in the watchdog_device and
then use this function to set the user "preferred" timeout value.
This routine returns zero on success and a negative errno code for failure.
+
+The watchdog_do_reboot function can be used reboot the system. This is intended
+to be used in systems which do not have an explicit reboot capability, but
+implement reboot by programming the watchdog to expire immediately. If the
+function is called, and a watchdog driver with reboot functionality was
+previously registered, the reboot function of that driver will be called.
+Architecture code should call watchdog_do_reboot from its machine_reboot
+function after other means to reboot the system failed.
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 6/5] watchdog: Document reboot API
2014-05-10 16:23 ` [PATCH 6/5] watchdog: Document " Guenter Roeck
@ 2014-05-10 21:01 ` Randy Dunlap
0 siblings, 0 replies; 14+ messages in thread
From: Randy Dunlap @ 2014-05-10 21:01 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
Catalin Marinas, Maxime Ripard, Will Deacon, Arnd Bergmann,
Heiko Stuebner, Russell King, Jonas Jensen, linux-kernel,
linux-doc
On 05/10/2014 09:23 AM, Guenter Roeck wrote:
> Document the new reboot API functionality.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Documentation/watchdog/watchdog-kernel-api.txt | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt
> index a0438f3..f8f0f18 100644
> --- a/Documentation/watchdog/watchdog-kernel-api.txt
> +++ b/Documentation/watchdog/watchdog-kernel-api.txt
> @@ -90,6 +90,8 @@ struct watchdog_ops {
> int (*stop)(struct watchdog_device *);
> /* optional operations */
> int (*ping)(struct watchdog_device *);
> + void (*reboot)(struct watchdog_device *, enum reboot_mode,
> + const char *);
> unsigned int (*status)(struct watchdog_device *);
> int (*set_timeout)(struct watchdog_device *, unsigned int);
> unsigned int (*get_timeleft)(struct watchdog_device *);
> @@ -148,6 +150,10 @@ they are supported. These optional routines/operations are:
> info structure).
> * status: this routine checks the status of the watchdog timer device. The
> status of the device is reported with watchdog WDIOF_* status flags/bits.
> +* reboot: if this routine is present, it may be called to reboot the system.
> + Parameters are the pointer to the watchdog device, the reboot mode, and a
> + command string. The latter two parameters are the system reboot mode
> + and the cmd parameter passed to machine_restart().
> * set_timeout: this routine checks and changes the timeout of the watchdog
> timer device. It returns 0 on success, -EINVAL for "parameter out of range"
> and -EIO for "could not write value to the watchdog". On success this
> @@ -224,3 +230,11 @@ the device tree (if the module timeout parameter is invalid). Best practice is
> to set the default timeout value as timeout value in the watchdog_device and
> then use this function to set the user "preferred" timeout value.
> This routine returns zero on success and a negative errno code for failure.
> +
> +The watchdog_do_reboot function can be used reboot the system. This is intended
to reboot
> +to be used in systems which do not have an explicit reboot capability, but
> +implement reboot by programming the watchdog to expire immediately. If the
> +function is called, and a watchdog driver with reboot functionality was
> +previously registered, the reboot function of that driver will be called.
> +Architecture code should call watchdog_do_reboot from its machine_reboot
> +function after other means to reboot the system failed.
>
Thanks for the Doc patch.
--
~Randy
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem
2014-05-10 0:31 ` [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem Guenter Roeck
@ 2014-05-15 1:37 ` Guenter Roeck
2014-05-15 9:09 ` Will Deacon
0 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2014-05-15 1:37 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel
On 05/09/2014 05:31 PM, Guenter Roeck wrote:
> The watchdog subsystem provides an API to perform a system reboot.
> Use it.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Any comments / Ack from the arm maintainers ?
Thanks,
Guenter
> ---
> v2: No change
>
> arch/arm64/kernel/process.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index 6391485..29c2bc0 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -42,6 +42,7 @@
> #include <linux/hw_breakpoint.h>
> #include <linux/personality.h>
> #include <linux/notifier.h>
> +#include <linux/watchdog.h>
>
> #include <asm/compat.h>
> #include <asm/cacheflush.h>
> @@ -144,6 +145,8 @@ void machine_restart(char *cmd)
> if (arm_pm_restart)
> arm_pm_restart(reboot_mode, cmd);
>
> + watchdog_do_reboot(reboot_mode, cmd);
> +
> /*
> * Whoops - the architecture was unable to reboot.
> */
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/5] arm: Support reboot through watchdog subsystem
2014-05-10 0:31 ` [PATCH v2 3/5] arm: " Guenter Roeck
@ 2014-05-15 1:37 ` Guenter Roeck
0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-15 1:37 UTC (permalink / raw)
To: linux-watchdog, linux-arm-kernel
Cc: Wim Van Sebroeck, Catalin Marinas, Maxime Ripard, Will Deacon,
Arnd Bergmann, Heiko Stuebner, Russell King, Jonas Jensen,
linux-kernel
On 05/09/2014 05:31 PM, Guenter Roeck wrote:
> The watchdog subsystem provides an API to perform a system reboot.
> Use it.
>
> With this change, the arm_pm_restart callback is now optional,
> so check if it is set before calling it.
>
> Tested-by: Jonas Jensen <jonas.jensen@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Any comments / ack from the arm maintainers ?
Thanks,
Guenter
> ---
> v2: No change
>
> arch/arm/kernel/process.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
> index 81ef686..c3b7b5e 100644
> --- a/arch/arm/kernel/process.c
> +++ b/arch/arm/kernel/process.c
> @@ -32,6 +32,7 @@
> #include <linux/hw_breakpoint.h>
> #include <linux/leds.h>
> #include <linux/reboot.h>
> +#include <linux/watchdog.h>
>
> #include <asm/cacheflush.h>
> #include <asm/idmap.h>
> @@ -230,7 +231,10 @@ void machine_restart(char *cmd)
> local_irq_disable();
> smp_send_stop();
>
> - arm_pm_restart(reboot_mode, cmd);
> + if (arm_pm_restart)
> + arm_pm_restart(reboot_mode, cmd);
> +
> + watchdog_do_reboot(reboot_mode, cmd);
>
> /* Give a grace period for failure to restart of 1s */
> mdelay(1000);
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem
2014-05-15 1:37 ` Guenter Roeck
@ 2014-05-15 9:09 ` Will Deacon
2014-05-15 16:50 ` Guenter Roeck
0 siblings, 1 reply; 14+ messages in thread
From: Will Deacon @ 2014-05-15 9:09 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Wim Van Sebroeck,
Catalin Marinas, Maxime Ripard, Arnd Bergmann, Heiko Stuebner,
Russell King, Jonas Jensen, linux-kernel@vger.kernel.org
On Thu, May 15, 2014 at 02:37:30AM +0100, Guenter Roeck wrote:
> On 05/09/2014 05:31 PM, Guenter Roeck wrote:
> > The watchdog subsystem provides an API to perform a system reboot.
> > Use it.
> >
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>
> Any comments / Ack from the arm maintainers ?
I'm fine with the arm/arm64 changes, but I still reckon the parameters
should be dropped unless you have a use for them.
Will
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem
2014-05-15 9:09 ` Will Deacon
@ 2014-05-15 16:50 ` Guenter Roeck
0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2014-05-15 16:50 UTC (permalink / raw)
To: Will Deacon
Cc: linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Wim Van Sebroeck,
Catalin Marinas, Maxime Ripard, Arnd Bergmann, Heiko Stuebner,
Russell King, Jonas Jensen, linux-kernel@vger.kernel.org
On Thu, May 15, 2014 at 10:09:52AM +0100, Will Deacon wrote:
> On Thu, May 15, 2014 at 02:37:30AM +0100, Guenter Roeck wrote:
> > On 05/09/2014 05:31 PM, Guenter Roeck wrote:
> > > The watchdog subsystem provides an API to perform a system reboot.
> > > Use it.
> > >
> > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> >
> > Any comments / Ack from the arm maintainers ?
>
> I'm fine with the arm/arm64 changes, but I still reckon the parameters
> should be dropped unless you have a use for them.
Ok, I'll drop the parameters and send a new version.
Guenter
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-05-15 16:51 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-10 0:31 [PATCH v2 0/5] watchdog: Add reboot API Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 1/5] watchdog: Add API to trigger reboots Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 2/5] arm64: Support reboot through watchdog subsystem Guenter Roeck
2014-05-15 1:37 ` Guenter Roeck
2014-05-15 9:09 ` Will Deacon
2014-05-15 16:50 ` Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 3/5] arm: " Guenter Roeck
2014-05-15 1:37 ` Guenter Roeck
2014-05-10 0:31 ` [PATCH 4/5] watchdog: moxart: Register reboot handler with " Guenter Roeck
2014-05-10 0:31 ` [PATCH v2 5/5] watchdog: sunxi: " Guenter Roeck
2014-05-10 0:37 ` [PATCH v2 0/5] watchdog: Add reboot API Randy Dunlap
2014-05-10 0:53 ` Guenter Roeck
2014-05-10 16:23 ` [PATCH 6/5] watchdog: Document " Guenter Roeck
2014-05-10 21:01 ` Randy Dunlap
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).