Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp920363rdg; Fri, 13 Oct 2023 05:25:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhWLjAa1glxEj4OuMJAAFOnO0TQh00PXN5HKGr4Jyoq2yVuoP5lFUQOLEWXpMbuP5tn3Jm X-Received: by 2002:a17:902:f203:b0:1c9:fdbf:296a with SMTP id m3-20020a170902f20300b001c9fdbf296amr1149942plc.8.1697199901629; Fri, 13 Oct 2023 05:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697199901; cv=none; d=google.com; s=arc-20160816; b=pxbDvez+jzftNreiQBdQ+tQY5WDFJ2CC1sDHndoBnqrINMpHLfJ0vEsgNsTiXMpmFK tTM20S8+TOmOmX87lPzMbKRTuUAwrz1GHdLZsSTpC/lCpBRm8JLY/GgVDbnBebl/S2Ib bZ8x1jfP92Fv43O52vhcOUf6X9xCeEuI8QTY9XkdZs+Xugze8Q6MlkU713k8X7Tz7KkQ VpzhwUbvDaMlwtG5F7UZvDmbsMefiooMKfiQdpMVw4JaNzRJ6Gy7i0eqmx2y64VesFGC mNBEloSPlJt0ukL0qNAPRszrxFSer1AOyMm2egSe/2Qoxdf15LDy6I7FL2/Bwv4Gb+im Y9mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bgOvKty/eD7k+SlUsHfg96w+XhuiHXQbsXMi0x9JBi4=; fh=J4gjwt0mePoRaYCjaHLm28JnUFi5LyPM6ZZbSRFLAL0=; b=hFlEJTQ6IHYluKkcGU7EOxvzCNPqOSNcOVthNo+6PjUkVePKoyUsri6c+2paYjjU0H y9MDKKwFry+rxl23rMxvqgzH3nsWleu2yVJo0KcXj6yjz6w1z0RhsKaBPBpkT/JK1tKL z5LRYAtTI1zscONEKiRfZAwAXk2lfZJjIoS2oLURCr6D3SE+tuKJEZQJLwceOV4uO4aV q13rCIUtD2QpMzNNdtLpz8yaodMmtRgEDQc3Pjy0L4Fx1fmb7T7heq4Y+JVL3QI02tQx 6eP9ZQPIK3skQLKHNxguBZcxmUfFFk4VaxO4zxjUmanJttWbSTgXbYgkVaDoM4bsE/8m SaFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g10-20020a170902740a00b001c9c733c422si3087647pll.95.2023.10.13.05.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 05:25:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 56C8F82DFD2A; Fri, 13 Oct 2023 05:24:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjJMMY3 (ORCPT + 99 others); Fri, 13 Oct 2023 08:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbjJMMY2 (ORCPT ); Fri, 13 Oct 2023 08:24:28 -0400 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 0DDA4BE for ; Fri, 13 Oct 2023 05:24:26 -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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 13 Oct 2023 05:24:53 -0700 (PDT) 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); -- 2.39.2