From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39E54606A684 for ; Thu, 3 Dec 2026 22:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IzmkcmZA; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G4Xm5Zwv DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=qXIbWtmcJDFNRlri3z42+eeIepBsK61/nmtk54NM7Ow=; b=IzmkcmZATRqXkDfdTxscqD3KX9 eSD/IqQwt7pNlRekNeppk5CcEf6EKzeSWb+C14/LM119vLbcvQIcciNyb9U4ftMAK/gs8h/NHj10y vwz2bJ676hABtRMU+v6N4ERiLyPghjyCVSdAmpu7KDlyL1qsqoyWrMDRfYk/BT9oHHMuheTU6T97r U00JFCvFBKnE3gmFpj2xmyh3lekBGqzfy2RFfFyPABZKhp2dsRKaXrdnXyX/2R0XXg4/y8P6bK6DQ Hcle+lEjnpEDocm3JibtH9jKpBQPq7thhq5rlGct3rwzTCjkDHeEEFe0t2Td/maeHzjBzLM/q2yHq Fpi0rilA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZErm-0000000G4Tl-38J5; Thu, 03 Dec 2026 22:01:32 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZErf-0000000G4Qs-46ib for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 22:01:20 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 4F9FD62071; Thu, 3 Dec 2026 22:01:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E22891F0093A; Thu, 3 Dec 2026 22:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796335279; bh=qXIbWtmcJDFNRlri3z42+eeIepBsK61/nmtk54NM7Ow=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=G4Xm5Zwv3QbEH5hF7+t2JiqUZTlYwIUS0dGZrIpSVyiZcNYf9GLLWb0VlSH6qIenJ QfHAq53fNh4gS3wMAgUNZCeidbO6vK1ulO1LszUGm/HCJoGzKbnOMzrQBwygeZQ4zC qZTObbjHt5rBPEn7POtU+49um8ze3AVnrs/kJwovLMyvawymrJMVX3I7X6B2VBVmP/ 1s4Qaq+5KmS6sZ1/dxR07GDxWQDZBxZ1gNrECK7pi13zr5SLPv7LdreQpHZWGKIal8 59c5qwqazBjqxDRC39C4IjnOg2XEoZtsPMLKbUXLloK2bdQxn75VXHE5rumrnpsbus jHQOWmSHSTqWw== Subject: Re: [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue 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 Date: Thu, 03 Dec 2026 22:01:17 +0000 Message-ID: <179633527747.3146.4035394041809161718@kernel.org> In-Reply-To: <20261201-sf19a2890-gmac-v2-3-8d2c513db496@telaak.dev> References: <20261201-sf19a2890-gmac-v2-3-8d2c513db496@telaak.dev> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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