* [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
@ 2026-11-24 8:39 Linkui Xiao
2026-11-24 8:44 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Linkui Xiao @ 2026-11-24 8:39 UTC (permalink / raw)
To: Andrew Lunn, netdev
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rosen Penev, Christian Lamparter, Jacob Keller,
Kees Cook, Daniel Machon, Heiner Kallweit, linux-kernel,
Linkui Xiao
From: Linkui Xiao <xiaolinkui@kylinos.cn>
emac_init_phy() sets ndev->phydev by hand for a fixed link, so
phy_attach_direct() never runs. The PHY is missing from the netdev's PHY
link topology and ETHTOOL_MSG_PHY_GET dereferences the NULL link_topo in
phy_prepare_data().
Attach it with of_phy_connect(), as this driver already does for the
phy-handle case and as gianfar, fec, davinci_emac and nixge do, and start
it with phy_start(). phylib then resolves the link and calls
emac_adjust_link(), the same as for a real PHY. That callback fills in the
dev->phy speed, duplex and pause that emac_configure() reads to build MR1.
Nothing else fills those in since commit d99b408ed8e5 ("net: phy:
fixed_phy: remove not needed initialization of phy_device members"), so
today a fixed link is programmed as 10 Mbit/s half duplex with flow
control off, whatever the fixed-link property says.
Attaching also means detaching. Without phy_disconnect(), unbind leaves
phydev->attached_dev pointing at a freed netdev, and the next probe fails
with -EBUSY from phy_attach_direct(). The disconnect also stops the
phy-handle path, which calls phy_start() but never phy_stop(). The fixed
PHY is deregistered on the same paths.
Fixes: baab9de385a8 ("net: ibm: emac: use netdev's phydev directly")
Fixes: d99b408ed8e5 ("net: phy: fixed_phy: remove not needed initialization of phy_device members")
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
drivers/net/ethernet/ibm/emac/core.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
v3:
- dropped 2/2: no phy_read_status() and no hand called
emac_adjust_link(); the fixed link is started with phy_start() and
phylib calls the adjust link callback like it does for a real PHY
(Andrew Lunn)
- back to a single patch, so no cover letter
- the of_phy_connect() failure branch no longer deregisters the
fixed PHY itself: the new err_detach_tah cleanup covers every
probe failure, so the call was redundant
v2: https://lore.kernel.org/netdev/20261123093201.770552-1-xiaolinkui@126.com/
- 1/2: rewrote the commit message by hand (Andrew Lunn)
- 1/2: disconnect the PHY in emac_remove() and on probe failure, and
deregister the fixed PHY when of_phy_connect() fails (Andrew Lunn,
Sashiko AI review)
- 2/2: new, read the link status so emac_adjust_link() no longer copies
SPEED_UNKNOWN into dev->phy (Sashiko AI review)
v1: https://lore.kernel.org/netdev/20261112075321.3903875-1-xiaolinkui@126.com/
Cross compiled for powerpc out of ppc44x_defconfig with W=1, clean. No
hardware here, so no runtime test.
Per Documentation/process/generated-content.rst: the change and the commit
message were developed with an AI coding assistant; the analysis, the build
testing and the review are mine.
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 1b95b4d5deff..ddf33c029334 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2673,11 +2673,14 @@ static int emac_init_phy(struct emac_instance *dev)
return res;
res = of_phy_register_fixed_link(np);
- ndev->phydev = of_phy_find_device(np);
- if (res || !ndev->phydev)
- return res ? res : -EINVAL;
- emac_adjust_link(dev->ndev);
- put_device(&ndev->phydev->mdio.dev);
+ if (res)
+ return res;
+
+ if (!of_phy_connect(ndev, np, &emac_adjust_link, 0,
+ dev->phy_mode))
+ return -EINVAL;
+
+ phy_start(ndev->phydev);
}
return 0;
}
@@ -3190,6 +3193,10 @@ static int emac_probe(struct platform_device *ofdev)
/* I have a bad feeling about this ... */
err_detach_tah:
+ if (ndev->phydev)
+ phy_disconnect(ndev->phydev);
+ if (of_phy_is_fixed_link(np))
+ of_phy_deregister_fixed_link(np);
if (emac_has_feature(dev, EMAC_FTR_HAS_TAH))
tah_detach(dev->tah_dev, dev->tah_port);
err_detach_rgmii:
@@ -3223,6 +3230,11 @@ static void emac_remove(struct platform_device *ofdev)
cancel_work_sync(&dev->reset_work);
+ if (dev->ndev->phydev)
+ phy_disconnect(dev->ndev->phydev);
+ if (of_phy_is_fixed_link(ofdev->dev.of_node))
+ of_phy_deregister_fixed_link(ofdev->dev.of_node);
+
if (emac_has_feature(dev, EMAC_FTR_HAS_TAH))
tah_detach(dev->tah_dev, dev->tah_port);
if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
2026-11-24 8:39 [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY Linkui Xiao
@ 2026-11-24 8:44 ` netdev-bot+sinfo
2026-11-24 13:50 ` Andrew Lunn
2026-11-25 9:01 ` netdev-bot+sashiko
2 siblings, 0 replies; 6+ messages in thread
From: netdev-bot+sinfo @ 2026-11-24 8:44 UTC (permalink / raw)
To: Linkui Xiao
Cc: Andrew Lunn, netdev, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rosen Penev, Christian Lamparter,
Jacob Keller, Kees Cook, Daniel Machon, Heiner Kallweit,
linux-kernel, Linkui Xiao
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
2026-11-24 8:39 [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY Linkui Xiao
2026-11-24 8:44 ` netdev-bot+sinfo
@ 2026-11-24 13:50 ` Andrew Lunn
2026-11-27 1:47 ` Linkui Xiao
2026-11-25 9:01 ` netdev-bot+sashiko
2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2026-11-24 13:50 UTC (permalink / raw)
To: Linkui Xiao
Cc: Andrew Lunn, netdev, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rosen Penev, Christian Lamparter,
Jacob Keller, Kees Cook, Daniel Machon, Heiner Kallweit,
linux-kernel, Linkui Xiao
On Tue, Nov 24, 2026 at 04:39:41PM +0800, Linkui Xiao wrote:
> From: Linkui Xiao <xiaolinkui@kylinos.cn>
>
> emac_init_phy() sets ndev->phydev by hand for a fixed link, so
> phy_attach_direct() never runs. The PHY is missing from the netdev's PHY
> link topology and ETHTOOL_MSG_PHY_GET dereferences the NULL link_topo in
> phy_prepare_data().
>
> Attach it with of_phy_connect(), as this driver already does for the
> phy-handle case and as gianfar, fec, davinci_emac and nixge do, and start
> it with phy_start().
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.
However, this code is a horrible mix of phylib and mii. It really
needs a rewrite to make it pure phylib, or ideally phylink.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
2026-11-24 8:39 [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY Linkui Xiao
2026-11-24 8:44 ` netdev-bot+sinfo
2026-11-24 13:50 ` Andrew Lunn
@ 2026-11-25 9:01 ` netdev-bot+sashiko
2026-11-27 1:48 ` Linkui Xiao
2 siblings, 1 reply; 6+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 9:01 UTC (permalink / raw)
To: xiaolinkui
Cc: andrew+netdev, netdev, andrew, davem, edumazet, kuba, pabeni,
rosenp, chunkeey, jacob.e.keller, kees+treewide, daniel.machon,
hkallweit1, linux-kernel, xiaolinkui
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 1 · Low: 1
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] Unbind can leave a freed net_device queued on the global
linkwatch list.
- [Medium] After the patch, the fixed-link speed, duplex and pause reach
dev->phy only through phylib's asynchronous state machine.
- [Low] The commit message presents the new phy_disconnect() in
emac_remove() as fixing the fixed-link attach, and notes in passing…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it affects
every PHY-less configuration this patch touches, fixed-link included,…
--
net: ibm: emac: attach and start the fixed-link PHY
This patch attaches the fixed-link PHY in emac_init_phy() with
of_phy_connect() and starts it with phy_start(). phylib then fills in
dev->phy through emac_adjust_link(). It also adds phy_disconnect() and
of_phy_deregister_fixed_link() to the emac_probe() error path and to
emac_remove().
> Attaching also means detaching. Without phy_disconnect(), unbind leaves
> phydev->attached_dev pointing at a freed netdev, and the next probe fails
> with -EBUSY from phy_attach_direct(). The disconnect also stops the
> phy-handle path, which calls phy_start() but never phy_stop(). The fixed
> PHY is deregistered on the same paths.
[Severity: Low]
This isn't a bug, but could the commit message say that baab9de385a8
("net: ibm: emac: use netdev's phydev directly") is the commit that
removed this from emac_remove():
if (dev->phy_dev)
phy_disconnect(dev->phy_dev);
Since then, the phy-handle path has connected with of_phy_connect() and
started the PHY in emac_mdio_init_phy(), but it never detaches. So the
stale phydev->attached_dev problem described here has existed on that
path since baab9de385a8.
Saying that the emac_remove() hunk restores teardown removed by that
commit would make the backport scope clearer.
> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index 1b95b4d5deff5..ddf33c0293348 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> @@ -2673,11 +2673,14 @@ static int emac_init_phy(struct emac_instance *dev)
> return res;
>
> res = of_phy_register_fixed_link(np);
> - ndev->phydev = of_phy_find_device(np);
> - if (res || !ndev->phydev)
> - return res ? res : -EINVAL;
> - emac_adjust_link(dev->ndev);
> - put_device(&ndev->phydev->mdio.dev);
> + if (res)
> + return res;
> +
> + if (!of_phy_connect(ndev, np, &emac_adjust_link, 0,
> + dev->phy_mode))
> + return -EINVAL;
> +
> + phy_start(ndev->phydev);
[Severity: Medium]
The old code called emac_adjust_link() synchronously in probe.
phy_start() only queues phydev->state_queue, so dev->phy gets filled in
later from a kworker.
emac_adjust_link() only copies the values into dev->phy:
dev->phy.autoneg = phy->autoneg;
dev->phy.speed = phy->speed;
dev->phy.duplex = phy->duplex;
dev->phy.pause = phy->pause;
dev->phy.asym_pause = phy->asym_pause;
It never calls emac_configure() and never schedules a reset. When
dev->phy.address == -1, emac_open() forces carrier on, does not schedule
link_work, and calls emac_configure() only once.
Suppose emac_open() runs before the first state machine pass. Would MR1
then be programmed from the probe defaults (SPEED_100, DUPLEX_FULL,
pause = 1) and stay that way after emac_adjust_link() reports the
fixed-link values? A fixed link does not change state again, so
adjust_link would not be called again either.
The writer and the readers also share no lock. emac_adjust_link() runs
under phydev->lock. emac_configure() runs under dev->link_lock from
emac_open() and reset_work. A concurrent run could program a mix of old
and new speed and duplex.
Taking link_lock inside the callback is not simple, because the ethtool
paths take link_lock before they call into phylib.
Could the PHY state be read synchronously under link_lock before
emac_configure()? Alternatively, emac_adjust_link() could trigger a
reconfiguration (for example via reset_work) when the device is open.
> }
> return 0;
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. It
dates back to commit 9e3cb29497561c, but it affects every PHY-less
configuration this branch handles, fixed-link included.
The PHY-less branch returns before emac_init_phy() sets these:
dev->phy.mdio_read = emac_mdio_read;
dev->phy.mdio_write = emac_mdio_write;
...
dev->phy.gpcs_address = dev->gpcs_address;
emac_instance lives in zeroed netdev_priv, so mdio_read is NULL and
gpcs_address is 0. With phy-mode sgmii, tbi or rtbi, emac_configure()
does this on every open and reset:
if (emac_phy_gpcs(dev->phy.mode)) {
if (dev->phy.gpcs_address != 0xffffffff)
emac_mii_reset_gpcs(&dev->phy);
else
emac_mii_reset_phy(&dev->phy);
}
Can emac_mii_reset_gpcs()->gpcs_phy_read() then call through the NULL
phy->mdio_read? The else branch would also reach the NULL mdio_read,
through phy_read().
EMAC0 in arch/powerpc/boot/dts/arches.dts looks like it matches this
case (phy-mode = "sgmii", phy-map = <0xffffffff>, no phy-address). So
would any fixed-link node with an SGMII, TBI or RTBI phy-mode.
The 1000 Mbit/s path is now reached for fixed links. On that path MR1
would also get IPPA(0) instead of the DT gpcs-address.
> }
[ ... ]
> @@ -3223,6 +3230,11 @@ static void emac_remove(struct platform_device *ofdev)
>
> cancel_work_sync(&dev->reset_work);
>
> + if (dev->ndev->phydev)
> + phy_disconnect(dev->ndev->phydev);
[Severity: High]
Can this leave a freed net_device queued on the global linkwatch list?
emac_init_phy() now calls phy_start() at probe time. The fixed link
comes up on the first state machine pass, and phy_link_change() calls
netif_carrier_on(). Probe called netif_carrier_off() earlier, but that
does not stop it.
The phy-handle path already does the same through emac_mdio_init_phy().
If the interface is never opened, carrier is still on at unbind. The
call chain at unbind is then:
emac_remove()
unregister_netdev() /* reg_state = NETREG_UNREGISTERED */
phy_disconnect()
phy_stop()
_phy_state_machine() /* PHY_HALTED, phydev->link == 1 */
phy_link_down()
phy_link_change(false)
netif_carrier_off()
linkwatch_fire_event()
linkwatch_add_event() /* netdev_hold(), list_add */
devres -> free_netdev()
netif_carrier_off() only returns early for NETREG_UNINITIALIZED:
net/sched/sch_generic.c:netif_carrier_off() {
if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
if (dev->reg_state == NETREG_UNINITIALIZED)
return;
atomic_inc(&dev->carrier_down_count);
linkwatch_fire_event(dev);
}
}
linkwatch_add_event() does not check reg_state either.
ndev comes from devm_alloc_etherdev(), so free_netdev() runs right after
emac_remove() returns. free_netdev() does not take dev->link_watch_list
off lweventlist.
The device is not running, so the linkwatch work is not urgent and runs
up to HZ later. __linkwatch_run_queue() would then walk the freed device
and call __dev_put() on the freed pcpu_refcnt.
The err_detach_tah path in emac_probe() has the same ordering. It is hit
if register_netdev() fails after reg_state has become
NETREG_UNREGISTERED, for example when netdev_register_kobject() fails.
Would it work to move phy_start() and phy_stop() into emac_open() and
emac_close()? The PHY would then already be halted when
unregister_netdev() runs. Another option is to stop the PHY before
unregister_netdev().
> + if (of_phy_is_fixed_link(ofdev->dev.of_node))
> + of_phy_deregister_fixed_link(ofdev->dev.of_node);
> +
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124083941.2480237-1-xiaolinkui%40126.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
2026-11-24 13:50 ` Andrew Lunn
@ 2026-11-27 1:47 ` Linkui Xiao
0 siblings, 0 replies; 6+ messages in thread
From: Linkui Xiao @ 2026-11-27 1:47 UTC (permalink / raw)
To: Andrew Lunn
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, rosenp,
jacob.e.keller, daniel.machon, chunkeey, kees+treewide,
hkallweit1, netdev, linux-kernel, Linkui Xiao
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY
2026-11-25 9:01 ` netdev-bot+sashiko
@ 2026-11-27 1:48 ` Linkui Xiao
0 siblings, 0 replies; 6+ messages in thread
From: Linkui Xiao @ 2026-11-27 1:48 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: andrew+netdev, netdev, andrew, davem, edumazet, kuba, pabeni,
rosenp, chunkeey, jacob.e.keller, kees+treewide, daniel.machon,
hkallweit1, linux-kernel, Linkui Xiao
Thanks for the review. All four are legitimate. v4 is posted as a new
thread; it also starts the fixed PHY through emac_mdio_init_phy(), which is
what Andrew asked for in his review of v3.
- [High] Unbind can leave a freed net_device queued on the linkwatch list.
Correct, including the chain, and the reason is not that the reference is
weak. unregister_netdev() -> netdev_run_todo() drains lweventlist through
linkwatch_sync_dev(), and it is also the only place that waits for the
refcount, in netdev_wait_allrefs_any(); it returns as soon as the count
reaches one. A carrier change after that queues an event nobody will ever
wait for again: linkwatch_add_event() does list_add_tail() + netdev_hold(),
and netdev_hold() is a real __dev_hold(), but free_netdev() does not wait
for refs and never takes dev->link_watch_list back off, it goes straight to
ref_tracker_dir_exit(), free_percpu(dev->pcpu_refcnt) and put_device() ->
netdev_release() -> kvfree(). devres frees the netdev as soon as
emac_remove() returns, and __linkwatch_run_queue() then walks the list,
calling netdev_tracker_free() and __dev_put() on freed memory.
Fixed by stopping the PHY before unregister_netdev():
if (dev->ndev->phydev)
phy_stop(dev->ndev->phydev);
phy_stop() is what turns the carrier off, so the event is queued while the
netdev is still registered and unregister_netdev() drains it.
phy_disconnect() stays below it: it only stops the PHY when
phy_is_started(), which is false by then, and moving it up would detach
from a registered netdev without RTNL, which phy_detach_internal() only
tolerates once reg_state != NETREG_REGISTERED.
I did not move phy_start()/phy_stop() into emac_open()/emac_close(). Andrew
asked for the fixed PHY to be started the way this driver starts a real
PHY, and that is emac_mdio_init_phy() from emac_init_phy(), not from
ndo_open. Splitting the two belongs to the phylib/phylink rewrite he also
asked for.
err_detach_tah keeps its order, with one caveat. A failure before
register_netdev() leaves reg_state at NETREG_UNINITIALIZED, where
netif_carrier_off() returns before it reaches linkwatch, so the
phy_disconnect() there cannot queue anything.
The caveat is a failed register_netdev(). It leaves the netdev
NETREG_UNREGISTERED, whether netdev_register_kobject() failed or the
NETDEV_REGISTER veto ran the rollback, so netif_carrier_off() no longer
returns early. If the state machine brought the carrier up between the
probe's own netif_carrier_off() and the failure, the phy_stop() inside
that phy_disconnect() queues one more event: after netdev_run_todo() has
drained the queue on the veto path, with no drain at all on the other.
That takes register_netdev() to fail, so I did not widen the error path
for it.
- [Medium] dev->phy is now filled in asynchronously.
The ordering is real: phy_start() only does phy_queue_state_machine(phydev,
0) and emac_adjust_link() just copies the resolved values into dev->phy, so
emac_open() can win the race and build MR1 from the probe defaults, and
since a fixed link never changes state again the callback will not fire a
second time to correct it.
I left the code alone in v4, but the commit message no longer implies the
speed is settled. It now carries this paragraph:
> phy_start() only queues the state machine, so an emac_open() that wins the
> race against the first emac_adjust_link() still builds MR1 from the probe
> defaults, and a fixed link never changes state again for a second callback
> to correct it. That window is the one the phy-handle path has always had,
> this driver starts its PHY at probe time rather than in ndo_open, and the
> next ifdown/ifup closes it.
Two things bound the window. It is not new: this driver has always started
its PHY from emac_init_phy() at probe time and never from ndo_open, so the
phy-handle path has the same race against its first ifup. And it is not
permanent: emac_open() runs emac_configure() on every open, so an
ifdown/ifup picks up the dev->phy values the callback filled in meanwhile.
What is permanent is the behaviour before this patch, where dev->phy.speed
stays SPEED_UNKNOWN, emac_configure() takes the default case, and the port
is programmed 10 Mbit/s half duplex with flow control off whatever the
fixed-link property says.
Making it deterministic means reading the link under link_lock before
emac_configure(), or reconfiguring from the callback, and the ethtool paths
already take link_lock before calling into phylib. That is the same
rewrite; I would rather do it there than bolt it onto a crash fix.
- [High, pre-existing] NULL mdio_read on the gpcs path.
Also correct. The branch returns before dev->phy.mdio_read, mdio_write and
gpcs_address are assigned, and emac_configure() reaches
emac_mii_reset_gpcs() -> gpcs_phy_read() on every open and reset_work, so a
sgmii/tbi/rtbi port in that branch dereferences NULL. arches.dts EMAC0
(sgmii, phy-map 0xffffffff, gpcs-address 0xa) is exactly that case. It is
untouched by this patch and predates it; I will send a separate fix.
- [Low] name baab9de385a8 in the commit message.
Done. The v4 commit message now says that baab9de385a8 ("net: ibm: emac:
use netdev's phydev directly") dropped
if (dev->phy_dev)
phy_disconnect(dev->phy_dev);
from emac_remove() along with dev->phy_dev, and that the emac_remove() hunk
restores it.
Cross compiled for powerpc out of ppc44x_defconfig with W=1, clean. No
hardware here, so no runtime test.
Regards,
Linkui
pw-bot: cr
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-27 1:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 8:39 [PATCH net v3] net: ibm: emac: attach and start the fixed-link PHY Linkui Xiao
2026-11-24 8:44 ` netdev-bot+sinfo
2026-11-24 13:50 ` Andrew Lunn
2026-11-27 1:47 ` Linkui Xiao
2026-11-25 9:01 ` netdev-bot+sashiko
2026-11-27 1:48 ` Linkui Xiao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox