<feed xmlns='http://www.w3.org/2005/Atom'>
<title>BMC/Intel-BMC/linux.git/drivers/watchdog/watchdog_dev.c, branch dev-4.6</title>
<subtitle>Intel OpenBMC Linux kernel source tree (mirror)</subtitle>
<id>https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev-4.6</id>
<link rel='self' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev-4.6'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/'/>
<updated>2016-06-01T19:18:03+00:00</updated>
<entry>
<title>watchdog: core: Fix circular locking dependency</title>
<updated>2016-06-01T19:18:03+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/BMC/Intel-BMC/linux.git/commit/?id=21abae567dffb8c6ddff24261acd19f554abfa28'/>
<id>urn:sha1:21abae567dffb8c6ddff24261acd19f554abfa28</id>
<content type='text'>
commit e1f30282a1d3d0c75d5a08e47c6ac1563065be52 upstream.

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));

</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/BMC/Intel-BMC/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/BMC/Intel-BMC/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/BMC/Intel-BMC/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/BMC/Intel-BMC/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/BMC/Intel-BMC/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/BMC/Intel-BMC/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/BMC/Intel-BMC/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/BMC/Intel-BMC/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>
<entry>
<title>watchdog: Separate and maintain variables based on variable lifetime</title>
<updated>2015-12-29T19:36:03+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2015-12-26T00:01:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=b4ffb1909843b28f3b1b60197d517b123b7a9b66'/>
<id>urn:sha1:b4ffb1909843b28f3b1b60197d517b123b7a9b66</id>
<content type='text'>
All variables required by the watchdog core to manage a watchdog are
currently stored in struct watchdog_device. The lifetime of those
variables is determined by the watchdog driver. However, the lifetime
of variables used by the watchdog core differs from the lifetime of
struct watchdog_device. To remedy this situation, watchdog drivers
can implement ref and unref callbacks, to be used by the watchdog
core to lock struct watchdog_device in memory.

While this solves the immediate problem, it depends on watchdog drivers
to actually implement the ref/unref callbacks. This is error prone,
often not implemented in the first place, or not implemented correctly.

To solve the problem without requiring driver support, split the variables
in struct watchdog_device into two data structures - one for variables
associated with the watchdog driver, one for variables associated with
the watchdog core. With this approach, the watchdog core can keep track
of its variable lifetime and no longer depends on ref/unref callbacks
in the driver. As a side effect, some of the variables originally in
struct watchdog_driver are now private to the watchdog core and no longer
visible in watchdog drivers.

As a side effect of the changes made, an ioctl will now always fail
with -ENODEV after a watchdog device was unregistered with the character
device still open. Previously, it would only fail with -ENODEV in some
situations. Also, ioctl operations are now atomic from driver perspective.
With this change, it is now guaranteed that the driver will not unregister
a watchdog between a timeout change and the subsequent ping.

The 'ref' and 'unref' callbacks in struct watchdog_driver are no longer
used and marked as deprecated.

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>
