mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linkui Xiao <xiaolinkui@126.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: 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,
	hkallweit1@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn>
Subject: Re: [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
Date: Fri, 27 Nov 2026 09:47:56 +0800	[thread overview]
Message-ID: <20261127014756.2908959-1-xiaolinkui@126.com> (raw)
In-Reply-To: <7057d70b-033d-49cd-9fc7-d6b9b39ffc84@lunn.ch>

Hi Andrew,

Thanks for the review.

> There is also a call to phy_start() in emac_mdio_init_phy(). If that
> is how a real PHY is started, a fixed link PHY should be started in
> the same way.

Done in v4:

-			phy_start(ndev->phydev);
+			/* Start it the same way as a real PHY. */
+			res = emac_mdio_init_phy(&dev->phy);
+			if (res)
+				return res;

emac_mdio_init_phy() is the mii_phy_ops .init handler that
emac_init_phy() already calls at the init_phy: label for a real PHY, so
there is one start path again. It also runs phy_init_hw() a second time,
which is what the phy-handle path does today after of_phy_connect().

I did not let the fixed link fall into the init_phy: block itself. After
ops->init that block masks the features and then calls setup_aneg() or
setup_forced(). dev->phy.features for a fixed link has no
SUPPORTED_Autoneg, so it would take setup_forced(), pick a speed out of
dev->phy.def->features instead of out of the fixed-link property, and push
it into the phydev through emac_mdio_phy_start_aneg().

> However, this code is a horrible mix of phylib and mii. It really
> needs a rewrite to make it pure phylib, or ideally phylink.

Agreed. struct mii_phy and its ops duplicate what phylib already does,
emac_open() and emac_link_timer() poll the PHY on top of the state
machine, and emac_ethtool_nway_reset() reaches ops->setup_aneg() for a
link phylib owns.

That is much bigger than this crash fix, and I have no 4xx board here to
test a conversion on, so I kept v4 minimal. I would like to do the
conversion as a separate net-next series and would need someone with the
hardware to test it. Say the word if you would rather not take the
minimal fix first.

v4 also stops the PHY in emac_remove() before unregister_netdev().
phy_stop() turns the carrier off, which queues a linkwatch event, and
unregister_netdev() is what drains that queue, so a carrier change after it
leaves this netdev on the linkwatch list for the linkwatch work to pick up
once devres has freed it. phy_disconnect() stays below unregister_netdev(),
detaching a PHY from a registered netdev wants RTNL and ->remove does not
hold it. Details are in the changelog under the ---.

v4 is posted as a new thread. Cross compiled for powerpc out of
ppc44x_defconfig with W=1, clean. No hardware here, so no runtime test.

Thanks,
Linkui


  reply	other threads:[~2026-11-27  1:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  8:39 Linkui Xiao
2026-11-24  8:44 ` netdev-bot+sinfo
2026-11-24 13:50 ` Andrew Lunn
2026-11-27  1:47   ` Linkui Xiao [this message]
2026-11-25  9:01 ` netdev-bot+sashiko
2026-11-27  1:48   ` Linkui Xiao

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=20261127014756.2908959-1-xiaolinkui@126.com \
    --to=xiaolinkui@126.com \
    --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=hkallweit1@gmail.com \
    --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@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®