From: Matti Vaittinen <mazziesaccount@gmail.com>
To: George Cherian <george.cherian@marvell.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org
Subject: Re: [RFC PATCH v2 5/6] watchdog: ROHM BD96801 PMIC WDG driver
Date: Wed, 17 Apr 2024 10:35:43 +0300 [thread overview]
Message-ID: <a605e79e-7b3d-477b-b6af-56ffb0cca6d3@gmail.com> (raw)
In-Reply-To: <20240417042949.GA3513394@IPBU-BLR-SERVER1>
Hi George,
Thanks for the input! Reviewing is very much appreciated :)
On 4/17/24 07:29, George Cherian wrote:
> On 2024-04-12 at 16:52:46, Matti Vaittinen (mazziesaccount@gmail.com) wrote:
>> Introduce driver for WDG block on ROHM BD96801 scalable PMIC.
>>
>> This driver only supports watchdog with I2C feeding and delayed
>> response detection. Whether the watchdog toggles PRSTB pin or
>> just causes an interrupt can be configured via device-tree.
>>
>> The BD96801 PMIC HW supports also window watchdog (too early
>> feeding detection) and Q&A mode. These are not supported by
>> this driver.
>>
>> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
>>
>> ---
>> Revision history:
>> RFCv1 => RFCv2:
>> - remove always running
>> - add IRQ handling
>> - call emergency_restart()
>> - drop MODULE_ALIAS and add MODULE_DEVICE_TABLE
>> ---
>> drivers/watchdog/Kconfig | 13 ++
>> drivers/watchdog/Makefile | 1 +
>> drivers/watchdog/bd96801_wdt.c | 389 +++++++++++++++++++++++++++++++++
>> 3 files changed, 403 insertions(+)
>> create mode 100644 drivers/watchdog/bd96801_wdt.c
>>4
>> +
>> +static const struct watchdog_ops bd96801_wdt_ops = {
>> + .start = bd96801_wdt_start,
>> + .stop = bd96801_wdt_stop,
>> + .ping = bd96801_wdt_ping,
>> +};
> Is there no way to setup a timeout to the WDOG device from userspace?
>
For the BD96801 hardware? Currently no. (See below)
>> +
>> +static int init_wdg_hw(struct wdtbd96801 *w)
>> +{
>> + u32 hw_margin[2];
>> + int count, ret;
>> + u32 hw_margin_max = BD96801_WDT_DEFAULT_MARGIN, hw_margin_min = 0;
>> +
>> + count = device_property_count_u32(w->dev->parent, "rohm,hw-timeout-ms");
> Why is that timeout need to be configured from a devicce-tree property?
> set_timeout/get_timeout can't be done for this device?
The BD96801 supports 32 different "slow detection" timeouts - only 1 of
which is guaranteed to be greater than 1s (1.8432 Sec). The timeout
setting interface uses seconds.
Furthermore, I think that the HW heartbeat is not all that meaningful to
the user-space. What is meaningful to user-space is how often the
userland daemon needs to write the watchdog file to keep system alive.
This is different thing. With the sub-second HW timeouts it is better
the kernel keeps feeding the watchdog based on a timer (adjusted to meet
the HW requirements) and can thus require the userspace to ping less
frequently than the HW heartbeat.
>> + if (count < 0 && count != -EINVAL)
>> + return count;
>> +
>> + if (count > 0) {
>> + if (count > ARRAY_SIZE(hw_margin))
>> + return -EINVAL;
>> +
>> + ret = device_property_read_u32_array(w->dev->parent,
>> + "rohm,hw-timeout-ms",
>> + &hw_margin[0], count);
>> + if (ret < 0)
>> + return ret;
>> +
>> + if (count == 1)
>> + hw_margin_max = hw_margin[0];
>> +
>> + if (count == 2) {
>> + hw_margin_max = hw_margin[1];
>> + hw_margin_min = hw_margin[0];
>> + }
>> + }
>> +
>> + ret = bd96801_set_wdt_mode(w, hw_margin_max, hw_margin_min);
>> + if (ret)
>> + return ret;
>> +
>> + ret = device_property_match_string(w->dev->parent, "rohm,wdg-action",
>> + "prstb");
>> + if (ret >= 0) {
>> + ret = regmap_update_bits(w->regmap, BD96801_REG_WD_CONF,
>> + BD96801_WD_ASSERT_MASK,
>> + BD96801_WD_ASSERT_RST);
>> + return ret;
>> + }
>> +
>> + ret = device_property_match_string(w->dev->parent, "rohm,wdg-action",
>> + "intb-only");
>> + if (ret >= 0) {
>> + ret = regmap_update_bits(w->regmap, BD96801_REG_WD_CONF,
>> + BD96801_WD_ASSERT_MASK,
>> + BD96801_WD_ASSERT_IRQ);
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +extern void emergency_restart(void);
>> +static irqreturn_t bd96801_irq_hnd(int irq, void *data)
>> +{
>> + emergency_restart();
> In case of a full system hang will this function get executed?
Maybe, maybe not. It is probably still the best we can do if the
watchdog has not been configured to kill the power by HW. Or, do you
have some other suggestion? (The emergency_restart() was actually
suggested by Guenter during the v1 review).
>> + return IRQ_NONE;
>> +}
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2024-04-17 7:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 11:20 [RFC PATCH v2 0/6] Support ROHM BD96801 scalable PMIC Matti Vaittinen
2024-04-12 11:21 ` [RFC PATCH v2 1/6] dt-bindings: ROHM BD96801 PMIC regulators Matti Vaittinen
2024-04-13 21:27 ` Krzysztof Kozlowski
2024-04-15 6:51 ` Matti Vaittinen
2024-04-15 15:29 ` Krzysztof Kozlowski
2024-04-12 11:21 ` [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core Matti Vaittinen
2024-04-13 21:33 ` Krzysztof Kozlowski
2024-04-13 21:36 ` Krzysztof Kozlowski
2024-04-15 5:50 ` Matti Vaittinen
2024-04-15 6:24 ` Matti Vaittinen
2024-04-15 15:25 ` Krzysztof Kozlowski
2024-04-15 8:28 ` Matti Vaittinen
2024-04-18 17:28 ` Krzysztof Kozlowski
2024-04-19 5:48 ` Matti Vaittinen
2024-04-12 11:22 ` [RFC PATCH v2 3/6] mfd: support ROHM BD96801 " Matti Vaittinen
2024-04-12 11:22 ` [RFC PATCH v2 4/6] regulator: bd96801: ROHM BD96801 PMIC regulators Matti Vaittinen
2024-04-12 11:22 ` [RFC PATCH v2 5/6] watchdog: ROHM BD96801 PMIC WDG driver Matti Vaittinen
2024-04-17 4:29 ` George Cherian
2024-04-17 7:35 ` Matti Vaittinen [this message]
2024-04-17 18:20 ` Matti Vaittinen
2024-04-12 11:23 ` [RFC PATCH v2 6/6] MAINTAINERS: Add ROHM BD96801 'scalable PMIC' entries Matti Vaittinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a605e79e-7b3d-477b-b6af-56ffb0cca6d3@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=george.cherian@marvell.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=robh@kernel.org \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).