diff options
author | Damien Riegel <damien.riegel@savoirfairelinux.com> | 2015-11-16 12:27:59 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2015-12-13 09:27:10 -0500 |
commit | 2165bf524da5f5e496d1cdb8c5afae1345ecce1e (patch) | |
tree | 75a24ea774d08021e1c45e201ffc9f7a164ca661 /Documentation/watchdog | |
parent | 1f32f83e5d81c1e99a1c16366e71d5867cd1e364 (diff) |
watchdog: core: add restart handler support
Many watchdog drivers implement the same code to register a restart
handler. This patch provides a generic way to set such a function.
The patch adds a new restart watchdog operation. If a restart priority
greater than 0 is needed, the driver can call
watchdog_set_restart_priority to set it.
Suggested-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'Documentation/watchdog')
-rw-r--r-- | Documentation/watchdog/watchdog-kernel-api.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt index d8b0d3367706..dbc6a65f0bd1 100644 --- a/Documentation/watchdog/watchdog-kernel-api.txt +++ b/Documentation/watchdog/watchdog-kernel-api.txt | |||
@@ -53,6 +53,7 @@ struct watchdog_device { | |||
53 | unsigned int timeout; | 53 | unsigned int timeout; |
54 | unsigned int min_timeout; | 54 | unsigned int min_timeout; |
55 | unsigned int max_timeout; | 55 | unsigned int max_timeout; |
56 | struct notifier_block restart_nb; | ||
56 | void *driver_data; | 57 | void *driver_data; |
57 | struct mutex lock; | 58 | struct mutex lock; |
58 | unsigned long status; | 59 | unsigned long status; |
@@ -75,6 +76,10 @@ It contains following fields: | |||
75 | * timeout: the watchdog timer's timeout value (in seconds). | 76 | * timeout: the watchdog timer's timeout value (in seconds). |
76 | * min_timeout: the watchdog timer's minimum timeout value (in seconds). | 77 | * min_timeout: the watchdog timer's minimum timeout value (in seconds). |
77 | * max_timeout: the watchdog timer's maximum timeout value (in seconds). | 78 | * max_timeout: the watchdog timer's maximum timeout value (in seconds). |
79 | * restart_nb: notifier block that is registered for machine restart, for | ||
80 | internal use only. If a watchdog is capable of restarting the machine, it | ||
81 | should define ops->restart. Priority can be changed through | ||
82 | watchdog_set_restart_priority. | ||
78 | * bootstatus: status of the device after booting (reported with watchdog | 83 | * bootstatus: status of the device after booting (reported with watchdog |
79 | WDIOF_* status bits). | 84 | WDIOF_* status bits). |
80 | * driver_data: a pointer to the drivers private data of a watchdog device. | 85 | * driver_data: a pointer to the drivers private data of a watchdog device. |
@@ -100,6 +105,7 @@ struct watchdog_ops { | |||
100 | unsigned int (*status)(struct watchdog_device *); | 105 | unsigned int (*status)(struct watchdog_device *); |
101 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 106 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
102 | unsigned int (*get_timeleft)(struct watchdog_device *); | 107 | unsigned int (*get_timeleft)(struct watchdog_device *); |
108 | int (*restart)(struct watchdog_device *); | ||
103 | void (*ref)(struct watchdog_device *); | 109 | void (*ref)(struct watchdog_device *); |
104 | void (*unref)(struct watchdog_device *); | 110 | void (*unref)(struct watchdog_device *); |
105 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | 111 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); |
@@ -164,6 +170,8 @@ they are supported. These optional routines/operations are: | |||
164 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the | 170 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the |
165 | watchdog's info structure). | 171 | watchdog's info structure). |
166 | * get_timeleft: this routines returns the time that's left before a reset. | 172 | * get_timeleft: this routines returns the time that's left before a reset. |
173 | * restart: this routine restarts the machine. It returns 0 on success or a | ||
174 | negative errno code for failure. | ||
167 | * ref: the operation that calls kref_get on the kref of a dynamically | 175 | * ref: the operation that calls kref_get on the kref of a dynamically |
168 | allocated watchdog_device struct. | 176 | allocated watchdog_device struct. |
169 | * unref: the operation that calls kref_put on the kref of a dynamically | 177 | * unref: the operation that calls kref_put on the kref of a dynamically |
@@ -231,3 +239,14 @@ the device tree (if the module timeout parameter is invalid). Best practice is | |||
231 | to set the default timeout value as timeout value in the watchdog_device and | 239 | to set the default timeout value as timeout value in the watchdog_device and |
232 | then use this function to set the user "preferred" timeout value. | 240 | then use this function to set the user "preferred" timeout value. |
233 | This routine returns zero on success and a negative errno code for failure. | 241 | This routine returns zero on success and a negative errno code for failure. |
242 | |||
243 | To change the priority of the restart handler the following helper should be | ||
244 | used: | ||
245 | |||
246 | void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority); | ||
247 | |||
248 | User should follow the following guidelines for setting the priority: | ||
249 | * 0: should be called in last resort, has limited restart capabilities | ||
250 | * 128: default restart handler, use if no other handler is expected to be | ||
251 | available, and/or if restart is sufficient to restart the entire system | ||
252 | * 255: highest priority, will preempt all other restart handlers | ||