From patchwork Fri Feb 17 03:42:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144293 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC6A7C6379F for ; Fri, 17 Feb 2023 03:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbjBQDnZ (ORCPT ); Thu, 16 Feb 2023 22:43:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbjBQDnM (ORCPT ); Thu, 16 Feb 2023 22:43:12 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D2D16AF3 for ; Thu, 16 Feb 2023 19:42:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=4Nmv177UVExiH9XBDTcGp2IGiA1xL4Og6AUrRqnT35A=; b=nrzdwTe6yTxoGYnkgSUJV0rioC yIJUn9GjLihxk5V6x1W7Xz7rOpujI9mexPt472YTZcYhGsKD30v8Y7SOX1wifXzajp1oEGMX3Afpd KTFrhBeU5tp4nKD0/YYSFnOu5YwvBUIV0L4EdYLgeEWAIR6Crw1XwFHABmjqvkLnApwo=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSrdz-005F63-UV; Fri, 17 Feb 2023 04:42:43 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 01/18] net: phy: Add phydev->eee_active to simplify adjust link callbacks Date: Fri, 17 Feb 2023 04:42:13 +0100 Message-Id: <20230217034230.1249661-2-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC MAC drivers which support EEE need to know the results of the EEE auto-neg in order to program the hardware to perform EEE or not. The oddly named phy_init_eee() can be used to determine this, it returns 0 if EEE should be used, or a negative error code, e.g. -EOPPROTONOTSUPPORT if the PHY does not support EEE or negotiate resulted in it not being used. However, many MAC drivers get this wrong. Add phydev->eee_active which indicates the result of the autoneg for EEE, including if EEE is administratively disabled with ethtool. The MAC driver can then access this in the same way as link speed and duplex in the adjust link callback. Signed-off-by: Andrew Lunn Reviewed-by: Russell King (Oracle) --- drivers/net/phy/phy.c | 3 +++ include/linux/phy.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index b33e55a7364e..1e6df250d0d0 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -916,9 +916,12 @@ static int phy_check_link_status(struct phy_device *phydev) if (phydev->link && phydev->state != PHY_RUNNING) { phy_check_downshift(phydev); phydev->state = PHY_RUNNING; + phydev->eee_active = genphy_c45_eee_is_active(phydev, + NULL, NULL, NULL); phy_link_up(phydev); } else if (!phydev->link && phydev->state != PHY_NOLINK) { phydev->state = PHY_NOLINK; + phydev->eee_active = false; phy_link_down(phydev); } diff --git a/include/linux/phy.h b/include/linux/phy.h index 727bff531a14..b1fbb52ac5a4 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -575,6 +575,7 @@ struct macsec_ops; * @advertising: Currently advertised linkmodes * @adv_old: Saved advertised while power saving for WoL * @supported_eee: supported PHY EEE linkmodes + * @eee_active: EEE is active for the current link mode * @lp_advertising: Current link partner advertised linkmodes * @host_interfaces: PHY interface modes supported by host * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited @@ -687,6 +688,7 @@ struct phy_device { /* Energy efficient ethernet modes which should be prohibited */ u32 eee_broken_modes; + bool eee_active; #ifdef CONFIG_LED_TRIGGER_PHY struct phy_led_trigger *phy_led_triggers; From patchwork Fri Feb 17 03:42:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144281 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E0E9C6379F for ; Fri, 17 Feb 2023 03:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbjBQDnE (ORCPT ); Thu, 16 Feb 2023 22:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA994CA00 for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=eWWiBhiqBljb89lpSMM0ClqHrglv98JnoZgViyF6MrE=; b=cSSkGJogvDaLpd4s/XL1NIrmvT 4Nt9znQtxFJrAogqEIDg2+qbn3iQX4uaiCFs7Q2lyFSiWgTJC34Be80Vex/DO0pHauAd5Fm1IBg0i hS/vrXr9VhwyI53dy2NoI7yg+3GuJQvtOpqK36syyAqPActVtQZvgKIOyNaa9ZxFrFmQ=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSrdz-005F67-Vf; Fri, 17 Feb 2023 04:42:43 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 02/18] net: phy: Add helper to set EEE Clock stop enable bit Date: Fri, 17 Feb 2023 04:42:14 +0100 Message-Id: <20230217034230.1249661-3-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The MAC driver can request that the PHY stops the clock during EEE LPI. This has normally been does as part of phy_init_eee(), however that function is overly complex and often wrongly used. Add a standalone helper, to aid removing phy_init_eee(). Signed-off-by: Andrew Lunn --- drivers/net/phy/phy.c | 19 +++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1e6df250d0d0..b25e0946405b 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1475,6 +1475,25 @@ void phy_mac_interrupt(struct phy_device *phydev) } EXPORT_SYMBOL(phy_mac_interrupt); +/** + * phy_eee_clk_stop_enable - Clock should stop during LIP + * @phydev: target phy_device struct + * + * Description: Program the MMD register 3.0 setting the "Clock stop enable" + * bit. + */ +int phy_eee_clk_stop_enable(struct phy_device *phydev) +{ + int ret; + + mutex_lock(&phydev->lock); + ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_PCS_CTRL1_CLKSTOP_EN); + mutex_unlock(&phydev->lock); + + return ret; +} + /** * phy_init_eee - init and check the EEE feature * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index b1fbb52ac5a4..4f72ffcb8b02 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1840,6 +1840,7 @@ int phy_unregister_fixup_for_id(const char *bus_id); int phy_unregister_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask); int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); +int phy_eee_clk_stop_enable(struct phy_device *phydev); int phy_get_eee_err(struct phy_device *phydev); int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data); From patchwork Fri Feb 17 03:42:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144280 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADDE0C636D4 for ; Fri, 17 Feb 2023 03:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230344AbjBQDnE (ORCPT ); Thu, 16 Feb 2023 22:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjBQDm5 (ORCPT ); Thu, 16 Feb 2023 22:42:57 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF1EC159 for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=gPiBwEoL8fK6/gtjB6C+nLzgT6H0xrCI1mH5IZul55A=; b=yVzibHylapHaBNW5taVEWYt24f 98+oaQfH722wGbN7K1eyTZUjc0TWPbs4yrFHiMWdCHrJ2HGoO8TtlnXO78nKa11qBDnPdmTpUjObC fiD9VHt3j6WzGtwgMYQ8DhaXgafWkGV3szxeXfSpZGOn1i2R4Xbw78WhedlC7hH7EOJA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6B-0Y; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 03/18] net: marvell: mvneta: Simplify EEE configuration Date: Fri, 17 Feb 2023 04:42:15 +0100 Message-Id: <20230217034230.1249661-4-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC phylib already does most of the work. It will track eee_enabled and eee_active and correctly set them in the ethtool_get_eee callback. Replace the call to phy_init_eee() by looking at the phydev->eee_active member. Signed-off-by: Andrew Lunn Reviewed-by: Russell King (Oracle) --- drivers/net/ethernet/marvell/mvneta.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 0e39d199ff06..519a08354442 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -536,8 +536,6 @@ struct mvneta_port { struct mvneta_bm_pool *pool_short; int bm_win_id; - bool eee_enabled; - bool eee_active; bool tx_lpi_enabled; u64 ethtool_stats[ARRAY_SIZE(mvneta_statistics)]; @@ -4170,7 +4168,6 @@ static void mvneta_mac_link_down(struct phylink_config *config, mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val); } - pp->eee_active = false; mvneta_set_eee(pp, false); } @@ -4221,10 +4218,8 @@ static void mvneta_mac_link_up(struct phylink_config *config, mvneta_port_up(pp); - if (phy && pp->eee_enabled) { - pp->eee_active = phy_init_eee(phy, false) >= 0; - mvneta_set_eee(pp, pp->eee_active && pp->tx_lpi_enabled); - } + if (phy) + mvneta_set_eee(pp, phy->eee_active && pp->tx_lpi_enabled); } static const struct phylink_mac_ops mvneta_phylink_ops = { @@ -5028,8 +5023,6 @@ static int mvneta_ethtool_get_eee(struct net_device *dev, lpi_ctl0 = mvreg_read(pp, MVNETA_LPI_CTRL_0); - eee->eee_enabled = pp->eee_enabled; - eee->eee_active = pp->eee_active; eee->tx_lpi_enabled = pp->tx_lpi_enabled; eee->tx_lpi_timer = (lpi_ctl0) >> 8; // * scale; @@ -5053,7 +5046,6 @@ static int mvneta_ethtool_set_eee(struct net_device *dev, lpi_ctl0 |= eee->tx_lpi_timer << 8; mvreg_write(pp, MVNETA_LPI_CTRL_0, lpi_ctl0); - pp->eee_enabled = eee->eee_enabled; pp->tx_lpi_enabled = eee->tx_lpi_enabled; mvneta_set_eee(pp, eee->tx_lpi_enabled && eee->eee_enabled); From patchwork Fri Feb 17 03:42:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144275 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93310C05027 for ; Fri, 17 Feb 2023 03:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbjBQDm4 (ORCPT ); Thu, 16 Feb 2023 22:42:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjBQDmz (ORCPT ); Thu, 16 Feb 2023 22:42:55 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146195FF6 for ; Thu, 16 Feb 2023 19:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=17JOIRwKgwIIdmDK+WQEw0IRSbXotMkUiDHR366NSC0=; b=BNIf2ric5veYm+DrPfTqsdFpX8 XonYSswY51jBN01zmiT6DjJbw6Znnvff4r8z2xO24A06lVEzyh7SXcZRIMStA8qoAolefhbNolu/K M0jb3nzE8UQTAWTJ5ilvzUWfcHUYE0LgsiWdTxJ4XDgc6S7ui84RQCtaF0ri9tWgOz4A=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6F-1j; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 04/18] net: stmmac: Drop usage of phy_init_eee() Date: Fri, 17 Feb 2023 04:42:16 +0100 Message-Id: <20230217034230.1249661-5-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Replace this method by looking at the eee_active member of the phydev structure. Additionally, call the phy_eee_clk_stop_enable() if the platform indicates the clock should be stopped while LPI is active. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e4902a7bb61e..23ad855626ee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1080,8 +1080,9 @@ static void stmmac_mac_link_up(struct phylink_config *config, stmmac_mac_set(priv, priv->ioaddr, true); if (phy && priv->dma_cap.eee) { - priv->eee_active = - phy_init_eee(phy, !priv->plat->rx_clk_runs_in_lpi) >= 0; + priv->eee_active = phy->eee_active; + if (!priv->plat->rx_clk_runs_in_lpi) + phy_eee_clk_stop_enable(phy); priv->eee_enabled = stmmac_eee_init(priv); priv->tx_lpi_enabled = priv->eee_enabled; stmmac_set_eee_pls(priv, priv->hw, true); From patchwork Fri Feb 17 03:42:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144288 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DBAFC05027 for ; Fri, 17 Feb 2023 03:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230396AbjBQDnT (ORCPT ); Thu, 16 Feb 2023 22:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6939610430 for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=tlFs/w4CnXPVETYsLA8ONSwYOFpKLZ3vV/xc+/ZiPcg=; b=LvrC27lpOX/crvQiP2NavLDBR/ ofliZ9j4G3gjbJAz8p62AlFlSAvYgZlqC57ckq6wvQp0dBmCtkEfk+FI7BWVK9uqWaPQurvX/yWPM szKaGYsM+B2SQrWYn1ybg36aLn+jvC+oBEmN7IHzCpe5bxy8yeb2LBq6TM+TXjkMdgek=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6J-2n; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 05/18] net: stmmac: Simplify ethtool get eee Date: Fri, 17 Feb 2023 04:42:17 +0100 Message-Id: <20230217034230.1249661-6-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC phylink_ethtool_get_eee() fills in eee_enabled and eee_active. So there is no need for the MAC driver to do it as well. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 35c8dd92d369..efea97e640f4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -782,8 +782,6 @@ static int stmmac_ethtool_op_get_eee(struct net_device *dev, if (!priv->dma_cap.eee) return -EOPNOTSUPP; - edata->eee_enabled = priv->eee_enabled; - edata->eee_active = priv->eee_active; edata->tx_lpi_timer = priv->tx_lpi_timer; edata->tx_lpi_enabled = priv->tx_lpi_enabled; From patchwork Fri Feb 17 03:42:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144279 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2697CC64EC4 for ; Fri, 17 Feb 2023 03:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbjBQDnD (ORCPT ); Thu, 16 Feb 2023 22:43:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjBQDm5 (ORCPT ); Thu, 16 Feb 2023 22:42:57 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B815BB92 for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=waYTpH7xzT+d9Vre098AMU+bvyjjZGWhg0/1S/e8Oh0=; b=XATibcZHXeDpEpIuxjOvIDREI9 BaZQ7SQitK54CrWrs5hX7OJpGiJLoqthM6yRhufhVXonTiCaJYc5l7p6OvDHCVNIqCjad9Q/2puTC Lr0eJhUGGhLMTaEp45aXmLc/nIkYvh0NzXeM4zlA87cDof6WFBMXj0rlChYAMNJetDbg=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6N-3r; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 06/18] net: lan743x: Fixup EEE Date: Fri, 17 Feb 2023 04:42:18 +0100 Message-Id: <20230217034230.1249661-7-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So move the enable/disable into lan743x_phy_link_status_change() which gets called by phylib when there is a change in link status. lan743x_ethtool_set_eee() now just programs the hardware with the LTI timer value, and passed everything else to phylib, so it can correctly setup the PHY. lan743x_ethtool_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LTI timer value, and tx_lpi_enabled based on if EEE is active. Signed-off-by: Andrew Lunn --- .../net/ethernet/microchip/lan743x_ethtool.c | 20 ------------------- drivers/net/ethernet/microchip/lan743x_main.c | 7 +++++++ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c index 2db5949b4c7e..044d67a564e0 100644 --- a/drivers/net/ethernet/microchip/lan743x_ethtool.c +++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c @@ -1073,15 +1073,11 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev, buf = lan743x_csr_read(adapter, MAC_CR); if (buf & MAC_CR_EEE_EN_) { - eee->eee_enabled = true; - eee->eee_active = !!(eee->advertised & eee->lp_advertised); eee->tx_lpi_enabled = true; /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */ buf = lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT); eee->tx_lpi_timer = buf; } else { - eee->eee_enabled = false; - eee->eee_active = false; eee->tx_lpi_enabled = false; eee->tx_lpi_timer = 0; } @@ -1095,7 +1091,6 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev, struct lan743x_adapter *adapter; struct phy_device *phydev; u32 buf = 0; - int ret = 0; if (!netdev) return -EINVAL; @@ -1112,23 +1107,8 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev, } if (eee->eee_enabled) { - ret = phy_init_eee(phydev, false); - if (ret) { - netif_err(adapter, drv, adapter->netdev, - "EEE initialization failed\n"); - return ret; - } - buf = (u32)eee->tx_lpi_timer; lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT, buf); - - buf = lan743x_csr_read(adapter, MAC_CR); - buf |= MAC_CR_EEE_EN_; - lan743x_csr_write(adapter, MAC_CR, buf); - } else { - buf = lan743x_csr_read(adapter, MAC_CR); - buf &= ~MAC_CR_EEE_EN_; - lan743x_csr_write(adapter, MAC_CR, buf); } return phy_ethtool_set_eee(phydev, eee); diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index 7e0871b631e4..803e83880887 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1457,6 +1457,13 @@ static void lan743x_phy_link_status_change(struct net_device *netdev) phydev->interface == PHY_INTERFACE_MODE_1000BASEX || phydev->interface == PHY_INTERFACE_MODE_2500BASEX) lan743x_sgmii_config(adapter); + + data = lan743x_csr_read(adapter, MAC_CR); + if (phydev->eee_active) + data |= MAC_CR_EEE_EN_; + else + data &= ~MAC_CR_EEE_EN_; + lan743x_csr_write(adapter, MAC_CR, data); } } From patchwork Fri Feb 17 03:42:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144292 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEF3DC05027 for ; Fri, 17 Feb 2023 03:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230403AbjBQDnY (ORCPT ); Thu, 16 Feb 2023 22:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjBQDm7 (ORCPT ); Thu, 16 Feb 2023 22:42:59 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8280713500 for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=W4YdDWf/ZfXoNp0eW0XBGH4diC+x1T1UIoNkkfx1asA=; b=u/KyPKYw90n0N8YrKFOFesDHPw h9QvzkA7BTy03caB2JEey64fwE7M/ac8QNa99ctI9QT6DbY7FYO81sTSM1FCKf5+TAyT9Q69hDnGb Cj7h6Zoj41Q4eLilsc1VZTUq7cA63um98qd4tnKrOMCm0A6sSQ3cMHRFa84lDSuMlOr8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6R-4z; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 07/18] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Fri, 17 Feb 2023 04:42:19 +0100 Message-Id: <20230217034230.1249661-8-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC FEC is about to get its EEE code re-written. To allow this, move fec_enet_eee_mode_set() before fec_enet_adjust_link() which will need to call it. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/freescale/fec_main.c | 79 ++++++++++++----------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index c73e25f8995e..195df75ee614 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1919,6 +1919,46 @@ static int fec_get_mac(struct net_device *ndev) /* * Phy section */ + +/* LPI Sleep Ts count base on tx clk (clk_ref). + * The lpi sleep cnt value = X us / (cycle_ns). + */ +static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + + return us * (fep->clk_ref_rate / 1000) / 1000; +} + +static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + struct ethtool_eee *p = &fep->eee; + unsigned int sleep_cycle, wake_cycle; + int ret = 0; + + if (enable) { + ret = phy_init_eee(ndev->phydev, false); + if (ret) + return ret; + + sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); + wake_cycle = sleep_cycle; + } else { + sleep_cycle = 0; + wake_cycle = 0; + } + + p->tx_lpi_enabled = enable; + p->eee_enabled = enable; + p->eee_active = enable; + + writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); + writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); + + return 0; +} + static void fec_enet_adjust_link(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); @@ -3057,45 +3097,6 @@ static int fec_enet_set_tunable(struct net_device *netdev, return ret; } -/* LPI Sleep Ts count base on tx clk (clk_ref). - * The lpi sleep cnt value = X us / (cycle_ns). - */ -static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - - return us * (fep->clk_ref_rate / 1000) / 1000; -} - -static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - struct ethtool_eee *p = &fep->eee; - unsigned int sleep_cycle, wake_cycle; - int ret = 0; - - if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; - - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); - wake_cycle = sleep_cycle; - } else { - sleep_cycle = 0; - wake_cycle = 0; - } - - p->tx_lpi_enabled = enable; - p->eee_enabled = enable; - p->eee_active = enable; - - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); - writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); - - return 0; -} - static int fec_enet_get_eee(struct net_device *ndev, struct ethtool_eee *edata) { From patchwork Fri Feb 17 03:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144283 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE58C636D4 for ; Fri, 17 Feb 2023 03:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbjBQDnN (ORCPT ); Thu, 16 Feb 2023 22:43:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230322AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19509BB80 for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=NWPLjkOiol4WdkYiCHKHdxY2KSvzu0DydmlEAe9fRjY=; b=hla11GETVe5GSogIQVQIndPgz6 m/wklo0FC5g0Xt+60rO1LaOJdiTW1gZCaZG1M/UGeHzZss7cbG4kj9YUF7uR2BPe33bUqqHZV9tXI is0fb8kAi1pxfPSttA+UsZwLu0rCKpXzrfQ0ngcQSn77N/AjWhFwNgr5nIGyAjlPdCbg=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6V-6I; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 08/18] net: FEC: Fixup EEE Date: Fri, 17 Feb 2023 04:42:20 +0100 Message-Id: <20230217034230.1249661-9-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So move the enable/disable into fec_enet_adjust_link() which gets called by phylib when there is a change in link status. fec_enet_set_eee() now just stores away the LTI timer value and if TX LPI should be enabled. Everything else is passed to phylib, so it can correctly setup the PHY. fec_enet_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LTI timer value and the stored tx_lpi_enabled. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/freescale/fec_main.c | 27 ++++------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 195df75ee614..5aca705876fe 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1930,18 +1930,13 @@ static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) return us * (fep->clk_ref_rate / 1000) / 1000; } -static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) +static int fec_enet_eee_mode_set(struct net_device *ndev, bool eee_active) { struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_eee *p = &fep->eee; unsigned int sleep_cycle, wake_cycle; - int ret = 0; - - if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; + if (eee_active && p->tx_lpi_enabled) { sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); wake_cycle = sleep_cycle; } else { @@ -1949,10 +1944,6 @@ static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) wake_cycle = 0; } - p->tx_lpi_enabled = enable; - p->eee_enabled = enable; - p->eee_active = enable; - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); @@ -1997,6 +1988,7 @@ static void fec_enet_adjust_link(struct net_device *ndev) netif_tx_unlock_bh(ndev); napi_enable(&fep->napi); } + fec_enet_eee_mode_set(ndev, phy_dev->eee_active); } else { if (fep->link) { napi_disable(&fep->napi); @@ -3109,8 +3101,6 @@ fec_enet_get_eee(struct net_device *ndev, struct ethtool_eee *edata) if (!netif_running(ndev)) return -ENETDOWN; - edata->eee_enabled = p->eee_enabled; - edata->eee_active = p->eee_active; edata->tx_lpi_timer = p->tx_lpi_timer; edata->tx_lpi_enabled = p->tx_lpi_enabled; @@ -3122,7 +3112,6 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_eee *edata) { struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_eee *p = &fep->eee; - int ret = 0; if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) return -EOPNOTSUPP; @@ -3131,15 +3120,7 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_eee *edata) return -ENETDOWN; p->tx_lpi_timer = edata->tx_lpi_timer; - - if (!edata->eee_enabled || !edata->tx_lpi_enabled || - !edata->tx_lpi_timer) - ret = fec_enet_eee_mode_set(ndev, false); - else - ret = fec_enet_eee_mode_set(ndev, true); - - if (ret) - return ret; + p->tx_lpi_enabled = edata->tx_lpi_enabled; return phy_ethtool_set_eee(ndev->phydev, edata); } From patchwork Fri Feb 17 03:42:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144286 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8F79C636D4 for ; Fri, 17 Feb 2023 03:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbjBQDnR (ORCPT ); Thu, 16 Feb 2023 22:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAE72CA0A for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=8Ih7+tI9YF4CFVQwfqKaCqSy8PwUxM+IhBYOL5o9cjA=; b=qnHhoJh9Tt79nSxuzIDHgXMGAQ 2m6KyiqZk0vcFqetOd/xioaRY132XIX2PHGyQA6P6WRWYd0ccl1WNFfNnNz02JuTUoGDrcLQPc2i/ J6gYn5DfM4Ma4J3+1kuasxVPHsPrMp3Zt0AbS7ROSGpZQDmtokOkc7NAt0XFRPPbjt2I=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6Z-7Y; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 09/18] net: genet: Fixup EEE Date: Fri, 17 Feb 2023 04:42:21 +0100 Message-Id: <20230217034230.1249661-10-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So move the enable/disable into bcmgenet_mii_setup() which gets called by phylib when there is a change in link status. bcmgenet_set_eee() now just writes the LTI timer value to the hardware and stores if TX LPI should be enabled. Everything else is passed to phylib, so it can correctly setup the PHY. bcmgenet_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LTI timer value from hardware and the stored tx_lpi_enabled. Signed-off-by: Andrew Lunn --- .../net/ethernet/broadcom/genet/bcmgenet.c | 31 ++++++------------- .../net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 1 + 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index d937daa8ee88..2793d94ed32c 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1272,12 +1272,17 @@ static void bcmgenet_get_ethtool_stats(struct net_device *dev, } } -static void bcmgenet_eee_enable_set(struct net_device *dev, bool enable) +void bcmgenet_eee_enable_set(struct net_device *dev, bool eee_active) { struct bcmgenet_priv *priv = netdev_priv(dev); - u32 off = priv->hw_params->tbuf_offset + TBUF_ENERGY_CTRL; + struct ethtool_eee *p = &priv->eee; + bool enable; + u32 off; u32 reg; + off = priv->hw_params->tbuf_offset + TBUF_ENERGY_CTRL; + enable = eee_active && p->tx_lpi_enabled; + if (enable && !priv->clk_eee_enabled) { clk_prepare_enable(priv->clk_eee); priv->clk_eee_enabled = true; @@ -1310,9 +1315,6 @@ static void bcmgenet_eee_enable_set(struct net_device *dev, bool enable) clk_disable_unprepare(priv->clk_eee); priv->clk_eee_enabled = false; } - - priv->eee.eee_enabled = enable; - priv->eee.eee_active = enable; } static int bcmgenet_get_eee(struct net_device *dev, struct ethtool_eee *e) @@ -1326,8 +1328,7 @@ static int bcmgenet_get_eee(struct net_device *dev, struct ethtool_eee *e) if (!dev->phydev) return -ENODEV; - e->eee_enabled = p->eee_enabled; - e->eee_active = p->eee_active; + e->tx_lpi_enabled = p->tx_lpi_enabled; e->tx_lpi_timer = bcmgenet_umac_readl(priv, UMAC_EEE_LPI_TIMER); return phy_ethtool_get_eee(dev->phydev, e); @@ -1337,7 +1338,6 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e) { struct bcmgenet_priv *priv = netdev_priv(dev); struct ethtool_eee *p = &priv->eee; - int ret = 0; if (GENET_IS_V1(priv)) return -EOPNOTSUPP; @@ -1345,20 +1345,9 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e) if (!dev->phydev) return -ENODEV; - p->eee_enabled = e->eee_enabled; + p->tx_lpi_enabled = e->tx_lpi_enabled; - if (!p->eee_enabled) { - bcmgenet_eee_enable_set(dev, false); - } else { - ret = phy_init_eee(dev->phydev, false); - if (ret) { - netif_err(priv, hw, dev, "EEE initialization failed\n"); - return ret; - } - - bcmgenet_umac_writel(priv, e->tx_lpi_timer, UMAC_EEE_LPI_TIMER); - bcmgenet_eee_enable_set(dev, true); - } + bcmgenet_umac_writel(priv, e->tx_lpi_timer, UMAC_EEE_LPI_TIMER); return phy_ethtool_set_eee(dev->phydev, e); } diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h index 946f6e283c4e..7458a62afc2c 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -703,4 +703,5 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv, void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv, enum bcmgenet_power_mode mode); +void bcmgenet_eee_enable_set(struct net_device *dev, bool eee_active); #endif /* __BCMGENET_H__ */ diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index b615176338b2..eb1747503c2e 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -100,6 +100,7 @@ void bcmgenet_mii_setup(struct net_device *dev) if (phydev->link) { bcmgenet_mac_config(dev); + bcmgenet_eee_enable_set(dev, phydev->eee_active); } else { reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL); reg &= ~RGMII_LINK; From patchwork Fri Feb 17 03:42:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144290 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52F58C05027 for ; Fri, 17 Feb 2023 03:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbjBQDnV (ORCPT ); Thu, 16 Feb 2023 22:43:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbjBQDm7 (ORCPT ); Thu, 16 Feb 2023 22:42:59 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1235B1630A for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=ARW6GOF5TfQOrkWA0JF4PugCqoKViikleVVTg3syvS4=; b=SLifKbAUNJxJYaumuaxGUI8/DK 8qz3ik4zPnNse9bMN4g2TgsykfbGz+j3zSdi7FIjUI7QV4rfiPiQb/jwshOJ5g/L9LC8gXmA/jlIE 2olUruRctuJLwGDICIUdQm5UfRzSbdepYtxZ3cg4FoePC2Mmv+e+ypoGjkIpSDEPbH5g=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6d-92; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 10/18] net: sxgdb: Fixup EEE Date: Fri, 17 Feb 2023 04:42:22 +0100 Message-Id: <20230217034230.1249661-11-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So rework sxgbe_eee_adjust() to take the result of negotiation into account. sxgbe_set_eee() now just stores LTI timer value and tx_lpi_enabled. Everything else is passed to phylib, so it can correctly setup the PHY. sxgbe_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LTI timer value and tx_lpi_enabled. The hw_cap.eee is now used to control timers, rather than eee_enabled, which was wrongly being set based on the value of phy_init_eee() before auto-neg even completed. Signed-off-by: Andrew Lunn --- .../net/ethernet/samsung/sxgbe/sxgbe_common.h | 4 +- .../ethernet/samsung/sxgbe/sxgbe_ethtool.c | 23 ++---------- .../net/ethernet/samsung/sxgbe/sxgbe_main.c | 37 ++++++------------- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h index 0f45107db8dd..6860369ca88f 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h @@ -502,9 +502,8 @@ struct sxgbe_priv_data { struct timer_list eee_ctrl_timer; bool tx_path_in_lpi_mode; int lpi_irq; - int eee_enabled; - int eee_active; int tx_lpi_timer; + bool tx_lpi_enabled; }; /* Function prototypes */ @@ -528,5 +527,4 @@ int sxgbe_restore(struct net_device *ndev); const struct sxgbe_mtl_ops *sxgbe_get_mtl_ops(void); void sxgbe_disable_eee_mode(struct sxgbe_priv_data * const priv); -bool sxgbe_eee_init(struct sxgbe_priv_data * const priv); #endif /* __SXGBE_COMMON_H__ */ diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c index 8ba017ec9849..0ec523b24df9 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c @@ -140,8 +140,7 @@ static int sxgbe_get_eee(struct net_device *dev, if (!priv->hw_cap.eee) return -EOPNOTSUPP; - edata->eee_enabled = priv->eee_enabled; - edata->eee_active = priv->eee_active; + edata->tx_lpi_enabled = priv->tx_lpi_enabled; edata->tx_lpi_timer = priv->tx_lpi_timer; return phy_ethtool_get_eee(dev->phydev, edata); @@ -152,22 +151,8 @@ static int sxgbe_set_eee(struct net_device *dev, { struct sxgbe_priv_data *priv = netdev_priv(dev); - priv->eee_enabled = edata->eee_enabled; - - if (!priv->eee_enabled) { - sxgbe_disable_eee_mode(priv); - } else { - /* We are asking for enabling the EEE but it is safe - * to verify all by invoking the eee_init function. - * In case of failure it will return an error. - */ - priv->eee_enabled = sxgbe_eee_init(priv); - if (!priv->eee_enabled) - return -EOPNOTSUPP; - - /* Do not change tx_lpi_timer in case of failure */ - priv->tx_lpi_timer = edata->tx_lpi_timer; - } + priv->tx_lpi_timer = edata->tx_lpi_timer; + priv->tx_lpi_enabled = edata->tx_lpi_enabled; return phy_ethtool_set_eee(dev->phydev, edata); } @@ -230,7 +215,7 @@ static void sxgbe_get_ethtool_stats(struct net_device *dev, int i; char *p; - if (priv->eee_enabled) { + if (dev->phydev->eee_active) { int val = phy_get_eee_err(dev->phydev); if (val) diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c index 9664f029fa16..f9ad232133a4 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c @@ -119,18 +119,10 @@ static void sxgbe_eee_ctrl_timer(struct timer_list *t) * phy can also manage EEE, so enable the LPI state and start the timer * to verify if the tx path can enter in LPI state. */ -bool sxgbe_eee_init(struct sxgbe_priv_data * const priv) +static void sxgbe_eee_init(struct sxgbe_priv_data * const priv) { - struct net_device *ndev = priv->dev; - bool ret = false; - /* MAC core supports the EEE feature. */ if (priv->hw_cap.eee) { - /* Check if the PHY supports EEE */ - if (phy_init_eee(ndev->phydev, true)) - return false; - - priv->eee_active = 1; timer_setup(&priv->eee_ctrl_timer, sxgbe_eee_ctrl_timer, 0); priv->eee_ctrl_timer.expires = SXGBE_LPI_TIMER(eee_timer); add_timer(&priv->eee_ctrl_timer); @@ -140,23 +132,16 @@ bool sxgbe_eee_init(struct sxgbe_priv_data * const priv) priv->tx_lpi_timer); pr_info("Energy-Efficient Ethernet initialized\n"); - - ret = true; } - - return ret; } -static void sxgbe_eee_adjust(const struct sxgbe_priv_data *priv) +static void sxgbe_eee_adjust(const struct sxgbe_priv_data *priv, + bool eee_active) { - struct net_device *ndev = priv->dev; - - /* When the EEE has been already initialised we have to - * modify the PLS bit in the LPI ctrl & status reg according - * to the PHY link status. For this reason. - */ - if (priv->eee_enabled) - priv->hw->mac->set_eee_pls(priv->ioaddr, ndev->phydev->link); + if (priv->hw_cap.eee) + priv->hw->mac->set_eee_pls(priv->ioaddr, + eee_active && priv->tx_lpi_enabled); + phy_eee_clk_stop_enable(priv->dev->phydev); } /** @@ -250,7 +235,7 @@ static void sxgbe_adjust_link(struct net_device *dev) phy_print_status(phydev); /* Alter the MAC settings for EEE */ - sxgbe_eee_adjust(priv); + sxgbe_eee_adjust(priv, phydev->eee_active); } /** @@ -803,7 +788,7 @@ static void sxgbe_tx_all_clean(struct sxgbe_priv_data * const priv) sxgbe_tx_queue_clean(tqueue); } - if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) { + if (priv->hw_cap.eee && !priv->tx_path_in_lpi_mode) { sxgbe_enable_eee_mode(priv); mod_timer(&priv->eee_ctrl_timer, SXGBE_LPI_TIMER(eee_timer)); } @@ -1181,7 +1166,7 @@ static int sxgbe_open(struct net_device *dev) } priv->tx_lpi_timer = SXGBE_DEFAULT_LPI_TIMER; - priv->eee_enabled = sxgbe_eee_init(priv); + sxgbe_eee_init(priv); napi_enable(&priv->napi); netif_start_queue(dev); @@ -1208,7 +1193,7 @@ static int sxgbe_release(struct net_device *dev) { struct sxgbe_priv_data *priv = netdev_priv(dev); - if (priv->eee_enabled) + if (priv->hw_cap.eee) del_timer_sync(&priv->eee_ctrl_timer); /* Stop and disconnect the PHY */ From patchwork Fri Feb 17 03:42:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144276 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C3F4C636D4 for ; Fri, 17 Feb 2023 03:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbjBQDm5 (ORCPT ); Thu, 16 Feb 2023 22:42:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjBQDmz (ORCPT ); Thu, 16 Feb 2023 22:42:55 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E18F7EF8 for ; Thu, 16 Feb 2023 19:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=tCkA4tkurpleRo2USNzXXk2E0Y+Vu+lgbSxx6rJOiHw=; b=GyQ4adHC2PexJOcg1QFSA/GH2O tpqMzPIZrJSBHHoJ9dnmHhqhmENlQ2f13xaHIhykuD9T+q7qVAd/ay0Z0mu/3bmE1N1+7Pj4/747Z PLqyW8ecNWNWRCzNtRTm1U85mYG8r+fSyFKvu8EsiZM29IL8ayQWLP3f2lB9DnoXk/SA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6h-AT; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 11/18] net: dsa: mt7530: Swap to using phydev->eee_active Date: Fri, 17 Feb 2023 04:42:23 +0100 Message-Id: <20230217034230.1249661-12-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Rather than calling phy_init_eee() retrieve the same information from within the phydev structure. Signed-off-by: Andrew Lunn --- drivers/net/dsa/mt7530.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 3a15015bc409..214450378978 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2859,7 +2859,7 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port, mcr |= PMCR_RX_FC_EN; } - if (mode == MLO_AN_PHY && phydev && phy_init_eee(phydev, false) >= 0) { + if (mode == MLO_AN_PHY && phydev && phydev->eee_active) { switch (speed) { case SPEED_1000: mcr |= PMCR_FORCE_EEE1G; From patchwork Fri Feb 17 03:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144278 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FB12C05027 for ; Fri, 17 Feb 2023 03:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbjBQDnB (ORCPT ); Thu, 16 Feb 2023 22:43:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjBQDm4 (ORCPT ); Thu, 16 Feb 2023 22:42:56 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A9C83C6 for ; Thu, 16 Feb 2023 19:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=IKXfikYVEQK0YiYSa8fL5WQqzVqNY3QKUY67lWqb7F4=; b=dlF5hWoyUFpmAsAK57JN5qn3fY 5uUUtfOKkoRh03Atw9N7BfzI5C1qra3kyKFM2B1mzKHdZvOWm0nql8jnF1vRmNNyJ7jlAUehw2LxK ylY3DeKmhjmewkPozXWcpOzguQXjbrKBhIgHf6gAeeSqENnDBwqesD9CB8kNoFRanDH4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6l-Bh; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 12/18] net: dsa: mt7530: Call phylib for set_eee and get_eee Date: Fri, 17 Feb 2023 04:42:24 +0100 Message-Id: <20230217034230.1249661-13-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC phylib should be called in order to manage the EEE settings in the PHY, and to return EEE status such are supported link modes, and what the link peer supports. Signed-off-by: Andrew Lunn --- drivers/net/dsa/mt7530.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 214450378978..a472353f14f8 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -3124,10 +3124,13 @@ static int mt753x_get_mac_eee(struct dsa_switch *ds, int port, { struct mt7530_priv *priv = ds->priv; u32 eeecr = mt7530_read(priv, MT7530_PMEEECR_P(port)); + struct dsa_port *dp = dsa_to_port(ds, port); e->tx_lpi_enabled = !(eeecr & LPI_MODE_EN); e->tx_lpi_timer = GET_LPI_THRESH(eeecr); + if (dp->slave->phydev) + return phy_ethtool_get_eee(dp->slave->phydev, e); return 0; } @@ -3136,6 +3139,7 @@ static int mt753x_set_mac_eee(struct dsa_switch *ds, int port, { struct mt7530_priv *priv = ds->priv; u32 set, mask = LPI_THRESH_MASK | LPI_MODE_EN; + struct dsa_port *dp = dsa_to_port(ds, port); if (e->tx_lpi_timer > 0xFFF) return -EINVAL; @@ -3146,6 +3150,8 @@ static int mt753x_set_mac_eee(struct dsa_switch *ds, int port, set |= LPI_MODE_EN; mt7530_rmw(priv, MT7530_PMEEECR_P(port), mask, set); + if (dp->slave->phydev) + return phy_ethtool_set_eee(dp->slave->phydev, e); return 0; } From patchwork Fri Feb 17 03:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144285 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2670C64EC4 for ; Fri, 17 Feb 2023 03:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbjBQDnO (ORCPT ); Thu, 16 Feb 2023 22:43:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B6DA113CC for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=5b81H4rmgcClXvCoqPJvcxW3uGEU483hHM+AIAZN4Kg=; b=scmV3bd/v0wohXIbNMWF1kVTK5 lLoU4CiSh/n5NU+jOpuEEbyMwtghNniQfCglRda9VdVcqRKdTqtR8SilCXS7yowKI4U7BLlNqiDgw FmiQegf23E8wFOOIiwsDsgOIS5tSktY5HODwmMPMjpGxhke8KUB241QHX52d1CgS9mkc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6p-Cq; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 13/18] net: dsa: b53: Swap to using phydev->eee_active Date: Fri, 17 Feb 2023 04:42:25 +0100 Message-Id: <20230217034230.1249661-14-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Rather than calling phy_init_eee() retrieve the same information from within the phydev structure. Signed-off-by: Andrew Lunn --- drivers/net/dsa/b53/b53_common.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 59cdfc51ce06..1e8eaf143b65 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2168,10 +2168,7 @@ EXPORT_SYMBOL(b53_eee_enable_set); */ int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy) { - int ret; - - ret = phy_init_eee(phy, false); - if (ret) + if (!phy->eee_active) return 0; b53_eee_enable_set(ds, port, true); From patchwork Fri Feb 17 03:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144289 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7307C636D4 for ; Fri, 17 Feb 2023 03:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230397AbjBQDnU (ORCPT ); Thu, 16 Feb 2023 22:43:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbjBQDm7 (ORCPT ); Thu, 16 Feb 2023 22:42:59 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A2310AA4 for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=v0MEiMWS+uXrX6lIdQ1G6bplK2FfCnGNtr94G+uxu9E=; b=IZBYPtmm6yMRzi/ciD4yx7w6h/ a/Xbk5imBWRxy0SrbF4458CSG1yXc/whD60MWZ/Bt4IFwayt91VbDqMbkd6Yjo19PoC1exO92xKDS lgNUFnI3Oms8AjbDym4fL+C9UcpP9m9hRBlXvyyAWbZDYslrKtF3lLTeNRRvPHIQCbyk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6t-E8; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 14/18] net: dsa: b53: Call phylib for set_eee and get_eee Date: Fri, 17 Feb 2023 04:42:26 +0100 Message-Id: <20230217034230.1249661-15-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC phylib should be called in order to manage the EEE settings in the PHY, and to return EEE status such are supported link modes, and what the link peer supports. Signed-off-by: Andrew Lunn --- drivers/net/dsa/b53/b53_common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 1e8eaf143b65..f782a08a9bc9 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2179,6 +2179,7 @@ EXPORT_SYMBOL(b53_eee_init); int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) { + struct dsa_port *dp = dsa_to_port(ds, port); struct b53_device *dev = ds->priv; struct ethtool_eee *p = &dev->ports[port].eee; u16 reg; @@ -2190,12 +2191,15 @@ int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) e->eee_enabled = p->eee_enabled; e->eee_active = !!(reg & BIT(port)); + if (dp->slave->phydev) + return phy_ethtool_get_eee(dp->slave->phydev, e); return 0; } EXPORT_SYMBOL(b53_get_mac_eee); int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) { + struct dsa_port *dp = dsa_to_port(ds, port); struct b53_device *dev = ds->priv; struct ethtool_eee *p = &dev->ports[port].eee; @@ -2205,6 +2209,8 @@ int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) p->eee_enabled = e->eee_enabled; b53_eee_enable_set(ds, port, e->eee_enabled); + if (dp->slave->phydev) + return phy_ethtool_set_eee(dp->slave->phydev, e); return 0; } EXPORT_SYMBOL(b53_set_mac_eee); From patchwork Fri Feb 17 03:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144277 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CD0FC6379F for ; Fri, 17 Feb 2023 03:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230338AbjBQDnA (ORCPT ); Thu, 16 Feb 2023 22:43:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjBQDm4 (ORCPT ); Thu, 16 Feb 2023 22:42:56 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8ACD6191 for ; Thu, 16 Feb 2023 19:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=tEXjK3L41ZR/mWy7vbTDLRFWyvjUPm6tTNkixyNaKEU=; b=eNLxn/HiyWfLn2ymvj5IKgZRcY TtA1ZtgdDgOuEpWurcOTqN21cmJYnsmxzC8VSxzCQX7RXNpvpimjbHmjhqhI1m4iA2nzXnepQsF42 g8VIuYiwHelqt2FDqzApEAn7Q8Ie7NL+DHJiRFBplluyhEKGuv8EI84kGGR33eSpgfcw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F6x-FJ; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 15/18] net: phylink: Remove unused phylink_init_eee() Date: Fri, 17 Feb 2023 04:42:27 +0100 Message-Id: <20230217034230.1249661-16-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This is not used in tree, and the phylib equivalent phy_init_eee() is about to be removed. Signed-off-by: Andrew Lunn Reviewed-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 18 ------------------ include/linux/phylink.h | 1 - 2 files changed, 19 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 1a2f074685fa..f84d92230806 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2501,24 +2501,6 @@ int phylink_get_eee_err(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_get_eee_err); -/** - * phylink_init_eee() - init and check the EEE features - * @pl: a pointer to a &struct phylink returned from phylink_create() - * @clk_stop_enable: allow PHY to stop receive clock - * - * Must be called either with RTNL held or within mac_link_up() - */ -int phylink_init_eee(struct phylink *pl, bool clk_stop_enable) -{ - int ret = -EOPNOTSUPP; - - if (pl->phydev) - ret = phy_init_eee(pl->phydev, clk_stop_enable); - - return ret; -} -EXPORT_SYMBOL_GPL(phylink_init_eee); - /** * phylink_ethtool_get_eee() - read the energy efficient ethernet parameters * @pl: a pointer to a &struct phylink returned from phylink_create() diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..d9ea4651426d 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -603,7 +603,6 @@ void phylink_ethtool_get_pauseparam(struct phylink *, int phylink_ethtool_set_pauseparam(struct phylink *, struct ethtool_pauseparam *); int phylink_get_eee_err(struct phylink *); -int phylink_init_eee(struct phylink *, bool); int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); From patchwork Fri Feb 17 03:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 337B4C636D4 for ; Fri, 17 Feb 2023 03:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbjBQDnX (ORCPT ); Thu, 16 Feb 2023 22:43:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbjBQDm7 (ORCPT ); Thu, 16 Feb 2023 22:42:59 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1229715CB9 for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=waNlJxho+j/jWIlWyl9YppmFv9BY1aOiis9DALxLuiA=; b=iw0uIl8gHeBizEWzCXS5dbnkZT RRmi9kRL+8ZbVeSPxbZnhiXEdohitm6+nJX/VrL3uMNGrMn1ZUc3vJt8l16mZ9gPfrAJ8DrWMf8Iz FzEHtwZgqWgqp3e+bcRlwk9UcJDmXu8IRntaFpd+muYo4Jkm1AeEPDmu/AuqiEOe9FJo=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F71-GV; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 16/18] net: phylink: Update comment about configuring EEE in mac_link_up() Date: Fri, 17 Feb 2023 04:42:28 +0100 Message-Id: <20230217034230.1249661-17-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC phy_init_eee() is about to be removed. If eee is active can be determined directly from the phydev structure. Update the documentation to indicate this. Signed-off-by: Andrew Lunn Reviewed-by: Russell King (Oracle) --- include/linux/phylink.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/phylink.h b/include/linux/phylink.h index d9ea4651426d..78f25990e498 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -424,9 +424,9 @@ void mac_link_down(struct phylink_config *config, unsigned int mode, * be allowed when considering the implementation of this method. * * If in-band negotiation mode is disabled, allow the link to come up. If - * @phy is non-%NULL, configure Energy Efficient Ethernet by calling - * phy_init_eee() and perform appropriate MAC configuration for EEE. - * Interface type selection must be done in mac_config(). + * @phy is non-%NULL, configure Energy Efficient Ethernet in the MAC if + * phy->eee_active is true. Interface type selection must be done in + * mac_config(). */ void mac_link_up(struct phylink_config *config, struct phy_device *phy, unsigned int mode, phy_interface_t interface, From patchwork Fri Feb 17 03:42:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144282 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF7E1C05027 for ; Fri, 17 Feb 2023 03:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbjBQDnM (ORCPT ); Thu, 16 Feb 2023 22:43:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5531AC14D for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=ygthPH9f2ZFlJ6/YxFm7wCGgCwcPeizw5FS8cv8McVo=; b=QYTl23jPy7bjdWVzIvjaXHcB4e etzKWj+KDctoevCVIkKBe4kwm/DQc0AlMBA4zSpH4pNSEPlA91J/9BOolkUZbzK5lH6uyjxm8B51K hZlmCTWWAJM2hKph/Ne3yrXFkrVWfCMvr4qE5PJMOEez4yypgQjsAg51HiysFWFPJoEk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F75-Hl; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 17/18] net: phy: remove unused phy_init_eee() Date: Fri, 17 Feb 2023 04:42:29 +0100 Message-Id: <20230217034230.1249661-18-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC There are no users left of phy_init_eee(), and it is often wrongly used. So remove it. Signed-off-by: Andrew Lunn --- drivers/net/phy/phy.c | 34 ---------------------------------- include/linux/phy.h | 1 - 2 files changed, 35 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index b25e0946405b..135f30d576b2 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1494,40 +1494,6 @@ int phy_eee_clk_stop_enable(struct phy_device *phydev) return ret; } -/** - * phy_init_eee - init and check the EEE feature - * @phydev: target phy_device struct - * @clk_stop_enable: PHY may stop the clock during LPI - * - * Description: it checks if the Energy-Efficient Ethernet (EEE) - * is supported by looking at the MMD registers 3.20 and 7.60/61 - * and it programs the MMD register 3.0 setting the "Clock stop enable" - * bit if required. - */ -int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) -{ - int ret; - - if (!phydev->drv) - return -EIO; - - ret = genphy_c45_eee_is_active(phydev, NULL, NULL, NULL); - if (ret < 0) - return ret; - if (!ret) - return -EPROTONOSUPPORT; - - if (clk_stop_enable) - /* Configure the PHY to stop receiving xMII - * clock while it is signaling LPI. - */ - ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, - MDIO_PCS_CTRL1_CLKSTOP_EN); - - return ret < 0 ? ret : 0; -} -EXPORT_SYMBOL(phy_init_eee); - /** * phy_get_eee_err - report the EEE wake error count * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index 4f72ffcb8b02..593a80d43454 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1839,7 +1839,6 @@ int phy_unregister_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask); int phy_unregister_fixup_for_id(const char *bus_id); int phy_unregister_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask); -int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); int phy_eee_clk_stop_enable(struct phy_device *phydev); int phy_get_eee_err(struct phy_device *phydev); int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); From patchwork Fri Feb 17 03:42:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144287 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A901C64ED6 for ; Fri, 17 Feb 2023 03:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbjBQDnS (ORCPT ); Thu, 16 Feb 2023 22:43:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676C510248 for ; Thu, 16 Feb 2023 19:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=S/Jx5gMwx/xTf99BMu4GouHv5wT2CqOdQODOmD1Tv4M=; b=gb70nzqO01fb66fyYsvA0OfMKI yqKgkYWpHNDK23ArFfmz2WG/RoIB25PVh2tD+5l3yx8wW3wXCtE5oTgIQbRZfKYA3jIKC6zTUfT5D D+ZfZnmxwDpKoCGY/0Tbr5xFazO5fmnffuAaOmkKX+dgboIlqc4pfVXyOXW7ZnRRAZJc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSre0-005F79-Iw; Fri, 17 Feb 2023 04:42:44 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 18/18] net: usb: lan78xx: Fixup EEE Date: Fri, 17 Feb 2023 04:42:30 +0100 Message-Id: <20230217034230.1249661-19-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So move the enable/disable into lan783xx_phy_link_status_change() which gets called by phylib when there is a change in link status. lan78xx_set_eee() now just programs the hardware with the LTI timer value, and passed everything else to phylib, so it can correctly setup the PHY. lan743x_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LTI timer value, and tx_lpi_enabled based on if EEE is active. Signed-off-by: Andrew Lunn --- drivers/net/usb/lan78xx.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index f18ab8e220db..a06eac83cc01 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1690,16 +1690,11 @@ static int lan78xx_get_eee(struct net_device *net, struct ethtool_eee *edata) ret = lan78xx_read_reg(dev, MAC_CR, &buf); if (buf & MAC_CR_EEE_EN_) { - edata->eee_enabled = true; - edata->eee_active = !!(edata->advertised & - edata->lp_advertised); edata->tx_lpi_enabled = true; /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */ ret = lan78xx_read_reg(dev, EEE_TX_LPI_REQ_DLY, &buf); edata->tx_lpi_timer = buf; } else { - edata->eee_enabled = false; - edata->eee_active = false; edata->tx_lpi_enabled = false; edata->tx_lpi_timer = 0; } @@ -1721,24 +1716,16 @@ static int lan78xx_set_eee(struct net_device *net, struct ethtool_eee *edata) if (ret < 0) return ret; - if (edata->eee_enabled) { - ret = lan78xx_read_reg(dev, MAC_CR, &buf); - buf |= MAC_CR_EEE_EN_; - ret = lan78xx_write_reg(dev, MAC_CR, buf); - - phy_ethtool_set_eee(net->phydev, edata); - - buf = (u32)edata->tx_lpi_timer; - ret = lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, buf); - } else { - ret = lan78xx_read_reg(dev, MAC_CR, &buf); - buf &= ~MAC_CR_EEE_EN_; - ret = lan78xx_write_reg(dev, MAC_CR, buf); - } + ret = phy_ethtool_set_eee(net->phydev, edata); + if (ret < 0) + goto out; + buf = (u32)edata->tx_lpi_timer; + ret = lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, buf); +out: usb_autopm_put_interface(dev->intf); - return 0; + return ret; } static u32 lan78xx_get_link(struct net_device *net) @@ -2114,8 +2101,10 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev) static void lan78xx_link_status_change(struct net_device *net) { + struct lan78xx_net *dev = netdev_priv(net); struct phy_device *phydev = net->phydev; int temp; + u32 data; /* At forced 100 F/H mode, chip may fail to set mode correctly * when cable is switched between long(~50+m) and short one. @@ -2142,6 +2131,13 @@ static void lan78xx_link_status_change(struct net_device *net) temp |= LAN88XX_INT_MASK_MDINTPIN_EN_; phy_write(phydev, LAN88XX_INT_MASK, temp); } + + lan78xx_read_reg(dev, MAC_CR, &data); + if (phydev->eee_active) + data |= MAC_CR_EEE_EN_; + else + data &= ~MAC_CR_EEE_EN_; + lan78xx_write_reg(dev, MAC_CR, data); } static int irq_map(struct irq_domain *d, unsigned int irq,