Re: [PATCH net-next 2/3] net: phy: broadcom: Add support for Wake-on-LAN

From: Simon Horman
Date: Mon May 08 2023 - 15:23:29 EST


On Mon, May 08, 2023 at 11:43:08AM -0700, Florian Fainelli wrote:
> Add support for WAKE_UCAST, WAKE_MCAST, WAKE_BCAST, WAKE_MAGIC and
> WAKE_MAGICSECURE. This is only supported with the BCM54210E and
> compatible Ethernet PHYs. Using the in-band interrupt or an out of band
> GPIO interrupts are supported.
>
> Broadcom PHYs will generate a Wake-on-LAN level low interrupt on LED4 as
> soon as one of the supported patterns is being matched. That includes
> generating such an interrupt even if the PHY is operated during normal
> modes. If WAKE_UCAST is selected, this could lead to the LED4 interrupt
> firing up for every packet being received which is absolutely
> undesirable from a performance point of view.
>
> Because the Wake-on-LAN configuration can be set long before the system
> is actually put to sleep, we cannot have an interrupt service routine to
> clear on read the interrupt status register and ensure that new packet
> matches will be detected.
>
> It is desirable to enable the Wake-on-LAN interrupt as late as possible
> during the system suspend process such that we limit the number of
> interrupts to be handled by the system, but also conversely feed into
> the Linux's system suspend way of dealing with interrupts in and around
> the points of no return.
>
> Signed-off-by: Florian Fainelli <f.fainelli@xxxxxxxxx>

...

> @@ -437,14 +460,38 @@ static int bcm54xx_iddq_set(struct phy_device *phydev, bool enable)
> return ret;
> }
>
> -static int bcm54xx_suspend(struct phy_device *phydev)
> +static int bcm54xx_set_wakeup_irq(struct phy_device *phydev, bool state)
> {
> + struct bcm54xx_phy_priv *priv = phydev->priv;
> int ret;
>
> + if (!bcm54xx_phy_can_wakeup(phydev))
> + return 0;
> +
> + if (priv->wake_irq_enabled != state) {
> + if (state)
> + ret = enable_irq_wake(priv->wake_irq);
> + else
> + ret = disable_irq_wake(priv->wake_irq);
> + priv->wake_irq_enabled = state;
> + }

Hi Florian,

If priv->wake_irq_enabled == state the ret is uninitialised here.

> +
> + return ret;
> +}

...