[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231013122405.3745475-8-o.rempel@pengutronix.de>
Date: Fri, 13 Oct 2023 14:24:05 +0200
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: "David S. Miller" <davem@...emloft.net>,
Andrew Lunn <andrew@...n.ch>,
Eric Dumazet <edumazet@...gle.com>,
Florian Fainelli <f.fainelli@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Vladimir Oltean <olteanv@...il.com>,
Woojung Huh <woojung.huh@...rochip.com>,
Arun Ramadoss <arun.ramadoss@...rochip.com>,
Conor Dooley <conor+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Rob Herring <robh+dt@...nel.org>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>, kernel@...gutronix.de,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
UNGLinuxDriver@...rochip.com,
"Russell King (Oracle)" <linux@...linux.org.uk>,
devicetree@...r.kernel.org
Subject: [PATCH net-next v3 7/7] net: dsa: microchip: do not shut down the switch if WoL is active
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@...gutronix.de>
---
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);
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 820edda82cea..c3669b9cc6ce 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -2959,6 +2959,24 @@ static int ksz_set_wol(struct dsa_switch *ds, int port,
return -EOPNOTSUPP;
}
+bool ksz_wol_is_active(struct ksz_device *dev)
+{
+ struct dsa_port *dp;
+
+ if (!dev->wakeup_source)
+ return false;
+
+ dsa_switch_for_each_user_port(dp, dev->ds) {
+ struct ethtool_wolinfo wol;
+
+ ksz_get_wol(dev->ds, dp->index, &wol);
+ if (wol.wolopts)
+ return true;
+ }
+
+ return false;
+}
+
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);
--
2.39.2
Powered by blists - more mailing lists