From: Diogo Ivo <diogo.ivo@bootlin.com>
To: sashiko-reviews@lists.linux.dev
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org,
linux-watchdog@vger.kernel.org
Subject: Re: [PATCH 2/3] watchdog: omap: Add support for reading boot status
Date: Fri, 11 Sep 2026 17:11:44 +0200 [thread overview]
Message-ID: <394c64f5-aa0e-4af6-ba69-2c2c60722d44@bootlin.com> (raw)
In-Reply-To: <20260911093051.D2B671F000FF@smtp.kernel.org>
On 9/11/26 11:30 AM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> New issues:
> - [Medium] omap_wdt_is_running() fails to detect a running watchdog if the bootloader configured a hardware prescaler, causing a false negative.
>
> Pre-existing issues:
> - [High] Missing return value check for pm_runtime_get_sync() leads to potential system crash on unclocked MMIO access.
> --
>
> commit a118768ddc7f3bc1aec5e3a2e71d0f63ab1a2766
> Author: Diogo Ivo <diogo.ivo@bootlin.com>
> Subject: watchdog: omap: Add support for reading boot status
>
> This commit adds support for determining the boot status of the watchdog
> during driver probe. By checking if the counter is actively incrementing,
> the driver can maintain a running watchdog previously enabled by the
> bootloader.
>
>> diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
>> index f8a76df3c7882..d9ab46c70f8c8 100644
>> --- a/drivers/watchdog/omap_wdt.c
>> +++ b/drivers/watchdog/omap_wdt.c
>
> [ ... ]
>
>> @@ -225,6 +228,20 @@ static const struct watchdog_ops omap_wdt_ops = {
>> .get_timeleft = omap_wdt_get_timeleft,
>> };
>>
>> +static bool omap_wdt_is_running(struct omap_wdt_dev *wdev)
>> +{
>> + unsigned long period_us = USEC_PER_SEC / RATE_32K;
>> + void __iomem *base = wdev->base;
>> + u32 value;
>> +
>> + value = readl_relaxed(base + OMAP_WATCHDOG_CRR);
>> +
>> + /* Give the watchdog some time to count if it's on */
>> + usleep_range(period_us * 10, period_us * 11);
>
> [Severity: Medium]
> Could this wait duration fail to detect a running watchdog if the bootloader
> configured a hardware prescaler?
>
> The duration statically assumes an unscaled 32kHz clock. If the bootloader
> enabled the watchdog and configured a non-zero prescaler via the PTV bits in
> OMAP_WATCHDOG_CNTRL, a single clock tick will take much longer.
>
> For example, with a large prescaler like PTV=7, the 32kHz clock is divided
> by 128, meaning a single clock tick takes around 3.9ms. The hardcoded wait
> of ~330us would complete before the counter increments.
>
> Would this cause omap_wdt_is_running() to return a false negative, leading
> the probe function to incorrectly conclude the watchdog is stopped and
> subsequently disable it?
This is a valid point that I will address in v2.
>> +
>> + return readl_relaxed(base + OMAP_WATCHDOG_CRR) != value;
>> +}
>> +
>> static int omap_wdt_probe(struct platform_device *pdev)
>
> [ ... ]
>
>> @@ -267,7 +284,7 @@ static int omap_wdt_probe(struct platform_device *pdev)
>> wdev->wdog.bootstatus = WDIOF_CARDRESET;
>> }
>>
>> - if (early_enable) {
>> + if (omap_wdt_is_running(wdev) || early_enable) {
>
> [Severity: High]
> This is a pre-existing issue, but does pm_runtime_get_sync() need a return
> value check before we attempt hardware register accesses in this path?
>
> If the clock domain cannot be enabled and pm_runtime_get_sync() fails earlier
> in omap_wdt_probe(), proceeding to call the newly added omap_wdt_is_running()
> will result in reading from unclocked OMAP registers.
>
> Can this unclocked MMIO access trigger an asynchronous external abort and
> crash the system? The same concern applies to omap_wdt_start() and
> omap_wdt_disable() where pm_runtime_get_sync() is also left unchecked.
Again, pre-existing issue that I can take a look at in a separate patch
series.
Diogo
>> omap_wdt_start(&wdev->wdog);
>> set_bit(WDOG_HW_RUNNING, &wdev->wdog.status);
>> } else {
>
next prev parent reply other threads:[~2026-09-11 15:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 9:17 [PATCH 0/3] watchdog: omap: Preserve OMAP watchdog across boot to detect faulty boots Diogo Ivo
2026-09-11 9:17 ` [PATCH 1/3] watchdog: omap: Remove duplicate start() with early_init Diogo Ivo
2026-09-11 9:29 ` sashiko-bot
2026-09-11 15:09 ` Diogo Ivo
2026-09-11 9:17 ` [PATCH 2/3] watchdog: omap: Add support for reading boot status Diogo Ivo
2026-09-11 9:30 ` sashiko-bot
2026-09-11 15:11 ` Diogo Ivo [this message]
2026-09-11 9:17 ` [PATCH 3/3] arm: dts: ti: omap: Prevent watchdog from being reset on kernel boot Diogo Ivo
2026-09-11 9:30 ` sashiko-bot
2026-09-11 15:13 ` Diogo Ivo
2026-09-11 14:29 ` [PATCH 0/3] watchdog: omap: Preserve OMAP watchdog across boot to detect faulty boots Guenter Roeck
2026-09-11 15:17 ` Diogo Ivo
2026-09-11 17:25 ` Guenter Roeck
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=394c64f5-aa0e-4af6-ba69-2c2c60722d44@bootlin.com \
--to=diogo.ivo@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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