watchdog: da9062: da9063: use unlocked xfer function in restart
authorPrimoz Fiser <primoz.fiser@norik.com>
Fri, 16 Dec 2022 08:36:45 +0000 (09:36 +0100)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 18 Feb 2023 14:11:30 +0000 (15:11 +0100)
commitf8ee39b44b75ac955bb54f46d5370481727c47e7
tree662eaa12381e0b9aa32e1e97bb6bd358f36819c9
parent00bdbc9a860152cafc0bcfa4fc70f38401101ebc
watchdog: da9062: da9063: use unlocked xfer function in restart

Machine resets via da9062/da9063 PMICs are challenging since one needs
to use special i2c atomic transfers due to the fact interrupts are
disabled in such late system stages. This is the reason both PMICs don't
use regmap and have instead opted for i2c_smbus_write_byte_data() in
restart handlers.

However extensive testing revealed that even using atomic safe function
is not enough and occasional resets fail with error message "Failed to
shutdown (err =  -11)". This is due to the fact that function
i2c_smbus_write_byte_data() in turn calls __i2c_lock_bus_helper()
which might fail with -EAGAIN when bus lock is already taken and cannot
be released anymore.

Thus replace i2c_smbus_write_byte_data() with unlocked flavor of
i2c_smbus_xfer() function to avoid above dead-lock scenario. At this
system stage we don't care about proper locking anymore and only want
proper machine reset to be carried out.

Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20221216083645.2574077-1-primoz.fiser@norik.com
[groeck: Fixed continuation line alignment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/da9062_wdt.c
drivers/watchdog/da9063_wdt.c