Netdev List
 help / color / mirror / Atom feed
From: Linkui Xiao <xiaolinkui@126.com>
To: netdev-bot+sashiko@kernel.org
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,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	xiaolinkui@kylinos.cn, Linkui Xiao <xiaolinkui@126.com>
Subject: Re: [PATCH net] net: ibm: emac: attach the fixed-link PHY with of_phy_connect()
Date: Mon, 23 Nov 2026 17:20:53 +0800	[thread overview]
Message-ID: <20261123092053.743714-1-xiaolinkui@126.com> (raw)
In-Reply-To: <179483706662.3136.12689489417547730312@kernel.org>

Thanks for the review. All three issues are legitimate; v2 is a two patch
series posted as a new thread, [PATCH net v2 0/2].

- [High] The fixed-link PHY is attached but never detached.

Fixed in 1/2. emac_remove() and err_detach_tah in emac_probe() now call
phy_disconnect() and of_phy_deregister_fixed_link(), so the stale
attached_dev, the NUM_FP slot, the of_node reference and the module
references are all released. emac_remove() already unregisters the netdev
before this point, and phy_detach_internal() explicitly allows detaching
without RTNL once dev is unregistered, so the suspend use-after-free on
the stale attached_dev is gone.

The rebind analysis is correct: without the disconnect the second
of_phy_find_device() returns the still-attached PHY and phy_attach_direct()
fails with -EBUSY. Adding phy_disconnect() also stops the PHY, which the
phy-handle path never did - emac_mdio_init_phy() calls phy_start() and
nothing calls phy_stop().

You are also right that "the rest of the driver already treats
dev->phy.address < 0 as no PHY to poll, so nothing else changes" was too
strong, since the attach state does change. That claim is gone from the v2
commit message.

- [Medium] of_phy_connect() failure leaves the fixed PHY registered.

Fixed in 1/2: the failure branch calls of_phy_deregister_fixed_link(np)
before returning. The teardown paths guard the call with
of_phy_is_fixed_link(), which is the pattern ravb, nixge, davinci_emac and
cpsw use; of_phy_deregister_fixed_link() is also a no-op when no fixed PHY
is registered, so reaching it twice is safe.

- [Medium] emac_adjust_link() copies SPEED_UNKNOWN/DUPLEX_UNKNOWN.

This one is worse than "the old code behaved the same way", so thank you
for pushing on it. The regression comes from d99b408ed8e5 ("net: phy:
fixed_phy: remove not needed initialization of phy_device members"), which
stopped copying the device tree status into the phy_device on the
assumption that the state machine fills those members in once the PHY is
started. EMAC never starts it on the fixed-link path, so emac_configure()
builds MR1 without EMAC_MR1_FDE and without EMAC_MR1_MF_1000 /
EMAC_MR1_MF_100, and flow control is left off.

Fixed in 2/2 with phy_read_status() after the attach, which is what
emac_mdio_read_link() already does on the phy-handle path. The fixed PHY
is bound to genphy, so genphy_read_status() resolves speed, duplex and
pause from the BMSR/LPA/STAT1000/ESTATUS registers that swphy_read_reg()
emulates out of the device tree status. phy_read_status() rather than
phy_start() because a fixed link cannot change and there is no reason to
run the state machine for it.

Cross compiled for powerpc with W=1 out of ppc44x_defconfig, clean. No
hardware here, so no runtime test.

Regards,
Linkui

pw-bot: cr


      reply	other threads:[~2026-11-23  9:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  7:53 [PATCH net] net: ibm: emac: attach the fixed-link PHY with of_phy_connect() Linkui Xiao
2026-11-13 13:50 ` Andrew Lunn
2026-11-23  9:10   ` Linkui Xiao
2026-11-16 13:51 ` netdev-bot+sashiko
2026-11-23  9:20   ` Linkui Xiao [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=20261123092053.743714-1-xiaolinkui@126.com \
    --to=xiaolinkui@126.com \
    --cc=andrew+netdev@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-bot+sashiko@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