mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: xiaolinkui@126.com
Cc: andrew@lunn.ch, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	rosenp@gmail.com, jacob.e.keller@intel.com,
	daniel.machon@microchip.com, chunkeey@gmail.com,
	kees+treewide@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, xiaolinkui@kylinos.cn
Subject: Re: [PATCH net v2 2/2] net: ibm: emac: read the fixed-link status before adjusting the link
Date: Tue, 24 Nov 2026 09:34:02 +0000	[thread overview]
Message-ID: <179551284212.3135.10573123366533276098@kernel.org> (raw)
In-Reply-To: <20261123093201.770552-3-xiaolinkui@126.com>

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

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

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] The fix does not cover 10 Mbit/s full-duplex fixed links.

--

net: ibm: emac: read the fixed-link status before adjusting the link

For a fixed link, emac_init_phy() never starts the PHY state machine, so
after d99b408ed8e5 emac_adjust_link() copied SPEED_UNKNOWN/DUPLEX_UNKNOWN
into dev->phy. This patch calls phy_read_status() once after
of_phy_connect(), so the emulated swphy registers fill in speed, duplex
and pause. It also disconnects the PHY if the read fails.

> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index ba02cf878a124..8b9ffbcd2ff42 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> @@ -2677,9 +2677,16 @@ static int emac_init_phy(struct emac_instance *dev)
>  				return res;
>  
>  			if (!of_phy_connect(ndev, np, &emac_adjust_link, 0,
> -					    dev->phy_mode)) {
> +					    dev->phy_mode))
> +				res = -EINVAL;
> +			else
> +				res = phy_read_status(ndev->phydev);

[Severity: High]
Does this resolve a 10 Mbit/s full duplex fixed link? The commit message
says:

  The PHY is emulated, so genphy_read_status() resolves speed, duplex
  and pause from the registers swphy generates out of the device tree
  status.

For 10 Mbit the swphy tables in drivers/net/phy/swphy.c never set the
10 Mbit BMSR ability bits. Only the LPA register gets them:

static const struct swmii_regs speed[] = {
	[SWMII_SPEED_10] = {
		.lpa   = LPA_10FULL | LPA_10HALF,
	},
	...

static const struct swmii_regs duplex[] = {
	[SWMII_DUPLEX_HALF] = {
		.bmsr  = BMSR_ESTATEN | BMSR_100HALF,
	...
	[SWMII_DUPLEX_FULL] = {
		.bmsr  = BMSR_ESTATEN | BMSR_100FULL,
	...

genphy_read_abilities() builds phydev->supported from BMSR only, so no
10baseT mode ends up in supported or advertising. Then, in
phy_read_status()->genphy_read_status():

  genphy_read_lpa()
    lp_advertising gets 10baseT_Full plus the pause bits
  phy_resolve_aneg_linkmode()
    lp_advertising & advertising has no speed mode, so
    phy_caps_lookup_by_linkmode() returns NULL and speed/duplex
    stay SPEED_UNKNOWN/DUPLEX_UNKNOWN
  phy_resolve_aneg_pause()
    only runs for DUPLEX_FULL, so pause stays 0

phy_read_status() still returns 0, so the error path is skipped, and
emac_adjust_link() copies DUPLEX_UNKNOWN and pause = 0 into dev->phy.

emac_configure() only sets full duplex and flow control when duplex is
DUPLEX_FULL:

	else if (dev->phy.duplex == DUPLEX_FULL)
		mr1 |= EMAC_MR1_FDE | EMAC_MR1_MWSW_001;
	...
	if (!emac_has_feature(dev, EMAC_FTR_NO_FLOW_CONTROL_40x) &&
	    dev->phy.duplex == DUPLEX_FULL) {
		if (dev->phy.pause)
			mr1 |= EMAC_MR1_EIFC | EMAC_MR1_APP;

So for a fixed-link node with speed 10 and full-duplex, wouldn't the MAC
still be programmed half duplex with flow control off? That is the
symptom the commit message describes, and it worked before d99b408ed8e5.
100 and 1000 Mbit links resolve correctly. 10 Mbit half duplex only comes
out right because the unknown values fall back to 10/half.

Could swphy report the 10 Mbit abilities in BMSR? Alternatively, could
the PHY-less path take speed, duplex and pause directly from the
fixed-link status, or at least check that phydev->speed and
phydev->duplex were resolved before using them?

> +
> +			if (res) {
> +				if (ndev->phydev)
> +					phy_disconnect(ndev->phydev);
>  				of_phy_deregister_fixed_link(np);
> -				return -EINVAL;
> +				return res;
>  			}
>  
>  			emac_adjust_link(ndev);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123093201.770552-1-xiaolinkui%40126.com

      parent reply	other threads:[~2026-11-24  9:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:31 [PATCH net v2 0/2] net: ibm: emac: fix the fixed-link PHY setup Linkui Xiao
2026-11-23  9:32 ` [PATCH net v2 1/2] net: ibm: emac: attach the fixed-link PHY with of_phy_connect() Linkui Xiao
2026-11-24  9:34   ` netdev-bot+sashiko
2026-11-23  9:32 ` [PATCH net v2 2/2] net: ibm: emac: read the fixed-link status before adjusting the link Linkui Xiao
2026-11-23 14:55   ` Andrew Lunn
2026-11-24  8:39     ` Linkui Xiao
2026-11-24  9:34   ` netdev-bot+sashiko [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=179551284212.3135.10573123366533276098@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=chunkeey@gmail.com \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kees+treewide@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rosenp@gmail.com \
    --cc=xiaolinkui@126.com \
    --cc=xiaolinkui@kylinos.cn \
    /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

all inboxes | Powered by JetHome®