netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: arturo.buzarra@digi.com
Cc: netdev@vger.kernel.org, Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Russell King - ARM Linux <linux@armlinux.org.uk>
Subject: Re: [PATCH] net: phy: return EPROBE_DEFER if PHY is not accessible
Date: Fri, 17 Mar 2023 19:21:20 +0100	[thread overview]
Message-ID: <3e904a01-7ea8-705c-bf7a-05059729cebf@gmail.com> (raw)
In-Reply-To: <20230317121646.19616-1-arturo.buzarra@digi.com>

On 17.03.2023 13:16, arturo.buzarra@digi.com wrote:
> From: Arturo Buzarra <arturo.buzarra@digi.com>
> 
> A PHY driver can dynamically determine the devices features, but in some
> circunstances, the PHY is not yet ready and the read capabilities does not fail
> but returns an undefined value, so incorrect capabilities are assumed and the
> initialization process fails. This commit postpones the PHY probe to ensure the
> PHY is accessible.
> 
To complement what has been said by Florian and Andrew:

"under some circumstances" is too vague in general. List potential such
circumstances and best what happened exactly in your case.

When genphy_read_abilities() is called the PHY has been accessed already,
reading the PHY ID. 

So best start with some details about your use case, which MAC, which PHY, etc.

> Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
> ---
>  drivers/net/phy/phy_device.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 1785f1cead97..f8c31e741936 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -2628,10 +2628,14 @@ int genphy_read_abilities(struct phy_device *phydev)
>  			       phydev->supported);
>  
>  	val = phy_read(phydev, MII_BMSR);
>  	if (val < 0)
>  		return val;
> +	if (val == 0x0000 || val == 0xffff) {
> +		phydev_err(phydev, "PHY is not accessible\n");
> +		return -EPROBE_DEFER;
> +	}
>  
>  	linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported,
>  			 val & BMSR_ANEGCAPABLE);
>  
>  	linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported,


  parent reply	other threads:[~2023-03-17 18:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 12:16 [PATCH] net: phy: return EPROBE_DEFER if PHY is not accessible arturo.buzarra
2023-03-17 17:05 ` Florian Fainelli
2023-03-17 17:24 ` Andrew Lunn
2023-03-17 18:21 ` Heiner Kallweit [this message]
2023-03-20  9:45   ` Buzarra, Arturo
2023-03-20 10:12     ` Russell King (Oracle)
2023-03-20 12:00     ` Andrew Lunn
2023-03-23  8:02       ` Buzarra, Arturo
2023-03-23 14:19         ` Andrew Lunn
2023-03-23 14:35           ` Russell King (Oracle)
2023-03-30  7:46             ` Buzarra, Arturo
2023-03-30 12:01               ` Andrew Lunn

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=3e904a01-7ea8-705c-bf7a-05059729cebf@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=arturo.buzarra@digi.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).