Re: [PATCH net v4 2/2] net: phy: restore the interrupt after a generic-driver bind cycle

From: Aleksei Sviridkin

Date: Fri Sep 04 2026 - 20:09:57 EST


On Wed, 2 Sep 2026 22:53, Andrew Lunn wrote:
> Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Thanks, but please hold that one. The Sashiko bot pointed at bus->irq[]
afterwards and it is right, so v4 does not do what its changelog says on
a fair number of buses. I would rather tell you before sending a v5 that
changes the approach.

mdiobus_alloc_size() fills the whole table with PHY_POLL, and consumers
that install the interrupt only on the phy_device never touch it.
smsc95xx does "pdata->phydev->irq = phy_irq" and lan78xx does
"phydev->irq = dev->domain_data.phyirq", both without a matching write
to bus->irq[]. There my helper reads PHY_POLL back out and restores
nothing, while the comment I put next to it claims the table still holds
the pre-bind value. Only fwnode_mdio, stmmac_mdio and mlxbf_gige mirror
it, so only they are covered.

The same bot made a second point I cannot argue with: the == PHY_POLL
test cannot tell a bind-installed PHY_POLL from one the caller asked
for. PHY_F_NO_IRQ in phy_attach_direct(), and ixp4xx_eth, ax88796c and
emac-mac after connect, all write it deliberately. On a bus that does
mirror a live interrupt, phy_detach() would hand back a number the board
took out of service.

So the shape I would like to send instead: save phydev->irq in
phy_probe() before it is overwritten, and put it back in phy_remove().
That drops the table as a source, drops the provenance guess, and it is
the symmetric undo, since phy_remove() already reverts other probe-time
state and is reachable through a sysfs unbind that never goes near
phy_detach().

The part I would rather agree with you first is where the saved value
lives. A field in struct phy_device is the obvious answer and also the
most expensive one. Is that acceptable, or would you rather it went
somewhere else?