Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2180581rdb; Tue, 20 Feb 2024 22:22:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLdeId6yO+zJpVX+wpE7yMuCd0iTEqxDk885WfLMcqOIy2+9nkFGA8/j1vC7v73i0ub3pZto445PHeXsWl8ARZM9giN3ENf1FrN1ePvA== X-Google-Smtp-Source: AGHT+IHRBIfJhJv6Mi3lg3EdtVsufPVa9tGfuXaiba2v7+DYVYq7SyRO+nr+mzaWMJHmKgmZQ7hJ X-Received: by 2002:a17:906:68b:b0:a3f:3470:6055 with SMTP id u11-20020a170906068b00b00a3f34706055mr525960ejb.37.1708496539011; Tue, 20 Feb 2024 22:22:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708496538; cv=pass; d=google.com; s=arc-20160816; b=UftnSfeyOpDZbOrISxeO/t/G/Z6xoiyd8KPJx7V7XefF59auKOpRLZZ4CdGOuShHON y+xhkTIb/jr8H1QilSyOmpd9fcN3CcuIQyB6w4d/UwqlmmBvzu/lXeuv9B4aRYAMx9Bc llhIB3cZPqix8cLnnKJXd4gEzpI5E5H2d6ndEwUp2P/u3SipnCwK+5VSvg3KWvE7NbqP s+shTsy4CT5qolHQJYDin+h+Dlm6US3zMDZRQByuyrQBdXEWrQQkOh0lGWGLIcA/PK7V I+Js8lRJxv1evllUwizjtXBFxT8j5DbVBsw5irOE+1rcwdhAV2bu/77Fl/0vnMlrTxDe zEPg== 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=BouYgS5w6ZIQP0Epo13ts15RkS/QGnTkNrgbIbzM+bI=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=0TkYbU8A4ExTC37AU6vOsccSk9j0+CuJoX/fLn9AZII74P660rdR9mEpZT6wCuURmO wAHpoRkopeo8s52r2Zh7gOzQ1OPzDm6VFTCSS4rPjbigsPSyNRVJERsRqhI4YytuxKQ2 iW7F4tiiHGb9BL455Ny8zb1atOivvJFyAG8Mro30SAkhbsl5VCNUgNKiG0q0poYG//j8 AWjmbb4dwnev6WSxq07tkk6yKkc5qZpoBfOpgDx6l86yndCM1N5Y3tln1kRHit0Mwx/p czNtP6TfVuEUWJk0Mbsaj0l0P4ectn7geFcUdJGhDjVtUnDxnvqpOx1gsPvCNMefED+M Av8A==; 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-74138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74138-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y4-20020a1709063a8400b00a3f0c8a7795si1120115ejd.653.2024.02.20.22.22.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 22:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-74138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74138-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 840CD1F23C55 for ; Wed, 21 Feb 2024 06:21:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DD753A278; Wed, 21 Feb 2024 06:21:22 +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 0D74F39FE4 for ; Wed, 21 Feb 2024 06:21:19 +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=1708496481; cv=none; b=SURBonoXQjw0DtXlYnaO6i972ezffOicxXeM0os2A1sh+9DTnWl+fI3Y0UaoVykbIZxWd9qRcGYYtiBP11VhJ3d9UsJiFen5ATqruY/CdSy9YHribNFqqEg0znahs6bSp5ctqXwDgXtiGv0jPcpjkCGFC+bI2XnjoJ9zGQ3WrdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708496481; c=relaxed/simple; bh=V4cfKVDLC+fhR2Mehz0xn+9Mu9FWD2amC3utiRxvDhg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MOT9UgYGIwh3o37D8fCQdT/UObZ1veLX/PP79jHh6I8VrJGX7bqFmJdk2jhlHn2onyJqwW+kTMSqva7dj3BFYmLM4nG6hvyH0SbBSPtdTvWdJjGoxfi27wDDMBUDbXTilZCkVvEVd8XGyR1fAwTEv1mXMkzhJBuVVI0S2wenwS8= 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 1rcfyh-00010W-4b; Wed, 21 Feb 2024 07:21:11 +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 1rcfye-001zFM-Qc; Wed, 21 Feb 2024 07:21:08 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rcfye-003Gaw-2K; Wed, 21 Feb 2024 07:21:08 +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 v5 8/8] net: fec: Fixup EEE Date: Wed, 21 Feb 2024 07:21:07 +0100 Message-Id: <20240221062107.778661-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240221062107.778661-1-o.rempel@pengutronix.de> References: <20240221062107.778661-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 --- 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