From: "Alexis Lothoré" <alexis.lothore@bootlin.com>
To: "Maxime Chevallier" <maxime.chevallier@bootlin.com>
Cc: "Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Jose Abreu" <joabreu@synopsys.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Phil Reid" <preid@electromag.com.au>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
<netdev@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] net: stmmac: add explicit check and error on invalid PTP clock rate
Date: Wed, 28 May 2025 10:06:23 +0200 [thread overview]
Message-ID: <DA7N0K4FSI14.QARGA1ALU2XV@bootlin.com> (raw)
In-Reply-To: <20250527183105.7c4bad49@device-24.home>
Hey Maxime,
On Tue May 27, 2025 at 6:31 PM CEST, Maxime Chevallier wrote:
> Hi Alexis,
>
> On Tue, 27 May 2025 08:33:44 +0200
> Alexis Lothoré <alexis.lothore@bootlin.com> wrote:
[...]
>> + if (!priv->plat->clk_ptp_rate) {
>> + netdev_err(priv->dev, "Invalid PTP clock rate");
>> + return -EINVAL;
>> + }
>> +
>> stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
>> priv->systime_flags = systime_flags;
>
> This may be some nitpick that can be addressed at a later point, but we
> now have a guarantee that when stmmac_ptp_register() gets called,
> priv->ptp_clk_rate is non-zero, right ? If so, we can drop the test in
> said function :
>
> if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate)
> priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate;
You are right, my series makes this check a duplicate, I'll remove it.
> There is another spot in the code, like in the EST handling, where we
> divide by priv->plat->ptp_clk_rate :
>
> stmmac_adjust_time(...)
> stmmac_est_configure(priv, priv, priv->est,
> priv->plat->clk_ptp_rate)
> .est_configure()
> ctrl |= ((NSEC_PER_SEC / ptp_rate) [...]
>
> Maybe we should fail EST configuration as well if ptp_clk_rate is 0
> (probably in stmmac_tc.c's tc_taprio_configure or in the
> .est_configure). That can be a step for later as well, as I don't know
> if the setup you found this bug on even supports taprio/EST, and setups
> that do didn't seem to encounter the bug yet.
I guess you are right as well, it may not make sense to try to configure
EST if we have a bogus clk_ptp_rate value. est_configure seems to be called
in both tc_taprio_configure and stmmac_adjust_time, so I'll add the check
in est_configure.
Thanks,
Alexis
--
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2025-05-28 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 6:33 [PATCH v2] net: stmmac: add explicit check and error on invalid PTP clock rate Alexis Lothoré
2025-05-27 16:31 ` Maxime Chevallier
2025-05-28 8:06 ` Alexis Lothoré [this message]
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=DA7N0K4FSI14.QARGA1ALU2XV@bootlin.com \
--to=alexis.lothore@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=preid@electromag.com.au \
--cc=richardcochran@gmail.com \
--cc=thomas.petazzoni@bootlin.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.