Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp850019rdb; Fri, 23 Feb 2024 01:47:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxehSpZTDq99XQwr8K0FaC4Yt8iSM7aYiTzPXkaC4DpQy+L9RSPeialKHLKYIdypsq+UH5mWHuKuxKaVT0Jzl7g1RAXtqHwhiQr6LGqQ== X-Google-Smtp-Source: AGHT+IHEIJYTatgqS9uWBWiKT1Ytqnl0H9rgu3b18SdFv0FSqR9Xwb4/mm3TEnlAoNGcZg0LzVDe X-Received: by 2002:a05:6870:c6a4:b0:21e:579f:a4f3 with SMTP id cv36-20020a056870c6a400b0021e579fa4f3mr1546308oab.47.1708681626997; Fri, 23 Feb 2024 01:47:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681626; cv=pass; d=google.com; s=arc-20160816; b=OghSaS3mkTOnykWm4vepdtpyTFf6qsL6rDrMN1EkC61Hk6thEozc2plkFQoZRf3zwu FyKedppil+erqXdhGsLGL28R4T0Kofhrll92+UwU5XxPqd45XK5qxkryPLWr716FS5YQ HxIYzxi9Tioca+qrhytMicSjVxCWSrWFYDHbsCw/JFV450UMcu9jL5QELpBi4tbCmbTY NYvSv0hzIrsyCcoXbnm+m1OQe68stloPoCuf/VCXDtvKbQmjV6q220XJNZiv0YVbPKNX fhe76WwHWe7wDrZT7y9eh5wE9M0hmMLWdEU/qCHfU7cSnCdPbG7O01YDOlpsAJEdanox C8DQ== 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=DDbrUC5I1OaMgn5CRqUriz+FGHjAWn0xlJzdmc+uPbg=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=rmYFh/cVhvm0iHzEAvX+pT80zheUV+nAP+ZVrrnVZDqMJdADYIo/28hFSxk9GftyK+ mMzctwVXgyRBC+iXOVYjMcMoiPykBgZK2Uauj1onffD3A5XdteGf62MbgowpEC663eUL h+6xuxeDxAFXR/7MqEVJlil8trWysEIBQajMKmOvGtNZ1jMrRN+zk1cDqTmwYFl2VlSP GSFJdrZhJSiofbpvCv54MWbYv+WDkVRpPQz93sD76tIVvltnjeEyEkMOPlPjn82/BZSt LXySAwfXbjohBVpXjawhccy6kqv3VT8RzcvcbqGm5ExXHbIyKzQ8e3Kos8lMlrwXRw9Q wXxA==; 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-78061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78061-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i193-20020a636dca000000b005dc87bb5496si11649478pgc.132.2024.02.23.01.47.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:47:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78061-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A76AC28201A for ; Fri, 23 Feb 2024 09:47:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7131F5F47C; Fri, 23 Feb 2024 09:44:56 +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 DB4E65CDC3 for ; Fri, 23 Feb 2024 09:44:38 +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=1708681490; cv=none; b=OlE1unc9hg/gSoNbhvMyW4SXHhd3m5Wfo3pJwoeUIgq2VVVmDTU7r3jJtbe41ntAQn9K5TNOPLjQS+6RO5NMQjQ4RbjwOAc2wOM4vKio73BhRA3yacv+AP/kz4G1gncMqbIUl5ct4Z4EohsNps32KY9bzINXVJ+U6xIgROuWumw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681490; c=relaxed/simple; bh=XKcT45bumpicsgmOQeai5NcHMqk50lyvyruWB4lGLD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hsq6pIcRVUYoul4xgBMVZH4owqw14gsSYDkILXJPKtts3AdAXvvYu/gvqOKp7n+5Qtxw+r8fh/tdq0jthMeakp90csBuueOaO47aXEzovCLuccQXP7CoifRYHj8NopL8bSQ2/7z6YU7MlJy8z1Qzk3t41fKtQiA2D66PDz8YT7o= 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 1rdS6W-00080q-F4; Fri, 23 Feb 2024 10:44:28 +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 1rdS6V-002Okf-F4; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tqb-1A; Fri, 23 Feb 2024 10:44:27 +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 v6 8/8] net: fec: Fixup EEE Date: Fri, 23 Feb 2024 10:44:25 +0100 Message-Id: <20240223094425.691209-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org 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 a2c786550342..d7693fdf640d 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); } -- 2.39.2