Re: [PATCH net v8 1/5] net: phy: move irq_suspended and irq_rerun out of the bitfield

From: netdev-bot+sashiko

Date: Mon Nov 23 2026 - 20:11:53 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch adds this comment above the two new bools in struct
phy_device (include/linux/phy.h): "Not bitfields: phy_interrupt() and…

--

net: phy: move irq_suspended and irq_rerun out of the bitfield

This commit turns irq_suspended and irq_rerun in struct phy_device from
1-bit bitfields into separate bools. phy_interrupt() and the PM callbacks
write them without phydev->lock, so a read-modify-write on the shared
bitfield word could lose a concurrent irq_rerun update. The call sites in
phy.c and phy_device.c are updated to use true/false.

[ ... ]

> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 21afc2082b174..59c75296d5355 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -726,8 +726,11 @@ struct phy_device {
>
> /* Interrupts are enabled */
> unsigned interrupts:1;
> - unsigned irq_suspended:1;
> - unsigned irq_rerun:1;
> + /* Not bitfields: phy_interrupt() and the PM callbacks write them
> + * without phydev->lock
> + */

[Severity: Low]
This isn't a bug, but could this comment mislead readers about the
bitfields that remain?

The reason it gives, written by the PM callbacks without phydev->lock,
also applies to interrupts:1 on the line just above it. PHY driver suspend
callbacks run from phy_suspend()->phydrv->suspend(), and phy_suspend()
does not take phydev->lock. For example, in dp83867_suspend():

drivers/net/phy/dp83867.c:dp83867_suspend() {
...
if (phy_interrupt_is_valid(phydev)) {
phydev->interrupts = PHY_INTERRUPT_DISABLED;
dp83867_config_intr(phydev);
}
...
}

marvell-88q2xxx.c and micrel.c do the same thing in their suspend paths.

phy_suspend() also sets phydev->suspended = true without the lock, and
suspended:1 is in the same bitfield word.

Both fields still share that word with link:1 and autoneg_complete:1,
which the state machine writes under phydev->lock. From this comment, a
reader could conclude that the remaining bitfields in the word are only
written under phydev->lock.

Would it be clearer to word the comment so it doesn't imply that rule?
It could, for example, just describe the irq_rerun race that this patch
fixes.

> + bool irq_suspended;
> + bool irq_rerun;
>
> unsigned default_timestamp:1;
>

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-b4-phylib-mac-pm-irq-v3-v8-0-e9f706e79614%40iav.lv