Netdev List
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: aiyengar1990@gmail.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>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup
Date: Sun, 22 Nov 2026 18:35:11 +0100	[thread overview]
Message-ID: <7de5e572-dba5-4429-90fa-3cddb2e5cad8@bootlin.com> (raw)
In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-5-57eba8915f25@gmail.com>

Hi,

On 11/20/26 11:45, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
> 
> Both PHYs sit behind the mux, but the mux is registered only after
> stmmac_pltfr_probe() has registered the netdev, so an early open does
> not find the PHY. On remove, the mux goes away before
> unregister_netdev(), and unbinding with the link up oopses in
> phy_stop().
> 
> Register and unregister the mux through the new mdio_init() and
> mdio_exit() hooks.
> 
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

Looks good, I tested that on Allwinner H2+, the mux probes fine. This
has run on the stmmac netdevCI anyways and no breakage reported on
other plaftorms.

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime

> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 41 ++++++-----------------
>  1 file changed, 10 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 4acfda235394..0ec25ae0b77e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -17,7 +17,6 @@
>  #include <linux/of_platform.h>
>  #include <linux/phy.h>
>  #include <linux/platform_device.h>
> -#include <linux/pm_runtime.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/regmap.h>
>  #include <linux/stmmac.h>
> @@ -941,6 +940,13 @@ static int sun8i_dwmac_register_mdio_mux(struct stmmac_priv *priv)
>  	return ret;
>  }
>  
> +static void sun8i_dwmac_unregister_mdio_mux(struct stmmac_priv *priv)
> +{
> +	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
> +
> +	mdio_mux_uninit(gmac->mux_handle);
> +}
> +
>  static int sun8i_dwmac_set_syscon(struct device *dev,
>  				  struct plat_stmmacenet_data *plat)
>  {
> @@ -1133,8 +1139,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>  	struct stmmac_resources stmmac_res;
>  	struct sunxi_priv_data *gmac;
>  	struct device *dev = &pdev->dev;
> -	struct stmmac_priv *priv;
> -	struct net_device *ndev;
>  	struct regmap *regmap;
>  	int ret;
>  
> @@ -1217,6 +1221,9 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>  		ret = get_ephy_nodes(dev, gmac);
>  		if (ret)
>  			return ret;
> +
> +		plat_dat->mdio_init = sun8i_dwmac_register_mdio_mux;
> +		plat_dat->mdio_exit = sun8i_dwmac_unregister_mdio_mux;
>  	}
>  
>  	ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
> @@ -1227,33 +1234,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto dwmac_syscon;
>  
> -	ndev = dev_get_drvdata(&pdev->dev);
> -	priv = netdev_priv(ndev);
> -
> -	/* the MAC is runtime suspended after stmmac_dvr_probe(), so we
> -	 * need to ensure the MAC resume back before other operations such
> -	 * as reset.
> -	 */
> -	pm_runtime_get_sync(&pdev->dev);
> -
> -	/* The mux must be registered after parent MDIO
> -	 * so after stmmac_dvr_probe()
> -	 */
> -	if (gmac->variant->soc_has_internal_phy) {
> -		ret = sun8i_dwmac_register_mdio_mux(priv);
> -		if (ret) {
> -			dev_err(&pdev->dev, "Failed to register mux\n");
> -			goto dwmac_remove;
> -		}
> -	}
> -
> -	pm_runtime_put(&pdev->dev);
> -
>  	return 0;
>  
> -dwmac_remove:
> -	pm_runtime_put_noidle(&pdev->dev);
> -	stmmac_pltfr_remove(pdev);
>  dwmac_syscon:
>  	sun8i_dwmac_unset_syscon(gmac);
>  dwmac_ephy:
> @@ -1269,9 +1251,6 @@ static void sun8i_dwmac_remove(struct platform_device *pdev)
>  	struct stmmac_priv *priv = netdev_priv(ndev);
>  	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
>  
> -	if (gmac->variant->soc_has_internal_phy)
> -		mdio_mux_uninit(gmac->mux_handle);
> -
>  	stmmac_pltfr_remove(pdev);
>  	reset_control_put(gmac->rst_ephy);
>  	clk_put(gmac->ephy_clk);
> 


      reply	other threads:[~2026-11-22 17:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:45 [PATCH net-next v4 0/5] net: stmmac: dwmac-sun8i: Fix the EPHY and MDIO mux ordering Arun Iyengar via B4 Relay
2026-11-20 10:45 ` [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC Arun Iyengar via B4 Relay
2026-11-22 16:47   ` Maxime Chevallier
2026-11-20 10:45 ` [PATCH net-next v4 2/5] net: stmmac: dwmac-sun8i: Get the EPHY clock and reset before the MAC probe Arun Iyengar via B4 Relay
2026-11-22 16:51   ` Maxime Chevallier
2026-11-20 10:45 ` [PATCH net-next v4 3/5] net: stmmac: Balance runtime PM when the probe fails Arun Iyengar via B4 Relay
2026-11-22 17:03   ` Maxime Chevallier
2026-11-20 10:45 ` [PATCH net-next v4 4/5] net: stmmac: Add MDIO init and exit platform hooks Arun Iyengar via B4 Relay
2026-11-22 17:05   ` Maxime Chevallier
2026-11-22 17:35   ` Maxime Chevallier
2026-11-20 10:45 ` [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup Arun Iyengar via B4 Relay
2026-11-22 17:35   ` Maxime Chevallier [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=7de5e572-dba5-4429-90fa-3cddb2e5cad8@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=aiyengar1990@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux@armlinux.org.uk \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=samuel@sholland.org \
    --cc=wens@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