Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: cristian.ciocaltea@collabora.com
Cc: ansuelsmth@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com,
	linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, kernel@collabora.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH net 13/14] net: phy: as21xxx: Fix speed and duplex reporting
Date: Tue, 01 Dec 2026 01:51:00 +0000	[thread overview]
Message-ID: <179608986082.3146.5210575164778107241@kernel.org> (raw)
In-Reply-To: <20261130-as21xxx-fixes-v1-13-1bd2eae6ccbc@collabora.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] Forced mode: as21xxx_read_status() can still leave phydev->speed
  = SPEED_UNKNOWN, which is the failure this patch says it removes.
- [Low] The LPA_1000MSFAIL check in as21xxx_read_lpa() now only runs once
  the link is up: as21xxx_read_status() returns early at 'if…
- [Low] The commit message justifies the duplex resolution with 'Since
  aeon_config_aneg() makes phydev->advertising reflect what the firmware…

--

net: phy: as21xxx: Fix speed and duplex reporting

With autoneg enabled, this patch takes the speed from VEND1_SPEED_STATUS
instead of resolving the advertisements. Duplex and pause are then
resolved from the link partner abilities, which are read from the mapped
C22 registers and the 10GBASE-T status register. With autoneg disabled,
it reports the PMA-programmed settings via genphy_c45_read_pma(), and
overrides the speed from VEND1_SPEED_STATUS once the link is up.

> Use VEND1_SPEED_STATUS, the authoritative source, on the autoneg path
> too.  Since aeon_config_aneg() makes phydev->advertising reflect what
> the firmware puts on the wire, it is still reliable for picking the
> duplex mode at that speed: resolve duplex from the link partner

[Severity: Low]
There is no aeon_config_aneg() in drivers/net/phy/as21xxx.c. Should this
be as21xxx_config_aneg()?

That function and its advertising expansion ("Let the advertisement
reflect the slower speeds which go on the wire along with the highest
one") come from the preceding patch, "net: phy: as21xxx: Configure
autoneg advertisement via IPC". The baseline driver has no config_aneg
callback at all.

Both patches carry only the Fixes: 830877d89edc tag, with no dependency
note. If this patch is backported alone, as21xxx_resolve_duplex() would
run this line without the implicitly advertised slower modes in
phydev->advertising:

	linkmode_and(common, phydev->lp_advertising, phydev->advertising);

Could a partner that negotiated full duplex below the advertised maximum
speed then fall into the parallel detection fallback and be reported as
half duplex?

Would it be worth stating the dependency for stable?

> diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
> index 967ff3020814e..5eea6baa75bfc 100644
> --- a/drivers/net/phy/as21xxx.c
> +++ b/drivers/net/phy/as21xxx.c

[ ... ]

> @@ -781,15 +781,107 @@ static int as21xxx_read_c22_lpa(struct phy_device *phydev)

[ ... ]

> +static int as21xxx_read_speed(struct phy_device *phydev)
> +{
> +	int val;
> +
> +	val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_SPEED_STATUS);
> +	if (val < 0)
> +		return val;
> +
> +	switch (val & VEND1_SPEED_MASK) {

[ ... ]

> +	default:
> +		dev_warn_once(&phydev->mdio.dev,
> +			      "Unknown speed status 0x%04x\n", val);
> +		phydev->speed = SPEED_UNKNOWN;
> +		break;
> +	}
> +
> +	return 0;
> +}

[ ... ]

> @@ -797,64 +889,54 @@ static int as21xxx_read_status(struct phy_device *phydev)
>  	if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
>  		return 0;
>  
> -	phydev->speed = SPEED_UNKNOWN;
> -	phydev->duplex = DUPLEX_UNKNOWN;
>  	phydev->pause = 0;
>  	phydev->asym_pause = 0;
>  
> -	if (phydev->autoneg == AUTONEG_ENABLE) {
> -		ret = genphy_c45_read_lpa(phydev);
> +	if (phydev->autoneg == AUTONEG_DISABLE) {
> +		ret = genphy_c45_read_pma(phydev);
>  		if (ret)
>  			return ret;
>  
> -		ret = as21xxx_read_c22_lpa(phydev);
> -		if (ret)
> -			return ret;
> +		if (phydev->link) {
> +			ret = as21xxx_read_speed(phydev);
>  
> -		phy_resolve_aneg_linkmode(phydev);
> -	} else {
> -		int speed;
> +			/* Hold the link down until the speed status settles */
> +			if (!ret && phydev->speed == SPEED_UNKNOWN)
> +				phydev->link = 0;
> +		}

[Severity: High]
Can this branch still leave phydev->speed set to SPEED_UNKNOWN in forced
mode?

genphy_c45_read_pma() sets phydev->speed from PMA CTRL1, which holds the
forced speed the user configured. If the link bit is up while
VEND1_SPEED_STATUS reads an unrecognised code, the default case in
as21xxx_read_speed() overwrites phydev->speed with SPEED_UNKNOWN. Only the
link is held down, and the PMA speed is not restored.

In forced mode, phydev->speed is also the configuration. PHY_HALTED does
not reset speed when autoneg is disabled, so if phy_stop() lands in this
window, the next phy_start() goes through:

phy_start()
  _phy_start_aneg()
    phy_sanitize_settings()
      phy_caps_lookup(SPEED_UNKNOWN, DUPLEX_FULL, supported, false)
    as21xxx_config_aneg()
      genphy_c45_pma_setup_forced()

When speed is -1, phy_caps_lookup() finds no entry with
lcap->speed <= speed and returns the slowest supported capability.

If 10baseT_Half is in phydev->supported, the result is 10/HALF.
genphy_c45_pma_setup_forced() returns -EINVAL for anything other than full
duplex, so the PHY goes to PHY_ERROR, and every later restart retries the
same sanitized setting. If 10baseT_Half is not supported, the slowest full
duplex speed is written into PMA CTRL1 instead, and the forced speed is
lost.

Isn't this the same problem the commit message says is being fixed?

    "Otherwise phy_sanitize_settings() sees unknown values on the next
    autoneg restart with the link down and falls back to the slowest
    mode."

Could as21xxx_read_speed() return the speed in a local variable, or leave
phydev->speed untouched in its default case, so that the PMA-derived
speed is kept?

> -		linkmode_zero(phydev->lp_advertising);
> +		return ret;
> +	}

[ ... ]

> +	phydev->speed = SPEED_UNKNOWN;
> +	phydev->duplex = DUPLEX_UNKNOWN;
> +	linkmode_zero(phydev->lp_advertising);

[ ... ]

> +	/* as21xxx_read_link() reports link up only once autoneg completed */
> +	if (!phydev->link)
> +		return 0;

[Severity: Low]
Because of this early return, as21xxx_read_lpa() is only reached once the
link is up. Before this patch, as21xxx_read_c22_lpa() ran on every
autoneg read_status where the link was not already up, including while
the link was down.

A 1000BASE-T master/slave configuration fault keeps the link down. Does
that mean the LPA_1000MSFAIL check in as21xxx_read_lpa(), and its
"Master/Slave resolution failed" message, are no longer reached in the
case they exist for?

If the check is reached with the link up, for example through a latched
fault bit, it still returns -ENOLINK. That moves the PHY to PHY_ERROR
while the link is actually up.

Should this follow the hold-the-link-down approach used here for an
unrecognised speed status instead?

The commit message says partner abilities are now read only once the
link is up, but it does not mention the lost diagnostic.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-as21xxx-fixes-v1-0-1bd2eae6ccbc%40collabora.com

  parent reply	other threads:[~2026-12-01  1:51 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  0:55 [PATCH net 00/14] net: phy: as21xxx: Fix a batch of driver issues Cristian Ciocaltea
2026-11-30  0:55 ` [PATCH net 01/14] net: phy: as21xxx: handle stale link status during autoneg Cristian Ciocaltea
2026-11-30  0:55 ` [PATCH net 02/14] net: phy: as21xxx: handle odd firmware on loading Cristian Ciocaltea
2026-11-30  0:55 ` [PATCH net 03/14] net: phy: as21xxx: Fix LED index bounds check Cristian Ciocaltea
2026-11-30  2:37   ` Andrew Lunn
2026-11-30 10:35     ` Cristian Ciocaltea
2026-11-30  0:55 ` [PATCH net 04/14] net: phy: as21xxx: Use the correct mask for the speed status Cristian Ciocaltea
2026-11-30  2:39   ` Andrew Lunn
2026-11-30  0:55 ` [PATCH net 05/14] net: phy: as21xxx: Correct the 10M speed status value Cristian Ciocaltea
2026-11-30  2:40   ` Andrew Lunn
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 06/14] net: phy: as21xxx: Do not write the IPC reply to a NULL buffer Cristian Ciocaltea
2026-11-30  2:49   ` Andrew Lunn
2026-11-30 10:53     ` Cristian Ciocaltea
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 07/14] net: phy: as21xxx: Write IPC payload under ipc_lock Cristian Ciocaltea
2026-11-30  2:53   ` Andrew Lunn
2026-11-30 11:09     ` Cristian Ciocaltea
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 08/14] net: phy: as21xxx: Handle IPC payload write errors Cristian Ciocaltea
2026-11-30  2:54   ` Andrew Lunn
2026-11-30  0:55 ` [PATCH net 09/14] net: phy: as21xxx: Reject odd IPC payload lengths Cristian Ciocaltea
2026-11-30  2:55   ` Andrew Lunn
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 10/14] net: phy: as21xxx: Fix LED hw control set for unsupported rules Cristian Ciocaltea
2026-11-30  3:01   ` Andrew Lunn
2026-11-30 11:29     ` Cristian Ciocaltea
2026-11-30 13:37       ` Andrew Lunn
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 11/14] net: phy: as21xxx: Read 10/100/1000 link modes from C22 advertisement Cristian Ciocaltea
2026-11-30  3:34   ` Andrew Lunn
2026-11-30 11:53     ` Cristian Ciocaltea
2026-11-30 13:39       ` Andrew Lunn
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 12/14] net: phy: as21xxx: Configure autoneg advertisement via IPC Cristian Ciocaltea
2026-11-30  3:43   ` Andrew Lunn
2026-11-30 12:05     ` Cristian Ciocaltea
2026-12-01  1:50   ` netdev-bot+sashiko
2026-11-30  0:55 ` [PATCH net 13/14] net: phy: as21xxx: Fix speed and duplex reporting Cristian Ciocaltea
2026-11-30  3:50   ` Andrew Lunn
2026-11-30 12:21     ` Cristian Ciocaltea
2026-11-30 14:01       ` Andrew Lunn
2026-12-01  1:51   ` netdev-bot+sashiko [this message]
2026-11-30  0:55 ` [PATCH net 14/14] net: phy: as21xxx: Release reset before reading ID in match Cristian Ciocaltea
2026-11-30  3:53   ` Andrew Lunn
2026-11-30 12:22     ` Cristian Ciocaltea
2026-12-01  1:51   ` netdev-bot+sashiko

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=179608986082.3146.5210575164778107241@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@collabora.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --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