public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Tarun Alle <Tarun.Alle@microchip.com>
Cc: arun.ramadoss@microchip.com, UNGLinuxDriver@microchip.com,
	andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] net: phy: phy-c45: Auto-negotiaion changes for T1 phy in phy library
Date: Mon, 9 Dec 2024 16:48:58 +0000	[thread overview]
Message-ID: <Z1cfepBZXlGoz0ue@shell.armlinux.org.uk> (raw)
In-Reply-To: <20241209161427.3580256-2-Tarun.Alle@microchip.com>

On Mon, Dec 09, 2024 at 09:44:26PM +0530, Tarun Alle wrote:
> Below auto-negotiation library changes required for T1 phys:
> - Lower byte advertisement register need to read after higher byte as
>   per 802.3-2022 : Section 45.2.7.22.

In my copy of 802.3, this refers to the link partner base page
ability register, which is not the same as the advertisement
register.

The advertisement registers are covered by the preceeding section,
45.2.7.21. This says:

"The Base Page value is transferred to mr_adv_ability when register
7.514 is written. Therefore, registers 7.515 and 7.516 should be
written before 7.514."

which I think is what's pertinent to your commit.

> - Link status need to be get from control T1 registers for T1 phys.

This statement appears to be inaccurate - more below against the
actual code change.

> 
> Signed-off-by: Tarun Alle <Tarun.Alle@microchip.com>
> ---
>  drivers/net/phy/phy-c45.c | 36 ++++++++++++++++++++++++++----------
>  1 file changed, 26 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
> index 0dac08e85304..85d8a9b9c3f6 100644
> --- a/drivers/net/phy/phy-c45.c
> +++ b/drivers/net/phy/phy-c45.c
> @@ -234,15 +234,11 @@ static int genphy_c45_baset1_an_config_aneg(struct phy_device *phydev)
>  		return -EOPNOTSUPP;
>  	}
>  
> -	adv_l |= linkmode_adv_to_mii_t1_adv_l_t(phydev->advertising);
> -
> -	ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_T1_ADV_L,
> -				     adv_l_mask, adv_l);
> -	if (ret < 0)
> -		return ret;
> -	if (ret > 0)
> -		changed = 1;
> -
> +	/* Ref. 802.3-2022 : Section 45.2.7.22
> +	 * The Base Page value is transferred to mr_adv_ability when register
> +	 * 7.514 is written.
> +	 * Therefore, registers 7.515 and 7.516 should be written before 7.514.
> +	 */
>  	adv_m |= linkmode_adv_to_mii_t1_adv_m_t(phydev->advertising);
>  
>  	ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_T1_ADV_M,
> @@ -252,6 +248,23 @@ static int genphy_c45_baset1_an_config_aneg(struct phy_device *phydev)
>  	if (ret > 0)
>  		changed = 1;
>  
> +	adv_l |= linkmode_adv_to_mii_t1_adv_l_t(phydev->advertising);
> +
> +	if (changed) {
> +		ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_ADV_L,
> +				    adv_l);
> +		if (ret < 0)
> +			return ret;
> +	} else {
> +		ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN,
> +					     MDIO_AN_T1_ADV_L,
> +					     adv_l_mask, adv_l);

Why do you write the complete register if changed is true, but only
modify bits 12, 11 and 10 if changed is false?

>  int genphy_c45_read_link(struct phy_device *phydev)
>  {
>  	u32 mmd_mask = MDIO_DEVS_PMAPMD;
> +	u16 reg = MDIO_CTRL1;
>  	int val, devad;
>  	bool link = true;
>  
>  	if (phydev->c45_ids.mmds_present & MDIO_DEVS_AN) {
> -		val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
> +		if (genphy_c45_baset1_able(phydev))
> +			reg = MDIO_AN_T1_CTRL;
> +		val = phy_read_mmd(phydev, MDIO_MMD_AN, reg);
>  		if (val < 0)
>  			return val;

This is not checking link status as you mention in your commit
message, it is checking whether the PHY is in the process of
restarting autoneg.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2024-12-09 16:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 16:14 [PATCH net-next 0/2] Add auto-negotiation support for LAN887x T1 phy Tarun Alle
2024-12-09 16:14 ` [PATCH net-next 1/2] net: phy: phy-c45: Auto-negotiaion changes for T1 phy in phy library Tarun Alle
2024-12-09 16:48   ` Russell King (Oracle) [this message]
2024-12-09 16:54   ` Andrew Lunn
2024-12-10  6:39     ` Tarun.Alle
2024-12-09 16:14 ` [PATCH net-next 2/2] net: phy: microchip_t1: Autonegotiaion support for LAN887x T1 phy Tarun Alle
2024-12-09 17:03   ` Andrew Lunn
2024-12-10  6:42     ` Tarun.Alle
2024-12-09 17:11   ` Andrew Lunn
2024-12-12  8:47     ` Tarun.Alle

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=Z1cfepBZXlGoz0ue@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Tarun.Alle@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=arun.ramadoss@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.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