Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: iav@iav.lv
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, neil.armstrong@linaro.org,
	khilman@baylibre.com, jbrunet@baylibre.com,
	martin.blumenstingl@googlemail.com, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: mdio: mux-meson-g12a: keep the MAC data path when switching MDIO
Date: Mon, 16 Nov 2026 19:24:05 +0000	[thread overview]
Message-ID: <179485704584.3136.17355463997361048256@kernel.org> (raw)
In-Reply-To: <20261115-g12a-mux-data-path-v1-1-011dad738698@iav.lv>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

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] The patch only sets the internal-PHY data-path bits when it
  finds the internal PHY through the MAC's "phy-handle" property.

--

net: mdio: mux-meson-g12a: keep the MAC data path when switching MDIO

With this change, switching to the internal MDIO bus no longer sets
USE_INTERNAL and RX_CLK_EPHY in ETH_PHY_CNTL2 unconditionally. Those two
bits route the MAC data path and RX clock to the internal PHY. They are
now set only when the MAC's phy-handle points at a PHY on the internal
mux bus. The aim is to stop external-PHY boards from losing RX after
suspend/resume, when phylib touches the unattached internal PHY.

> diff --git a/drivers/net/mdio/mdio-mux-meson-g12a.c b/drivers/net/mdio/mdio-mux-meson-g12a.c
> index 71c44385489d4..ed688d48eaf08 100644
> --- a/drivers/net/mdio/mdio-mux-meson-g12a.c
> +++ b/drivers/net/mdio/mdio-mux-meson-g12a.c

[ ... ]

> @@ -169,10 +171,11 @@ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
>  		PHY_CNTL1_CLK_EN |
>  		PHY_CNTL1_CLKFREQ;
>  	writel(value, priv->regs + ETH_PHY_CNTL1);
> -	writel(PHY_CNTL2_USE_INTERNAL |
> -	       PHY_CNTL2_SMI_SRC_MAC |
> -	       PHY_CNTL2_RX_CLK_EPHY,
> -	       priv->regs + ETH_PHY_CNTL2);
> +
> +	cntl2 = PHY_CNTL2_SMI_SRC_MAC;
> +	if (priv->mac_uses_internal_phy)
> +		cntl2 |= PHY_CNTL2_USE_INTERNAL | PHY_CNTL2_RX_CLK_EPHY;
> +	writel(cntl2, priv->regs + ETH_PHY_CNTL2);

[ ... ]

> @@ -301,6 +304,41 @@ static int g12a_ephy_glue_clk_register(struct device *dev)
>  	return 0;
>  }
>  
> +/* Like dwmac-rk: the PHY named by the MAC's phy-handle decides the data path */
> +static bool g12a_mac_uses_internal_phy(struct device_node *mux_np)
> +{
> +	struct device_node *parent_bus, *mac, *phy, *phy_bus, *mux;
> +	bool internal = false;
> +	u32 reg;
> +
> +	parent_bus = of_parse_phandle(mux_np, "mdio-parent-bus", 0);
> +	if (!parent_bus)
> +		return false;
> +
> +	mac = of_get_parent(parent_bus);
> +	of_node_put(parent_bus);
> +	if (!mac)
> +		return false;
> +
> +	phy = of_parse_phandle(mac, "phy-handle", 0);

[Severity: Medium]
Can this check pick a different PHY from the one stmmac actually
attaches?

Only "phy-handle" is read here. stmmac_init_phy() and
phylink_fwnode_phy_connect() find the PHY through fwnode_get_phy_node().
On DT, that function also falls back to the legacy "phy" and
"phy-device" properties:

drivers/net/phy/phy_device.c:fwnode_get_phy_node() {
	...
	phy_node = fwnode_find_reference(fwnode, "phy-handle", 0);
	if (!IS_ERR(phy_node) || is_acpi_node(fwnode))
		return phy_node;
	phy_node = fwnode_find_reference(fwnode, "phy", 0);
	if (!IS_ERR(phy_node))
		return phy_node;
	return fwnode_find_reference(fwnode, "phy-device", 0);
}

ethernet-controller.yaml still lists both names as deprecated aliases of
phy-handle.

Take a DT such as:

  &ethmac { phy = <&internal_ephy>; phy-mode = "rmii"; };

Before this patch, stmmac attached internal_ephy, and every switch to the
internal bus wrote USE_INTERNAL | SMI_SRC_MAC | RX_CLK_EPHY.

After this patch, g12a_mdio_mux_probe() sets mac_uses_internal_phy to
false. stmmac still attaches the EPHY over MDIO, but
g12a_enable_internal_mdio() writes only SMI_SRC_MAC. The MAC data path
and RX clock then stay on the external pins. Would RX on such a board
stop working, even though the link can come up?

Every in-tree internal-PHY DT (sei510, u200, fbx8am, sei610,
sm1-a95xf3-air, sm1-x96-air, s4-aq222, s4-vim1s, c3 boards) appears to
use phy-handle. So this would only hit out-of-tree or
bootloader-supplied DTs that use the deprecated names.

The comment refers to dwmac-rk. dwmac-rk has read only phy-handle from
the start, though, so it never broke a working setup. Here a setup that
used to work would break.

Would fwnode_get_phy_node(of_fwnode_handle(mac)), or the same
three-property fallback, keep the mux in step with the PHY stmmac
attaches?

> +	of_node_put(mac);
> +	if (!phy)
> +		return false;

[ ... ]

> @@ -313,6 +351,7 @@ static int g12a_mdio_mux_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	platform_set_drvdata(pdev, priv);
> +	priv->mac_uses_internal_phy = g12a_mac_uses_internal_phy(dev->of_node);
>  
>  	priv->regs = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(priv->regs))

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115-g12a-mux-data-path-v1-1-011dad738698%40iav.lv

      reply	other threads:[~2026-11-16 19:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 19:22 [PATCH net] net: mdio: mux-meson-g12a: keep the MAC data path when switching MDIO Igor Velkov via B4 Relay
2026-11-16 19:24 ` 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=179485704584.3136.17355463997361048256@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=iav@iav.lv \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=kuba@kernel.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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