From nobody Wed Feb 11 01:25:59 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 E96B3158202; Thu, 16 May 2024 21:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715893953; cv=none; b=p+b/f54d5E92/SJlmUnsAnb7h//tGky4LbgtxLWRT44BnqOkRZFZ1nTS4JAwdOUhXrReRXPlJ/NpW7e+LYXmVUpC3dzmI+xx6CYK/R19XEssSn+njrstjKBrMekxf3KfBovwzQy/HwBEWyc/5F3rCQ2E0D/8Y97Zs70um8WJRII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715893953; c=relaxed/simple; bh=1o11Mx+hN3YEAxxf3v2SYf20qJsgk0EksHe5sNU0Tl0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=thTAeiHlqsChE0jGCrs16XvVzUH00KIoOolCuGvGNnnPS/YfBTzQf9fe1NRIBsmA8xeoER9REkifvY2cFiQIOJbxYmLSOgFMhsQV47HHc+hNvXGqXc1lqIc6pk6pc3ISwfElkly2bBholRg3zWKxm3sj2XHHxiq9tn0Iy3IsrSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mRMVl+LP; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mRMVl+LP" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2b33e342c03so597963a91.0; Thu, 16 May 2024 14:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715893950; x=1716498750; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OFtOdCDDS8pWsU5ibi88uExXYYlil4P3yRNei2oTBUs=; b=mRMVl+LPw8uZyh/IY7zdZHtGzqWDIUwJjcaumqEk1140pwshN23sdaTBz99foXZxAV 2/C2BKOj1T2b2pMZA1kQv4RG59emv0EsMDhI3r6kh9nuPkR+Xz3wT3vIGf4GkMgM2iwd c0STCnAnBgx7ygDL441z2RXIgLTbsnoOhqvL3I9OXiWAftyB8iYExH5ePSjB6i1rQ//N wANu/01IDmvEijIVFF8HfgmWNhtN/i/IM+TqofPd3Ls36DgIW2hZAURCqqkQdlbks/jp lWmvwVF6H12hAYYLn9a6knQeKPaWgJeNc4uLUS5h2xFiJ4ckPfTMFiGjObI38LtFMo4t vJTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715893950; x=1716498750; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OFtOdCDDS8pWsU5ibi88uExXYYlil4P3yRNei2oTBUs=; b=CRSDPPCIn+IAgDHS7ptp5Oi7uq5ETzRjAsyhVh4/BzbKfMZBKRzuR6FylP2BG8VJc9 odUWs7oKtwzBfHnIyrE6V9cx2wojzlfqyCgqILLSHf9bnbDFPRJxe21Gn5ZuaWWVC2mx 0QSN34UR7BF7hc3XyQA8K8X1NHj4ER0kpI06QPoIEKofajp2SjdGR/IaYu0/nI+ghgjX Fb/ZKq8FtGvtNnb8Wb645QjLUHHgF+9c6iF2s1jELWLkjgMYjANxbJaXIecsPDk96OWh ZpbVSz5j3pxoF4B4XNQjGhq+t9irIVyU8Uz7CQU732bK8ZRXKVL0CTITO+ETVgfHmxB+ i2ew== X-Forwarded-Encrypted: i=1; AJvYcCWMznDNUH4w9EoHl94qIC5Xsvpj717Eg6LeFX/Od7yhIT1DiSJec7xhDgUDKzLXCK5gQ9UDwXGH9WQzSiew7E/MFgbi+Zp043nLixA4WtXuGrHErf+uCGlIMja053pstsoUvuEU X-Gm-Message-State: AOJu0YxNT/xD8XDLIu1XwR5a9qqpG6vPF3ojWGPrvD6ueZOrbTpVcRPs i7VjClVvoi4/YLfTiCsUu4e0jzyKGfwZA8kVkFoqS8wba/n1eIke3LZnfA== X-Google-Smtp-Source: AGHT+IExhfu/u94b4vM7u9H/fv9s4GDAFHntuZSICPi8lvFLfEgazxxH3ohuG+GDrWxK2KDVCAUNCw== X-Received: by 2002:a17:90b:1d01:b0:2b6:22ab:7b05 with SMTP id 98e67ed59e1d1-2b6ccd9cea1mr16888138a91.49.1715893950269; Thu, 16 May 2024 14:12:30 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b628ca5279sm16116918a91.41.2024.05.16.14.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 14:12:29 -0700 (PDT) From: Doug Berger To: stable@vger.kernel.org Cc: Doug Berger , Florian Fainelli , "David S. Miller" , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH stable 5.4 1/2] Revert "net: bcmgenet: use RGMII loopback for MAC reset" Date: Thu, 16 May 2024 14:11:52 -0700 Message-Id: <20240516211153.140679-2-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516211153.140679-1-opendmb@gmail.com> References: <20240516211153.140679-1-opendmb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" [ Upstream commit 612eb1c3b9e504de24136c947ed7c07bc342f3aa ] This reverts commit 3a55402c93877d291b0a612d25edb03d1b4b93ac. This is not a good solution when connecting to an external switch that may not support the isolation of the TXC signal resulting in output driver contention on the pin. A different solution is necessary. Signed-off-by: Doug Berger Acked-by: Florian Fainelli Signed-off-by: David S. Miller [Adjusted to accommodate lack of commit 4f8d81b77e66] Signed-off-by: Doug Berger --- .../net/ethernet/broadcom/genet/bcmgenet.c | 2 ++ drivers/net/ethernet/broadcom/genet/bcmmii.c | 33 ------------------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 380bf7a328ba..2afd056056fb 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2015,6 +2015,8 @@ static void reset_umac(struct bcmgenet_priv *priv) =20 /* issue soft reset with (rg)mii loopback to ensure a stable rxclk */ bcmgenet_umac_writel(priv, CMD_SW_RESET | CMD_LCL_LOOP_EN, UMAC_CMD); + udelay(2); + bcmgenet_umac_writel(priv, 0, UMAC_CMD); } =20 static void bcmgenet_intr_disable(struct bcmgenet_priv *priv) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/eth= ernet/broadcom/genet/bcmmii.c index 026f00ccaa0c..213434aaf07f 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -187,38 +187,8 @@ int bcmgenet_mii_config(struct net_device *dev, bool i= nit) const char *phy_name =3D NULL; u32 id_mode_dis =3D 0; u32 port_ctrl; - int bmcr =3D -1; - int ret; u32 reg; =20 - /* MAC clocking workaround during reset of umac state machines */ - reg =3D bcmgenet_umac_readl(priv, UMAC_CMD); - if (reg & CMD_SW_RESET) { - /* An MII PHY must be isolated to prevent TXC contention */ - if (priv->phy_interface =3D=3D PHY_INTERFACE_MODE_MII) { - ret =3D phy_read(phydev, MII_BMCR); - if (ret >=3D 0) { - bmcr =3D ret; - ret =3D phy_write(phydev, MII_BMCR, - bmcr | BMCR_ISOLATE); - } - if (ret) { - netdev_err(dev, "failed to isolate PHY\n"); - return ret; - } - } - /* Switch MAC clocking to RGMII generated clock */ - bcmgenet_sys_writel(priv, PORT_MODE_EXT_GPHY, SYS_PORT_CTRL); - /* Ensure 5 clks with Rx disabled - * followed by 5 clks with Reset asserted - */ - udelay(4); - reg &=3D ~(CMD_SW_RESET | CMD_LCL_LOOP_EN); - bcmgenet_umac_writel(priv, reg, UMAC_CMD); - /* Ensure 5 more clocks before Rx is enabled */ - udelay(2); - } - priv->ext_phy =3D !priv->internal_phy && (priv->phy_interface !=3D PHY_INTERFACE_MODE_MOCA); =20 @@ -250,9 +220,6 @@ int bcmgenet_mii_config(struct net_device *dev, bool in= it) phy_set_max_speed(phydev, SPEED_100); bcmgenet_sys_writel(priv, PORT_MODE_EXT_EPHY, SYS_PORT_CTRL); - /* Restore the MII PHY after isolation */ - if (bmcr >=3D 0) - phy_write(phydev, MII_BMCR, bmcr); break; =20 case PHY_INTERFACE_MODE_REVMII: --=20 2.34.1 From nobody Wed Feb 11 01:25:59 2026 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 72FDA1586DB; Thu, 16 May 2024 21:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715893954; cv=none; b=rm7keCuSWRE6xr8w1x7A5/nNKkqNeT6NjThcjQE3JA5bTfn0qwIQq9NRhpHB9RPoS4Vf5PtZNg48gGgfRyfr9StNvQlGASF19kDtkLKjw+aUONr9pjTAe0FwEMpny4iWkkj2vWtseJQ0BUGOBwJoruUdwbiHnPdqFTFaJOnD5yM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715893954; c=relaxed/simple; bh=we9weee/JaV4Vp7YJEKnES+bZmUID0P2SZEqnOi/knc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZJwGkYpLhvAoL/kdOZk6rnC7gcCdxkjyR+aFY6wR4rkTukxfqHw5X/1TRFZL3Iqe9ra0bxf2E2aTddga945X88+uwy/nH+uWIqrZp7FFYAwcjXlHGN4OnXH1USuxkjrBKlBWJWfMaBoxMkst/xSV2jojuIi/TXNBX2yaYpgBVXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DDE6e53A; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DDE6e53A" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso463169a12.2; Thu, 16 May 2024 14:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715893952; x=1716498752; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UJD1FQA2D1Smtm7463pP0IFT3MI0WmcYycw6S//0twI=; b=DDE6e53Aq/qRh8xvgBgAmt2aFUTw+JJuS6oBCi+jbfq9IBpGXn1Hfa5Ka0CZ+t3nac caP49jmFsMFRtzIGt4S1AnjfrZYjBW/oq2zKKOmUT3hu0JNLU2pLyN6NFJpJjGQwpMtr PknmAxWTIjEA/4VYI69HyvFRV3g38MkB3tPjMfRlcEXoK5RtG154db9BSNC5a/WXIxGD GMf9akna9IfeMTAOd8c/7KLZ3b9sivFaSD0dhePyD9KysUld9BF51Vx6i4DcmEebrUZ1 hcwz9+c0fWO5Knt3O6SwtQpXSFgadQIStZ8vp66EBwc75bkREDgp0OBZPr2Ouh3he4sw RXnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715893952; x=1716498752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UJD1FQA2D1Smtm7463pP0IFT3MI0WmcYycw6S//0twI=; b=Uf6wjaUa6T5aghNiteC2LoV25oC4HtVtgm5+wGQUYoUTXUmagyQYtQAYts4wLSzNIo YA2B5fQ22K5+V6ewCKQ93CFs0zbLyBPot3+L+uOSAqOEI2U86aJGA7rVVNUHswhQzGFj pJG3DrFhBauBaV/nL7pfV3Lz8bqxhv+e2bkvOjRjQGzI0dD9qu+XqthEaY6JdSXbT/0r yLNmKDVpnMwmLq3jO8m73TdfEXlJI7pjaQm86wfVLm0fG5jhnV9u1ZyjXHnFktXHhPi2 XQE6eGuHkOoe1GGNkE1JLztnnjG1b1B0ttt0ywwbt8S2kr/p/203bhJbOKwaSkcMI4M4 vDxQ== X-Forwarded-Encrypted: i=1; AJvYcCVmnp0NTO4R5c0lMqjzKNNSrxOS8W4V+KIudjOko1mvtbwSMLmzOVzzk0D8hY87oEgRWJhDM9g6upjiOGb6tZ2xBVfGW7bUooJaNUhVcH1aPb/YrwqhFV+XmD3168GKtEpKtLew X-Gm-Message-State: AOJu0YysLi2woNKQbqye48aeQ+z8docFr/1ZHoZX/yYgPHi1lsgBz8Wd OoYrT6npPeQjb2AiGPvM5FKNGjEtc7h0yhWtySFxKqHSDWmkqhhvTFVFRg== X-Google-Smtp-Source: AGHT+IFHoa0Y6j1jY2owaUpg9KLpsukud/n/1x0HI3JElMooj9GsS/8alvC1sCkJxkQVTSbUUBoAaw== X-Received: by 2002:a17:90a:2d8b:b0:2b2:bccc:5681 with SMTP id 98e67ed59e1d1-2b6ccd6bb21mr18407189a91.33.1715893951892; Thu, 16 May 2024 14:12:31 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b628ca5279sm16116918a91.41.2024.05.16.14.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 14:12:31 -0700 (PDT) From: Doug Berger To: stable@vger.kernel.org Cc: Doug Berger , Florian Fainelli , "David S. Miller" , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH stable 5.4 2/2] net: bcmgenet: keep MAC in reset until PHY is up Date: Thu, 16 May 2024 14:11:53 -0700 Message-Id: <20240516211153.140679-3-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516211153.140679-1-opendmb@gmail.com> References: <20240516211153.140679-1-opendmb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" [ Upstream commit 88f6c8bf1aaed5039923fb4c701cab4d42176275 ] As noted in commit 28c2d1a7a0bf ("net: bcmgenet: enable loopback during UniMAC sw_reset") the UniMAC must be clocked at least 5 cycles while the sw_reset is asserted to ensure a clean reset. That commit enabled local loopback to provide an Rx clock from the GENET sourced Tx clk. However, when connected in MII mode the Tx clk is sourced by the PHY so if an EPHY is not supplying clocks (e.g. when the link is down) the UniMAC does not receive the necessary clocks. This commit extends the sw_reset window until the PHY reports that the link is up thereby ensuring that the clocks are being provided to the MAC to produce a clean reset. One consequence is that if the system attempts to enter a Wake on LAN suspend state when the PHY link has not been active the MAC may not have had a chance to initialize cleanly. In this case, we remove the sw_reset and enable the WoL reception path as normal with the hope that the PHY will provide the necessary clocks to drive the WoL blocks if the link becomes active after the system has entered suspend. Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file") Signed-off-by: Doug Berger Acked-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++------ drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 6 +++++- drivers/net/ethernet/broadcom/genet/bcmmii.c | 6 ++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 2afd056056fb..bf52bd643846 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1991,6 +1991,8 @@ static void umac_enable_set(struct bcmgenet_priv *pri= v, u32 mask, bool enable) u32 reg; =20 reg =3D bcmgenet_umac_readl(priv, UMAC_CMD); + if (reg & CMD_SW_RESET) + return; if (enable) reg |=3D mask; else @@ -2010,13 +2012,9 @@ static void reset_umac(struct bcmgenet_priv *priv) bcmgenet_rbuf_ctrl_set(priv, 0); udelay(10); =20 - /* disable MAC while updating its registers */ - bcmgenet_umac_writel(priv, 0, UMAC_CMD); - - /* issue soft reset with (rg)mii loopback to ensure a stable rxclk */ - bcmgenet_umac_writel(priv, CMD_SW_RESET | CMD_LCL_LOOP_EN, UMAC_CMD); + /* issue soft reset and disable MAC while updating its registers */ + bcmgenet_umac_writel(priv, CMD_SW_RESET, UMAC_CMD); udelay(2); - bcmgenet_umac_writel(priv, 0, UMAC_CMD); } =20 static void bcmgenet_intr_disable(struct bcmgenet_priv *priv) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/n= et/ethernet/broadcom/genet/bcmgenet_wol.c index a2da09da4907..8ebca6bf300e 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c @@ -132,8 +132,12 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *= priv, return -EINVAL; } =20 - /* disable RX */ + /* Can't suspend with WoL if MAC is still in reset */ reg =3D bcmgenet_umac_readl(priv, UMAC_CMD); + if (reg & CMD_SW_RESET) + reg &=3D ~CMD_SW_RESET; + + /* disable RX */ reg &=3D ~CMD_RX_EN; bcmgenet_umac_writel(priv, reg, UMAC_CMD); mdelay(10); diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/eth= ernet/broadcom/genet/bcmmii.c index 213434aaf07f..56fad34461f7 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -96,6 +96,12 @@ void bcmgenet_mii_setup(struct net_device *dev) CMD_HD_EN | CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE); reg |=3D cmd_bits; + if (reg & CMD_SW_RESET) { + reg &=3D ~CMD_SW_RESET; + bcmgenet_umac_writel(priv, reg, UMAC_CMD); + udelay(2); + reg |=3D CMD_TX_EN | CMD_RX_EN; + } bcmgenet_umac_writel(priv, reg, UMAC_CMD); =20 priv->eee.eee_active =3D phy_init_eee(phydev, 0) >=3D 0; --=20 2.34.1