From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Biju Das <biju.das.jz@bp.renesas.com>,
Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [PATCH v2 7/9] watchdog: rzv2h: Set min_timeout based on max_hw_heartbeat_ms
Date: Fri, 1 Aug 2025 21:51:06 +0100 [thread overview]
Message-ID: <CA+V-a8v0KZaeJwJAmEpRRdS3F3vC_CYv7zGN_n9a+M6qhFDMHg@mail.gmail.com> (raw)
In-Reply-To: <cd0653d0-4a2f-4361-8eb2-c1937d988a8c@roeck-us.net>
Hi Guenter,
On Fri, Aug 1, 2025 at 7:04 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 8/1/25 08:30, Lad, Prabhakar wrote:
> > Hi Guenter,
> >
> > On Fri, Aug 1, 2025 at 2:52 PM Guenter Roeck <linux@roeck-us.net> wrote:
> >>
> >> On 8/1/25 04:05, Lad, Prabhakar wrote:
> >>> Hi Wolfram,
> >>>
> >>> Thank you for the review.
> >>>
> >>> On Fri, Aug 1, 2025 at 5:10 AM Wolfram Sang
> >>> <wsa+renesas@sang-engineering.com> wrote:
> >>>>
> >>>> On Tue, Jul 29, 2025 at 04:59:13PM +0100, Prabhakar wrote:
> >>>>> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >>>>>
> >>>>> Update the watchdog minimum timeout value to be derived from
> >>>>> `max_hw_heartbeat_ms` using `DIV_ROUND_UP()` to ensure a valid and
> >>>>> consistent minimum timeout in seconds.
> >>>>
> >>>> I don't understand this change. Why is the _minimum_ timeout based on
> >>>> the _maximum_ heartbeat?
> >>>>
> >>> The reason for deriving min_timeout from max_hw_heartbeat_ms is to
> >>> ensure the minimum watchdog period (in seconds) is compatible with the
> >>> underlying hardware.
> >>>
> >>> max_hw_heartbeat_ms is calculated as:
> >>> max_hw_heartbeat_ms = (1000 * 16384 * cks_div) / clk_rate;
> >>>
> >>> This value varies by SoC:
> >>> RZ/T2H: cks_div = 8192, clk ≈ 62.5 MHz -> max_hw_heartbeat_ms ~ 2147ms
> >>> RZ/V2H: cks_div = 256, clk ≈ 240 MHz -> max_hw_heartbeat_ms ~ 174ms
> >>>
> >>> Since min_timeout is in seconds, setting it to:
> >>> min_timeout = DIV_ROUND_UP(max_hw_heartbeat_ms, 1000);
> >>>
> >>> ensures:
> >>> The minimum timeout period is never less than what the hardware can support.
> >>> - For T2H, this results in a min_timeout of 3s (2147ms -> 3s).
> >>> - For V2H, it’s just 1s (174ms -> 1s).
> >>>
> >>
> >> Sorry, I completely fail to understand the logic.
> >>
> >> If the maximum timeout is, say, 2 seconds, why would the hardware
> >> not be able to support a timeout of 1 second ?
> >>
> > The watchdog timer on RZ/V2H (and RZ/T2H) is a 14 bit down counter. On
> > initialization the down counters on the SoCs are configured to the max
> > down counter. On RZ/V2H down counter value 4194304 (which evaluates to
> > 174ms) is and on RZ/T2H is 134217728 (which evaluates to 2147ms). The
> > board will be reset when we get an underflow error.
> >
> > So for example on T2H consider this example:
> > - down counter is 134217728
> > - min_timeout is set to 1 in the driver
> > - When set WDIOC_SETTIMEOUT to 1
> > In this case the board will be reset after 2147ms, i.e. incorrect
> > behaviour as we expect the board to be reset after 1 sec. Hence the
> > min_timeout is set to 3s (2147ms -> 3s).
> >
> > Please let me know if my understanding of min_timeout is incorrect here.
> >
>
> The driver is missing a set_timeout function. It should set RZ/T2H
> to 62514079 if a timeout of 1 second is configured.
>
Ok, you mean to handle the 1sec case, introduce the set_timeout for RZ/T2H SoC.
Although we cannot achieve the exact 1sec case as we can have only 4
timeout period options (number of cycles):
1] For TIMEOUT_CYCLES = 1024
- (1000×1024×8192)/62500000 = 134.22 ms
2] For TIMEOUT_CYCLES = 4096
- (1000×4096×8192)/62500000 = 536.87 ms
3] For TIMEOUT_CYCLES = 8192
- (1000×8192×8192)/62500000 = 1,073.74 ms
4] For TIMEOUT_CYCLES = 16384
- (1000×16384×8192)/62500000 = 2,147.48 ms
So to handle the 1sec case I'll set the timeout period to 8192 with
which we get a timeout of 1,073.74 ms.
Cheers,
Prabhakar
next prev parent reply other threads:[~2025-08-01 20:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 15:59 [PATCH v2 0/9] Add watchdog driver support for RZ/T2H and RZ/N2H SoCs Prabhakar
2025-07-29 15:59 ` [PATCH v2 1/9] dt-bindings: watchdog: renesas,wdt: Add support for RZ/T2H and RZ/N2H Prabhakar
2025-07-29 15:59 ` [PATCH v2 2/9] watchdog: rzv2h_wdt: Obtain clock-divider ranges from OF match data Prabhakar
2025-08-01 4:03 ` Wolfram Sang
2025-07-29 15:59 ` [PATCH v2 3/9] watchdog: rzv2h_wdt: Obtain CKS divider via OF data Prabhakar
2025-08-01 4:04 ` Wolfram Sang
2025-08-01 11:41 ` Lad, Prabhakar
2025-07-29 15:59 ` [PATCH v2 4/9] watchdog: rzv2h_wdt: Make "oscclk" an optional clock Prabhakar
2025-08-01 4:04 ` Wolfram Sang
2025-07-29 15:59 ` [PATCH v2 5/9] watchdog: rzv2h_wdt: Add support for configurable count clock source Prabhakar
2025-08-01 4:04 ` Wolfram Sang
2025-07-29 15:59 ` [PATCH v2 6/9] watchdog: rzv2h_wdt: Make reset controller optional Prabhakar
2025-08-01 4:04 ` Wolfram Sang
2025-08-01 11:42 ` Lad, Prabhakar
2025-07-29 15:59 ` [PATCH v2 7/9] watchdog: rzv2h: Set min_timeout based on max_hw_heartbeat_ms Prabhakar
2025-08-01 4:10 ` Wolfram Sang
2025-08-01 11:05 ` Lad, Prabhakar
2025-08-01 13:52 ` Guenter Roeck
2025-08-01 15:30 ` Lad, Prabhakar
2025-08-01 18:04 ` Guenter Roeck
2025-08-01 20:51 ` Lad, Prabhakar [this message]
2025-08-01 21:04 ` Guenter Roeck
2025-08-02 19:26 ` Lad, Prabhakar
2025-08-03 0:16 ` Guenter Roeck
2025-08-04 11:24 ` Lad, Prabhakar
2025-07-29 15:59 ` [PATCH v2 8/9] watchdog: rzv2h: Add support for RZ/T2H Prabhakar
2025-08-01 4:12 ` Wolfram Sang
2025-08-01 11:15 ` Lad, Prabhakar
2025-08-03 21:38 ` Wolfram Sang
2025-07-29 15:59 ` [PATCH v2 9/9] watchdog: rzv2h_wdt: Improve error strings and add newlines Prabhakar
2025-08-01 4:17 ` Wolfram Sang
2025-07-29 17:08 ` [PATCH v2 0/9] Add watchdog driver support for RZ/T2H and RZ/N2H SoCs Wolfram Sang
2025-07-29 17:10 ` Lad, Prabhakar
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=CA+V-a8v0KZaeJwJAmEpRRdS3F3vC_CYv7zGN_n9a+M6qhFDMHg@mail.gmail.com \
--to=prabhakar.csengg@gmail.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=magnus.damm@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=robh@kernel.org \
--cc=wim@linux-watchdog.org \
--cc=wsa+renesas@sang-engineering.com \
/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).