From patchwork Thu Feb 29 10:53:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ernberg X-Patchwork-Id: 208304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp308987dyb; Thu, 29 Feb 2024 02:54:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUqwkjBmIM7B+103Fv8oimeI6tOzUf1cot2PwkHmijGYiBy1Hyrv0qx8wonckrSUECCq+HT0nVsm2rkqQOuKX4xhtdcGQ== X-Google-Smtp-Source: AGHT+IFXkHzQ7xEdK9lte3Yv5mk2DkQDk2MJcfXh6N/XZfWR4SEOFyDLIaISabK29J/KLqUImxyX X-Received: by 2002:a17:906:fac5:b0:a3e:c94b:a06d with SMTP id lu5-20020a170906fac500b00a3ec94ba06dmr1167513ejb.57.1709204045983; Thu, 29 Feb 2024 02:54:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709204045; cv=pass; d=google.com; s=arc-20160816; b=v9n689VtsZzCZOYpsL3wTMUGY/TFeLaAX0fj8OOLwnPnfH7D/XoxjID5H97tV+X867 TW4N3d4IR1bf7/2tc578JmFYmrzBcXygzUjSAw/9Y038dTyJAGONgN3Y/vOJ/0ZJ4smz kv29mXvPtcwIBZR9lqbViPjmzP14rWVbXZp92FboJlGt6aLlnR5pQ498A7PGcWeFJpcU hB3HoBF7m2HHmJgt0gIBzuiSGKT3jsf0ZAzB6W/HcNTOHdYIz2WqAj5D9kEONHFPDg/s lNMMFAXckf/Ba/c9X+uox+cg6CiUaGR3WPoMdweZPuVu/iZaZsRcuyVcz4PkWYynUuEw MeMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=pvb8V48o1baY28W9QnTYOH6/XgYarIJBKyNPg5k3k+4=; fh=CrDPfPlgkeovG7op10fbcGzHGY6r1dnuK3p4aI6pv3Y=; b=hHShE2vThQAoWZnxr06xJqysd4rALzZPUP/hi++AXFLWjtmfb/tDik02bRWOlIZR11 eDwWKC/ahfAlE1pACOh6j6hkGFcoSNLklajgHmcdx7BEmH90yYt7ioXK4KByMyIhx43y BYoca3kV+h6+hltx6ps5gZ6oHFD4ac4jxYcZdfYeB4I9IEaO4gqWs+FpN7oWUk8sL+GB YKQyPB/+17Rh4663QoRLZpStKaPiMLdrpnCzLN3QWOng/42QwmclVTrxwNVtzNMVsWl6 M57kx6qsFqrgB2b65A3/A4xxuydFjGXi+aZhHCbnsM/3exbHQJz/TZwwjdqn2Ung5NBv SNOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=actia.se); spf=pass (google.com: domain of linux-kernel+bounces-86583-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86583-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d8-20020a1709064c4800b00a4425f89409si464265ejw.821.2024.02.29.02.54.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 02:54:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86583-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=actia.se); spf=pass (google.com: domain of linux-kernel+bounces-86583-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86583-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8972A1F2648F for ; Thu, 29 Feb 2024 10:54:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7B397B3C8; Thu, 29 Feb 2024 10:53:29 +0000 (UTC) Received: from mail.actia.se (mail.actia.se [212.181.117.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A8761665; Thu, 29 Feb 2024 10:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.181.117.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709204008; cv=none; b=HAKiDGjrSDyOoamZCzbjTFzRj407WjLI8QNrj9xplZWNC8QwRGKtcYqVP48VfFbhNOUiLPpXk7UvgcwwAhMnjOrnemBdhfng+kGGy8jIvunJFvamJiNB/SBN8uNY1b4A7P0mHZUZe3C7tmf9sMo2a64kJ7c9lnHnFH6oigNj+5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709204008; c=relaxed/simple; bh=pW1/W/As+i4n7LgWM8KkC3siKC1GZ+dKVBK5Eg/eIz8=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=Q6DjL6tJK7ZlWXZLam0Etg3M4ICSRITJfwRhbieEiKs1UFaXkGznCoMkb3QYfGHa3vSS45/tWkQyocJE9dTbLspuMjHrol8Q2ZQ9Lxq8llvZ0yVEH3YJFaKD34xgtkhTsU4sEDRL9NsQlyFL3hiPABxA/UpeBks0fmS6gcE2rAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=actia.se; spf=pass smtp.mailfrom=actia.se; arc=none smtp.client-ip=212.181.117.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=actia.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=actia.se Received: from S036ANL.actianordic.se (10.12.31.117) by S035ANL.actianordic.se (10.12.31.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 29 Feb 2024 11:53:15 +0100 Received: from S036ANL.actianordic.se ([fe80::e13e:1feb:4ea6:ec69]) by S036ANL.actianordic.se ([fe80::e13e:1feb:4ea6:ec69%4]) with mapi id 15.01.2507.035; Thu, 29 Feb 2024 11:53:15 +0100 From: John Ernberg To: Wei Fang CC: Shenwei Wang , Clark Wang , NXP Linux Team , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Heiner Kallweit , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , John Ernberg Subject: [PATCH net v2 1/2] net: fec: Set mac_managed_pm during probe Thread-Topic: [PATCH net v2 1/2] net: fec: Set mac_managed_pm during probe Thread-Index: AQHaav1/YpGNknjjfEWLwsQTgai9Sw== Date: Thu, 29 Feb 2024 10:53:15 +0000 Message-ID: <20240229105256.2903095-2-john.ernberg@actia.se> References: <20240229105256.2903095-1-john.ernberg@actia.se> In-Reply-To: <20240229105256.2903095-1-john.ernberg@actia.se> Accept-Language: en-US, sv-SE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.43.0 x-esetresult: clean, is OK x-esetid: 37303A2921D72955637266 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792230342066288711 X-GMAIL-MSGID: 1792230342066288711 From: Wei Fang Setting mac_managed_pm during interface up is too late. In situations where the link is not brought up yet and the system suspends the regular PHY power management will run. Since the FEC ETHEREN control bit is cleared (automatically) on suspend the controller is off in resume. When the regular PHY power management resume path runs in this context it will write to the MII_DATA register but nothing will be transmitted on the MDIO bus. This can be observed by the following log: fec 5b040000.ethernet eth0: MDIO read timeout Microchip LAN87xx T1 5b040000.ethernet-1:04: PM: dpm_run_callback(): mdio_bus_phy_resume+0x0/0xc8 returns -110 Microchip LAN87xx T1 5b040000.ethernet-1:04: PM: failed to resume: error -110 The data written will however remain in the MII_DATA register. When the link later is brought up it will trigger a call to fec_restart() which will restore the MII_SPEED register. This triggers the quirk explained in f166f890c8f0 ("net: ethernet: fec: Replace interrupt driven MDIO with polled IO") causing a MII_EVENT storm. This event storm causes all the MDIO register reads to read as 0 because fec_enet_mdio_wait() returns too early. When a Microchip LAN8700R PHY is connected to the FEC, the 0 reads causes the PHY to be initialized incorrectly and the PHY will not transmit any ethernet signal in this state. It cannot be brought out of this state without a power cycle of the PHY. Fixes: 557d5dc83f68 ("net: fec: use mac-managed PHY PM") Closes: https://lore.kernel.org/netdev/1f45bdbe-eab1-4e59-8f24-add177590d27@actia.se/ Signed-off-by: Wei Fang [jernberg: commit message] Signed-off-by: John Ernberg --- v2: New patch. Big thanks to Wei for the help on this issue. --- drivers/net/ethernet/freescale/fec_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 432523b2c789..8decb1b072c5 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2406,8 +2406,6 @@ static int fec_enet_mii_probe(struct net_device *ndev) fep->link = 0; fep->full_duplex = 0; - phy_dev->mac_managed_pm = true; - phy_attached_info(phy_dev); return 0; @@ -2419,10 +2417,12 @@ static int fec_enet_mii_init(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct fec_enet_private *fep = netdev_priv(ndev); bool suppress_preamble = false; + struct phy_device *phydev; struct device_node *node; int err = -ENXIO; u32 mii_speed, holdtime; u32 bus_freq; + int addr; /* * The i.MX28 dual fec interfaces are not equal. @@ -2536,6 +2536,13 @@ static int fec_enet_mii_init(struct platform_device *pdev) goto err_out_free_mdiobus; of_node_put(node); + /* find all the PHY devices on the bus and set mac_managed_pm to true */ + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + phydev = mdiobus_get_phy(fep->mii_bus, addr); + if (phydev) + phydev->mac_managed_pm = true; + } + mii_cnt++; /* save fec0 mii_bus */