lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRJGZjgTgcjZgIqe@horms.kernel.org>
Date: Mon, 10 Nov 2025 20:09:10 +0000
From: Simon Horman <horms@...nel.org>
To: Inochi Amaoto <inochiama@...il.com>
Cc: Han Gao <rabenda.cn@...il.com>, Icenowy Zheng <uwu@...nowy.me>,
	Vivian Wang <wangruikang@...as.ac.cn>, Yao Zi <ziyao@...root.org>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Chen Wang <unicorn_wang@...look.com>,
	Maxime Coquelin <mcoquelin.stm32@...il.com>,
	Alexandre Torgue <alexandre.torgue@...s.st.com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
	netdev@...r.kernel.org, devicetree@...r.kernel.org,
	sophgo@...ts.linux.dev, linux-kernel@...r.kernel.org,
	linux-stm32@...md-mailman.stormreply.com,
	linux-arm-kernel@...ts.infradead.org, Yixun Lan <dlan@...too.org>,
	Longbin Li <looong.bin@...il.com>, Andrew Lunn <andrew@...n.ch>
Subject: Re: [PATCH v7 3/3] net: stmmac: dwmac-sophgo: Add phy interface
 filter

On Fri, Nov 07, 2025 at 07:17:15PM +0800, Inochi Amaoto wrote:
> As the SG2042 has an internal rx delay, the delay should be removed
> when initializing the mac, otherwise the phy will be misconfigurated.
> 
> Fixes: 543009e2d4cd ("net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC")
> Signed-off-by: Inochi Amaoto <inochiama@...il.com>
> Tested-by: Han Gao <rabenda.cn@...il.com>
> Reviewed-by: Andrew Lunn <andrew@...n.ch>
> ---
>  .../ethernet/stmicro/stmmac/dwmac-sophgo.c    | 20 ++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c

...

> @@ -50,11 +56,23 @@ static int sophgo_dwmac_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> +	data = device_get_match_data(&pdev->dev);
> +	if (data && data->has_internal_rx_delay) {
> +		plat_dat->phy_interface = phy_fix_phy_mode_for_mac_delays(plat_dat->phy_interface,
> +									  false, true);
> +		if (plat_dat->phy_interface == PHY_INTERFACE_MODE_NA)
> +			return -EINVAL;

I'm sorry if this is a false positive. Because, more so than Russell [1], I
confused about how about the treatment of phy_interface. But it seems that
there is a miss match between the use of phy_fix_phy_mode_for_mac_delays()
above and the binding.

The call to phy_fix_phy_mode_for_mac_delays() above will return
PHY_INTERFACE_MODE_NA unless phy_interface is PHY_INTERFACE_MODE_RGMII_ID
or PHY_INTERFACE_MODE_RGMII_RXID.

  phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
						bool mac_txid, bool mac_rxid)
  ...
	if (mac_rxid) {
		if (interface == PHY_INTERFACE_MODE_RGMII_ID)
			return PHY_INTERFACE_MODE_RGMII_TXID;
		if (interface == PHY_INTERFACE_MODE_RGMII_RXID)
			return PHY_INTERFACE_MODE_RGMII;
		return PHY_INTERFACE_MODE_NA;
	}
  ...

Looking at phy_modes(), unsurprisingly, the following mappings occur:
* "rgmii" -> PHY_INTERFACE_MODE_RGMII
* "rgmii-id" -> PHY_INTERFACE_MODE_RGMII_ID
* "rgmii-rxid" -> PHY_INTERFACE_MODE_RGMII_RXID
* "rgmii-txid" -> PHY_INTERFACE_MODE_RGMII_TXID

And in the binding, patch 1/3 of this series, only phy-mode rgmii-txid or
rgmii-id is allowed.

But if rgmii-txid is used, PHY_INTERFACE_MODE_RGMII_TXID will be passed to
phy_fix_phy_mode_for_mac_delays(), which will return PHY_INTERFACE_MODE_NA.

Again, I'm confused about the mapping in phy_fix_phy_mode_for_mac_delays().
But there does seem to be some inconsistency between the binding and
the driver implementation here.

Flagged by Claude Code with https://github.com/masoncl/review-prompts/ 

[1] https://lore.kernel.org/all/aPSubO4tJjN_ns-t@shell.armlinux.org.uk/

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ