Re: [PATCH net] net: ibm: emac: attach the fixed-link PHY with of_phy_connect()

From: Linkui Xiao

Date: Mon Nov 23 2026 - 04:22:16 EST


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