All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net.de>
To: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, biju.das.jz@bp.renesas.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH net] net: phy: micrel: Fix MMD register access during SPD in ksz9131_resume()
Date: Fri, 03 Apr 2026 14:30:01 +0200	[thread overview]
Message-ID: <fbdabca34daf7eb4bdf3fbef1ceb95bc@tipi-net.de> (raw)
In-Reply-To: <20260403111738.37749-1-ovidiu.panait.rb@renesas.com>

On 3.4.2026 13:17, Ovidiu Panait wrote:
> During system suspend, phy_suspend() puts the PHY into Software 
> Power-Down
> (SPD) by setting the BMCR_PDOWN bit in MII_BMCR. According to the 
> KSZ9131
> datasheet, MMD register access is restricted during SPD:
> 
>   - Only access to the standard registers (0 through 31) is supported.
>   - Access to MMD address spaces other than MMD address space 1 is
>     possible if the spd_clock_gate_override bit is set.
>   - Access to MMD address space 1 is not possible.
> 
> However, ksz9131_resume() calls ksz9131_config_rgmii_delay() before
> kszphy_resume() clears BMCR_PDOWN. This means MMD registers are 
> accessed
> while the PHY is still in SPD, contrary to the datasheet.
> 
> Additionally, on platforms where the PHY loses power during suspend
> (e.g. RZ/G3E), all settings from ksz9131_config_init(), not just the
> RGMII delays, are lost and need to be restored. When the MAC driver
> sets mac_managed_pm (e.g. stmmac), mdio_bus_phy_resume() is skipped,
> so phy_init_hw() (which calls config_init to restore all PHY settings)
> is never invoked during resume.
> 
> Fix this by replacing the RGMII delay restoration with a call to
> phy_init_hw(), which takes the PHY out of SPD and performs full
> reinitialization.
> 
> Fixes: f25a7eaa897f ("net: phy: micrel: Add ksz9131_resume()")
> Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
> ---
>  drivers/net/phy/micrel.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 2aa1dedd21b8..4236dbf4ad6b 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -6016,8 +6016,13 @@ static int lan8841_suspend(struct phy_device 
> *phydev)
> 
>  static int ksz9131_resume(struct phy_device *phydev)
>  {
> -	if (phydev->suspended && phy_interface_is_rgmii(phydev))
> -		ksz9131_config_rgmii_delay(phydev);
> +	int ret;
> +
> +	if (phydev->suspended) {
> +		ret = phy_init_hw(phydev);
> +		if (ret)
> +			return ret;
> +	}

Fix looks correct.

nit: phy_init_hw() already clears PDOWN, so the PDOWN clear and
1ms sleep in kszphy_resume() become redundant. But this is probably
something for a future cleanup.

> 
>  	return kszphy_resume(phydev);
>  }

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>

  reply	other threads:[~2026-04-03 12:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03 11:17 [PATCH net] net: phy: micrel: Fix MMD register access during SPD in ksz9131_resume() Ovidiu Panait
2026-04-03 12:30 ` Nicolai Buchwitz [this message]
2026-04-03 12:47 ` Biju Das
2026-04-03 13:22   ` Ovidiu Panait
2026-04-03 13:36     ` Biju Das
2026-04-03 13:50       ` Ovidiu Panait
2026-04-03 15:56         ` Biju Das
2026-04-03 16:28           ` Biju Das
2026-04-03 16:30             ` Biju Das
2026-04-03 14:53 ` Russell King (Oracle)
2026-04-03 15:48   ` Ovidiu Panait
2026-04-03 16:28     ` Russell King (Oracle)
2026-04-08 11:45 ` Geert Uytterhoeven
2026-04-09 10:13   ` Ovidiu Panait

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=fbdabca34daf7eb4bdf3fbef1ceb95bc@tipi-net.de \
    --to=nb@tipi-net.de \
    --cc=andrew@lunn.ch \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=ovidiu.panait.rb@renesas.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.