From patchwork Sat Mar 2 19:53:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 209251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp629700dyc; Sat, 2 Mar 2024 11:54:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXW4M/jEyStj33hllRvgxHTLNPD7aDR8nSarLdjys9dCfzW4GqS8+ZboVcjzFtzVXRNhcUbRGGGKn00vqzAGdToUATjTA== X-Google-Smtp-Source: AGHT+IFqkBaMT5j3EpM12iqL3pqLt7ge+l0lX0YWL0IbYRq3j2HZ6vX2LWq0pRP9eOgOYFxIk/zB X-Received: by 2002:a05:620a:2851:b0:788:1336:d7c0 with SMTP id h17-20020a05620a285100b007881336d7c0mr4251263qkp.11.1709409296333; Sat, 02 Mar 2024 11:54:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709409296; cv=pass; d=google.com; s=arc-20160816; b=B2UUd+fJpBxvYuI+K2v+MTW7ma0fdZmaTbtLEod60iPpVJegjOigwjPzAxyjfH5J1g ytYkqwyeyyLo7/7VQBEPOE/dJ1SX5OUK7xSczdINzR+Notglj1/T8zH9y4nh6i1vgZ9g nI3Phe4gS+IqNsm0w16sboA5WYNtyyCOToXNjnX0AZHB6Dgi5OTgEylnkEcLOW0ZLzXK cTrMJUMU5iaXqjAL/svxyJvqcbItHgtSoyCxXFPalpWLNJj6E0ArpM8Hqp+A0bl0pDJj IhAsawm9nqzmW6bFXLQ+oO+8CSMLxnoGwbAbiAYUuA6sW4U9J89OTaj33dFly1uBDpRw fwYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pgk4E3Cvc5LjD4Uhu9r9ZltitvR9BK7MtQIcW0C4Nuw=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=Nyz5TRJ/O7LRrmMNdvD7gvb4nSaAHCmx11Odf+onTu6XxWs6765lXIXIGJ9J+Y5R9F OVPoOzoaUuWy2CnXu0my/Enpx2Su8KLVcZu4Fn2An1RxiFllty8HoAxG2+jxhIu6PCiC Qs9w6ZADQD8c00fNWe91y0EzOK4uhreIysDAvh9Z88PqnMwv8rwxYNHUOx54BWCCaeTW FEZEV/Q3dlssmDAp9JfwwMOCn/xTtBmBexhZJox15QoxDfT6OH3o7ZdvuK3x3uuAgrKP UR4u9XbdUG8HG4+b78a8pWHNcuh999RzE8OG8X4ieqi4ffS/RjztNqODOQZzDpVbt1by g+RA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-89572-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89572-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c19-20020a05620a269300b007880e2d96b5si3610870qkp.95.2024.03.02.11.54.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 11:54:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89572-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-89572-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89572-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 058191C20EFD for ; Sat, 2 Mar 2024 19:54:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1212E481A3; Sat, 2 Mar 2024 19:53:24 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 606733FE4C for ; Sat, 2 Mar 2024 19:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709409201; cv=none; b=O4KeEzA5ds5AlmCU++LzNbCf+oI9wMLGDVtVC5WcivtXBdaazVueBFGcrbmZqGHcLaT77DvNDWF27y7/57tXcAGXIZHKdhtbylKgOnCtv01gK6XjFEpYalqJjcFArTNQP44rPZ6IQzIBPG7XDcljJyZ4bOP9gftRHjk8genJpDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709409201; c=relaxed/simple; bh=VwqUETHkMr9Jr4MpYgf8mhr2gN0RvJdCzWv8zQr3mPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mmmDI8PDACvreH7B6+KyGb60H20ROcTpXNgMiPFz4HrHaIwrXHc8IPNXXcp8gegJUJfy72mLSoHju0KCMLADICXR1IQ2Eg8v7K+VwiF5wA5tbGI76BHGVgFNaGJY8yK5+A+Eo9Mt/vgosIGpXy4JzAEe3/V0Rw3Yd8qpmp9aTQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rgVPx-0007Gz-Ln; Sat, 02 Mar 2024 20:53:09 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgVPv-0041mM-S9; Sat, 02 Mar 2024 20:53:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rgVPv-00DSV2-2W; Sat, 02 Mar 2024 20:53:07 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v9 7/7] net: fec: Fixup EEE Date: Sat, 2 Mar 2024 20:53:06 +0100 Message-Id: <20240302195306.3207716-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240302195306.3207716-1-o.rempel@pengutronix.de> References: <20240302195306.3207716-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792445562036310912 X-GMAIL-MSGID: 1792445562036310912 From: Andrew Lunn The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So move the enable/disable into fec_enet_adjust_link() which gets called by phylib when there is a change in link status. fec_enet_set_eee() now just stores away the LPI timer value. Everything else is passed to phylib, so it can correctly setup the PHY. fec_enet_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LPI timer value. Call phy_support_eee() if the quirk is present to indicate the MAC actually supports EEE. Signed-off-by: Andrew Lunn Tested-by: Oleksij Rempel (On iMX8MP debix) Signed-off-by: Oleksij Rempel Reviewed-by: Wei Fang --- v2: Only call fec_enet_eee_mode_set for those that support EEE v7: update against kernel v6.8-rc4 --- drivers/net/ethernet/freescale/fec_main.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index a2c786550342f..d7693fdf640d5 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2033,13 +2033,8 @@ static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_keee *p = &fep->eee; unsigned int sleep_cycle, wake_cycle; - int ret = 0; if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); wake_cycle = sleep_cycle; } else { @@ -2047,8 +2042,6 @@ static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) wake_cycle = 0; } - p->tx_lpi_enabled = enable; - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); @@ -2094,6 +2087,8 @@ static void fec_enet_adjust_link(struct net_device *ndev) netif_tx_unlock_bh(ndev); napi_enable(&fep->napi); } + if (fep->quirks & FEC_QUIRK_HAS_EEE) + fec_enet_eee_mode_set(ndev, phy_dev->enable_tx_lpi); } else { if (fep->link) { netif_stop_queue(ndev); @@ -2453,6 +2448,9 @@ static int fec_enet_mii_probe(struct net_device *ndev) else phy_set_max_speed(phy_dev, 100); + if (fep->quirks & FEC_QUIRK_HAS_EEE) + phy_support_eee(phy_dev); + fep->link = 0; fep->full_duplex = 0; @@ -3172,7 +3170,6 @@ fec_enet_get_eee(struct net_device *ndev, struct ethtool_keee *edata) return -ENETDOWN; edata->tx_lpi_timer = p->tx_lpi_timer; - edata->tx_lpi_enabled = p->tx_lpi_enabled; return phy_ethtool_get_eee(ndev->phydev, edata); } @@ -3182,7 +3179,6 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_keee *edata) { struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_keee *p = &fep->eee; - int ret = 0; if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) return -EOPNOTSUPP; @@ -3192,15 +3188,6 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_keee *edata) p->tx_lpi_timer = edata->tx_lpi_timer; - if (!edata->eee_enabled || !edata->tx_lpi_enabled || - !edata->tx_lpi_timer) - ret = fec_enet_eee_mode_set(ndev, false); - else - ret = fec_enet_eee_mode_set(ndev, true); - - if (ret) - return ret; - return phy_ethtool_set_eee(ndev->phydev, edata); }