U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Shmuel Melamud <smelamud@redhat.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>
Cc: Shmuel Leib Melamud via B4 Relay
	<devnull+smelamud.redhat.com@kernel.org>,
	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>, Tom Rini <trini@konsulko.com>,
	Stefan Roese <sr@denx.de>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v3 2/2] renesas: Renesas R-Car Gen4 watchdog driver
Date: Thu, 05 Jun 2025 11:06:35 +0200	[thread overview]
Message-ID: <8734ce36ck.fsf@kernel.org> (raw)
In-Reply-To: <CAMFVLy3mBpTsLD4nKr=cfY0oRYbkRf9rszKYAY3vxhJ81_X=2w@mail.gmail.com>

Hi Shmuel,

On jeu., juin 05, 2025 at 06:33, Shmuel Melamud <smelamud@redhat.com> wrote:

> On Wed, Jun 4, 2025 at 12:02 PM Mattijs Korpershoek
> <mkorpershoek@kernel.org> wrote:
>>
>> Hi Shmuel,
>>
>> Thank you for the patch.
>>
>> On Tue, Jun 03, 2025 at 06:06, Shmuel Leib Melamud via B4 Relay <devnull+smelamud.redhat.com@kernel.org> wrote:
>>
>> > From: Shmuel Leib Melamud <smelamud@redhat.com>

[...]

>> >
>> > +
>> > +static int rwdt_start(struct udevice *dev, u64 timeout, ulong flags)
>> > +{
>> > +     struct rwdt_priv *priv = dev_get_priv(dev);
>> > +     u64 max_timeout;
>> > +     u8 val;
>> > +
>> > +     max_timeout = DIV_BY_CLKS_PER_SEC(priv, 65536);
>>
>> Why 65536. This number is used here ...
>
> 65536 here is the maximal value of the counter plus 1. If we divide it
> by the number of impulses per second, we get the maximal timeout in
> seconds.
>
>> > +     timeout = min(max_timeout, timeout / 1000);
>> > +
>> > +     /* Stop the timer before we modify any register */
>> > +     val = readb_relaxed(&priv->wdt->csra) & ~RWTCSRA_TME;
>> > +     writel_relaxed(val | CSR_MASK, &priv->wdt->csra);
>> > +     /* Delay 2 cycles before setting watchdog counter */
>> > +     rwdt_wait_cycles(priv, 2);
>> > +
>> > +     while (readb_relaxed(&priv->wdt->csra) & RWTCSRA_WRFLG)
>> > +             cpu_relax();
>> > +
>> > +     writel_relaxed((65536 - MUL_BY_CLKS_PER_SEC(priv, timeout)) | CNT_MASK,
>> > +                    &priv->wdt->cnt);
>>
>> ... and here. Can we move it to a define to document its meaning?
>
> 65536 here is for negation. Since the counter is incremented on every
> impulse, the timeout is the number of impulses that are left till
> overflow of the counter.
>
> In both cases it is the maximal value of the counter, so maybe it
> makes sense to add a define for it.

Yes, please move this to a #define. With this constant moved to a
#define, you can add the following to v4 patch:

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

Thanks,
Mattijs

>
>> > +

  reply	other threads:[~2025-06-05  9:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03  3:06 [PATCH v3 0/2] renesas: Renesas R-Car Gen4 watchdog driver Shmuel Leib Melamud via B4 Relay
2025-06-03  3:06 ` [PATCH v3 1/2] renesas: Handle CLK_TYPE_GEN4_MDSEL in gen3_clk_get_rate64() Shmuel Leib Melamud via B4 Relay
2025-06-04  8:39   ` Mattijs Korpershoek
2025-06-08 14:39   ` Marek Vasut
2025-06-03  3:06 ` [PATCH v3 2/2] renesas: Renesas R-Car Gen4 watchdog driver Shmuel Leib Melamud via B4 Relay
2025-06-04  8:52   ` Mattijs Korpershoek
2025-06-05  3:33     ` Shmuel Melamud
2025-06-05  9:06       ` Mattijs Korpershoek [this message]
2025-06-08 14:48   ` Marek Vasut

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=8734ce36ck.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=devnull+smelamud.redhat.com@kernel.org \
    --cc=iwamatsu@nigauri.org \
    --cc=lukma@denx.de \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=seanga2@gmail.com \
    --cc=smelamud@redhat.com \
    --cc=sr@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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