Re: [PATCH net-next v3 7/7] net: dsa: microchip: do not shut down the switch if WoL is active

From: Vladimir Oltean
Date: Mon Oct 16 2023 - 06:23:04 EST


On Fri, Oct 13, 2023 at 02:24:05PM +0200, Oleksij Rempel wrote:
> For Wake on Lan we should not reconfigure, reset or power down the
> switch on shut down sequence.
>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> ---
> drivers/net/dsa/microchip/ksz9477_i2c.c | 3 +++
> drivers/net/dsa/microchip/ksz_common.c | 18 ++++++++++++++++++
> drivers/net/dsa/microchip/ksz_common.h | 2 ++
> drivers/net/dsa/microchip/ksz_spi.c | 3 +++
> 4 files changed, 26 insertions(+)
>
> diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c b/drivers/net/dsa/microchip/ksz9477_i2c.c
> index 2710afad4f3a..fe818742051c 100644
> --- a/drivers/net/dsa/microchip/ksz9477_i2c.c
> +++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
> @@ -66,6 +66,9 @@ static void ksz9477_i2c_shutdown(struct i2c_client *i2c)
> if (!dev)
> return;
>
> + if (ksz_wol_is_active(dev))
> + return;
> +
> if (dev->dev_ops->reset)
> dev->dev_ops->reset(dev);

The rest of the code used to read:

dsa_switch_shutdown(dev->ds);

i2c_set_clientdata(i2c, NULL);
}

and that part is non-optional. Please only skip the dev->dev_ops->reset()
call if ksz_wol_is_active().

> static void ksz_set_xmii(struct ksz_device *dev, int port,
> phy_interface_t interface)
> {
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index 80679f38ee12..84b1eed8cd2a 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h
> @@ -397,6 +397,8 @@ bool ksz_get_gbit(struct ksz_device *dev, int port);
> phy_interface_t ksz_get_xmii(struct ksz_device *dev, int port, bool gbit);
> extern const struct ksz_chip_data ksz_switch_chips[];
>
> +bool ksz_wol_is_active(struct ksz_device *dev);
> +
> /* Common register access functions */
> static inline struct regmap *ksz_regmap_8(struct ksz_device *dev)
> {
> diff --git a/drivers/net/dsa/microchip/ksz_spi.c b/drivers/net/dsa/microchip/ksz_spi.c
> index 279338451621..c5d9c3d86ddb 100644
> --- a/drivers/net/dsa/microchip/ksz_spi.c
> +++ b/drivers/net/dsa/microchip/ksz_spi.c
> @@ -114,6 +114,9 @@ static void ksz_spi_shutdown(struct spi_device *spi)
> if (!dev)
> return;
>
> + if (ksz_wol_is_active(dev))
> + return;
> +
> if (dev->dev_ops->reset)
> dev->dev_ops->reset(dev);

Same here. Maybe introducing a common ksz_switch_shutdown() would be
appropriate.