public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Asmaa Mnebhi <asmaa@nvidia.com>,
	davem@davemloft.net, marek.mojik@nic.cz, netdev@vger.kernel.org
Cc: davthompson@nvidia.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] net: phy: micrel: Add workaround for incomplete autonegotiation
Date: Thu, 28 Dec 2023 15:17:08 +0100	[thread overview]
Message-ID: <4a9ae956-993b-4377-8ebe-ac655683c536@gmail.com> (raw)
In-Reply-To: <20231227231657.15152-1-asmaa@nvidia.com>

On 28.12.2023 00:16, Asmaa Mnebhi wrote:
> Very rarely, the KSZ9031 fails to complete autonegotiation although it was
> initiated via phy_start(). As a result, the link stays down. Restarting
> autonegotiation when in this state solves the issue.
> 
The patch isn't addressed to all relevant maintainers. Please use the
get_maintainers script.

You should use the net/net-next annotation to make clear whether this should
be treated as a fix (in this case add a Fixes tag) or net-next material.

> Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
> ---
> v1->v2:
> - Use msleep() instead of mdelay()
> 
>  drivers/net/phy/micrel.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 08e3915001c3..9952a073413f 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1475,6 +1475,7 @@ static int ksz9031_get_features(struct phy_device *phydev)
>  
>  static int ksz9031_read_status(struct phy_device *phydev)
>  {
> +	u8 timeout = 10;
>  	int err;
>  	int regval;
>  
> @@ -1494,6 +1495,22 @@ static int ksz9031_read_status(struct phy_device *phydev)
>  		return genphy_config_aneg(phydev);
>  	}
>  
> +	/* KSZ9031's autonegotiation takes normally 4-5 seconds to complete.
> +	 * Occasionally it fails to complete autonegotiation. The workaround is
> +	 * to restart it.
> +	 */
> +        if (phydev->autoneg == AUTONEG_ENABLE) {
> +		while (timeout) {
> +			if (phy_aneg_done(phydev))
> +				break;
> +			msleep(1000);
> +			timeout--;

It's not too nice to do this synchronously. Even in the non-problem case this
will block the phylib state machine for seconds. Better find a way to do it
asynchronously.

> +		};
> +
> +		if (timeout == 0)
> +			phy_restart_aneg(phydev);
> +	}
> +
>  	return 0;
>  }
>  


      parent reply	other threads:[~2023-12-28 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-27 23:16 [PATCH v2 1/1] net: phy: micrel: Add workaround for incomplete autonegotiation Asmaa Mnebhi
2023-12-28  8:43 ` Florian Fainelli
2023-12-28 13:37   ` Asmaa Mnebhi
2023-12-28 14:09     ` Heiner Kallweit
2023-12-28 21:21       ` Asmaa Mnebhi
2023-12-28 14:17 ` Heiner Kallweit [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=4a9ae956-993b-4377-8ebe-ac655683c536@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=asmaa@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=davthompson@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.mojik@nic.cz \
    --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