<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/watchdog/watchdog_dev.c, branch linux-4.7.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-4.7.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-4.7.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2016-10-07T13:21:24+00:00</updated>
<entry>
<title>watchdog: core: Clear WDOG_HW_RUNNING before calling the stop function</title>
<updated>2016-10-07T13:21:24+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-07-21T21:21:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b7d9885f97676b5b0c5162bd4720c1f956306813'/>
<id>urn:sha1:b7d9885f97676b5b0c5162bd4720c1f956306813</id>
<content type='text'>
commit 3c10bbde10fe4dca52726e246cefa6b0a1dfbd3e upstream.

WDOG_HW_RUNNING indicates that the hardware watchdog is running while the
watchdog device is closed. The flag may be set by the driver when it is
instantiated to indicate that the watchdog is running, and that the
watchdog core needs to send heartbeat requests to the driver until the
watchdog device is opened.

When the watchdog device is closed, the flag can be used by the driver's
stop function to indicate to the watchdog core that it was unable to stop
the watchdog, and that the watchdog core needs to send heartbeat requests.
This only works if the flag is actually cleared when the watchdog is
stopped. To avoid having to clear the flag in each driver's stop function,
clear it in the watchdog core before calling the stop function.

Reported-by: Rasmus Villemoes &lt;rasmus.villemoes@prevas.dk&gt;
Fixes: ee142889e32f ("watchdog: Introduce WDOG_HW_RUNNING flag")
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>watchdog: core: Fix circular locking dependency</title>
<updated>2016-05-14T14:10:33+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-04-21T14:38:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e1f30282a1d3d0c75d5a08e47c6ac1563065be52'/>
<id>urn:sha1:e1f30282a1d3d0c75d5a08e47c6ac1563065be52</id>
<content type='text'>
lockdep reports the following circular locking dependency.

======================================================
INFO: possible circular locking dependency detected ]
4.6.0-rc3-00191-gfabf418 #162 Not tainted
-------------------------------------------------------
systemd/1 is trying to acquire lock:
((&amp;(&amp;wd_data-&gt;work)-&gt;work)){+.+...}, at: [&lt;80141650&gt;] flush_work+0x0/0x280

but task is already holding lock:

(&amp;wd_data-&gt;lock){+.+...}, at: [&lt;804acfa8&gt;] watchdog_release+0x18/0x190

which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:

-&gt; #1 (&amp;wd_data-&gt;lock){+.+...}:
	[&lt;80662310&gt;] mutex_lock_nested+0x64/0x4a8
	[&lt;804aca4c&gt;] watchdog_ping_work+0x18/0x4c
	[&lt;80143128&gt;] process_one_work+0x1ac/0x500
	[&lt;801434b4&gt;] worker_thread+0x38/0x554
	[&lt;80149510&gt;] kthread+0xf4/0x108
	[&lt;80107c10&gt;] ret_from_fork+0x14/0x24

-&gt; #0 ((&amp;(&amp;wd_data-&gt;work)-&gt;work)){+.+...}:
	[&lt;8017c4e8&gt;] lock_acquire+0x70/0x90
	[&lt;8014169c&gt;] flush_work+0x4c/0x280
	[&lt;801440f8&gt;] __cancel_work_timer+0x9c/0x1e0
	[&lt;804acfcc&gt;] watchdog_release+0x3c/0x190
	[&lt;8022c5e8&gt;] __fput+0x80/0x1c8
	[&lt;80147b28&gt;] task_work_run+0x94/0xc8
	[&lt;8010b998&gt;] do_work_pending+0x8c/0xb4
	[&lt;80107ba8&gt;] slow_work_pending+0xc/0x20

other info that might help us debug this:
Possible unsafe locking scenario:

CPU0                    CPU1
----                    ----
lock(&amp;wd_data-&gt;lock);
                        lock((&amp;(&amp;wd_data-&gt;work)-&gt;work));
                        lock(&amp;wd_data-&gt;lock);
lock((&amp;(&amp;wd_data-&gt;work)-&gt;work));

*** DEADLOCK ***

1 lock held by systemd/1:

stack backtrace:
CPU: 2 PID: 1 Comm: systemd Not tainted 4.6.0-rc3-00191-gfabf418 #162
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[&lt;8010f5e4&gt;] (unwind_backtrace) from [&lt;8010c038&gt;] (show_stack+0x10/0x14)
[&lt;8010c038&gt;] (show_stack) from [&lt;8039d7fc&gt;] (dump_stack+0xa8/0xd4)
[&lt;8039d7fc&gt;] (dump_stack) from [&lt;80177ee0&gt;] (print_circular_bug+0x214/0x334)
[&lt;80177ee0&gt;] (print_circular_bug) from [&lt;80179230&gt;] (check_prevs_add+0x4dc/0x8e8)
[&lt;80179230&gt;] (check_prevs_add) from [&lt;8017b3d8&gt;] (__lock_acquire+0xc6c/0x14ec)
[&lt;8017b3d8&gt;] (__lock_acquire) from [&lt;8017c4e8&gt;] (lock_acquire+0x70/0x90)
[&lt;8017c4e8&gt;] (lock_acquire) from [&lt;8014169c&gt;] (flush_work+0x4c/0x280)
[&lt;8014169c&gt;] (flush_work) from [&lt;801440f8&gt;] (__cancel_work_timer+0x9c/0x1e0)
[&lt;801440f8&gt;] (__cancel_work_timer) from [&lt;804acfcc&gt;] (watchdog_release+0x3c/0x190)
[&lt;804acfcc&gt;] (watchdog_release) from [&lt;8022c5e8&gt;] (__fput+0x80/0x1c8)
[&lt;8022c5e8&gt;] (__fput) from [&lt;80147b28&gt;] (task_work_run+0x94/0xc8)
[&lt;80147b28&gt;] (task_work_run) from [&lt;8010b998&gt;] (do_work_pending+0x8c/0xb4)
[&lt;8010b998&gt;] (do_work_pending) from [&lt;80107ba8&gt;] (slow_work_pending+0xc/0x20)

Turns out the call to cancel_delayed_work_sync() in watchdog_release()
is not necessary and can be dropped. If the worker is no longer necessary,
the subsequent call to watchdog_update_worker() will cancel it. If it is
already running, it won't do anything, since the worker function checks
if it needs to ping the watchdog or not.

Reported-by: Clemens Gruber &lt;clemens.gruber@pqgruber.com&gt;
Tested-by: Clemens Gruber &lt;clemens.gruber@pqgruber.com&gt;
Fixes: 11d7aba9ceb7 ("watchdog: imx2: Convert to use infrastructure triggered keepalives")
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Ensure that wdd is not dereferenced if NULL</title>
<updated>2016-03-16T20:11:50+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-03-09T02:46:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d1ed3ba4e3d76b4ebec239c64f990c26d7935700'/>
<id>urn:sha1:d1ed3ba4e3d76b4ebec239c64f990c26d7935700</id>
<content type='text'>
Smatch rightfully complains that wdd is dereferenced in the watchdog
release function after being checked for NULL. Also make sure that it
is not accessed outside mutex protection to avoid use-after-free problems.

Fixes: e6c71e84e4c0 ("watchdog: Introduce WDOG_HW_RUNNING flag")
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Add support for minimum time between heartbeats</title>
<updated>2016-03-16T20:11:19+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-02-28T21:12:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=15013ad813f6544be8e79afc23672745950d59bc'/>
<id>urn:sha1:15013ad813f6544be8e79afc23672745950d59bc</id>
<content type='text'>
Some watchdogs require a minimum time between heartbeats.
Examples are the watchdogs in DA9062 and AT91SAM9x.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Make stop function optional</title>
<updated>2016-03-16T20:11:16+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-02-28T21:12:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d0684c8a9354953efdea214b437445c00743cf49'/>
<id>urn:sha1:d0684c8a9354953efdea214b437445c00743cf49</id>
<content type='text'>
Not all hardware watchdogs can be stopped. The driver for
such watchdogs would typically only set the WATCHDOG_HW_RUNNING
flag in its stop function. Make the stop function optional and set
WATCHDOG_HW_RUNNING in the watchdog core if it is not provided.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Introduce WDOG_HW_RUNNING flag</title>
<updated>2016-03-16T20:11:15+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-02-28T21:12:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ee142889e32f564f9b5e57b68b06693ec5473074'/>
<id>urn:sha1:ee142889e32f564f9b5e57b68b06693ec5473074</id>
<content type='text'>
The WDOG_HW_RUNNING flag is expected to be set by watchdog drivers if
the hardware watchdog is running. If the flag is set, the watchdog
subsystem will ping the watchdog even if the watchdog device is closed.

The watchdog driver stop function is now optional and may be omitted
if the watchdog can not be stopped. If stopping the watchdog is not
possible but the driver implements a stop function, it is responsible
to set the WDOG_HW_RUNNING flag in its stop function.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Introduce hardware maximum heartbeat in watchdog core</title>
<updated>2016-03-16T20:11:14+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-02-28T21:12:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=664a39236e718f9f03fa73fc01006da9ced04efc'/>
<id>urn:sha1:664a39236e718f9f03fa73fc01006da9ced04efc</id>
<content type='text'>
Introduce an optional hardware maximum heartbeat in the watchdog core.
The hardware maximum heartbeat can be lower than the maximum timeout.

Drivers can set the maximum hardware heartbeat value in the watchdog data
structure. If the configured timeout exceeds the maximum hardware heartbeat,
the watchdog core enables a timer function to assist sending keepalive
requests to the watchdog driver.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Make set_timeout function optional</title>
<updated>2016-03-16T20:11:07+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-02-28T21:12:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fb32e9b9deeb5df2913deb7d2ae8c36f4f66ecf3'/>
<id>urn:sha1:fb32e9b9deeb5df2913deb7d2ae8c36f4f66ecf3</id>
<content type='text'>
For some watchdogs, the watchdog driver handles timeout changes without
explicitly setting any registers. In this situation, the watchdog driver
might only set the 'timeout' variable but do nothing else.
This can as well be handled by the infrastructure, so make the set_timeout
callback optional. If WDIOF_SETTIMEOUT is configured but the .set_timeout
callback is not available, update the timeout variable in the
infrastructure code.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Drop pointer to watchdog device from struct watchdog_device</title>
<updated>2016-01-11T20:53:59+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-01-03T23:11:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0254e953537c92df3e7d0176f401a211e944fd61'/>
<id>urn:sha1:0254e953537c92df3e7d0176f401a211e944fd61</id>
<content type='text'>
The lifetime of the watchdog device pointer is different from the lifetime
of its character device. Remove it entirely to avoid race conditions.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
<entry>
<title>watchdog: Add support for creating driver specific sysfs attributes</title>
<updated>2016-01-11T20:53:57+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-01-03T23:11:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=faa584757b63aad42d19f1c6a6eac2c848618f83'/>
<id>urn:sha1:faa584757b63aad42d19f1c6a6eac2c848618f83</id>
<content type='text'>
The Zodiac watchdog driver attaches additional sysfs attributes to the
watchdog device. This has a number of problems: The watchdog device
lifetime differs from the driver lifetime, and the device structure
should therefore not be accessed from drivers. Also, creating sysfs
attributes after driver registration results in a potential race condition
if user space expects the attributes to exist but they don't exist yet.

Add support for creating driver specific sysfs attributes to the watchdog
core to solve the problems.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@iguana.be&gt;
</content>
</entry>
</feed>
