From: netdev-bot+sashiko@kernel.org
To: joseph@telaak.dev
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
richardcochran@gmail.com, alexandre.torgue@foss.st.com,
joabreu@synopsys.com, maxime.chevallier@bootlin.com,
mcoquelin.stm32@gmail.com, gch981213@gmail.com,
linux@armlinux.org.uk, linux-mips@vger.kernel.org,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue
Date: Thu, 03 Dec 2026 22:01:17 +0000 [thread overview]
Message-ID: <179633527747.3146.4035394041809161718@kernel.org> (raw)
In-Reply-To: <20261201-sf19a2890-gmac-v2-3-8d2c513db496@telaak.dev>
Thank you for your contribution! Sashiko AI review found 7 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 4 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Whenever the rgmii-delay calibration parses,
sf19a2890_gmac_set_delays() writes TX_DELAY and RX_DELAY, sets…
- [Medium] With CONFIG_NVMEM=n, the stub devm_nvmem_cell_get() in
include/linux/nvmem-consumer.h returns ERR_PTR(-EOPNOTSUPP).
- [Medium] When the rgmii-delay cell is absent (-ENOENT) or does not
parse, sf19a2890_gmac_set_delays() returns 0 without touching…
- [Medium] The binding calls byp_ref the 'RGMII transmit reference
clock'.
- [Low] In drivers/net/ethernet/stmicro/stmmac/Kconfig, DWMAC_SF19A2890
uses `default MACH_SIFLOWER_MIPS` and `depends on OF &&…
- [Low] The binding defines rgmii-delay as exactly 'four ASCII
hexadecimal digits giving the TX setting and then the RX setting'.
- [Low] The calibrated RGMII delays (TX_DELAY, RX_DELAY, RX_DELAY_EN) are
written only once, in sf19a2890_gmac_set_delays() during probe.
--
net: stmmac: Add Siflower SF19A2890 glue
This adds a stmmac glue driver for the DesignWare GMAC in the Siflower
SF19A2890. The driver sets the interface type in the GMAC configuration
block through set_phy_intf_sel. It also programs the RGMII delay lines
from a factory calibration nvmem cell and sets has_internal_tx_delay and
has_internal_rx_delay, so stmmac removes those delays from the mode it
passes to the PHY.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index c6559e749c0ce..3175f3c2bbc95 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -201,6 +201,18 @@ config DWMAC_S32
> SOCs GMAC ethernet controller, ie. S32G2xx, S32G3xx and
> S32R45.
>
> +config DWMAC_SF19A2890
> + tristate "Siflower SF19A2890 GMAC support"
> + default MACH_SIFLOWER_MIPS
> + depends on OF && (MACH_SIFLOWER_MIPS || COMPILE_TEST)
[Severity: Low]
Is MACH_SIFLOWER_MIPS defined anywhere? I couldn't find a config
MACH_SIFLOWER_MIPS entry in the tree, and arch/mips has no Siflower
platform.
Kconfig treats an undefined symbol as n. That means the default never
takes effect, and the driver can only be enabled through COMPILE_TEST.
Does this depend on a platform series that the commit message doesn't
mention?
[ ... ]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c
> new file mode 100644
> index 0000000000000..d53f8fbede71d
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c
> @@ -0,0 +1,167 @@
[ ... ]
> +static int sf19a2890_gmac_set_delays(struct device *dev,
> + struct sf19a2890_gmac *gmac,
> + struct plat_stmmacenet_data *plat_dat)
> +{
> + char str[SF19A2890_DELAY_CAL_LEN + 1] = {};
> + struct nvmem_cell *cell;
> + size_t len;
> + void *buf;
> + u16 cal;
> +
> + cell = devm_nvmem_cell_get(dev, "rgmii-delay");
> + if (IS_ERR(cell)) {
> + if (PTR_ERR(cell) == -ENOENT)
> + return 0;
> + return dev_err_probe(dev, PTR_ERR(cell),
> + "failed to get the delay calibration\n");
> + }
[Severity: Medium]
What happens here when CONFIG_NVMEM is disabled? The stub in
include/linux/nvmem-consumer.h returns a different error:
static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev,
const char *id)
{
return ERR_PTR(-EOPNOTSUPP);
}
Only -ENOENT is treated as "no calibration". So -EOPNOTSUPP reaches
dev_err_probe() and sf19a2890_gmac_probe() fails, even when the DT has
no rgmii-delay cell.
DWMAC_SF19A2890 neither depends on nor selects NVMEM, and NVMEM has no
default.
Should -EOPNOTSUPP also count as a missing calibration, or should the
Kconfig entry depend on NVMEM?
> +
> + buf = nvmem_cell_read(cell, &len);
> + if (IS_ERR(buf))
> + return dev_err_probe(dev, PTR_ERR(buf),
> + "failed to read the delay calibration\n");
> +
> + memcpy(str, buf, min(len, sizeof(str) - 1));
> + kfree(buf);
> +
> + /* An uncalibrated unit reads back erased flash */
> + if (len != SF19A2890_DELAY_CAL_LEN || kstrtou16(str, 16, &cal)) {
[Severity: Low]
Is kstrtou16() strict enough for the format the binding describes,
"four ASCII hexadecimal digits giving the TX setting and then the RX
setting"?
kstrtoull() skips a leading '+'. In base 16 it also skips a "0x"
prefix. It accepts one trailing '\n' and stops at an embedded NUL. With
a 4-byte cell this gives:
"123\n" -> 0x0123 (TX=0x01, RX=0x23)
"0x1F" -> 0x001F (TX=0x00, RX=0x1F)
"+123" -> 0x0123
"12\0\0" -> 0x0012 (TX=0x00, RX=0x12)
In each case the result is written to SF19A2890_GMAC_TX_DELAY and
SF19A2890_GMAC_RX_DELAY with RX_DELAY_EN set and both internal-delay
flags set. The driver does not fall back to the bootloader's values.
Would it help to check that each of the four bytes is a hex digit
before parsing?
> + dev_warn(dev, "no valid delay calibration, keeping the bootloader's\n");
> + return 0;
> + }
[Severity: Medium]
On this path, and on the -ENOENT path above, sf19a2890_gmac_set_delays()
returns 0 without touching TX_DELAY, RX_DELAY or RX_DELAY_EN.
has_internal_tx_delay and has_internal_rx_delay also stay false.
stmmac_pltfr_probe() then skips phy_fix_phy_mode_for_mac_delays():
if (plat->has_internal_tx_delay || plat->has_internal_rx_delay) {
As a result, the PHY gets the full DT mode (rgmii-id in the binding
example) and adds its own delays.
Suppose the bootloader armed the MAC delay lines, for example by
programming the same factory calibration for a network boot. Could the
MAC and the PHY then both add delay? The driver never reads back
RX_DELAY_EN or the delay registers. This depends on what the bootloader
leaves behind, and I can't check that from the tree.
This also seems to contradict the binding description, which says "the
MAC adds the delays only where that calibration is given".
> +
> + writel(FIELD_GET(SF19A2890_DELAY_CAL_TX, cal),
> + gmac->cfg + SF19A2890_GMAC_TX_DELAY);
> + writel(FIELD_GET(SF19A2890_DELAY_CAL_RX, cal),
> + gmac->cfg + SF19A2890_GMAC_RX_DELAY);
> + /* With RX_DELAY_EN clear, the RX delay line is bypassed */
> + writel(1, gmac->cfg + SF19A2890_GMAC_RX_DELAY_EN);
> +
> + /* The MAC adds the delays, so stmmac must not ask the PHY for them */
> + plat_dat->has_internal_tx_delay = true;
> + plat_dat->has_internal_rx_delay = true;
[Severity: Medium]
These flags are set whenever the calibration parses, and
plat_dat->phy_interface is never checked. Does this make probe fail for
any phy-mode other than rgmii-id?
stmmac_pltfr_probe() calls phy_fix_phy_mode_for_mac_delays(). When both
MAC delays are claimed, it only accepts rgmii-id:
drivers/net/phy/phy-core.c:phy_fix_phy_mode_for_mac_delays() {
...
if (mac_txid && mac_rxid) {
if (interface == PHY_INTERFACE_MODE_RGMII_ID)
return PHY_INTERFACE_MODE_RGMII;
return PHY_INTERFACE_MODE_NA;
}
...
}
stmmac_pltfr_probe() then bails out:
if (plat->phy_interface == PHY_INTERFACE_MODE_NA)
return dev_err_probe(&pdev->dev, -EINVAL,
"unsupported phy interface mode\n");
So a DT with phy-mode = "rgmii" (delays on the PCB), "rgmii-txid" or
"rgmii-rxid", plus the rgmii-delay cell, passes the schema but can't
probe. Whether a given DT works depends on what each unit's flash
holds.
When probe fails this way, the delay registers have already been
rewritten and RX_DELAY_EN set, and no driver is bound. With RMII or
GMII/MII, probe succeeds, but the RGMII delay lines are still programmed
and RX_DELAY_EN is still set.
Could the delay programming and each flag depend on the requested RGMII
variant? Or should the binding restrict phy-mode to rgmii-id when
rgmii-delay is present?
> +
> + return 0;
> +}
> +
> +static int sf19a2890_gmac_probe(struct platform_device *pdev)
> +{
[ ... ]
> + clk = devm_clk_get_enabled(dev, "byp_ref");
> + if (IS_ERR(clk))
> + return dev_err_probe(dev, PTR_ERR(clk),
> + "failed to enable the byp_ref clock\n");
[Severity: Medium]
The binding describes byp_ref as the "RGMII transmit reference clock".
Here the clock is enabled, but the handle is dropped and never stored
in plat_dat->clk_tx_i. No set_clk_tx_rate or fix_mac_speed hook is
installed either.
On link-up, stmmac only retunes the transmit clock through this hook in
stmmac_main.c:
if (priv->plat->set_clk_tx_rate) {
ret = priv->plat->set_clk_tx_rate(priv->plat->bsp_priv,
priv->plat->clk_tx_i,
interface, speed);
According to include/linux/stmmac.h, the RGMII clk_tx_i must be 125, 25
or 2.5 MHz for 1000, 100 or 10 Mbit/s. If the hardware doesn't divide
byp_ref by itself, will 10/100 Mbit/s RGMII links run with the wrong TX
clock?
The binding example uses a 1000 Mbit/s fixed-link, which wouldn't
exercise this. Other glues with a separate TX clock, such as dwmac-s32.c
and dwmac-sophgo.c, set clk_tx_i and use set_clk_tx_rate =
stmmac_set_clk_tx_rate.
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return ret;
> +
> + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return PTR_ERR(plat_dat);
> +
> + ret = sf19a2890_gmac_set_delays(dev, gmac, plat_dat);
> + if (ret)
> + return ret;
[Severity: Low]
The delay registers are written only once, here. Afterwards,
devm_stmmac_pltfr_probe()->stmmac_dvr_probe() toggles the GMAC reset:
if (priv->plat->stmmac_rst) {
ret = reset_control_assert(priv->plat->stmmac_rst);
reset_control_deassert(priv->plat->stmmac_rst);
No init or resume hook writes them again. Does the configuration block
keep TX_DELAY, RX_DELAY and RX_DELAY_EN across that reset and across
suspend?
If it doesn't, has_internal_tx_delay and has_internal_rx_delay still
make stmmac ask the PHY for plain rgmii, and neither side would add
delay. I couldn't find anything in the tree that answers this either
way.
> +
> + plat_dat->bsp_priv = gmac;
> + plat_dat->set_phy_intf_sel = sf19a2890_gmac_set_phy_intf_sel;
> +
> + return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-sf19a2890-gmac-v2-0-8d2c513db496%40telaak.dev
prev parent reply other threads:[~2026-12-03 22:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 7:00 [PATCH net-next v2 0/3] net: stmmac: Add the Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell Joseph Telaak via B4 Relay
2026-12-03 22:01 ` netdev-bot+sashiko
2026-12-01 7:00 ` [PATCH net-next v2 2/3] dt-bindings: net: Add Siflower SF19A2890 GMAC Joseph Telaak via B4 Relay
2026-12-03 22:01 ` netdev-bot+sashiko
2026-12-01 7:00 ` [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2026-12-03 22:01 ` netdev-bot+sashiko [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=179633527747.3146.4035394041809161718@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=gch981213@gmail.com \
--cc=joabreu@synopsys.com \
--cc=joseph@telaak.dev \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
/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