From: sashiko-bot@kernel.org
To: "Rustam Adilov" <adilov@disroot.org>
Cc: krzk+dt@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org,
linux-watchdog@vger.kernel.org
Subject: Re: [PATCH 3/3] watchdog: realtek-otto: add RTL9607C support
Date: Sat, 09 May 2026 17:27:47 +0000 [thread overview]
Message-ID: <20260509172748.54B33C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260509163101.722793-4-adilov@disroot.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Registers accessed before peripheral clock is enabled
- [High] Sleeping function `disable_irq()` called in atomic restart handler
- [High] Integer underflow in timeout calculation causes massively delayed watchdog reset
--
commit be1a33571f33f241ada324d2648ec90cdf1e9b91
Author: Rustam Adilov <adilov@disroot.org>
watchdog: realtek-otto: add RTL9607C support
The RTL9607C SoC has a watchdog timer identical to the already
supported SoCs. The peripheral is memory mapped at 0x18003260
and driven by the Lexra bus clock.
> diff --git a/drivers/watchdog/realtek_otto_wdt.c b/drivers/watchdog/realtek_otto_wdt.c
> index e5e9cb480f4f9..7ad196802eeb5 100644
> --- a/drivers/watchdog/realtek_otto_wdt.c
> +++ b/drivers/watchdog/realtek_otto_wdt.c
> @@ -355,6 +355,7 @@ static const struct of_device_id otto_wdt_ids[] = {
> { .compatible = "realtek,rtl8390-wdt" },
> { .compatible = "realtek,rtl9300-wdt" },
> { .compatible = "realtek,rtl9310-wdt" },
> + { .compatible = "realtek,rtl9607-wdt" },
This isn't a bug introduced by this patch, but enabling this driver for the
new SoC exposes a few existing regressions in the code.
For example, can the driver safely access the peripheral's memory-mapped
registers before its clock domain is enabled?
otto_wdt_probe() {
[ ... ]
/* Clear any old interrupts and reset initial state */
regmap_write(ctrl->regmap, OTTO_WDT_REG_INTR,
OTTO_WDT_INTR_PHASE_1 | OTTO_WDT_INTR_PHASE_2);
regmap_write(ctrl->regmap, OTTO_WDT_REG_CTRL, OTTO_WDT_CTRL_DEFAULT);
ret = otto_wdt_probe_clk(ctrl);
[ ... ]
}
Writing to OTTO_WDT_REG_INTR and OTTO_WDT_REG_CTRL before calling
otto_wdt_probe_clk() might violate hardware access requirements and could
cause a synchronous external bus abort or system hang during driver probe.
Also, does the system restart handler sleep in an atomic context?
otto_wdt_restart() {
[ ... ]
disable_irq(ctrl->irq_phase1);
[ ... ]
}
The otto_wdt_restart() function is a system restart handler executed in an
atomic context with local interrupts disabled. Since disable_irq() internally
invokes synchronize_irq(), which uses wait_event() to wait for executing
interrupt handlers to finish, it can sleep.
Calling a sleeping function with local interrupts disabled triggers a kernel
panic, and waiting for an IRQ handler to complete while other CPUs are stopped
during a machine restart can result in a hard deadlock. Should this use
disable_irq_nosync() instead?
Finally, is there an integer underflow in the timeout calculation?
otto_wdt_determine_timeouts() {
[ ... ]
total_ticks = div_round_ticks(timeout_ms, tick_ms, 2);
phase1_ticks = div_round_ticks(timeout_ms - pretimeout_ms, tick_ms, 1);
phase2_ticks = total_ticks - phase1_ticks;
[ ... ]
val |= FIELD_PREP(OTTO_WDT_CTRL_PHASE2, phase2_ticks - 1);
[ ... ]
}
If the pretimeout is configured to 0 (or a value small enough that it maps to
the same tick interval), total_ticks and phase1_ticks evaluate to the exact
same value, resulting in phase2_ticks = 0.
Since phase2_ticks is an unsigned integer, 0 - 1 underflows to 0xFFFFFFFF,
which FIELD_PREP masks to the maximum field value of 31. Does this configure
the hardware to delay the system reset by 32 ticks (over 5 seconds) instead
of the intended minimum of 1 tick?
> { }
> };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260509163101.722793-1-adilov@disroot.org?part=3
next prev parent reply other threads:[~2026-05-09 17:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 16:30 [PATCH 0/3] watchdog: realtek-otto: Make use of regmap API and add RTL9607C support Rustam Adilov
2026-05-09 16:30 ` [PATCH 1/3] watchdog: realtek-otto: Change to use regmap API Rustam Adilov
2026-05-09 17:16 ` sashiko-bot
2026-05-09 16:31 ` [PATCH 2/3] dt-bindings: watchdog: realtek,otto-wdt: add compatible for RTL9607C Rustam Adilov
2026-05-09 18:13 ` Conor Dooley
2026-05-10 8:19 ` Rustam Adilov
2026-05-10 19:23 ` Sander Vanheule
2026-05-09 16:31 ` [PATCH 3/3] watchdog: realtek-otto: add RTL9607C support Rustam Adilov
2026-05-09 17:27 ` sashiko-bot [this message]
2026-05-10 18:12 ` Sander Vanheule
2026-05-10 15:13 ` [PATCH 0/3] watchdog: realtek-otto: Make use of regmap API and " 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=20260509172748.54B33C2BCB2@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=adilov@disroot.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko@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