From nobody Fri Dec 19 20:18:23 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 4A0C81F6694 for ; Mon, 28 Apr 2025 12:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745844697; cv=none; b=W+thzJNpNRBB+Mu4qyqWrZAeJsfV4wZIc5mKug7InWp9231rHNA12ywxjnRZt1M9BCys75JES1vsnEx1DbcJu5zv/5KByU97V3d/twT/ZWgrQQcLZ/m3IJnEsmqeHA3sjwC4eN0kTRFCBEUiX7+2ryE/LHd5DsDzsCIgRFzWwSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745844697; c=relaxed/simple; bh=JIQwydwFWZlPN3ngN48yH8aK8cCEPw7Uxcw6j2JoWwI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vFFjcrHoAaQMF48nGXB+vna+zqNcshhcJ6eXy07y7sfcZJDvthpkGeYNYUQPpZiojCj14R18Q3PgzVhiUXeLPVScXpYSucEv6+MwhiIkE6C3xH9yioaonpXQ+gZgWnt0++CkV4Mn5yKeSukRrwnA30Fm7x01gUzTZG5h3MpKfL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de 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 1u9NxD-0002iG-AH; Mon, 28 Apr 2025 14:51:23 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u9NxB-00068G-2o; Mon, 28 Apr 2025 14:51:21 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1u9NxB-00EK9u-2Z; Mon, 28 Apr 2025 14:51:21 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , "Russell King (Oracle)" , Heiner Kallweit Cc: Oleksij Rempel , stable@vger.kernel.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net v1 1/2] net: dsa: microchip: let phylink manage PHY EEE configuration on KSZ switches Date: Mon, 28 Apr 2025 14:51:18 +0200 Message-Id: <20250428125119.3414046-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428125119.3414046-1-o.rempel@pengutronix.de> References: <20250428125119.3414046-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Content-Type: text/plain; charset="utf-8" Phylink expects MAC drivers to provide LPI callbacks to properly manage Energy Efficient Ethernet (EEE) configuration. On KSZ switches with integrated PHYs, LPI is internally handled by hardware, while ports without integrated PHYs have no documented MAC-level LPI support. Provide dummy mac_disable_tx_lpi() and mac_enable_tx_lpi() callbacks to satisfy phylink requirements. Also, set default EEE capabilities during phylink initialization where applicable. Since phylink can now gracefully handle optional EEE configuration, remove the need for the MICREL_NO_EEE PHY flag. This change addresses issues caused by incomplete EEE refactoring introduced in commit fe0d4fd9285e ("net: phy: Keep track of EEE configuration"). It is not easily possible to fix all older kernels, but this patch ensures proper behavior on latest kernels and can be considered for backporting to stable kernels starting from v6.14. Fixes: fe0d4fd9285e ("net: phy: Keep track of EEE configuration") Signed-off-by: Oleksij Rempel Cc: stable@vger.kernel.org # v6.14+ --- drivers/net/dsa/microchip/ksz_common.c | 97 ++++++++++++++++++-------- 1 file changed, 69 insertions(+), 28 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index b45052497f8a..f4b928e54c5b 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -265,16 +265,48 @@ static void ksz_phylink_mac_link_down(struct phylink_= config *config, unsigned int mode, phy_interface_t interface); =20 +/** + * ksz_phylink_mac_disable_tx_lpi() - Dummy handler to disable TX LPI + * @config: phylink config structure + * + * For ports with integrated PHYs, LPI is managed internally by hardware. + * Ports without integrated PHYs do not document MAC-level LPI support. + * No software action is needed. + */ +static void ksz_phylink_mac_disable_tx_lpi(struct phylink_config *config) +{ +} + +/** + * ksz_phylink_mac_enable_tx_lpi() - Dummy handler to enable TX LPI + * @config: phylink config structure + * @timer: timer value before entering LPI + * @tx_clock_stop: whether to stop the TX clock in LPI mode + * + * For ports with integrated PHYs, LPI is managed internally by hardware. + * Ports without integrated PHYs do not document MAC-level LPI support. + * Always return success. + */ +static int ksz_phylink_mac_enable_tx_lpi(struct phylink_config *config, + u32 timer, bool tx_clock_stop) +{ + return 0; +} + static const struct phylink_mac_ops ksz88x3_phylink_mac_ops =3D { .mac_config =3D ksz88x3_phylink_mac_config, .mac_link_down =3D ksz_phylink_mac_link_down, .mac_link_up =3D ksz8_phylink_mac_link_up, + .mac_disable_tx_lpi =3D ksz_phylink_mac_disable_tx_lpi, + .mac_enable_tx_lpi =3D ksz_phylink_mac_enable_tx_lpi, }; =20 static const struct phylink_mac_ops ksz8_phylink_mac_ops =3D { .mac_config =3D ksz_phylink_mac_config, .mac_link_down =3D ksz_phylink_mac_link_down, .mac_link_up =3D ksz8_phylink_mac_link_up, + .mac_disable_tx_lpi =3D ksz_phylink_mac_disable_tx_lpi, + .mac_enable_tx_lpi =3D ksz_phylink_mac_enable_tx_lpi, }; =20 static const struct ksz_dev_ops ksz88xx_dev_ops =3D { @@ -358,6 +390,8 @@ static const struct phylink_mac_ops ksz9477_phylink_mac= _ops =3D { .mac_config =3D ksz_phylink_mac_config, .mac_link_down =3D ksz_phylink_mac_link_down, .mac_link_up =3D ksz9477_phylink_mac_link_up, + .mac_disable_tx_lpi =3D ksz_phylink_mac_disable_tx_lpi, + .mac_enable_tx_lpi =3D ksz_phylink_mac_enable_tx_lpi, }; =20 static const struct ksz_dev_ops ksz9477_dev_ops =3D { @@ -401,6 +435,8 @@ static const struct phylink_mac_ops lan937x_phylink_mac= _ops =3D { .mac_config =3D ksz_phylink_mac_config, .mac_link_down =3D ksz_phylink_mac_link_down, .mac_link_up =3D ksz9477_phylink_mac_link_up, + .mac_disable_tx_lpi =3D ksz_phylink_mac_disable_tx_lpi, + .mac_enable_tx_lpi =3D ksz_phylink_mac_enable_tx_lpi, }; =20 static const struct ksz_dev_ops lan937x_dev_ops =3D { @@ -2016,6 +2052,18 @@ static void ksz_phylink_get_caps(struct dsa_switch *= ds, int port, =20 if (dev->dev_ops->get_caps) dev->dev_ops->get_caps(dev, port, config); + + if (ds->ops->support_eee && ds->ops->support_eee(ds, port)) { + memcpy(config->lpi_interfaces, config->supported_interfaces, + sizeof(config->lpi_interfaces)); + + config->lpi_capabilities =3D MAC_100FD; + if (dev->info->gbit_capable[port]) + config->lpi_capabilities |=3D MAC_1000FD; + + /* EEE is fully operational */ + config->eee_enabled_default =3D true; + } } =20 void ksz_r_mib_stats64(struct ksz_device *dev, int port) @@ -3008,31 +3056,6 @@ static u32 ksz_get_phy_flags(struct dsa_switch *ds, = int port) if (!port) return MICREL_KSZ8_P1_ERRATA; break; - case KSZ8567_CHIP_ID: - /* KSZ8567R Errata DS80000752C Module 4 */ - case KSZ8765_CHIP_ID: - case KSZ8794_CHIP_ID: - case KSZ8795_CHIP_ID: - /* KSZ879x/KSZ877x/KSZ876x Errata DS80000687C Module 2 */ - case KSZ9477_CHIP_ID: - /* KSZ9477S Errata DS80000754A Module 4 */ - case KSZ9567_CHIP_ID: - /* KSZ9567S Errata DS80000756A Module 4 */ - case KSZ9896_CHIP_ID: - /* KSZ9896C Errata DS80000757A Module 3 */ - case KSZ9897_CHIP_ID: - case LAN9646_CHIP_ID: - /* KSZ9897R Errata DS80000758C Module 4 */ - /* Energy Efficient Ethernet (EEE) feature select must be manually disab= led - * The EEE feature is enabled by default, but it is not fully - * operational. It must be manually disabled through register - * controls. If not disabled, the PHY ports can auto-negotiate - * to enable EEE, and this feature can cause link drops when - * linked to another device supporting EEE. - * - * The same item appears in the errata for all switches above. - */ - return MICREL_NO_EEE; } =20 return 0; @@ -3475,15 +3498,33 @@ static bool ksz_support_eee(struct dsa_switch *ds, = int port) =20 switch (dev->chip_id) { case KSZ8563_CHIP_ID: + case KSZ9563_CHIP_ID: + case KSZ9893_CHIP_ID: + return true; case KSZ8567_CHIP_ID: + /* KSZ8567R Errata DS80000752C Module 4 */ + case KSZ8765_CHIP_ID: + case KSZ8794_CHIP_ID: + case KSZ8795_CHIP_ID: + /* KSZ879x/KSZ877x/KSZ876x Errata DS80000687C Module 2 */ case KSZ9477_CHIP_ID: - case KSZ9563_CHIP_ID: + /* KSZ9477S Errata DS80000754A Module 4 */ case KSZ9567_CHIP_ID: - case KSZ9893_CHIP_ID: + /* KSZ9567S Errata DS80000756A Module 4 */ case KSZ9896_CHIP_ID: + /* KSZ9896C Errata DS80000757A Module 3 */ case KSZ9897_CHIP_ID: case LAN9646_CHIP_ID: - return true; + /* KSZ9897R Errata DS80000758C Module 4 */ + /* Energy Efficient Ethernet (EEE) feature select must be manually disab= led + * The EEE feature is enabled by default, but it is not fully + * operational. It must be manually disabled through register + * controls. If not disabled, the PHY ports can auto-negotiate + * to enable EEE, and this feature can cause link drops when + * linked to another device supporting EEE. + * + * The same item appears in the errata for all switches above. + */ } =20 return false; --=20 2.39.5 From nobody Fri Dec 19 20:18:23 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 35D115D477 for ; Mon, 28 Apr 2025 12:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745844696; cv=none; b=hMH0v8E3jW+E5Lf3MghrN+CRZpGbxaEQZuauepIQ4RSfevSQbLF8ypjb0uHL36ejmHX3bqjsauq7zTRmEeMMuoE2Jtwv4hNIE0bQ4clRm4ZXAEUHEerLLRuF9NcJWS7p1+eNzLxmgpbIfwiuPm6aNf5AReywQHGQ7zikiM7E+h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745844696; c=relaxed/simple; bh=xtQH8hL/JAq5BZPBxmrrmwIJH1+MKVZHkg0hPfy9pV0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JWJj14SLEUC5qBqt6EeAGZjdbHuWGjvew+wUJHgkrWedf1teJG9dr4xFHkqCIvzzF6h5a05z5s7Me9kCrBK/tKTEt6yuX5Hcbny91ca9e5xlCmAor/iWvirLXNqwtD6ilOhDOEIQvtXDsAcEtmNGHi5MJ+E4CuH6JfbPlHJ/uTc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de 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 1u9NxD-0002iW-AH; Mon, 28 Apr 2025 14:51:23 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u9NxB-00068H-2t; Mon, 28 Apr 2025 14:51:21 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1u9NxB-00EKA4-2e; Mon, 28 Apr 2025 14:51:21 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , "Russell King (Oracle)" , Heiner Kallweit Cc: Oleksij Rempel , stable@vger.kernel.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net v1 2/2] net: phy: micrel: remove KSZ9477 EEE quirks now handled by phylink Date: Mon, 28 Apr 2025 14:51:19 +0200 Message-Id: <20250428125119.3414046-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428125119.3414046-1-o.rempel@pengutronix.de> References: <20250428125119.3414046-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Content-Type: text/plain; charset="utf-8" The KSZ9477 PHY driver contained workarounds for broken EEE capability advertisements by manually masking supported EEE modes and forcibly disabling EEE if MICREL_NO_EEE was set. With proper MAC-side EEE handling implemented via phylink, these quirks are no longer necessary. Remove MICREL_NO_EEE handling and the use of ksz9477_get_features(). This simplifies the PHY driver and avoids duplicated EEE management logic. Signed-off-by: Oleksij Rempel Cc: stable@vger.kernel.org # v6.14+ --- drivers/net/phy/micrel.c | 7 ------- include/linux/micrel_phy.h | 1 - 2 files changed, 8 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 71fb4410c31b..c2e5be404f07 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -2027,12 +2027,6 @@ static int ksz9477_config_init(struct phy_device *ph= ydev) return err; } - /* According to KSZ9477 Errata DS80000754C (Module 4) all EEE modes - * in this switch shall be regarded as broken. - */ - if (phydev->dev_flags & MICREL_NO_EEE) - phy_disable_eee(phydev); - return kszphy_config_init(phydev); } @@ -5698,7 +5692,6 @@ static struct phy_driver ksphy_driver[] =3D { .handle_interrupt =3D kszphy_handle_interrupt, .suspend =3D genphy_suspend, .resume =3D ksz9477_resume, - .get_features =3D ksz9477_get_features, } }; module_phy_driver(ksphy_driver); diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h index 591bf5b5e8dc..9af01bdd86d2 100644 --- a/include/linux/micrel_phy.h +++ b/include/linux/micrel_phy.h @@ -44,7 +44,6 @@ #define MICREL_PHY_50MHZ_CLK BIT(0) #define MICREL_PHY_FXEN BIT(1) #define MICREL_KSZ8_P1_ERRATA BIT(2) -#define MICREL_NO_EEE BIT(3) #define MICREL_KSZ9021_EXTREG_CTRL 0xB #define MICREL_KSZ9021_EXTREG_DATA_WRITE 0xC -- 2.39.5