From patchwork Tue Jan 28 15:46:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952662 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 47FD919DF61 for ; Tue, 28 Jan 2025 15:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079239; cv=none; b=X39idGSfZO9VxSBYPC7TxZ6sYRIC/uihuzHF6b7GAXnhdvu4icsRerFQjKu4mdpFD6j7qkEuF5Nfe5WYgYugjWDD6w0kapbGpIcHrLmcwLFy569u8SRNo6Zvs8yTmVER7uoCXEU8PqUOdzzUBz9ro5kPCkVOnpOFG4DO7BDRxiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079239; c=relaxed/simple; bh=QXp6k/6G0Nf6cNFZnwNIqeMgoUujMBBH3dJfepnU2Tc=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=cyQ2pdU2e+Caepvi8iGOilVDUb/tCVpRiQWroL59Tv4rxCotB5AZCq/B7grcXkCiSObKAha6MAoh4zFa0a7vqGG9fCFmOQcdVJQBejPP62rzek3Y+wKixLSihmIhNv5+IhdYM8hNlLOwNtyNhfDwoFw8vWo7hs97mRy6IS7Y22I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=b4VKyTFa; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="b4VKyTFa" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZMJJltXWTlPgnB8E7H4VZiWjG4lWjUspm9Wi3VxQZ7g=; b=b4VKyTFa+0liIqI6J+5VQpjYld sHW4GloEcB++WR5BjxyTM1lnOn7gZN+ycy7PdvsrStbrhg2dyR5d2kpmW9oexlp9T7qrF1Ed8CvJk Uzxoo6fmw9yXhp2lhh0C/iTT/IN0ApkiFzdDr14s2C2JIQTYks3uimYk+MWCbRQosJf7CT3MPz/+d FyScdoQBXn70z5RAKpI+SXffh3O7ZUp2fItFP/dtCm9xuKA05i93Tpxqwx/alBxJU2n10VGA++boi qszaxTPgcLq3Z+/7y21cypruz8LJOngqmjWUCEJxuR5TarmyYVZaqD+RPO/H6m/dEgboZzQbIRt98 flmrpWoQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:55496 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnnx-0007Sn-0q; Tue, 28 Jan 2025 15:47:09 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnnd-0037G8-Vg; Tue, 28 Jan 2025 15:46:50 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 01/22] net: stmmac: delete software timer before disabling LPI Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:46:49 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Delete the software timer to ensure that the timer doesn't fire while we are modifying the LPI register state, potentially re-enabling LPI. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index edbf8994455d..a1a788bbc75a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -447,8 +447,8 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv) */ static void stmmac_stop_sw_lpi(struct stmmac_priv *priv) { - stmmac_reset_eee_mode(priv, priv->hw); del_timer_sync(&priv->eee_ctrl_timer); + stmmac_reset_eee_mode(priv, priv->hw); priv->tx_path_in_lpi_mode = false; } @@ -492,8 +492,8 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active) if (priv->eee_enabled) { netdev_dbg(priv->dev, "disable EEE\n"); priv->eee_sw_timer_en = false; - stmmac_disable_hw_lpi_timer(priv); del_timer_sync(&priv->eee_ctrl_timer); + stmmac_disable_hw_lpi_timer(priv); stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); if (priv->hw->xpcs) From patchwork Tue Jan 28 15:46:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952663 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 90ED619DF61 for ; Tue, 28 Jan 2025 15:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079243; cv=none; b=Ojudgji1tt1ieEHel0FcnPSEQkZdsB6ZTAfQ5PjXtyJbifSPpdbS0HVFYULUEPxKKl67+w4218FB49Za09p5IEMVx1kww5GXtIQt5pH5gluId6TIeP4QUOjpdxukV0foWEii0OK8W86Ud3U5hFvH2bl3drVEooRJGLDjaQjR4m4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079243; c=relaxed/simple; bh=3WsnWd1a5z9s0abwveTDxKRxXLr2X7nm3gjHHlWG5UY=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=RkwC5/+RyOWW8aWnrkDambUCpO++y4bEyG8/KgqF9NFNkKxGhHukSR46QobtrsyCNgwtCAREjNba84Ee0bjjqRJ8Tplnur/DrKyHlz4o0nVEeQ5G4GAu7MQ4yPAJmbwW9Bj7jJj8kY/5O1zJiGdfKXABbeVV5rJ+lxQbtud6YPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=iXi2056j; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="iXi2056j" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JoLZ33LNKwoAa71fKGzvEpEXOzJfCAkJh5baBBKZatA=; b=iXi2056j0eNW1rMUPL/5DviVLD hYmXJaxUnw5pqu415V0u7DVXT6dhWUQ4eHwdn7xOecxV+CUclkNfNC0/cLXjzGab6R4MNB1293iLy TyvH6FifIgJS82vrQbzmLvv+P6795fSR3KrbH8vZAr4sBSIke2iy3aakvXX6jMAKMfgRnXg+zXs49 1Oizn8GpJXQaoQyKfmjC87sBRQMqVcvol5WXk8l/N0HPMA7si9+S0/St47SNADXfTiPqGku1Ixhy8 n67OJJFNgSbq3SZNKlHnR1UlCt2i2jl+8znfQCuxtHsewggRZaG780e1S6jmKWn2ebFXoo+heUuTS qfhiH0XA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:49224 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcno2-0007T3-1O; Tue, 28 Jan 2025 15:47:14 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnnj-0037GE-3X; Tue, 28 Jan 2025 15:46:55 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 02/22] net: stmmac: ensure LPI is disabled when disabling EEE Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:46:55 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC When EEE is disabled, we call stmmac_set_eee_lpi_timer(..., 0). For dwmac4, this will result in LPIATE being cleared, but LPIEN and LPITXA being set, causing LPI mode to be signalled (if it wasn't before). For others MACs, stmmac_set_eee_lpi_timer() does nothing, which means that LPI mode will continue to be signalled despite the expectation for it to be disabled. In both cases, LPI mode will be terminated when the transmitter has a packet to send, and LPIEN will be cleared by hardware. Call stmmac_reset_eee_mode() to ensure that LPI mode is disabled when EEE mode is requested to be disabled. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index a1a788bbc75a..7480825389e9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -494,6 +494,7 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active) priv->eee_sw_timer_en = false; del_timer_sync(&priv->eee_ctrl_timer); stmmac_disable_hw_lpi_timer(priv); + stmmac_reset_eee_mode(priv, priv->hw); stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); if (priv->hw->xpcs) From patchwork Tue Jan 28 15:47:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952664 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 9CD2F19DF61 for ; Tue, 28 Jan 2025 15:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079248; cv=none; b=GKpoHQ2MiA9Qt1X19XKMHhRRq3dDxt2X0ThuV88Rx4Bk+1CrnTzxh8taLlRWzbsVSYpyvjOhUBu8hYieVI9EbU3w8sAnG2FhZE8vkRP0l7LK6eeFvfUupU/mSCV6VtbztHQ5HcUQE+eUHJ7RTjMtJZez8fKfKeK0Tzb+bsEPJEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079248; c=relaxed/simple; bh=BjB+f1cBVPgnew39RbbFn2ojhTrvPU6iEsIiiKONVE0=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=XOweWMiDsyJrrk1m0evUN032aCCVsc05j71cSRRND3AT8CeuK7c8+sK5ys9GWw8yOJnWTo+ceesseIpL86SL4j7IfjGomO8Anb8QRy9/GIqrC3YD648MeKrSZjMaNB+34lGkkfPz4K7r4L2Y5VkaBVim0+5wRq1CeNAMg3Rv8XY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=QuUz8KNS; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="QuUz8KNS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=07l2JUwowhU6Kds29hM9ev3VTddwmEBKcHtBEEd7LSM=; b=QuUz8KNS2b6kxIsPGQp11LQfmn pQRbY8a2C6byP0dgrbIZWs317/4ADiqxGskxjCzS39sMG2xNWELMEdH5tiIv8dwvEYgKWok05QEQO Ya6CWQFJk//ANio8eNOinoMfWBIP2h6FmoKJycxpD94EkMjQNsyJP3ezgCViN0uAICmN5+uFamFM0 BD+Yh9JXnxANzTf8e6qdCqMsOhnbLUeilkFbelf69Xi5UMdMlhLOIzLqvuoDwTYtZNUVm+pD7ykVY 42Fq3M1oJgqP+UcZJwWYZ3Vwj8r2mLEbtePI10gkcL1AdlPnxb8wkRQT1eGQmhs/e3JEjJha/zvEY bssGk1/Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:49236 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcno7-0007TJ-2S; Tue, 28 Jan 2025 15:47:19 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnno-0037GK-7U; Tue, 28 Jan 2025 15:47:00 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 03/22] net: stmmac: dwmac4: ensure LPIATE is cleared Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:00 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC LPIATE enables the hardware timer for entering LPI mode. To sure that the correct mode is used, clear LPIATE when using manual/software-timed mode to prevent the hardware using the timer. stmmac_main.c avoids this being a problem at the moment by calling stmmac_set_eee_lpi_timer(..., 0) before switching to software mode. We no longer need to call stmmac_set_eee_lpi_timer(..., 0) when disabling EEE as stmmac_reset_eee_mode() will now clear all LPI settings. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 +++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 9ed8620580a8..17bf836eba7f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -387,6 +387,7 @@ static void dwmac4_set_eee_mode(struct mac_device_info *hw, * state. */ value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); + value &= ~GMAC4_LPI_CTRL_STATUS_LPIATE; value |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA; if (en_tx_lpi_clockgating) @@ -401,7 +402,8 @@ static void dwmac4_reset_eee_mode(struct mac_device_info *hw) u32 value; value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - value &= ~(GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA); + value &= ~(GMAC4_LPI_CTRL_STATUS_LPIATE | GMAC4_LPI_CTRL_STATUS_LPIEN | + GMAC4_LPI_CTRL_STATUS_LPITXA); writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 7480825389e9..e6a6aaa74185 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -493,7 +493,6 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active) netdev_dbg(priv->dev, "disable EEE\n"); priv->eee_sw_timer_en = false; del_timer_sync(&priv->eee_ctrl_timer); - stmmac_disable_hw_lpi_timer(priv); stmmac_reset_eee_mode(priv, priv->hw); stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); From patchwork Tue Jan 28 15:47:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952665 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 AAE731D5ABF for ; Tue, 28 Jan 2025 15:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079254; cv=none; b=SGVg0h3T6J5UbLhpWuPIitk8PT53VIVBU4r73URLX5WIWi8YQ3lYpzVhbIJO+Ce1plSwbt7Bz6e7ZBfr5ZOWvIe8BVqYrJRubv+VuBYW11qt38sex/LrFF78Kf5UKtGpiVdzIagoWL5BykhcjgFCvXJZHjmfIKjP2NQzMQFQ5EM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079254; c=relaxed/simple; bh=9aDK12uVpD9nLVH3wKJNwmFuy6LplT73i8Ct0ttTEh0=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=hniKD+ER1SiEwQeLPcctSV6rTUkCFJgBcbUnivdmAtu0rfJKx5NWy7869p2dovmEP/s2OCMiJ+x9Vs7OwNgaDrL67MPT83XB0t8RLOWfy2wr7RQ9L2Sv6QUwApUei2lqPfl1K5ihzZT9v0yaGe4RSm4QOxOylkhMyofBCirz2Vw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=k5YO3aGZ; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="k5YO3aGZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LgK/r5nGV4DprNay2NXmi2Nhjdf4AdIUiVGgxoFQbKs=; b=k5YO3aGZ8PjsfbnHRZrIDIu+wY do+UB2/szY3EgTFPxe/cJaanODaSbwqz4aFpFpA1TR8j98+yn3ncCZBdYqDcJzhKb65Tc126j+9o1 yKWqGCX17T8FflV6WIcGuPv6DvVNtGOuLjHDDnLvQY91TXs9uDqZbI1Z+2F79g7q+XX+keaXssC0R HCZMpkG2DnOt+h6/f7jTDVfj13zWfVkUdPY+Qsh+0V3Kh7NmUt8ErY2Xc3c1MGOe9/UhO5z+VmHdV gg6auK9/DBkq0pN0vBwZmytE4tQXixA0X5anfm7WBI3gz3HfCQUZ9Gt87oGMAbB0LptZaKBVTI/Bn dNTXdPoQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:41974 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoC-0007Te-32; Tue, 28 Jan 2025 15:47:25 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnnt-0037GQ-Ay; Tue, 28 Jan 2025 15:47:05 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 04/22] net: stmmac: split stmmac_init_eee() and move to phylink methods Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:05 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Move the appropriate parts of stmmac_init_eee() into the phylink mac_enable_tx_lpi() and mac_disable_tx_lpi() methods. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 133 +++++++++--------- 1 file changed, 63 insertions(+), 70 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e6a6aaa74185..3a0f1003f7a8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -466,74 +466,6 @@ static void stmmac_eee_ctrl_timer(struct timer_list *t) stmmac_try_to_start_sw_lpi(priv); } -/** - * stmmac_eee_init - init EEE - * @priv: driver private structure - * @active: indicates whether EEE should be enabled. - * Description: - * if the GMAC supports the EEE (from the HW cap reg) and the phy device - * can also manage EEE, this function enable the LPI state and start related - * timer. - */ -static void stmmac_eee_init(struct stmmac_priv *priv, bool active) -{ - priv->eee_active = active; - - /* Check if MAC core supports the EEE feature. */ - if (!priv->dma_cap.eee) { - priv->eee_enabled = false; - return; - } - - mutex_lock(&priv->lock); - - /* Check if it needs to be deactivated */ - if (!priv->eee_active) { - if (priv->eee_enabled) { - netdev_dbg(priv->dev, "disable EEE\n"); - priv->eee_sw_timer_en = false; - del_timer_sync(&priv->eee_ctrl_timer); - stmmac_reset_eee_mode(priv, priv->hw); - stmmac_set_eee_timer(priv, priv->hw, 0, - STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, - false); - } - priv->eee_enabled = false; - mutex_unlock(&priv->lock); - return; - } - - if (priv->eee_active && !priv->eee_enabled) { - stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, - STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, - true); - } - - if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) { - /* Use hardware LPI mode */ - del_timer_sync(&priv->eee_ctrl_timer); - priv->tx_path_in_lpi_mode = false; - priv->eee_sw_timer_en = false; - stmmac_enable_hw_lpi_timer(priv); - } else { - /* Use software LPI mode */ - priv->eee_sw_timer_en = true; - stmmac_disable_hw_lpi_timer(priv); - stmmac_restart_sw_lpi_timer(priv); - } - - priv->eee_enabled = true; - - mutex_unlock(&priv->lock); - netdev_dbg(priv->dev, "Energy-Efficient Ethernet initialized\n"); -} - /* stmmac_get_tx_hwtstamp - get HW TX timestamps * @priv: driver private structure * @p : descriptor pointer @@ -1110,7 +1042,33 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) { struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); - stmmac_eee_init(priv, false); + priv->eee_active = false; + + /* Check if MAC core supports the EEE feature. */ + if (!priv->dma_cap.eee) { + priv->eee_enabled = false; + return; + } + + mutex_lock(&priv->lock); + + /* Check if it needs to be deactivated */ + if (!priv->eee_active) { + if (priv->eee_enabled) { + netdev_dbg(priv->dev, "disable EEE\n"); + priv->eee_sw_timer_en = false; + del_timer_sync(&priv->eee_ctrl_timer); + stmmac_reset_eee_mode(priv, priv->hw); + stmmac_set_eee_timer(priv, priv->hw, 0, + STMMAC_DEFAULT_TWT_LS); + if (priv->hw->xpcs) + xpcs_config_eee(priv->hw->xpcs, + priv->plat->mult_fact_100ns, + false); + } + priv->eee_enabled = false; + } + mutex_unlock(&priv->lock); } static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, @@ -1119,7 +1077,42 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); priv->tx_lpi_timer = timer; - stmmac_eee_init(priv, true); + priv->eee_active = true; + + /* Check if MAC core supports the EEE feature. */ + if (!priv->dma_cap.eee) { + priv->eee_enabled = false; + return 0; + } + + mutex_lock(&priv->lock); + + if (priv->eee_active && !priv->eee_enabled) { + stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, + STMMAC_DEFAULT_TWT_LS); + if (priv->hw->xpcs) + xpcs_config_eee(priv->hw->xpcs, + priv->plat->mult_fact_100ns, + true); + } + + if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) { + /* Use hardware LPI mode */ + del_timer_sync(&priv->eee_ctrl_timer); + priv->tx_path_in_lpi_mode = false; + priv->eee_sw_timer_en = false; + stmmac_enable_hw_lpi_timer(priv); + } else { + /* Use software LPI mode */ + priv->eee_sw_timer_en = true; + stmmac_disable_hw_lpi_timer(priv); + stmmac_restart_sw_lpi_timer(priv); + } + + priv->eee_enabled = true; + + mutex_unlock(&priv->lock); + netdev_dbg(priv->dev, "Energy-Efficient Ethernet initialized\n"); return 0; } From patchwork Tue Jan 28 15:47:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952666 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 922B21D61A1 for ; Tue, 28 Jan 2025 15:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079258; cv=none; b=ldyDylfIil/4ja5pX5fntRyFIjVv1oX77snvQHLmSjpk0jA64XB8RSsSLGOG8uqAgSzuynvxRJ2z/Q3ieoUR4pUren/3ovF4QCfFr/f9IlfYE7Ss9MQ9sODuCQStSVsMQhW1X+ebRYTzaAG7E4TghAkhgQnA1g/mPKymmij6Dv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079258; c=relaxed/simple; bh=7ZK2S3ewWJ/OUzkcElUw2MiHCaOSP8r/ZslkIY3Lk3M=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=UfqK2BLkBQjZ+Qkrar9EHQIVNYuJiHyyGRp+9Ly+9e6R6fYG+k5iuM+LWS/jeSbCJwmdYfBcwBzbMCah9VTYvJRvzTgNwZRdqN/j8WKGb0GlhHYC4goNg5icsxdxQJjA6/3/kbvc+d4ywiq+LPev5d8r9kvGM3/+MpxZkilmVKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=iKwRr8Re; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="iKwRr8Re" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3YIoH6VA55wVjjgJMjTs7y6r79V9JBvos9FiOPbICR8=; b=iKwRr8ReVs813x0XopkdelSqpD cwTu6G2N8BuZZu/v+XLIo1QH1UQho1+KfxKaOzqk1In3rfYsJi7egcVXPf/0OA+Ub74PG0uxfnKYp 1SOeQGzjQlNiandPGVWe/3fsVw+UJJGNMeSThfhXtSlvXSqxTQheUeGPWEdkLLmLxFfzvK5sH+MNQ o04bdkdscv8KOe7nRevoATawh7qCVUQJuPkXQq7gAFbVOhGLno2O8nXcPi1nAzrDWdK+GbWn0Qd8D cXiFTdOR4FuwbPq23xECBjzqUjszwXUpMmRqoa4E7nYT5qk5UhsUgBKn3DovNKFCM4ZyKBHMoM2nv 7xslCfvg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:41988 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoH-0007Tu-2t; Tue, 28 Jan 2025 15:47:29 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnny-0037GW-Eo; Tue, 28 Jan 2025 15:47:10 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 05/22] net: stmmac: remove priv->dma_cap.eee test in tx_lpi methods Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:10 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The tests for priv->dma_cap.eee in stmmac_mac_{en,dis}able_tx_lpi() is useless as these methods will only be called when using phylink managed EEE, and that will only be enabled if the LPI capabilities in phylink_config have been populated during initialisation. This only occurs when priv->dma_cap.eee was true. As priv->dma_cap.eee remains constant during the lifetime of the driver instance, there is no need to re-check it in these methods. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3a0f1003f7a8..c2cc75624a8c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1044,12 +1044,6 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) priv->eee_active = false; - /* Check if MAC core supports the EEE feature. */ - if (!priv->dma_cap.eee) { - priv->eee_enabled = false; - return; - } - mutex_lock(&priv->lock); /* Check if it needs to be deactivated */ @@ -1079,12 +1073,6 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, priv->tx_lpi_timer = timer; priv->eee_active = true; - /* Check if MAC core supports the EEE feature. */ - if (!priv->dma_cap.eee) { - priv->eee_enabled = false; - return 0; - } - mutex_lock(&priv->lock); if (priv->eee_active && !priv->eee_enabled) { From patchwork Tue Jan 28 15:47:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952667 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 3DC7619DF61 for ; Tue, 28 Jan 2025 15:47:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079262; cv=none; b=N7GaPbsIFtSpDuaJbV4cy29cgihSivN9exPjrvDdsgDodn5gSMUvk6ogRD8ycdggZcrGTcI14BP2glxFky7HRw/nPdPpi1iPoYqzQxvY1eB0FwXzaviOF4ovCiI8QufGDvxqBh+oC6y7bTepGf2dtsuGOTV6yYBaIK+uV/DvVrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079262; c=relaxed/simple; bh=RdRPUWxHH2zg99KBNU5MMpU/DLZx/CwYivYJG0OSqiA=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=THSPw3DwDIdH03sQATisSIaWQXJjaaLZO/5glhP1HDK/HcjblXuHesZ4bLRBtEkJiijcJRZa5PaFV5tp1jgt0ayYzE1vQYOS3ZIsCPVt5HVgSH2hPBBlUbnQ4TSNMgcIbDCHI9A922px5fLUJBu0rVlWcgiWeBZF1rzF0XpKCII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=DUoJvcMN; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="DUoJvcMN" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RdaJHDcetawhw7n/tKdXgSJrOfxgqAK1m9UgeH2faDY=; b=DUoJvcMNtYWYHhnUOG2+m3iGt+ mh0kg9EQjZsMkN0tcXxx5jOE+j6mkcveB1SZXSIf6JsPVg10V5bNRMxXGwhqQZbsCqH+Gg70y9D55 ogY9tG1X7hK5MJEq4qn1jyUb5P8EfJVreJugMzX2i2389hJaksgvxcmdy+VgpR8s/iTUEhWi24YYl ZGlp2FBeC9ByMclEpVkel4GTKeK34cYFSPiP8CmMpMssP92iAx/68KS1EDDhLZVYVConBlRoHv2UN VfpRqXRrwicQlrf7zFUEUMwIM5shpWuOV9BRfptBzfuxMKHJHFoTJUOC4PlzCvPv6+uQ/5e7B8MkX rxQg27dQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45790 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoM-0007UD-35; Tue, 28 Jan 2025 15:47:34 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcno3-0037Gc-Is; Tue, 28 Jan 2025 15:47:15 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 06/22] net: stmmac: remove unnecessary priv->eee_active tests Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:15 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Since priv->eee_active is assigned with a constant value in each of these methods, there is no need to test its value later. Remove these unnecessary tests. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c2cc75624a8c..f63946eb6747 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1047,21 +1047,17 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) mutex_lock(&priv->lock); /* Check if it needs to be deactivated */ - if (!priv->eee_active) { - if (priv->eee_enabled) { - netdev_dbg(priv->dev, "disable EEE\n"); - priv->eee_sw_timer_en = false; - del_timer_sync(&priv->eee_ctrl_timer); - stmmac_reset_eee_mode(priv, priv->hw); - stmmac_set_eee_timer(priv, priv->hw, 0, - STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, - false); - } - priv->eee_enabled = false; + if (priv->eee_enabled) { + netdev_dbg(priv->dev, "disable EEE\n"); + priv->eee_sw_timer_en = false; + del_timer_sync(&priv->eee_ctrl_timer); + stmmac_reset_eee_mode(priv, priv->hw); + stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); + if (priv->hw->xpcs) + xpcs_config_eee(priv->hw->xpcs, + priv->plat->mult_fact_100ns, false); } + priv->eee_enabled = false; mutex_unlock(&priv->lock); } @@ -1075,13 +1071,12 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, mutex_lock(&priv->lock); - if (priv->eee_active && !priv->eee_enabled) { + if (!priv->eee_enabled) { stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, STMMAC_DEFAULT_TWT_LS); if (priv->hw->xpcs) xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, - true); + priv->plat->mult_fact_100ns, true); } if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) { From patchwork Tue Jan 28 15:47:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952668 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 8572F1D5AAD for ; Tue, 28 Jan 2025 15:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079268; cv=none; b=rqIAO7p8DtJ447yXOLsfqaEnKCu/pq4kA2Wnpv5TTJ/9PLAQQeNQ9vJ18VT0BLukeqLi3H01hjSjqvt6FvfGWDzaoOewC5q/zuw7U+1Go3yZv3w8kswGTMxV8s8bKf9IFBj8LZpQ8dy1ZyZhbgGs41QezYowds5exMf3VCwIEJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079268; c=relaxed/simple; bh=1A5HUh3zzw8eMuKg+8ZlEU6PRqhFFqySc4yfyJUEE+A=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=p2dJOBQKxQyWMuMMwRPcnfj5SWnB4yf9JoaOPvM+hha+Y9lN/QVbW5PazKjw/K3i74a5HeTO5moBqUbqb2cqw5oklkZmXZ3t5VMwmq1rCJfiZHywuSJ0gyHNaKTShZufBufJDqkZmn8osIO0H4tZAkqjaYtpaqg43ftW4sHPAe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=yV54mE8F; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="yV54mE8F" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FzqEwFhraiQ3i+QhTMew1i129n2QgfNW9SfHL20WQVw=; b=yV54mE8Fn+8MuE63sRKrarSyHV ZUkrCUnVb/wnlo+9HqcZ3EjLtmaJMc4NL6jvLCsyxoD0K9JdJRwknwl1Ywt66JgMQcK4MN6cTRQXf q4j921CVN1Z06sKeelsSMy1s7JVAJAvhUuOFRWao61fw0hnRrRk9qPOALu4CvbM3/79+V8H97qHnp nGt0GqQdoF3/gGiLbXOHfjo/+KMdVm3260YqU8A4nY4iMEUJygU9TUXtvgK1Rl4UCP2H5XaeWmJjM LQqGJk3dsZHVXLhTi71DT3FiuR6fObhWYMIDVcT5pnxkcB83XLLZv4yxZPCICZ21UTttv7OvHZd+P 1CdXXQNQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45792 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoS-0007UU-01; Tue, 28 Jan 2025 15:47:40 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcno8-0037Gi-Mp; Tue, 28 Jan 2025 15:47:20 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 07/22] net: stmmac: remove unnecessary priv->eee_enabled tests Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:20 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Phylink will not call the mac_disable_tx_lpi() and mac_enable_tx_lpi() methods randomly - the first method to be called will be the enable method, and then after, the disable method will be called once between subsequent enable calls. Thus there is a guaranteed ordering. Therefore, we know the previous state of priv->eee_enabled, and can remove it from both methods. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f63946eb6747..485b2bfaf811 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1046,18 +1046,17 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) mutex_lock(&priv->lock); - /* Check if it needs to be deactivated */ - if (priv->eee_enabled) { - netdev_dbg(priv->dev, "disable EEE\n"); - priv->eee_sw_timer_en = false; - del_timer_sync(&priv->eee_ctrl_timer); - stmmac_reset_eee_mode(priv, priv->hw); - stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, false); - } priv->eee_enabled = false; + + netdev_dbg(priv->dev, "disable EEE\n"); + priv->eee_sw_timer_en = false; + del_timer_sync(&priv->eee_ctrl_timer); + stmmac_reset_eee_mode(priv, priv->hw); + stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); + if (priv->hw->xpcs) + xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, + false); + mutex_unlock(&priv->lock); } @@ -1071,13 +1070,13 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, mutex_lock(&priv->lock); - if (!priv->eee_enabled) { - stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, - STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, true); - } + priv->eee_enabled = true; + + stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, + STMMAC_DEFAULT_TWT_LS); + if (priv->hw->xpcs) + xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, + true); if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) { /* Use hardware LPI mode */ @@ -1092,8 +1091,6 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, stmmac_restart_sw_lpi_timer(priv); } - priv->eee_enabled = true; - mutex_unlock(&priv->lock); netdev_dbg(priv->dev, "Energy-Efficient Ethernet initialized\n"); From patchwork Tue Jan 28 15:47:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952669 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 383781D5AAD for ; Tue, 28 Jan 2025 15:47:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079272; cv=none; b=sjZ/3ZNZ4N/tsJyVkkMqiVYi2P4QT+ym9fmSozML+38iwsqtRwih/I0RItKtuVWwht/6SHa3D9WGfoZRUMwRqJgiwcxdQdOfrHQ7YRvcc6v93xL+cRwtliH82fn2wZX0cj0yiiN4fQqXsbRar4r5/FN/FpMlqpWcTIucB0hWWa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079272; c=relaxed/simple; bh=6imLKz0hYki81nIhjrpo6UVOuivfz9z45xecINSvdxc=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=Vfb+1t4XLyybn3RJ3sO6I6qhOnkpTj6cJ/QpDBWoHjSXfLZMWyR4+2EvCL42rsIqcbd/lExn4I19R4JnfUrMeaVQZUausrjTFKYe2TR8tuObXSjZGtci1Pv8foPm7v9G3gr9h62P2vqhZmbwheJlIfHlN/6And8vuGYMpBDevms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=th2CPtAL; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="th2CPtAL" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Tz+ycJGyz3nSRG9p8hP5+LC1RqbEPoiShhFlu0+Ke9o=; b=th2CPtALOBlUQkboIvRSC7VEXS RqpZL/4H1pWtv+K0plXkn8ApIMU1cRhVBXV+L4neCOBobIKpMagIsf+rP8Fw6sWhn9VE5p0UQfSYf cI84ux9DzXKScvoGztv34XcfP8NRc2w46LNWABCePnThSDUY3TTjXlxrJyXjcphjVVuLNg1wu2FP/ ILeVHQuqAqJ1ckJ47hB+IIj2Xl+1uZIvG7wMPxCMFTLaJoqc5a96Q3piw1SDWJJ8LRUSKG5KyHGE2 lzphbQywc5NPAu+t27Y05DJTvkf9W1El0xhQ9BxmjITtzwWt54sUwKgOXCS1qLiI6bGveo+XUL2np tnzseGhQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39312 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoX-0007Ul-0H; Tue, 28 Jan 2025 15:47:45 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnoD-0037Go-Qj; Tue, 28 Jan 2025 15:47:25 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 08/22] net: stmmac: clear priv->tx_path_in_lpi_mode when disabling LPI Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:25 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC As other code paths do, clear priv->tx_path_in_lpi_mode when disabling LPI. This is done after the software timer has been deleted and hardware LPI has been disabled. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 485b2bfaf811..40b9e387446e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1052,6 +1052,8 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) priv->eee_sw_timer_en = false; del_timer_sync(&priv->eee_ctrl_timer); stmmac_reset_eee_mode(priv, priv->hw); + priv->tx_path_in_lpi_mode = false; + stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); if (priv->hw->xpcs) xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, From patchwork Tue Jan 28 15:47:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952670 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 9FD5E1D5AAD for ; Tue, 28 Jan 2025 15:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079278; cv=none; b=pOnP4iHBjk3kuHXTjlaY3SmIMZFInKMJN2Gba6nEYFZmsmKea+N872K6WSY1kDrQ8tsvBBPk804gCROFa6gFDAaehQ1p46M4YZ97FK0CEnXi1//MoCz7BI7gNfHDu/aGe0uXSb7imWKgJGcM8QwBLVsFiwHezKDFiKZX/Be3Ims= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079278; c=relaxed/simple; bh=MY64WJXoUa4NS8o6jFRbvqxULTqhnaYrjJjewbV4CmM=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=YINMXc/h1zdfC22YknFfvnegkzXZA0BEw9I27CSuuDYKAFwXv9A2fCE+YlSSK8/yhTSlcYj7eG0tPK+oNpCHEQveVFi8DGfpWna91398G5j5fNVIXot6Vw+fNe+jRMipI0bIlxnl+o7YatiPQb1vi0IH3ymFqrweLhKq05xGihM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=Xobegc1R; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="Xobegc1R" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RC2pmzmWH4CgIBdJHLFPft8uDI2Dakt08wcW9mTokec=; b=Xobegc1RU6kQEofhgts4nN2yIP /XloiGBM64YCtWkJc2tMPyGBDaWfJ6c5WBa9mL+9wnpmtmkk9zsbzJv/LBh9z8mHKf8TVTygHjNvc eBUHp8hDdw00deaNjknn6CEaMUkmZZlfMuszQhrtiGpMVfvixga6ETSSCyeZ5gyuBaLeCGMIskQVW saBlOphZqyD1YSsAERYHDxT7UP3Q/tyZxKnF0m52UcN+PDAuFlbg604Et4n/K/RaOgVePqs8RxfAH NBKi7jphRw71PfgKkGIVREqzTOfPg1FEsoIk7SCan/pHVxW5uogiYixng9dfCgkrDifIzxo8XEY8l XgklHl2Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39314 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoc-0007V3-0m; Tue, 28 Jan 2025 15:47:50 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnoI-0037Gu-UM; Tue, 28 Jan 2025 15:47:30 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 09/22] net: stmmac: remove unnecessary LPI disable when enabling LPI Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:30 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Remove the unnecessary LPI disable when enabling LPI - as noted in previous commits, there will never be two consecutive calls to stmmac_mac_enable_tx_lpi() without an intervening stmmac_mac_disable_tx_lpi. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 40b9e387446e..aafd9cee304e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -390,11 +390,6 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue) return dirty; } -static void stmmac_disable_hw_lpi_timer(struct stmmac_priv *priv) -{ - stmmac_set_eee_lpi_timer(priv, priv->hw, 0); -} - static void stmmac_enable_hw_lpi_timer(struct stmmac_priv *priv) { stmmac_set_eee_lpi_timer(priv, priv->hw, priv->tx_lpi_timer); @@ -1082,14 +1077,10 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) { /* Use hardware LPI mode */ - del_timer_sync(&priv->eee_ctrl_timer); - priv->tx_path_in_lpi_mode = false; - priv->eee_sw_timer_en = false; stmmac_enable_hw_lpi_timer(priv); } else { /* Use software LPI mode */ priv->eee_sw_timer_en = true; - stmmac_disable_hw_lpi_timer(priv); stmmac_restart_sw_lpi_timer(priv); } From patchwork Tue Jan 28 15:47:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952671 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 882BB1D5AAD for ; Tue, 28 Jan 2025 15:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079284; cv=none; b=cK4MfCYLKA2OMgEaUnqEZ2vil3P6h7YTywsE/YmCasdRId1VH9V5GSlHqTYBxEh1NiX3ipWexbwqT9no7U7PvBdl6oDuvjhccaYgvPen/ej8DQrkmKWo2fLfk7JDPMVMuafhdWH1C0bumb4wIBLYyXAMW/KQDPjky/Pp+g4TDJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079284; c=relaxed/simple; bh=CuMhmakQHhGdT+HpG2EpR2kiIpdkwsmsjF2TCnjBiiQ=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=j3LjDcRAEzWnKWNPadNiD7TTWdBrDSncSqDhzC47cWakuM7k/iLRRlh6vZiCvL1tyh7MRXIaQqrA7CQgmghR0A23U5OP+hDQLP91MXOlPMZwY8H7RWmsuiz5Xkb+czTOvgecROhTXa0UZ9KR8G/6WWRvLAWP6Vca3CGoMiqZg7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=I+fOel8a; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="I+fOel8a" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TekHCCUHCmCERxcU/o0a7msZFaeEFOla/9UtzyX7LR4=; b=I+fOel8aDuz+i6VE549Bd8OkCh /K3qCJi8eJ75D2jN69DhjrYWXMsGpZnxEG+cXstAL8qIQ5hyGO16RgifA3qbzdjdOCLLidQCFLzla MBZ03Psq5uaoKIxBA70gc5WOrVrVRFCssUx3NwVehjwbouwQgUIvoGOgQsuP46Odt9oWWVbzVNOX6 rS2vXySdxMwbC64L/K8/JacUemnMKGxU7p+Mk8YAp1wTZpEiMODMCqYk6XZ04KniIRna3y90u3Mjo ua5YxEhmNc516LeKgEoByIH5eNwjPz6CjaDOA04hxVh2vFXGRGJ2Au0gbSfvvLQhDehWzsEYNe4By MuaK/dqA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:42464 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnoh-0007VL-1C; Tue, 28 Jan 2025 15:47:55 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnoO-0037H0-1n; Tue, 28 Jan 2025 15:47:36 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 10/22] net: stmmac: use common LPI_CTRL_STATUS bit definitions Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:36 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The bit definitions for the LPI control/status register are identical across all MAC versions, with the exception that some bits may not be implemented. Provide definitions for bits in this register in common.h, convert to use them, and remove the core- specific definitions. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/common.h | 14 ++++++++++ .../net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +-------- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 12 +------- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 28 +++++++++---------- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 9 +----- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 18 ++++++------ 6 files changed, 40 insertions(+), 54 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index e25db747a81a..55053528e498 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -530,6 +530,20 @@ struct dma_features { #define STMMAC_DEFAULT_TWT_LS 0x1E #define STMMAC_ET_MAX 0xFFFFF +/* Common LPI register bits */ +#define LPI_CTRL_STATUS_LPITCSE BIT(21) /* LPI Tx Clock Stop Enable, gmac4, xgmac2 only */ +#define LPI_CTRL_STATUS_LPIATE BIT(20) /* LPI Timer Enable, gmac4 only */ +#define LPI_CTRL_STATUS_LPITXA BIT(19) /* Enable LPI TX Automate */ +#define LPI_CTRL_STATUS_PLSEN BIT(18) /* Enable PHY Link Status */ +#define LPI_CTRL_STATUS_PLS BIT(17) /* PHY Link Status */ +#define LPI_CTRL_STATUS_LPIEN BIT(16) /* LPI Enable */ +#define LPI_CTRL_STATUS_RLPIST BIT(9) /* Receive LPI state, gmac1000 only? */ +#define LPI_CTRL_STATUS_TLPIST BIT(8) /* Transmit LPI state, gmac1000 only? */ +#define LPI_CTRL_STATUS_RLPIEX BIT(3) /* Receive LPI Exit */ +#define LPI_CTRL_STATUS_RLPIEN BIT(2) /* Receive LPI Entry */ +#define LPI_CTRL_STATUS_TLPIEX BIT(1) /* Transmit LPI Exit */ +#define LPI_CTRL_STATUS_TLPIEN BIT(0) /* Transmit LPI Entry */ + #define STMMAC_CHAIN_MODE 0x1 #define STMMAC_RING_MODE 0x2 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h index 600fea8f712f..967a16212faf 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -59,22 +59,11 @@ enum power_event { /* Energy Efficient Ethernet (EEE) * * LPI status, timer and control register offset + * For LPI control and status bit definitions, see common.h. */ #define LPI_CTRL_STATUS 0x0030 #define LPI_TIMER_CTRL 0x0034 -/* LPI control and status defines */ -#define LPI_CTRL_STATUS_LPITXA 0x00080000 /* Enable LPI TX Automate */ -#define LPI_CTRL_STATUS_PLSEN 0x00040000 /* Enable PHY Link Status */ -#define LPI_CTRL_STATUS_PLS 0x00020000 /* PHY Link Status */ -#define LPI_CTRL_STATUS_LPIEN 0x00010000 /* LPI Enable */ -#define LPI_CTRL_STATUS_RLPIST 0x00000200 /* Receive LPI state */ -#define LPI_CTRL_STATUS_TLPIST 0x00000100 /* Transmit LPI state */ -#define LPI_CTRL_STATUS_RLPIEX 0x00000008 /* Receive LPI Exit */ -#define LPI_CTRL_STATUS_RLPIEN 0x00000004 /* Receive LPI Entry */ -#define LPI_CTRL_STATUS_TLPIEX 0x00000002 /* Transmit LPI Exit */ -#define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */ - /* GMAC HW ADDR regs */ #define GMAC_ADDR_HIGH(reg) ((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \ 0x00000040 + (reg * 8)) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index 184d41a306af..42fe29a4e300 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -177,23 +177,13 @@ enum power_event { /* Energy Efficient Ethernet (EEE) for GMAC4 * * LPI status, timer and control register offset + * For LPI control and status bit definitions, see common.h. */ #define GMAC4_LPI_CTRL_STATUS 0xd0 #define GMAC4_LPI_TIMER_CTRL 0xd4 #define GMAC4_LPI_ENTRY_TIMER 0xd8 #define GMAC4_MAC_ONEUS_TIC_COUNTER 0xdc -/* LPI control and status defines */ -#define GMAC4_LPI_CTRL_STATUS_LPITCSE BIT(21) /* LPI Tx Clock Stop Enable */ -#define GMAC4_LPI_CTRL_STATUS_LPIATE BIT(20) /* LPI Timer Enable */ -#define GMAC4_LPI_CTRL_STATUS_LPITXA BIT(19) /* Enable LPI TX Automate */ -#define GMAC4_LPI_CTRL_STATUS_PLS BIT(17) /* PHY Link Status */ -#define GMAC4_LPI_CTRL_STATUS_LPIEN BIT(16) /* LPI Enable */ -#define GMAC4_LPI_CTRL_STATUS_RLPIEX BIT(3) /* Receive LPI Exit */ -#define GMAC4_LPI_CTRL_STATUS_RLPIEN BIT(2) /* Receive LPI Entry */ -#define GMAC4_LPI_CTRL_STATUS_TLPIEX BIT(1) /* Transmit LPI Exit */ -#define GMAC4_LPI_CTRL_STATUS_TLPIEN BIT(0) /* Transmit LPI Entry */ - /* MAC Debug bitmap */ #define GMAC_DEBUG_TFCSTS_MASK GENMASK(18, 17) #define GMAC_DEBUG_TFCSTS_SHIFT 17 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 17bf836eba7f..c324aaf691e0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -387,11 +387,11 @@ static void dwmac4_set_eee_mode(struct mac_device_info *hw, * state. */ value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - value &= ~GMAC4_LPI_CTRL_STATUS_LPIATE; - value |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA; + value &= ~LPI_CTRL_STATUS_LPIATE; + value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; if (en_tx_lpi_clockgating) - value |= GMAC4_LPI_CTRL_STATUS_LPITCSE; + value |= LPI_CTRL_STATUS_LPITCSE; writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); } @@ -402,8 +402,8 @@ static void dwmac4_reset_eee_mode(struct mac_device_info *hw) u32 value; value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - value &= ~(GMAC4_LPI_CTRL_STATUS_LPIATE | GMAC4_LPI_CTRL_STATUS_LPIEN | - GMAC4_LPI_CTRL_STATUS_LPITXA); + value &= ~(LPI_CTRL_STATUS_LPIATE | LPI_CTRL_STATUS_LPIEN | + LPI_CTRL_STATUS_LPITXA); writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); } @@ -415,9 +415,9 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link) value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); if (link) - value |= GMAC4_LPI_CTRL_STATUS_PLS; + value |= LPI_CTRL_STATUS_PLS; else - value &= ~GMAC4_LPI_CTRL_STATUS_PLS; + value &= ~LPI_CTRL_STATUS_PLS; writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); } @@ -433,12 +433,12 @@ static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, u32 et) /* Enable/disable LPI entry timer */ regval = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - regval |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA; + regval |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; if (et) - regval |= GMAC4_LPI_CTRL_STATUS_LPIATE; + regval |= LPI_CTRL_STATUS_LPIATE; else - regval &= ~GMAC4_LPI_CTRL_STATUS_LPIATE; + regval &= ~LPI_CTRL_STATUS_LPIATE; writel(regval, ioaddr + GMAC4_LPI_CTRL_STATUS); } @@ -851,17 +851,17 @@ static int dwmac4_irq_status(struct mac_device_info *hw, /* Clear LPI interrupt by reading MAC_LPI_Control_Status */ u32 status = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - if (status & GMAC4_LPI_CTRL_STATUS_TLPIEN) { + if (status & LPI_CTRL_STATUS_TLPIEN) { ret |= CORE_IRQ_TX_PATH_IN_LPI_MODE; x->irq_tx_path_in_lpi_mode_n++; } - if (status & GMAC4_LPI_CTRL_STATUS_TLPIEX) { + if (status & LPI_CTRL_STATUS_TLPIEX) { ret |= CORE_IRQ_TX_PATH_EXIT_LPI_MODE; x->irq_tx_path_exit_lpi_mode_n++; } - if (status & GMAC4_LPI_CTRL_STATUS_RLPIEN) + if (status & LPI_CTRL_STATUS_RLPIEN) x->irq_rx_path_in_lpi_mode_n++; - if (status & GMAC4_LPI_CTRL_STATUS_RLPIEX) + if (status & LPI_CTRL_STATUS_RLPIEX) x->irq_rx_path_exit_lpi_mode_n++; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index 20027d3c25a7..a03f5d771566 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -112,14 +112,7 @@ #define XGMAC_MGKPKTEN BIT(1) #define XGMAC_PWRDWN BIT(0) #define XGMAC_LPI_CTRL 0x000000d0 -#define XGMAC_TXCGE BIT(21) -#define XGMAC_LPITXA BIT(19) -#define XGMAC_PLS BIT(17) -#define XGMAC_LPITXEN BIT(16) -#define XGMAC_RLPIEX BIT(3) -#define XGMAC_RLPIEN BIT(2) -#define XGMAC_TLPIEX BIT(1) -#define XGMAC_TLPIEN BIT(0) +/* For definitions, see LPI_CTRL_STATUS_xxx in common.h */ #define XGMAC_LPI_TIMER_CTRL 0x000000d4 #define XGMAC_HW_FEATURE0 0x0000011c #define XGMAC_HWFEAT_EDMA BIT(31) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index 9a60a6e8f633..19cfb1dcb332 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -316,17 +316,17 @@ static int dwxgmac2_host_irq_status(struct mac_device_info *hw, if (stat & XGMAC_LPIIS) { u32 lpi = readl(ioaddr + XGMAC_LPI_CTRL); - if (lpi & XGMAC_TLPIEN) { + if (lpi & LPI_CTRL_STATUS_TLPIEN) { ret |= CORE_IRQ_TX_PATH_IN_LPI_MODE; x->irq_tx_path_in_lpi_mode_n++; } - if (lpi & XGMAC_TLPIEX) { + if (lpi & LPI_CTRL_STATUS_TLPIEX) { ret |= CORE_IRQ_TX_PATH_EXIT_LPI_MODE; x->irq_tx_path_exit_lpi_mode_n++; } - if (lpi & XGMAC_RLPIEN) + if (lpi & LPI_CTRL_STATUS_RLPIEN) x->irq_rx_path_in_lpi_mode_n++; - if (lpi & XGMAC_RLPIEX) + if (lpi & LPI_CTRL_STATUS_RLPIEX) x->irq_rx_path_exit_lpi_mode_n++; } @@ -433,9 +433,9 @@ static void dwxgmac2_set_eee_mode(struct mac_device_info *hw, value = readl(ioaddr + XGMAC_LPI_CTRL); - value |= XGMAC_LPITXEN | XGMAC_LPITXA; + value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; if (en_tx_lpi_clockgating) - value |= XGMAC_TXCGE; + value |= LPI_CTRL_STATUS_LPITCSE; writel(value, ioaddr + XGMAC_LPI_CTRL); } @@ -446,7 +446,7 @@ static void dwxgmac2_reset_eee_mode(struct mac_device_info *hw) u32 value; value = readl(ioaddr + XGMAC_LPI_CTRL); - value &= ~(XGMAC_LPITXEN | XGMAC_LPITXA | XGMAC_TXCGE); + value &= ~(LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA | LPI_CTRL_STATUS_LPITCSE); writel(value, ioaddr + XGMAC_LPI_CTRL); } @@ -457,9 +457,9 @@ static void dwxgmac2_set_eee_pls(struct mac_device_info *hw, int link) value = readl(ioaddr + XGMAC_LPI_CTRL); if (link) - value |= XGMAC_PLS; + value |= LPI_CTRL_STATUS_PLS; else - value &= ~XGMAC_PLS; + value &= ~LPI_CTRL_STATUS_PLS; writel(value, ioaddr + XGMAC_LPI_CTRL); } From patchwork Tue Jan 28 15:47:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952672 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 609301D63CC for ; Tue, 28 Jan 2025 15:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079290; cv=none; b=Y7gZO+U1SEDOY+KQsCHNyltwAGvFVrY/IDffYjwa74hSohxeE0qAJO5Ur03TQgD5a4T39Ekzy4GpiIdzIYkmd9hlVwRt8W43IslZRtEjG3vdiqdK9Ozqj8QfE4kQNVg5nTBx7oDCGn2RcpVo2lhMRN2IV4I9BQohFWKtlq82Qp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079290; c=relaxed/simple; bh=YV5l/XFy8YdmRfdAARdyuGsLA+oCwXvTW+hHMjbJa0I=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=bqle1HF0prgxLHRD5z3aFQ8gv3HVbEZzdqYmRwV3AhMwuVjln1+vg086JJ4zvjWuMmbD8SmxqeoIVYCPyuhqXdX8Txp/FgMjJ0vYpMJq1I6Qdya6jTgjNF6RqY/8mJUEOkN04uc6dimDO2G6hZUcz9/eFAQ2k7weHltUuPVUyN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=PveBDKny; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="PveBDKny" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1YBzEe/H5RKJuBk5a2TLtgHkf+Agl63gaQLV5BGeS+8=; b=PveBDKnyRgwX82zNa1Bm9Sze2y xgdOTr4+AFMJIhlSAFxuiYTFflxSOqZ0o0SEq9qj+oW2SgTxfyTOwgS+RMGuXJlFYUHaqI8fXJfpT d6eU163c4v8CI4rDV6Yt0j/20vsavHjv93m82LVAjKyJiKlDtFhiAzZYARAO0lZp8oACcvQh+tJbU djCIh3Q7eH/9gFMlp8fwxnEbDu3C6F1NlNJj0bELkPexYOuMw9Qnyj0wu9KIFWeMuKqPwhDj6FLCL I/Zk9oAiyWmdWRdm/NN+kjEMTFx1p0+swRroBPLHvfO+QuQaia2uUQCLF6qfeVNjeii6tMN+gyFDJ Be9Lnk8w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:42478 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnom-0007Vc-1f; Tue, 28 Jan 2025 15:48:00 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnoT-0037H8-5s; Tue, 28 Jan 2025 15:47:41 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 11/22] net: stmmac: add new MAC method set_lpi_mode() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:41 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add a new method to control LPI mode configuration. This is architected to have three configuration states: LPI disabled, LPI forced (active), or LPI under hardware timer control. This reflects the three modes which the main body of the driver wishes to deal with. We pass in whether transmit clock gating should be used, and the hardware timer value in microseconds to be set when using hardware timer control. Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 33 ++++---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 83 +++++++++++-------- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 36 +++++--- drivers/net/ethernet/stmicro/stmmac/hwif.h | 11 +++ 4 files changed, 102 insertions(+), 61 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 96bcda0856ec..622f5ef241d4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -342,31 +342,35 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, return ret; } -static void dwmac1000_set_eee_mode(struct mac_device_info *hw, - bool en_tx_lpi_clockgating) +static int dwmac1000_set_lpi_mode(struct mac_device_info *hw, + enum stmmac_lpi_mode mode, + bool en_tx_lpi_clockgating, u32 et) { void __iomem *ioaddr = hw->pcsr; u32 value; - /*TODO - en_tx_lpi_clockgating treatment */ + if (mode == STMMAC_LPI_TIMER) + return -EOPNOTSUPP; - /* Enable the link status receive on RGMII, SGMII ore SMII - * receive path and instruct the transmit to enter in LPI - * state. - */ value = readl(ioaddr + LPI_CTRL_STATUS); - value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; + if (mode == STMMAC_LPI_FORCED) + value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; + else + value &= ~(LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA); writel(value, ioaddr + LPI_CTRL_STATUS); + + return 0; } -static void dwmac1000_reset_eee_mode(struct mac_device_info *hw) +static void dwmac1000_set_eee_mode(struct mac_device_info *hw, + bool en_tx_lpi_clockgating) { - void __iomem *ioaddr = hw->pcsr; - u32 value; + dwmac1000_set_lpi_mode(hw, STMMAC_LPI_FORCED, en_tx_lpi_clockgating, 0); +} - value = readl(ioaddr + LPI_CTRL_STATUS); - value &= ~(LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA); - writel(value, ioaddr + LPI_CTRL_STATUS); +static void dwmac1000_reset_eee_mode(struct mac_device_info *hw) +{ + dwmac1000_set_lpi_mode(hw, STMMAC_LPI_DISABLE, false, 0); } static void dwmac1000_set_eee_pls(struct mac_device_info *hw, int link) @@ -509,6 +513,7 @@ const struct stmmac_ops dwmac1000_ops = { .pmt = dwmac1000_pmt, .set_umac_addr = dwmac1000_set_umac_addr, .get_umac_addr = dwmac1000_get_umac_addr, + .set_lpi_mode = dwmac1000_set_lpi_mode, .set_eee_mode = dwmac1000_set_eee_mode, .reset_eee_mode = dwmac1000_reset_eee_mode, .set_eee_timer = dwmac1000_set_eee_timer, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index c324aaf691e0..dc2d8c096fa3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -376,35 +376,61 @@ static void dwmac4_get_umac_addr(struct mac_device_info *hw, GMAC_ADDR_LOW(reg_n)); } -static void dwmac4_set_eee_mode(struct mac_device_info *hw, - bool en_tx_lpi_clockgating) +static int dwmac4_set_lpi_mode(struct mac_device_info *hw, + enum stmmac_lpi_mode mode, + bool en_tx_lpi_clockgating, u32 et) { void __iomem *ioaddr = hw->pcsr; - u32 value; + u32 value, mask; + + if (mode == STMMAC_LPI_DISABLE) { + value = 0; + } else { + value = LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; + + if (mode == STMMAC_LPI_TIMER) { + /* Return ERANGE if the timer is larger than the + * register field. + */ + if (et > STMMAC_ET_MAX) + return -ERANGE; + + /* Set the hardware LPI entry timer */ + writel(et, ioaddr + GMAC4_LPI_ENTRY_TIMER); + + /* Interpret a zero LPI entry timer to mean + * immediate entry into LPI mode. + */ + if (et) + value |= LPI_CTRL_STATUS_LPIATE; + } + + if (en_tx_lpi_clockgating) + value |= LPI_CTRL_STATUS_LPITCSE; + } + + mask = LPI_CTRL_STATUS_LPIATE | LPI_CTRL_STATUS_LPIEN | + LPI_CTRL_STATUS_LPITXA; + + value |= readl(ioaddr + GMAC4_LPI_CTRL_STATUS) & ~mask; + writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); + + return 0; +} +static void dwmac4_set_eee_mode(struct mac_device_info *hw, + bool en_tx_lpi_clockgating) +{ /* Enable the link status receive on RGMII, SGMII ore SMII * receive path and instruct the transmit to enter in LPI * state. */ - value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - value &= ~LPI_CTRL_STATUS_LPIATE; - value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; - - if (en_tx_lpi_clockgating) - value |= LPI_CTRL_STATUS_LPITCSE; - - writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); + dwmac4_set_lpi_mode(hw, STMMAC_LPI_FORCED, en_tx_lpi_clockgating, 0); } static void dwmac4_reset_eee_mode(struct mac_device_info *hw) { - void __iomem *ioaddr = hw->pcsr; - u32 value; - - value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - value &= ~(LPI_CTRL_STATUS_LPIATE | LPI_CTRL_STATUS_LPIEN | - LPI_CTRL_STATUS_LPITXA); - writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); + dwmac4_set_lpi_mode(hw, STMMAC_LPI_DISABLE, false, 0); } static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link) @@ -424,23 +450,7 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link) static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, u32 et) { - void __iomem *ioaddr = hw->pcsr; - u32 value = et & STMMAC_ET_MAX; - int regval; - - /* Program LPI entry timer value into register */ - writel(value, ioaddr + GMAC4_LPI_ENTRY_TIMER); - - /* Enable/disable LPI entry timer */ - regval = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); - regval |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; - - if (et) - regval |= LPI_CTRL_STATUS_LPIATE; - else - regval &= ~LPI_CTRL_STATUS_LPIATE; - - writel(regval, ioaddr + GMAC4_LPI_CTRL_STATUS); + dwmac4_set_lpi_mode(hw, STMMAC_LPI_TIMER, false, et & STMMAC_ET_MAX); } static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw) @@ -1203,6 +1213,7 @@ const struct stmmac_ops dwmac4_ops = { .pmt = dwmac4_pmt, .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, + .set_lpi_mode = dwmac4_set_lpi_mode, .set_eee_mode = dwmac4_set_eee_mode, .reset_eee_mode = dwmac4_reset_eee_mode, .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, @@ -1247,6 +1258,7 @@ const struct stmmac_ops dwmac410_ops = { .pmt = dwmac4_pmt, .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, + .set_lpi_mode = dwmac4_set_lpi_mode, .set_eee_mode = dwmac4_set_eee_mode, .reset_eee_mode = dwmac4_reset_eee_mode, .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, @@ -1293,6 +1305,7 @@ const struct stmmac_ops dwmac510_ops = { .pmt = dwmac4_pmt, .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, + .set_lpi_mode = dwmac4_set_lpi_mode, .set_eee_mode = dwmac4_set_eee_mode, .reset_eee_mode = dwmac4_reset_eee_mode, .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index 19cfb1dcb332..51c37a1180ac 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -425,29 +425,39 @@ static void dwxgmac2_get_umac_addr(struct mac_device_info *hw, addr[5] = (hi_addr >> 8) & 0xff; } -static void dwxgmac2_set_eee_mode(struct mac_device_info *hw, - bool en_tx_lpi_clockgating) +static int dwxgmac2_set_lpi_mode(struct mac_device_info *hw, + enum stmmac_lpi_mode mode, + bool en_tx_lpi_clockgating, u32 et) { void __iomem *ioaddr = hw->pcsr; u32 value; + if (mode == STMMAC_LPI_TIMER) + return -EOPNOTSUPP; + value = readl(ioaddr + XGMAC_LPI_CTRL); + if (mode == STMMAC_LPI_FORCED) { + value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; + if (en_tx_lpi_clockgating) + value |= LPI_CTRL_STATUS_LPITCSE; + } else { + value &= ~(LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA | + LPI_CTRL_STATUS_LPITCSE); + } + writel(value, ioaddr + XGMAC_LPI_CTRL); - value |= LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA; - if (en_tx_lpi_clockgating) - value |= LPI_CTRL_STATUS_LPITCSE; + return 0; +} - writel(value, ioaddr + XGMAC_LPI_CTRL); +static void dwxgmac2_set_eee_mode(struct mac_device_info *hw, + bool en_tx_lpi_clockgating) +{ + dwxgmac2_set_lpi_mode(hw, STMMAC_LPI_FORCED, en_tx_lpi_clockgating, 0); } static void dwxgmac2_reset_eee_mode(struct mac_device_info *hw) { - void __iomem *ioaddr = hw->pcsr; - u32 value; - - value = readl(ioaddr + XGMAC_LPI_CTRL); - value &= ~(LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA | LPI_CTRL_STATUS_LPITCSE); - writel(value, ioaddr + XGMAC_LPI_CTRL); + dwxgmac2_set_lpi_mode(hw, STMMAC_LPI_DISABLE, false, 0); } static void dwxgmac2_set_eee_pls(struct mac_device_info *hw, int link) @@ -1525,6 +1535,7 @@ const struct stmmac_ops dwxgmac210_ops = { .pmt = dwxgmac2_pmt, .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, + .set_lpi_mode = dwxgmac2_set_lpi_mode, .set_eee_mode = dwxgmac2_set_eee_mode, .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, @@ -1582,6 +1593,7 @@ const struct stmmac_ops dwxlgmac2_ops = { .pmt = dwxgmac2_pmt, .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, + .set_lpi_mode = dwxgmac2_set_lpi_mode, .set_eee_mode = dwxgmac2_set_eee_mode, .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 0f200b72c225..7279d30d6a8b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -306,6 +306,12 @@ struct stmmac_pps_cfg; struct stmmac_rss; struct stmmac_est; +enum stmmac_lpi_mode { + STMMAC_LPI_DISABLE, + STMMAC_LPI_FORCED, + STMMAC_LPI_TIMER, +}; + /* Helpers to program the MAC core */ struct stmmac_ops { /* MAC core initialization */ @@ -360,6 +366,9 @@ struct stmmac_ops { unsigned int reg_n); void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr, unsigned int reg_n); + int (*set_lpi_mode)(struct mac_device_info *hw, + enum stmmac_lpi_mode mode, + bool en_tx_lpi_clockgating, u32 et); void (*set_eee_mode)(struct mac_device_info *hw, bool en_tx_lpi_clockgating); void (*reset_eee_mode)(struct mac_device_info *hw); @@ -467,6 +476,8 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, set_umac_addr, __args) #define stmmac_get_umac_addr(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, get_umac_addr, __args) +#define stmmac_set_lpi_mode(__priv, __args...) \ + stmmac_do_callback(__priv, mac, set_lpi_mode, __args) #define stmmac_set_eee_mode(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_eee_mode, __args) #define stmmac_reset_eee_mode(__priv, __args...) \ From patchwork Tue Jan 28 15:47:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952673 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 B7EEC1D7E5C for ; Tue, 28 Jan 2025 15:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079293; cv=none; b=qiDqB2CyJ6WqZaLA6+dWOhhzom0H94xS3AferqXoPODwgDRlKAr6A1caExE2lzcIsGAu8257zronpjerWTbnhiLuHJvHMWwucOyi+rCabjaztkdPJs16YIYQBolwk6H50RSVfaVUTBCQUT+4dhPST29HyWv968DXZnODmw/XbNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079293; c=relaxed/simple; bh=FlnTT8+vKXxq0u9C0gjUSaAOgSfohUh82yFgJOybJ8k=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=R8ZJHn5TY5Yc3CQXMnW/ghuS9b3eEODzTTDD5ATljH9IkV4OWFPTB7gP5V1ljkH+uUkvEciYdKHMd5cQti+1Lb8j6PREWqF3fX4j9m8q7z4kU6SupR2kG4V/jVt/+iloM9yIvM2C/D7EKP9kFyhGK8MmohJy2TfIYP1ZehUfHyk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=jf5RPJXm; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="jf5RPJXm" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KOsTTbEIKnn1lDtoP6teYS5Q0yZvLkrVNJM/olKSH7k=; b=jf5RPJXm7QPeusxBSDM96GLvKP aaFex/REZNch/cfb9BENRZXIbOoIZH818x7HEhrpCxVrHj184z71pAFTjIomidNTN/ARIRGhOU+Pg WHg9V5IRVKwNbd5+nJB7ebHBLuJguE0MZOtVFaJAxZU/Ma9KpCEgooPg8U1MiUxbGGvaLP7IpsFfQ mrAuVWEeQrPusg0H0NCN01MGeYn+gOBcOrZehlm7K92JXeGg8+yhOqFRGQ+GsYyGipEqQBQC5YoMh kOVgt6G/GDQnSfE9EJ+tN3kuDPmkrIGijfow4PDvJuCtJo+G6E7gw0sE0AwKsHEE3fD//swjzwcoD a7UkPLtQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50182 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnor-0007Vr-21; Tue, 28 Jan 2025 15:48:05 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnoY-0037HE-A6; Tue, 28 Jan 2025 15:47:46 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 12/22] net: stmmac: dwmac4: clear LPI_CTRL_STATUS_LPITCSE too Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:46 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Ensure that LPI_CTRL_STATUS_LPITCSE is also appropriately cleared when disabling LPI or enabling LPI without TX clock gating. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index dc2d8c096fa3..ed42e1477cf8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -410,7 +410,7 @@ static int dwmac4_set_lpi_mode(struct mac_device_info *hw, } mask = LPI_CTRL_STATUS_LPIATE | LPI_CTRL_STATUS_LPIEN | - LPI_CTRL_STATUS_LPITXA; + LPI_CTRL_STATUS_LPITXA | LPI_CTRL_STATUS_LPITCSE; value |= readl(ioaddr + GMAC4_LPI_CTRL_STATUS) & ~mask; writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); From patchwork Tue Jan 28 15:47:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952674 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 82D121D47B4 for ; Tue, 28 Jan 2025 15:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079300; cv=none; b=j8oKrpoxEd5nl5jtPn9DF7TYdb6wd6SfsEqOn3y5RXE/J2eiGxdF0U5PLz24X1akZnnknFldv/LolicdzzNX0FoWefcByyIauBJkHLlt0HKzb7h1rjlUrrEMtKZcfvDBrJ7A6Dkb4wQn+Av4a2u9c0QfjpbRYjOo2oqEAhb5hRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079300; c=relaxed/simple; bh=Sz+v0KIS0xejJ8s+pO17deHQGwg7ZoRS5a5YW/z/gSI=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=OSama2n73hmetgw1mXQdm/jZDsqITHbe/BvzRy7yIhvmCgi3LB7/1kF4BrqSPiCQBEZUC3dux22fe8+Az6dzJNtdFZMta+dC8TB0wakhtt1sN/tWVBaHaVWith+Bm6LlAxDFwoylA5LEVceBSVkjyLCsqHROTYz45laP2T0soUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=X/7G3ku2; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="X/7G3ku2" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TiDJSvJNzK27YwKwilomGm2u5RweY/NCsbPGAL9OV2I=; b=X/7G3ku2yXh8QSbbTwmW+wYkcp UPyJnO9Xj1Hkbq82GIq4vdZkqgwOH56Y2+Q4UjSp2EwHuLvfnEvuSf17f9c33TqiHPVCIU01sLn4o HsCyZMCXAE/ovdye2juvZvowFaN8m8BnHMPSfBjtB7DY6EDvV7pzTIWzWzUmIjcGGOj7cGAfQiu0I +y2rHotrK+Ub/8cyRWmb8e7qyVpoTebEg1uwOjiGFQ+uUl6dMC5owdeli8ws1PUThlNDIwgfMgelx jgxBVLqWiGpFU7RYOTBOFd8VDksHUeWhMS8seEw5zT21yETbhxjHfRBtS3a327DI91d5pGS4aYnN6 OXKgEGIA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50184 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnow-0007WB-2K; Tue, 28 Jan 2025 15:48:10 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnod-0037HK-Di; Tue, 28 Jan 2025 15:47:51 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 13/22] net: stmmac: use stmmac_set_lpi_mode() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:51 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Use the new stmmac_set_lpi_mode() API to configure the parameters of the desired LPI mode rather than the older methods. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index aafd9cee304e..5b47b2ad6b49 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -390,11 +390,6 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue) return dirty; } -static void stmmac_enable_hw_lpi_timer(struct stmmac_priv *priv) -{ - stmmac_set_eee_lpi_timer(priv, priv->hw, priv->tx_lpi_timer); -} - static bool stmmac_eee_tx_busy(struct stmmac_priv *priv) { u32 tx_cnt = priv->plat->tx_queues_to_use; @@ -431,8 +426,9 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv) /* Check and enter in LPI mode */ if (!priv->tx_path_in_lpi_mode) - stmmac_set_eee_mode(priv, priv->hw, - priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING); + stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_FORCED, + priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING, + 0); } /** @@ -443,7 +439,7 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv) static void stmmac_stop_sw_lpi(struct stmmac_priv *priv) { del_timer_sync(&priv->eee_ctrl_timer); - stmmac_reset_eee_mode(priv, priv->hw); + stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_DISABLE, false, 0); priv->tx_path_in_lpi_mode = false; } @@ -1046,7 +1042,7 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) netdev_dbg(priv->dev, "disable EEE\n"); priv->eee_sw_timer_en = false; del_timer_sync(&priv->eee_ctrl_timer); - stmmac_reset_eee_mode(priv, priv->hw); + stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_DISABLE, false, 0); priv->tx_path_in_lpi_mode = false; stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); @@ -1061,6 +1057,7 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clk_stop) { struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); + int ret; priv->tx_lpi_timer = timer; priv->eee_active = true; @@ -1075,11 +1072,15 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, true); - if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) { - /* Use hardware LPI mode */ - stmmac_enable_hw_lpi_timer(priv); - } else { - /* Use software LPI mode */ + /* Try to cnfigure the hardware timer. */ + ret = stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_TIMER, + priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING, + priv->tx_lpi_timer); + + if (ret) { + /* Hardware timer mode not supported, or value out of range. + * Fall back to using software LPI mode + */ priv->eee_sw_timer_en = true; stmmac_restart_sw_lpi_timer(priv); } From patchwork Tue Jan 28 15:47:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952675 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 802A81D618E for ; Tue, 28 Jan 2025 15:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079306; cv=none; b=kwRTvfd2oDX/PXlznV/C4j6/UVe16+MiZyeSBEgToyP3dojsE9YIZ9/j9jnlbC+F0xSLyqIIhBr/DqQsF4SRMtulN+cTWrgXW7fA4TYpOzw/ntUjVzJfkU3AzL1eu5n98mwhpRrOwz6rqgwdTDpwd0RAbCfNuWJsJzP3Np8FuZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079306; c=relaxed/simple; bh=ckAzZ6uNx6H0/GjJjFx7zCzWRXvagDHbKAhO82LWxDI=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=GmycIf4BOfPG3bw/B+8Wd2s8se0rJYucUzspi6wCiyOzcElgEZER+jimdD97DHTd+3fn0CsvSOdL9m/TE9xeJYX+4/pzNzCIJ0RT1dIUeY5Kp5AWATL19de3Dez2QRtDZsYH8Z1byZsOumMzrYQymBgMlLjkJr/nUzmutMWY6ts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=xuhKidjn; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="xuhKidjn" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ksgaCjHXcNTsY42mVRcdo2AzL+mmzyJ8+XW8+N+WA34=; b=xuhKidjns8i42OiR8OCyzb21qU 18Uy4KhSwZWUVfZaXMnJvQiLy+NSKXzHy80rnOLdW24JroeHl5N7oePrh5BzH7nb6yol3fJt5aqd7 RwtKehCd4lPyVBctJYRZorSWNpDozn8N+dYQ3U5rDQMJiR5P2C1F/U0G+Xpb9B8/tQY6/qNdhcqXB 8AQeB0p26LVzeIHA0L2i8us1sWj190mNZbOwOcfUkhOmEjI5pqynpviFe9Xf5+n9LMYMmiRBJuMi2 G8Zk9e1+Lkoe382NKvUt7p/986A2ZQXDAZc+zps5ADyBEe/UlTYx8QZyH3HULiOCdD7NwCFOw6d7u hc3rSciQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39556 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnp2-0007WS-12; Tue, 28 Jan 2025 15:48:16 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnoi-0037HQ-Hc; Tue, 28 Jan 2025 15:47:56 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 14/22] net: stmmac: remove old EEE methods Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:47:56 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC As we no longer call the set_eee_mode(), reset_eee_mode() and set_eee_lpi_entry_timer() methods, remove these and their glue in common.h Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 13 --------- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 29 ------------------- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 15 ---------- drivers/net/ethernet/stmicro/stmmac/hwif.h | 10 ------- 4 files changed, 67 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 622f5ef241d4..7900bf3effa7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -362,17 +362,6 @@ static int dwmac1000_set_lpi_mode(struct mac_device_info *hw, return 0; } -static void dwmac1000_set_eee_mode(struct mac_device_info *hw, - bool en_tx_lpi_clockgating) -{ - dwmac1000_set_lpi_mode(hw, STMMAC_LPI_FORCED, en_tx_lpi_clockgating, 0); -} - -static void dwmac1000_reset_eee_mode(struct mac_device_info *hw) -{ - dwmac1000_set_lpi_mode(hw, STMMAC_LPI_DISABLE, false, 0); -} - static void dwmac1000_set_eee_pls(struct mac_device_info *hw, int link) { void __iomem *ioaddr = hw->pcsr; @@ -514,8 +503,6 @@ const struct stmmac_ops dwmac1000_ops = { .set_umac_addr = dwmac1000_set_umac_addr, .get_umac_addr = dwmac1000_get_umac_addr, .set_lpi_mode = dwmac1000_set_lpi_mode, - .set_eee_mode = dwmac1000_set_eee_mode, - .reset_eee_mode = dwmac1000_reset_eee_mode, .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index ed42e1477cf8..cc4ddf608652 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -418,21 +418,6 @@ static int dwmac4_set_lpi_mode(struct mac_device_info *hw, return 0; } -static void dwmac4_set_eee_mode(struct mac_device_info *hw, - bool en_tx_lpi_clockgating) -{ - /* Enable the link status receive on RGMII, SGMII ore SMII - * receive path and instruct the transmit to enter in LPI - * state. - */ - dwmac4_set_lpi_mode(hw, STMMAC_LPI_FORCED, en_tx_lpi_clockgating, 0); -} - -static void dwmac4_reset_eee_mode(struct mac_device_info *hw) -{ - dwmac4_set_lpi_mode(hw, STMMAC_LPI_DISABLE, false, 0); -} - static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link) { void __iomem *ioaddr = hw->pcsr; @@ -448,11 +433,6 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link) writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS); } -static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, u32 et) -{ - dwmac4_set_lpi_mode(hw, STMMAC_LPI_TIMER, false, et & STMMAC_ET_MAX); -} - static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw) { void __iomem *ioaddr = hw->pcsr; @@ -1214,9 +1194,6 @@ const struct stmmac_ops dwmac4_ops = { .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, .set_lpi_mode = dwmac4_set_lpi_mode, - .set_eee_mode = dwmac4_set_eee_mode, - .reset_eee_mode = dwmac4_reset_eee_mode, - .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, @@ -1259,9 +1236,6 @@ const struct stmmac_ops dwmac410_ops = { .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, .set_lpi_mode = dwmac4_set_lpi_mode, - .set_eee_mode = dwmac4_set_eee_mode, - .reset_eee_mode = dwmac4_reset_eee_mode, - .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, @@ -1306,9 +1280,6 @@ const struct stmmac_ops dwmac510_ops = { .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, .set_lpi_mode = dwmac4_set_lpi_mode, - .set_eee_mode = dwmac4_set_eee_mode, - .reset_eee_mode = dwmac4_reset_eee_mode, - .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index 51c37a1180ac..a6d395c6bacd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -449,17 +449,6 @@ static int dwxgmac2_set_lpi_mode(struct mac_device_info *hw, return 0; } -static void dwxgmac2_set_eee_mode(struct mac_device_info *hw, - bool en_tx_lpi_clockgating) -{ - dwxgmac2_set_lpi_mode(hw, STMMAC_LPI_FORCED, en_tx_lpi_clockgating, 0); -} - -static void dwxgmac2_reset_eee_mode(struct mac_device_info *hw) -{ - dwxgmac2_set_lpi_mode(hw, STMMAC_LPI_DISABLE, false, 0); -} - static void dwxgmac2_set_eee_pls(struct mac_device_info *hw, int link) { void __iomem *ioaddr = hw->pcsr; @@ -1536,8 +1525,6 @@ const struct stmmac_ops dwxgmac210_ops = { .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, .set_lpi_mode = dwxgmac2_set_lpi_mode, - .set_eee_mode = dwxgmac2_set_eee_mode, - .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, .set_eee_pls = dwxgmac2_set_eee_pls, .debug = NULL, @@ -1594,8 +1581,6 @@ const struct stmmac_ops dwxlgmac2_ops = { .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, .set_lpi_mode = dwxgmac2_set_lpi_mode, - .set_eee_mode = dwxgmac2_set_eee_mode, - .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, .set_eee_pls = dwxgmac2_set_eee_pls, .debug = NULL, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 7279d30d6a8b..27c63a9fc163 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -369,10 +369,6 @@ struct stmmac_ops { int (*set_lpi_mode)(struct mac_device_info *hw, enum stmmac_lpi_mode mode, bool en_tx_lpi_clockgating, u32 et); - void (*set_eee_mode)(struct mac_device_info *hw, - bool en_tx_lpi_clockgating); - void (*reset_eee_mode)(struct mac_device_info *hw); - void (*set_eee_lpi_entry_timer)(struct mac_device_info *hw, u32 et); void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw); void (*set_eee_pls)(struct mac_device_info *hw, int link); void (*debug)(struct stmmac_priv *priv, void __iomem *ioaddr, @@ -478,12 +474,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, get_umac_addr, __args) #define stmmac_set_lpi_mode(__priv, __args...) \ stmmac_do_callback(__priv, mac, set_lpi_mode, __args) -#define stmmac_set_eee_mode(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, set_eee_mode, __args) -#define stmmac_reset_eee_mode(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, reset_eee_mode, __args) -#define stmmac_set_eee_lpi_timer(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, set_eee_lpi_entry_timer, __args) #define stmmac_set_eee_timer(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_eee_timer, __args) #define stmmac_set_eee_pls(__priv, __args...) \ From patchwork Tue Jan 28 15:48:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952676 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 C57A51D63EF for ; Tue, 28 Jan 2025 15:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079310; cv=none; b=Izrul9OatdfyVjffcE9B9bMgNu30wrCnGLqD+IjA2QEB10BrGwfA3tB470+FB/LOrvzRjOoKwPbaErGkeEM7eBYVUjLLybJkXo7/tCbsXxvLEVTAZlYtJfIsERyV36VTiThkmQJG+P/Fx3g5epFUwsiWfyRHnIg6UagJizkHczQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079310; c=relaxed/simple; bh=9zcrminkBJIkeIfYSeCwqEcLknqlz9U9BpYU/7WSVb0=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=Y5dI6L8RObk/f4YFqlc8Tts1uAs+9VUdHT4XHc/ILWxAs92eFnhgIyiHpbThf3XsHY/U26HoWZEP0aTDOc46z8jrAjblsigYLbZgxVzQNiHj3IA5n9+wRGnXyX3BAYB7CYMLexlWx6CIvdQiyaNkzr7tH65PHI+coj1jHNxPUB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=NjKCHS4q; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="NjKCHS4q" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jXHt/5Eoh9udL8jpygkO/9L3xb0nJ0bR2NLfWApVjKY=; b=NjKCHS4q5QeyxXlRNmQy1NVAyO R/qYqGtJT98dmoWZBzDAaRauTeauxdNfqY5ZVHNsVn1vimhHa5zq8TX1cYKhgNw6+sNB/8kShCYFj zfTC5Vf+mZFMF2Do/YHLN5SrCiac5ZMOEFSSAeDsLHbf/QtAzn5b+vTiRccqGKsp1jJOGwYhxnBCl h8HtnPU479us0zsU/ifIAta8/nkigyQtb/iPOgyLaqMRCGI3vGyi4YnHVQyq0kWTrZZ4d9JFaF6Tn z7zx1XrSsSWUuD6M65DN5nU15EWMnaE21Lt2sTVAL1sZS/yeeXRPn8R9ZqEHQo89WgXRfrryrw5oa sOqkV2bg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43234 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnp7-0007Wj-0E; Tue, 28 Jan 2025 15:48:21 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnon-0037HW-LM; Tue, 28 Jan 2025 15:48:01 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 15/22] net: phylink: add support for notifying PCS about EEE Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:01 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC There are hooks in the stmmac driver into XPCS to control the EEE settings when LPI is configured at the MAC. This bypasses the layering. To allow this to be removed from the stmmac driver, add two new methods for PCS to inform them when the LPI/EEE enablement state changes at the MAC. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 25 ++++++++++++++++++++++--- include/linux/phylink.h | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 214b62fba991..840af19488d8 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1073,6 +1073,18 @@ static void phylink_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, pcs->ops->pcs_link_up(pcs, neg_mode, interface, speed, duplex); } +static void phylink_pcs_disable_eee(struct phylink_pcs *pcs) +{ + if (pcs && pcs->ops->pcs_disable_eee) + pcs->ops->pcs_disable_eee(pcs); +} + +static void phylink_pcs_enable_eee(struct phylink_pcs *pcs) +{ + if (pcs && pcs->ops->pcs_enable_eee) + pcs->ops->pcs_enable_eee(pcs); +} + /* Query inband for a specific interface mode, asking the MAC for the * PCS which will be used to handle the interface mode. */ @@ -1601,6 +1613,8 @@ static void phylink_deactivate_lpi(struct phylink *pl) phylink_dbg(pl, "disabling LPI\n"); pl->mac_ops->mac_disable_tx_lpi(pl->config); + + phylink_pcs_disable_eee(pl->pcs); } } @@ -1617,13 +1631,18 @@ static void phylink_activate_lpi(struct phylink *pl) phylink_dbg(pl, "LPI timer %uus, tx clock stop %u\n", pl->mac_tx_lpi_timer, pl->mac_tx_clk_stop); + phylink_pcs_enable_eee(pl->pcs); + err = pl->mac_ops->mac_enable_tx_lpi(pl->config, pl->mac_tx_lpi_timer, pl->mac_tx_clk_stop); - if (!err) - pl->mac_enable_tx_lpi = true; - else + if (err) { + phylink_pcs_disable_eee(pl->pcs); phylink_err(pl, "%ps() failed: %pe\n", pl->mac_ops->mac_enable_tx_lpi, ERR_PTR(err)); + return; + } + + pl->mac_enable_tx_lpi = true; } static void phylink_link_up(struct phylink *pl, diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 898b00451bbf..a692d638568f 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -477,6 +477,10 @@ struct phylink_pcs { * @pcs_an_restart: restart 802.3z BaseX autonegotiation. * @pcs_link_up: program the PCS for the resolved link configuration * (where necessary). + * @pcs_disable_eee: optional notification to PCS that EEE has been disabled + * at the MAC. + * @pcs_enable_eee: optional notification to PCS that EEE will be enabled at + * the MAC. * @pcs_pre_init: configure PCS components necessary for MAC hardware * initialization e.g. RX clock for stmmac. */ @@ -500,6 +504,8 @@ struct phylink_pcs_ops { void (*pcs_an_restart)(struct phylink_pcs *pcs); void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, int speed, int duplex); + void (*pcs_disable_eee)(struct phylink_pcs *pcs); + void (*pcs_enable_eee)(struct phylink_pcs *pcs); int (*pcs_pre_init)(struct phylink_pcs *pcs); }; @@ -625,6 +631,22 @@ void pcs_an_restart(struct phylink_pcs *pcs); void pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, int speed, int duplex); +/** + * pcs_disable_eee() - Disable EEE at the PCS + * @pcs: a pointer to a &struct phylink_pcs + * + * Optional method informing the PCS that EEE has been disabled at the MAC. + */ +void pcs_disable_eee(struct phylink_pcs *pcs); + +/** + * pcs_enable_eee() - Enable EEE at the PCS + * @pcs: a pointer to a &struct phylink_pcs + * + * Optional method informing the PCS that EEE is about to be enabled at the MAC. + */ +void pcs_enable_eee(struct phylink_pcs *pcs); + /** * pcs_pre_init() - Configure PCS components necessary for MAC initialization * @pcs: a pointer to a &struct phylink_pcs. From patchwork Tue Jan 28 15:48:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952677 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 2F1B51D61A4 for ; Tue, 28 Jan 2025 15:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079314; cv=none; b=HmCXoj7jLIHQhlpQn/+wMQYPELkeEamzUpMRZvqYkratSjzSiRHkut9xN2yvx+IHjHhmbgWYPT8WC5L83iudlisXphEXYmlbaIX9VQTa3bHNjxGstbZNcezenNRcZKw0F+fDmPEozupQsG1/Zs00wq/4rTGLT2Y/XZKL/6jz/tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079314; c=relaxed/simple; bh=3lEjclNIQAarZZzElBDdf9g3ebKiSzxLxIypX+Un3Ng=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=MfPbLYqOPNVLyQnuyfS1ZO1g3D2hY+OCe8cg1RQKO/6yFlR+pCRBqhq7tLMBQvsn0c/hRTb3g6HBDC41t5vhotmKcTFWsTnOK8rNoWnOc5GIi6oYbFdnUWbU2Vs6X4pXxa5U8oKfFOgPesn/wjcY3RlpiBZ/z5lWKoJ3Q4UuB+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=sQL2X3J9; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="sQL2X3J9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CSrV54CZkdKosAaMmEy/XHbQ07NRRzWFba+cISFZsFY=; b=sQL2X3J9A+Dxb9UAwmqesJ2Wr1 YjcLEMsf59y60fdMHdoNTi6mtYzZqVNjjLKxxk086u1VtYEGtL8ltTZMypyd70hQt/W1m6LZR4st9 yf0zpZs/b8ZBZ0+NqDT78/L6au0OyMecHvaEjafeoVnlYQQ/mHLNIH/0b3ewR+ovOqtPahp7ly7kD y+YnZm0asTsdFqZcN0y05zElSblq/1lJk3Cqf6DF9BL3qfqzR/Ku2BA/UW3XEceubuKzmslu+pxM2 zai3JEigmtoDN2WdnniOUs/YK0hpZOpto8VH8/MdD3TqPtvQcY3wi48qvvH8AdZeTioUCR5+tEFbg FuV4TEGg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43236 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpC-0007X0-0G; Tue, 28 Jan 2025 15:48:26 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnos-0037Hc-PG; Tue, 28 Jan 2025 15:48:06 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 16/22] net: xpcs: add function to configure EEE clock multiplying factor Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:06 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add a function to separate out the EEE clock multiplying factor. This will be called by the stmmac driver to configure this value. It would have been better had the driver used the CLK API to retrieve this clock, get its rate and calculate the appropriate multiplier, but that door has closed. Question: Is there any other solution to this so we can avoid keeping this XPCS-specific function that MAC drivers have to know about if they are going to use EEE with XPCS? Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-xpcs.c | 14 ++++++++++++++ drivers/net/pcs/pcs-xpcs.h | 1 + include/linux/pcs/pcs-xpcs.h | 1 + 3 files changed, 16 insertions(+) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 1faa37f0e7b9..91ce4b13df32 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1193,6 +1193,20 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) BMCR_ANRESTART); } +/** + * xpcs_config_eee_mult_fact() - set the EEE clock multiplying factor + * @xpcs: pointer to a &struct dw_xpcs instance + * @mult_fact: the multiplying factor + * + * Configure the EEE clock multiplying factor. This value should be such that + * clk_eee_time_period * (mult_fact + 1) is within the range 80 to 120ns. + */ +void xpcs_config_eee_mult_fact(struct dw_xpcs *xpcs, u8 mult_fact) +{ + xpcs->eee_mult_fact = mult_fact; +} +EXPORT_SYMBOL_GPL(xpcs_config_eee_mult_fact); + static int xpcs_read_ids(struct dw_xpcs *xpcs) { int ret; diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h index adc5a0b3c883..39d3f517b557 100644 --- a/drivers/net/pcs/pcs-xpcs.h +++ b/drivers/net/pcs/pcs-xpcs.h @@ -122,6 +122,7 @@ struct dw_xpcs { struct phylink_pcs pcs; phy_interface_t interface; bool need_reset; + u8 eee_mult_fact; }; int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 733f4ddd2ef1..749d40a9a086 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -52,6 +52,7 @@ struct phylink_pcs *xpcs_to_phylink_pcs(struct dw_xpcs *xpcs); int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); +void xpcs_config_eee_mult_fact(struct dw_xpcs *xpcs, u8 mult_fact); struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr); struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode); void xpcs_destroy(struct dw_xpcs *xpcs); From patchwork Tue Jan 28 15:48:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952678 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 68A181CF5E2 for ; Tue, 28 Jan 2025 15:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079319; cv=none; b=lFql0I/N/wvWTORXjXreE8XArr6i+Klun1ua6Mxi1SBPC0hYPfC7g2mC18FY8ymAs+OLBTw9D4tLlZAtf2nDIqM8+1zbBwUuhgYleJ8rdhvJzl28ew3UsokYPKWh+lUJOx7MrW8e2MXPmvkyzqRhiwNZiCvIptJl0iUCZ1t3zYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079319; c=relaxed/simple; bh=Sn/MEUMsk2TVTj/tfMTfKw4YYi1N2qB0G/JoTzTjh4c=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=P2wPBOvkJWveRLjgs2Qeot/UnUx3qrYiLain8x51J9hpjoM1fKnq7xkNr/xNbzz99SO2D7FjWFGTvewxmkYND/VSTgO+woJvRMUIpENmhpDOgMjJYfGN53K4AXHcGLpd4QNrPTiX1dRjRdykjFG1JmcjP7xLeJapp4Ik6VXjiC0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=a/aV2LOt; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="a/aV2LOt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EBcD+jSZTJ87ExoztZaJ1Ni32E6UJjFerwHmJRvv+KY=; b=a/aV2LOt7xBw5yzLtxitUS1+2I L+G+Myvps3CvvfoW30NH3lqiYQYPEzbPKh2ZT5ocOFwslPs+8ApI6iZDyLIxfkxjkEdq4W8G6qvS7 VDAQfUFivavg5dU/DPyM1tTXlc2b0JMmzUHj6wlsEL++riacU/Lkud4xKYjUnAO1kvudawn7Lmhy4 avl4MXF8vu5H6byq3L4agO/dSFPJuhgl1vrKx3lrcYfN9iSCKEM/ytkDMuOtcPaYs7MbQGo4Zj9/L PA0n0HCl4DF8BgYLgCfJeFiV7BdiHvu03aVCFdg1F3zhaB7335az7NiP9nGS1FeR8ky4Weq+d9W0E 6CEUynbw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45704 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpH-0007XK-1F; Tue, 28 Jan 2025 15:48:31 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnox-0037Hi-Su; Tue, 28 Jan 2025 15:48:11 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 17/22] net: stmmac: call xpcs_config_eee_mult_fact() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:11 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Arrange for stmmac to call the new xpcs_config_eee_mult_fact() function to configure the EEE clock multiplying factor. This will allow the removal of the xpcs_config_eee() calls in the next patch. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 0c7d81ddd440..7c0a4046bbe3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -524,6 +524,8 @@ int stmmac_pcs_setup(struct net_device *ndev) if (ret) return dev_err_probe(priv->device, ret, "No xPCS found\n"); + xpcs_config_eee_mult_fact(xpcs, priv->plat->mult_fact_100ns); + priv->hw->xpcs = xpcs; return 0; From patchwork Tue Jan 28 15:48:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952679 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 09B141CF5E2 for ; Tue, 28 Jan 2025 15:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079324; cv=none; b=DWWCSISXRJm+xg1BBTVrWT4jVrC+Kw75b7kQW/K6bQw7zvmSkakL65NyvyBt6Ffxby7N5tgrUEhrSWzVUNHpNcraGkKJeI+3dKb0G0ELwfO+XY8W/Q3W5es34TBHS/ylho/WL8ILwGqEPCYtXEFS6B1YssJlw2zZoVTJuNrtxIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079324; c=relaxed/simple; bh=auudkUENHR/rzJTrBZhDpWZRXW5L7xS8S3P1pJxlUnI=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=Ise7C23HUYfrw5LJ/kEegekuH5rGOTF+m56GrVI7lsEW8KjaiObOxA4H+0FI3Ijq83stNi1PC4BI6RYbw6YQNF46PpVv8fURNc6BaWYbXb4kt4KpyxUdcsqGxyj9xd3FaJ6y4kvLh30a3OoJOLdb5pv+E7DWoDi7od8zLYZPJ+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=oe44UCKY; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="oe44UCKY" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j461s14qgObm3BQcSpP69PwmbamUjRyDGX5X2yhG5V8=; b=oe44UCKY8l5X1WRxH1YJQkcxVl E6fOGhrBZANAxzVyo9bWBMGLJGRm3n6tkqJlJcFXh4aymNHlPBKgT5MwLpAx6pp3mP33+bOs+Hb1M dKDJ+ZnGkAIah0SF2w85oC7SyZWg9hd5naUQJxaadXt3DCanjtSPt0nWN2yHNFWFaUrAqwEysDeDE 0piFftfZ+7TrcF3v207yhem/TVYpn+LwlQmkiQ18L0kHIGaZqCT6l6SdzrzXKqQ5hADUNxdreubf/ dO1V2fFUrhY0xqvnYg7kiFNr0N2tlizwpQWmRcgVgHaCaNQcnIRAL5etWHkRMESg/7rRLhrKrG1CJ DUx4H4fA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45710 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpM-0007Xf-1C; Tue, 28 Jan 2025 15:48:36 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnp3-0037Ho-0d; Tue, 28 Jan 2025 15:48:17 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 18/22] net: xpcs: convert to phylink managed EEE Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:17 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Convert XPCS to use the new pcs_disable_eee() and pcs_enable_eee() methods. Since stmmac is the only user of xpcs_config_eee(), we can make this a no-op along with this change. Questions: 1. Do we actually need this level of control at the PCS - or would it be sufficient to configure it once during initialisation? 2. Do we need to clear the mult_fact field when disabling EEE? Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-xpcs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 91ce4b13df32..1f312b5589a3 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -602,7 +602,8 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) __set_bit(compat->interface, interfaces); } -int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) +static int __xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, + int enable) { u16 mask, val; int ret; @@ -630,6 +631,11 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) DW_VR_MII_EEE_TRN_LPI, enable ? DW_VR_MII_EEE_TRN_LPI : 0); } + +int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) +{ + return 0; +} EXPORT_SYMBOL_GPL(xpcs_config_eee); static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface) @@ -1193,6 +1199,20 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) BMCR_ANRESTART); } +static void xpcs_disable_eee(struct phylink_pcs *pcs) +{ + struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); + + __xpcs_config_eee(xpcs, 0, false); +} + +static void xpcs_enable_eee(struct phylink_pcs *pcs) +{ + struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); + + __xpcs_config_eee(xpcs, xpcs->eee_mult_fact, true); +} + /** * xpcs_config_eee_mult_fact() - set the EEE clock multiplying factor * @xpcs: pointer to a &struct dw_xpcs instance @@ -1355,6 +1375,8 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_get_state = xpcs_get_state, .pcs_an_restart = xpcs_an_restart, .pcs_link_up = xpcs_link_up, + .pcs_disable_eee = xpcs_disable_eee, + .pcs_enable_eee = xpcs_enable_eee, }; static int xpcs_identify(struct dw_xpcs *xpcs) From patchwork Tue Jan 28 15:48:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952680 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 971FD1D63C3 for ; Tue, 28 Jan 2025 15:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079330; cv=none; b=iuRTF+IqWQeQBAFJFDZZG6MGfu/Uiwblm3M0cmcaSsR9jrTM/hpI3oATl88JC+KBu76OK7Gk11uKdXObDyK5YTnLjnySG7VUAaQmAVO3wm0ns1s1MGh3ThL8gY/GsaSdxMaxs1c0uQBeamLXURcz2M2kiotiMlE5YmGGYVUBLT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079330; c=relaxed/simple; bh=RSAUIm2FWuLK8gT1Q8q5b/UQFRLwytZmEWaCDOoT+mY=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=T7SpsrcAU+BmCZxhs4sCSkWLZaln0Yp1KebmN/NpyymDypktreXgiutVT7mpf042JGWkFNf98y9PDwxXwQIOY5CyopI77g/cGx655xk7eEwMuNEtXxpNNkf/NgdEDTWFiAOx/03xWSaqP6Qcllpk/c+gMjkE7JiK16hPeetkTS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=G1Sp+FFr; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="G1Sp+FFr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=palMyM3mPY1asetOxby02+XjoraJnT8MIMUwZ6ft2jE=; b=G1Sp+FFrkgvasjMfr9sgaWfSSp UftYD+hqZqyy+fWOJndCV6ytedOzRdRVqyezZMgW2V8ugR5pErOD0K5nuQArQAixYIVZuCUVATuNs m2VW6c/OLmtZXMCqazy+Hjol3GK/vugbq3AGJ9d7dMuPjfhI3mr7dnp0p9qex/rvzuljppiKK1iwb FdHhRO+m5KfxbyfPZ3SYmmb0X5rYpN0oB5x66jmPhHIr/PcZuHtT99SPcMmdMwdFyQaytQafhyKkL J0Q9+zTGC3TFyoq9TC/9zijZ5bWTLvk5fQz1hrEg3FXc42AygCUj0l+RGxIiIe1PJDPIIFQ40gA+v Nm3UyJpQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50678 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpR-0007Xw-1f; Tue, 28 Jan 2025 15:48:41 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnp8-0037Hu-4Y; Tue, 28 Jan 2025 15:48:22 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 19/22] net: stmmac: remove calls to xpcs_config_eee() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:22 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Remove the explicit calls to xpcs_config_eee() from the stmmac driver, preferring instead for phylink to manage the EEE configuration at the PCS. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 5b47b2ad6b49..03d3042c12a3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1046,10 +1046,6 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) priv->tx_path_in_lpi_mode = false; stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, - false); - mutex_unlock(&priv->lock); } @@ -1068,9 +1064,6 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, STMMAC_DEFAULT_TWT_LS); - if (priv->hw->xpcs) - xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, - true); /* Try to cnfigure the hardware timer. */ ret = stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_TIMER, From patchwork Tue Jan 28 15:48:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952681 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 031D81D7E4F for ; Tue, 28 Jan 2025 15:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079334; cv=none; b=RazXi7l4TXaXFUtHBM5Di0RBwwE/5beb5T4qiJJUTrHKLYkgURolLOUQYMteWAGIMS4D1Pufnqfv/GY4qlyv4rTE93lxUGGyhQhCUtrsk60L/eOxohQbYnMhIk6bXQH8UO4QFi5deu+ZfHu3MSTkJOo9GMmL1ORi6kuIYcf9w1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079334; c=relaxed/simple; bh=1BHe094AG80R20DlfxTgsAkD26DnDmTqKqyftUdquZY=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=L7aIuuyYcSQF7xDNFbj/vZmd0dOg+Ww9oaR37uOj3zmZSXwhgrs8PB9rYZonXb9DtQsDm9fPWCfnr6CV+SJr6ENtMBlT3lg4srwAU7WFj+GH3KPXziVpqioiX1rBFXYJ0rOpFTExQJyTOT8ckLmTnDZ2XIpJ3P6jnkukowC8tfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=yB2Rd7p3; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="yB2Rd7p3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6rfnXHnjbMDiB1789GYEEadHIP4lGhQCiXiqIwLjLMI=; b=yB2Rd7p3hmHAn71SUOZ1OntbEK c6jInQgQtAYCxM3VjPIRwBhe9YRM277yOyYVhXGWPJaocZwYIqeE8u2VLrdq7KVEQd46GcuHjgAKs u++FgDDI0Ef7SqzMKzb7pxNgG5rc15PAD2dTgIgBQDep6IRgL5wOQsUm6+9VDr1k2kMhi6B/OkCyG qIP2V8OOaBiNHtGghWPH+F9G5CS3BTR4zgDPs8FelzISngZKgilozrVHFUzHK8NHdlHYX63qalaFV qzZiKwHwLI4mP/6tmoV7ZZJttEPO4ZBFg32GSYpEAX8QaQO+Kcf2l/ygfcJSm82jyIJdQ/icKa54x JoZ2r7Jw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50694 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpW-0007YD-1d; Tue, 28 Jan 2025 15:48:46 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnpD-0037I0-7t; Tue, 28 Jan 2025 15:48:27 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 20/22] net: xpcs: remove xpcs_config_eee() from global scope Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:27 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Make xpcs_config_eee() private to the XPCS driver, called only from the phylink pcs_disable_eee() and pcs_enable_eee() methods. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-xpcs.c | 14 ++++---------- include/linux/pcs/pcs-xpcs.h | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 1f312b5589a3..6a28a4eae21c 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -602,8 +602,8 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) __set_bit(compat->interface, interfaces); } -static int __xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, - int enable) +static int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, + int enable) { u16 mask, val; int ret; @@ -632,12 +632,6 @@ static int __xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, enable ? DW_VR_MII_EEE_TRN_LPI : 0); } -int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) -{ - return 0; -} -EXPORT_SYMBOL_GPL(xpcs_config_eee); - static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); @@ -1203,14 +1197,14 @@ static void xpcs_disable_eee(struct phylink_pcs *pcs) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); - __xpcs_config_eee(xpcs, 0, false); + xpcs_config_eee(xpcs, 0, false); } static void xpcs_enable_eee(struct phylink_pcs *pcs) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); - __xpcs_config_eee(xpcs, xpcs->eee_mult_fact, true); + xpcs_config_eee(xpcs, xpcs->eee_mult_fact, true); } /** diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 749d40a9a086..e40f554ff717 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -50,8 +50,6 @@ struct dw_xpcs; struct phylink_pcs *xpcs_to_phylink_pcs(struct dw_xpcs *xpcs); int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); -int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, - int enable); void xpcs_config_eee_mult_fact(struct dw_xpcs *xpcs, u8 mult_fact); struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr); struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode); From patchwork Tue Jan 28 15:48:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952682 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 B7B931CF5E2 for ; Tue, 28 Jan 2025 15:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079340; cv=none; b=GcyfbLYz6SZu5sJ8IFk5a1qo3kxUs4lTFxzKMFE4JkQ9s7iOOY3VB9F6FkscGXAo/eOdfwOE+dPeDE26nGVwQNEQSwuKPy4ghRwQD7Oq0Lq9r4Iazmyuh9W1fqNy2koqDgoNidU1A0aOq4CkyXvDg+aZhx0Ta2JoXUR7ylk6S1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079340; c=relaxed/simple; bh=nbgxpj0FpG6244JGxtTAv08/AJLwWyI+yts9EPSfmo4=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=ND4PuHvi2csQdQWOrYo7DamWTB/+3H3mihlVcB2JYEPUTPxBoauGONSyjj0uMV4CUhTS6DTVu5jCdjFbjJCfHUQRkhqKfBqn22iqOHi6MdSbi0oC7ZeHqHe/1cshuJx8XX248D8thVyinT0yA7cnFuBT7N5U5KJbbPSp1pwdYhE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=nT5Dv/is; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="nT5Dv/is" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QjfjNKm/xo2FxoguYUayqpH53OkqmwqZ6YW5PTiaRAA=; b=nT5Dv/isQyqg2A6Zpg5uYzZgJV GJgeT+5RxL5VFevCe7+etGRGUz0qWi3s/wBMlrtc0EVIQDuOlxdTZaYiLXsXWWwNBz7HQinSj7pxx f2kjB4IFBIa+Xq66IJqhnK4xSfq1xGuqO1FcUGJ+BKidPxrRI3q1CGob+pjrkdKm/ZicxKoRaOjH2 dLYychnTrxIu8VEabL7f4GDHgCuhSBe+mD1OnRh2U64+3bBiBMh944L7gbLlY+w8I46ehYvzRNjkV Th9YXbyRPR8phuCyUM+l0BVFct+jMkhHUltRse7/EKgUlc74BxyJbx8wkc5GM4tBDej5cTZ51tLs9 abt1woqA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59942 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpb-0007YU-28; Tue, 28 Jan 2025 15:48:51 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnpI-0037I6-CA; Tue, 28 Jan 2025 15:48:32 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 21/22] net: xpcs: clean up xpcs_config_eee() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:32 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC There is now no need to pass the mult_fact into xpcs_config_eee(), so let's remove that argument and use xpcs->eee_mult_fact directly. While changing the function signature, as we pass true/false for enable, use "bool" instead of "int" for this. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-xpcs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 6a28a4eae21c..cae6e8377191 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -602,8 +602,7 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) __set_bit(compat->interface, interfaces); } -static int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, - int enable) +static int xpcs_config_eee(struct dw_xpcs *xpcs, bool enable) { u16 mask, val; int ret; @@ -618,7 +617,7 @@ static int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN | DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL | FIELD_PREP(DW_VR_MII_EEE_MULT_FACT_100NS, - mult_fact_100ns); + xpcs->eee_mult_fact); else val = 0; @@ -1197,14 +1196,14 @@ static void xpcs_disable_eee(struct phylink_pcs *pcs) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); - xpcs_config_eee(xpcs, 0, false); + xpcs_config_eee(xpcs, false); } static void xpcs_enable_eee(struct phylink_pcs *pcs) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); - xpcs_config_eee(xpcs, xpcs->eee_mult_fact, true); + xpcs_config_eee(xpcs, true); } /** From patchwork Tue Jan 28 15:48:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13952683 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 772BB1D7E4F for ; Tue, 28 Jan 2025 15:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079344; cv=none; b=hpBtRFK6ejlecwLdS2sj/CwM4T5Qf4sFziRa0R4Px8uqQv18ZkJ06+NCZqXPqZH9pyjMxkcsaMBAIvhNDljR94PpyQ5Xj1vB/wQw9Q+pBIBXUA2XzJEDlBMY+ET6vtIRI+yRB8QOb9DurCwqJ/oSTX5cdTOHjdBQI0TGVpcYcfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738079344; c=relaxed/simple; bh=sTuYXbySmbjcVjNbfEfYlCDFF9wIlooim/PWT8qCq6Y=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=mpu4vEUMo01rctLMetuMj+egSj2F18py4hG8+rG9uXDg5169tmPwxPoQz3myUzn7DLB3sji/HPmuYmBDLzsVZf4DQYIDbg+URINjIZ1HSn/q5PVSPl//na8cp0kAS35fGBy0Da3JBWWxbpSwt2Cgki+lT3rsV2Em18zK3DW9jzk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=FrwZRmJH; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="FrwZRmJH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IYHYMMQNyPankXBbRMqXeOpq9/s7Dc9NDhL2nVI10Tc=; b=FrwZRmJHLwfATFGXy1APiwPtpZ UgRMGwPbUKOl6q/YhJHjQQ/SGeqERmGHvUophAT6qbpMZVydILqHaNW5ARqJfB0X6hutuiMcKr6uv 4P1sykj+BYMkXnT4k8+lqoxeimZp+JaeA2bet5UBoasZ4qVUCSHR/MVVBSGAH/3rrw5zE4vv+uDuc Pe1nAlBRFVZC02ieB+m92ptWea/T1dnzmxR7FqLZHOyybC1J/w8/16Pa+shA2H3sv08ts94QIy5Fo VKN7NoK3mB2saz4rw6ArgaGFuEh2HRfuQU95PKRBJUqu+ae17awYF5/Sz7+0BypHOd4uMt6Z0LQMm ZLkiqV/A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59948 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcnpg-0007Yl-2Y; Tue, 28 Jan 2025 15:48:56 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tcnpN-0037IC-G9; Tue, 28 Jan 2025 15:48:37 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean , Jiawen Wu Subject: [PATCH RFC net-next 22/22] net: xpcs: group EEE code together Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 Jan 2025 15:48:37 +0000 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Move xpcs_config_eee() with the other EEE-related functions. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-xpcs.c | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index cae6e8377191..ee0c1a27f06c 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -602,35 +602,6 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) __set_bit(compat->interface, interfaces); } -static int xpcs_config_eee(struct dw_xpcs *xpcs, bool enable) -{ - u16 mask, val; - int ret; - - mask = DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN | - DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN | - DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL | - DW_VR_MII_EEE_MULT_FACT_100NS; - - if (enable) - val = DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN | - DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN | - DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL | - FIELD_PREP(DW_VR_MII_EEE_MULT_FACT_100NS, - xpcs->eee_mult_fact); - else - val = 0; - - ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0, mask, - val); - if (ret < 0) - return ret; - - return xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1, - DW_VR_MII_EEE_TRN_LPI, - enable ? DW_VR_MII_EEE_TRN_LPI : 0); -} - static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); @@ -1192,6 +1163,35 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) BMCR_ANRESTART); } +static int xpcs_config_eee(struct dw_xpcs *xpcs, bool enable) +{ + u16 mask, val; + int ret; + + mask = DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN | + DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN | + DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL | + DW_VR_MII_EEE_MULT_FACT_100NS; + + if (enable) + val = DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN | + DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN | + DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL | + FIELD_PREP(DW_VR_MII_EEE_MULT_FACT_100NS, + xpcs->eee_mult_fact); + else + val = 0; + + ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0, mask, + val); + if (ret < 0) + return ret; + + return xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1, + DW_VR_MII_EEE_TRN_LPI, + enable ? DW_VR_MII_EEE_TRN_LPI : 0); +} + static void xpcs_disable_eee(struct phylink_pcs *pcs) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs);