From: Lucas Tanure <tanure@linux.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: xianwei.zhao@amlogic.com, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way
Date: Thu, 22 Oct 2026 18:37:19 +0100 [thread overview]
Message-ID: <00b94eed-fe1b-4cf3-a4ed-12813faacb86@linux.com> (raw)
In-Reply-To: <a1c0b76b-7b67-43e9-af15-3139f17d7fe7@lunn.ch>
On 12/10/2026 13:30, Andrew Lunn wrote:
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
>> @@ -82,6 +82,7 @@ struct meson8b_dwmac_data {
>> int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
>> bool has_prg_eth1_rgmii_rx_delay;
>> bool has_pipeline_clk;
>> + bool mac_applies_dt_delays;
>
> Please can you invert this and call it broken delays.
>
> We should make it clear that new devices should not set this, because
> it wrong, broken.
Moved to a function for T7. And the previous SoCs have their own
function which gets a comment that new SoCs must not use it.
>
>> +static int meson_dwmac_init_dt_delays(struct meson8b_dwmac *dwmac,
>> + struct plat_stmmacenet_data *plat_dat)
>> +{
>> + struct device_node *np = dwmac->dev->of_node;
>> + u32 tx_delay_ps = 0, rx_delay_ps = 0;
>> + phy_interface_t phy_mode;
>> + bool mac_tx, mac_rx;
>> +
>> + mac_tx = !of_property_read_u32(np, "tx-internal-delay-ps", &tx_delay_ps);
>> + mac_rx = !of_property_read_u32(np, "rx-internal-delay-ps", &rx_delay_ps);
>> +
>> + /* one step is a quarter of the RGMII clock period, 2ns at 1Gbit/s */
>> + if (tx_delay_ps > 6000 || tx_delay_ps % 2000)
>> + return dev_err_probe(dwmac->dev, -EINVAL,
>> + "The RGMII TX delay must be 0, 2000, 4000 or 6000ps\n");
>
> tx-internal-delay is not listed in amlogic,meson-dwmac.yaml. Please
> could you add it, and list the valid values.
Patch 2 of this series adds it to the T7 block with the valid values.
That changes in v4, see below.
>
> Do you have access to the datasheet? Could you check these numbers are
> correct, because they are larger than typical. 4ns, and 6ns makes no
> sense, the RGMII standard only calls for 2ns.
Yes. The field is not a delay line. It selects the phase of the TX
clock sent to the PHY: 0, 1/4, 1/2 or 3/4 of the clock period. At
1Gbit/s that is 0, 2, 4 or 6ns, which is where the numbers come from
(the existing amlogic,tx-delay-ns property lists the same four). Only
1/4 is a usable RGMII delay; 1/2 is an inverted clock and 3/4 is a 2ns
lead. And since it is a fraction of the period, the 2ns is only true at
1Gbit/s, at 100Mbit/s the same setting is 10ns. I agree 4000 and 6000
make no sense.
>
>> +
>> + /* the RX delay line moves in 200ps steps and reaches 3000ps */
>> + if (rx_delay_ps > 3000 || rx_delay_ps % 200)
>> + return dev_err_probe(dwmac->dev, -EINVAL,
>> + "The RGMII RX delay range is 0..3000ps in 200ps steps\n");
>
> Please could you listing these values in the binding.
>
> Also, mark that amlogic,tx-delay-ns & amlogic,rx-delay-ns are not
> valid for this compatible.
The RX values are in patch 2 as well, the T7 shares the G12A list
(0..3000ps in 200ps steps); v4 drops the 0. The two vendor properties
are already rejected for the T7: they are only defined for the older
compatibles and the schema has unevaluatedProperties: false. v4 adds an
explicit "false" for both in the T7 block so that it is visible.
>
>> +
>> + phy_mode = phy_fix_phy_mode_for_mac_delays(dwmac->phy_mode, mac_tx,
>> + mac_rx);
>
> This is not correct. This function assumes mac_tx and mac_rx are
> Boolean values, the MAC is applying the full 2ns delay. However, if
> rx-internal-delay-ps is only providing 200ps, that is not true.
>
> I would prefer you keep to the usual way of doing things. Allow the
> MAC to apply small tuning delays, but have the PHY do the 2ns. So
> don't make any modification to phy-mode.
>
OK. v4 does not touch phy-mode. rx-internal-delay-ps becomes the tuning
the MAC adds on top, 200..3000ps. On the TX side the T7 has nothing
small to offer, the only step is the 2ns phase, so v4 does not accept
tx-internal-delay-ps on the T7 at all, in the binding and in the
driver. The VIM4 then uses plain rgmii-id with the PHY adding both
delays. That also removes the wrong claim in patch 7 that the RTL8211F
TX delay does not work; the real cause was a bootloader value left in
the glue register, details in my reply to Martin on patch 7.
>> static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
>> {
>> u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
>> @@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
>> dwmac->dev = &pdev->dev;
>> dwmac->phy_mode = plat_dat->phy_interface;
>>
>> - /* use 2ns as fallback since this value was previously hardcoded */
>> - if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
>> - &dwmac->tx_delay_ns))
>> - dwmac->tx_delay_ns = 2;
>> -
>> - /* RX delay defaults to 0ps since this is what many boards use */
>> - if (of_property_read_u32(pdev->dev.of_node, "rx-internal-delay-ps",
>> - &dwmac->rx_delay_ps)) {
>> - if (!of_property_read_u32(pdev->dev.of_node,
>> - "amlogic,rx-delay-ns",
>> - &dwmac->rx_delay_ps))
>> - /* convert ns to ps */
>> - dwmac->rx_delay_ps *= 1000;
>> - }
>> -
>> - if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
>> - if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
>> - dev_err(dwmac->dev,
>> - "The RGMII RX delay range is 0..3000ps in 200ps steps");
>> - return -EINVAL;
>> + if (!dwmac->data->mac_applies_dt_delays) {
>
> I suggest you do this at a higher level. Either call this function if
> _broken_delay is set, or the other one.
Done through the callback. Probe makes one call, and the parsing of the
vendor properties moves into the older function.
>
> Andrew
next prev parent reply other threads:[~2026-10-22 17:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 10:58 [PATCH v3 0/8] Add ethernet support for the Amlogic T7 Lucas Tanure
2026-10-10 10:58 ` [PATCH v3 1/8] dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations Lucas Tanure
2026-10-10 22:04 ` Martin Blumenstingl
2026-10-11 14:16 ` Lucas Tanure
2026-10-11 21:13 ` Conor Dooley
2026-10-22 17:11 ` Lucas Tanure
2026-10-10 10:58 ` [PATCH v3 2/8] dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac Lucas Tanure
2026-10-10 22:14 ` Martin Blumenstingl
2026-10-11 14:21 ` Lucas Tanure
2026-10-10 10:58 ` [PATCH v3 3/8] net: stmmac: dwmac-meson8b: add support for the Amlogic T7 Lucas Tanure
2026-10-10 22:40 ` Martin Blumenstingl
2026-10-10 10:58 ` [PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way Lucas Tanure
2026-10-10 21:49 ` Martin Blumenstingl
2026-10-22 17:28 ` Lucas Tanure
2026-10-12 12:30 ` Andrew Lunn
2026-10-22 17:37 ` Lucas Tanure [this message]
2026-10-10 10:58 ` [PATCH v3 5/8] arm64: dts: amlogic: t7: add the ethernet pinctrl nodes Lucas Tanure
2026-10-10 10:58 ` [PATCH v3 6/8] arm64: dts: amlogic: t7: add the ethernet controller Lucas Tanure
2026-10-10 10:58 ` [PATCH v3 7/8] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port Lucas Tanure
2026-10-10 22:00 ` Martin Blumenstingl
2026-10-22 17:40 ` Lucas Tanure
2026-10-10 10:59 ` [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays Lucas Tanure
2026-10-10 22:37 ` Martin Blumenstingl
2026-10-22 17:48 ` Lucas Tanure
2026-10-12 19:18 ` Conor Dooley
2026-10-22 17:49 ` Lucas Tanure
2026-10-13 7:14 ` Jerome Brunet
2026-10-22 17:50 ` Lucas Tanure
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=00b94eed-fe1b-4cf3-a4ed-12813faacb86@linux.com \
--to=tanure@linux.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=xianwei.zhao@amlogic.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
all inboxes | Powered by JetHome®