[PATCH 0/6] watchdog: report effective timeout and add gettimeout command
adds a max_timeout_ms field to per-device uclass-plat data. Drivers set this
at probe time; wdt_start() then clamps the requested timeout to the hardware
maximum and prints both values when they differ, e.g.:
WDT: Started watchdog@31008000 without servicing (42s timeout, requested 60s)
adi_wdt was not updated as part of that series and needs a follow-up.
Problem
All ADI SC5xx defconfigs set CONFIG_WATCHDOG_TIMEOUT_MSECS=60000 (60 s).
WDOG_CNT is a 32-bit register. At typical sclk0 rates the 60 s request
overflows the register silently:
| Platform |
sclk0 |
Max timeout |
At 60 s requested |
| SC58X |
200 MHz |
~42.9 s |
truncated → ~14.9 s |
| Non-SC58X |
125 MHz |
~34.4 s |
truncated → ~25.6 s |
| Non-SC58X |
200 MHz |
~21.5 s |
truncated → ~17.1 s |
The boot log always prints 60s timeout regardless, so the discrepancy is
invisible.
Work Required
1. Set max_timeout_ms in adi_wdt_probe()
Once the upstream uclass change has landed, compute the hardware maximum during
probe and store it in the per-device uclass-plat data so the uclass can clamp
and report accurately:
/* in adi_wdt_probe(), after clk_get_by_name() succeeds */
struct wdt_uclass_plat *uc_plat = dev_get_uclass_plat(dev);
u64 clk_rate = clk_get_rate(&priv->clock);
if (IS_ENABLED(CONFIG_SC58X))
clk_rate /= 2;
if (clk_rate)
uc_plat->max_timeout_ms = lldiv((u64)U32_MAX * 1000, clk_rate);
2. Clamp WDOG_CNT and use lldiv() in adi_wdt_start()
The existing calculation overflows to a truncated u32 without clamping.
Fix it to match what the uclass will advertise:
u64 clk_rate = clk_get_rate(&priv->clock);
if (IS_ENABLED(CONFIG_SC58X))
clk_rate /= 2;
u64 cnt = lldiv(timeout_ms * clk_rate, 1000);
if (cnt > U32_MAX)
cnt = U32_MAX;
iowrite32((u32)cnt, priv->wdt_base + WDOG_CNT);
Acceptance Criteria
- Boot log on an SC5xx board with a 60 s requested timeout shows the clamped
effective timeout, e.g. (42s timeout, requested 60s).
WDOG_CNT contains the correctly clamped value, not a silently wrapped one.
[PATCH 0/6] watchdog: report effective timeout and add gettimeout command
adds a
max_timeout_msfield to per-device uclass-plat data. Drivers set thisat probe time;
wdt_start()then clamps the requested timeout to the hardwaremaximum and prints both values when they differ, e.g.:
adi_wdtwas not updated as part of that series and needs a follow-up.Problem
All ADI SC5xx defconfigs set
CONFIG_WATCHDOG_TIMEOUT_MSECS=60000(60 s).WDOG_CNTis a 32-bit register. At typical sclk0 rates the 60 s requestoverflows the register silently:
The boot log always prints
60s timeoutregardless, so the discrepancy isinvisible.
Work Required
1. Set
max_timeout_msinadi_wdt_probe()Once the upstream uclass change has landed, compute the hardware maximum during
probe and store it in the per-device uclass-plat data so the uclass can clamp
and report accurately:
2. Clamp
WDOG_CNTand uselldiv()inadi_wdt_start()The existing calculation overflows to a truncated u32 without clamping.
Fix it to match what the uclass will advertise:
Acceptance Criteria
effective timeout, e.g.
(42s timeout, requested 60s).WDOG_CNTcontains the correctly clamped value, not a silently wrapped one.