Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp458232lqb; Thu, 29 Feb 2024 06:08:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVsPTgY0c/e2HyY7QWMrkqa0ENavH0PbIgLFMcMolGyMZEV2XiAQxlYIbZ8dvT1mHGzfp9MKupXDt3UnDFi/k2A2y6NnhGX4tvOBC8h7Q== X-Google-Smtp-Source: AGHT+IEHZi2MUiBfO/lHG/6LUVgGiex5WNS850SpMn1v9xVFSU8mTBNzIeUaYJNqq9YyJNXmV59u X-Received: by 2002:a05:6e02:1301:b0:364:2447:469f with SMTP id g1-20020a056e02130100b003642447469fmr2186775ilr.31.1709215720581; Thu, 29 Feb 2024 06:08:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215720; cv=pass; d=google.com; s=arc-20160816; b=o+pfGqFZVUAnzqsy3EM8Z4UqWxEBKEko5NEjGdGQpQShYmQSyapQZ0oY4c05OCIsjZ pTKN8LG4yFRa5vBEIfvhW7pBoHpzDR9mM80hynVkoln8qBLx+lXklSktmOIheC1Wi8Ok zRUjW/bBEwXpcBD/l/1uj2CZ4zwwSFsbUP6eRhpcveVn5Z+l3Fy1X9uP7XxsEFQowHNk YMp1BBeeBxFezxTldGVxlLU12sta1FLWUs1M8fTmydaRSGjYKZ+q8NBC7XfbWDt6UfHa TQDX1tH1YPQAKut/gMUemL6gfcn1lKmCaHN46pM9n2x+JYSCyZzNP3D1WpzLU7FN5HX/ cgxg== 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=PM9f3pRIgOLvNVKer62FwywMADs44PSll55Id7YQy5q0z/9thNpsXegaDI6XYbVibK r9NcnStvWWiyDRyP+CqxNIogURgSlpPkvb1lm8ymVh/R588ATs2YZ3CQ3Flnty4G7skE Q3kGmTAqwPpJYNykx2m6Qe0+8XZtOBiz/P6Uyz2ruOCzO8Dm/UdxQebRSV37COBtRaZZ NN0VDR0E4gzWJNujXNNyHhdZWUtzDASroYbAqXR3NFyMfeZwdPkxBGnz2qAP3TUv6KaV DtgGfYZAVCt/kx4WoidSWX+hoJ7e8xh+y32cJWVGpq5LVDl7DBcErj6jWozU7qEDFFO3 K5dQ==; 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-86798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86798-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 q3-20020a056e0220e300b00365775de108si521301ilv.69.2024.02.29.06.08.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:08:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86798-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-86798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86798-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 13939286690 for ; Thu, 29 Feb 2024 14:08:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDEDD135416; Thu, 29 Feb 2024 14:08:23 +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 C922F651A1 for ; Thu, 29 Feb 2024 14:08:20 +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=1709215703; cv=none; b=IeC0y17To2LHtFr1iNakPpdFXWIDQGITSlH0erk+Eah87zQyBP582joR+UtnZ96PaCbLJklBLYLelWvwxyVZedI+XfsgQm/zPw33AnBxvaHN2haf91+IyQw17gaL92jcblwkgA5aqll0mj+7eXixfWN5+qzzL/vhlENPVE466Po= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709215703; c=relaxed/simple; bh=VwqUETHkMr9Jr4MpYgf8mhr2gN0RvJdCzWv8zQr3mPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nuC7wQPA2nJ/v+YJ6oabgAVvoEsXrUlB1bh48HodGkBlAv4Dht7+Ocm34mexPPD1EN2+TAO+K3JPXmPSeurqDAdhnwugHFtsRxf3Am+vAUar5S4mFEmX5Ird64X2N6+Cr+7h66xeiXqqNdyC8evrXSdPN8Rm1YmiqDeAZYMF1bA= 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 1rfh4t-0000Sz-CD; Thu, 29 Feb 2024 15:08:03 +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 1rfh4s-003ba9-AY; Thu, 29 Feb 2024 15:08:02 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfh4s-00ELnN-0V; Thu, 29 Feb 2024 15:08:02 +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 v7 8/8] net: fec: Fixup EEE Date: Thu, 29 Feb 2024 15:08:00 +0100 Message-Id: <20240229140800.3420180-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240229140800.3420180-1-o.rempel@pengutronix.de> References: <20240229140800.3420180-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 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); } -- 2.39.2