From patchwork Fri Oct 13 12:24:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 13420867 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B0C713FEC for ; Fri, 13 Oct 2023 12:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5108CBE for ; Fri, 13 Oct 2023 05:24:28 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qrHD6-00016J-4U; Fri, 13 Oct 2023 14:24:08 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qrHD5-001OKr-3q; Fri, 13 Oct 2023 14:24:07 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qrHD5-00FiOb-03; Fri, 13 Oct 2023 14:24:07 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, "Russell King (Oracle)" , devicetree@vger.kernel.org Subject: [PATCH net-next v3 7/7] net: dsa: microchip: do not shut down the switch if WoL is active Date: Fri, 13 Oct 2023 14:24:05 +0200 Message-Id: <20231013122405.3745475-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013122405.3745475-1-o.rempel@pengutronix.de> References: <20231013122405.3745475-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org For Wake on Lan we should not reconfigure, reset or power down the switch on shut down sequence. Signed-off-by: Oleksij Rempel --- 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);