Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp165163lqa; Fri, 26 Apr 2024 19:24:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUlLFmlw0IitzM/P/UECF4PuNcg9Tys0v7L0r90jb3dUpQWWdg1voS6OgZXQi+Qd8i8NHE2NrUfoaME7uc09mk5ePwVSHVqMMPRWitQA== X-Google-Smtp-Source: AGHT+IGCTGCWhK0j0JbL/c6tlWC+dSMys9Zk8nmreaz37KHWEmk1AtJAhzTUHsV/RMCUmpcISz3J X-Received: by 2002:a17:906:414:b0:a55:bd8e:b6ef with SMTP id d20-20020a170906041400b00a55bd8eb6efmr2850453eja.37.1714184692141; Fri, 26 Apr 2024 19:24:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714184692; cv=pass; d=google.com; s=arc-20160816; b=sx1tHk8F9QGc045TA+pHnrm/uWQPNwffVMb84JbHqB06RpPJ2qrMRGqfFIbAC6il7G gA9eWtLxO6B0j7BckqRzeTNxM3PJuZ7dGjfg8vcBk9/iLpbUf5OZthVWzhmbV1XMdUQ7 zysAoVmP1o3pz/Lh7blywAgOYV5YwA2jLegKrKH6kFC1sxIYrTRA0hXQfcckhMOdozk5 sCcf9EDc0OAnbP4fpNdWEX0EniXTA9cZzPMRnldHdYquYbngWRtCrrukC+YYRCMJcTTo P/JAEeRBaqZaOoKi2fAgz77H4jxQ8Kr7Fb5XDzzqUPtFoivBKCD+G9fDwXXF53evg/f8 IAcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=LR/N8sOjphbjY7ylgbYn/+iB6DYtb+qs9Q0b8OwvBnQ=; fh=Yu8l9KjV8p/zzQw9H9jZijhDFiVfJPQhYhNjL9unBpk=; b=0XLXJ1Matb2LqqvcO4ZrxXd+al7R5q9hGab0XgEZFs4BkSOBpKb7OgjAhyN6Zt9LNY u2fh7Jir+kJko5dimqT7SJVLWcV9C/VJKPtunTh1tNFm/HuFzHz9A8WoAMLfhYwLuB6c mg99cCOQj7jcNN32d1vc2ritvkVe68Lrv5nuy+sFwaTxtJAxO+Ig++Bzz8CULAvgDYUq jwdgdoNyF8apLwMrKL6l13jFic/PA1nHWDwZRzVpYEdOu/hv+P6JNBTNoA+LM7xZjayT JIi5LXH3Zfe1rDYxvC8G2w2bPLydKbY+IG16rOiAI0NeluR3i/wMbLtY58q4ikuP0PEJ 8zTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-160870-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160870-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lf28-20020a170907175c00b00a4734e76a0bsi11362672ejc.660.2024.04.26.19.24.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 19:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160870-linux.lists.archive=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=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-160870-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160870-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 8EA021F22A46 for ; Sat, 27 Apr 2024 02:24:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B44203A1C7; Sat, 27 Apr 2024 02:24:41 +0000 (UTC) Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 2BF83848E; Sat, 27 Apr 2024 02:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714184681; cv=none; b=OoeuOFDi5+PxTZUC45LUvOxbOhD+OiKuge24Hw2rRSgiDsbhoD1suIMODfgPGUlQhPB0/TvsMrPNe6QE4CcjG5lNudKqoclng8CBD6csJDIXTDt5y6YTtbpy7Rk7qQAmQbtSvNR1RXQcvHS5stoHeK1IKztgAjIQQFBWyNVSuOU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714184681; c=relaxed/simple; bh=1g27sArCdxbgAlOBIQTYU/aDJvTnXRH0RTbjbh4Bvxo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mLXHk69iKzBqEg5xcC6uhbCxqw70u5InVzAkmNG4DP9mxXe4AbmNN+fMklgMECyMaJPo1UyRT81o4QKMEglTEp8XEsog4fz7k1yMDe1rFbsfOLqtkSlqsHs1iM+LqFln4JXKzbbLP2NQ11d3GBoSjW8LoP5Uu+4SjTqcLFv36pA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.97.1) (envelope-from ) id 1s0Xjl-000000006AF-2noj; Sat, 27 Apr 2024 02:24:25 +0000 Date: Sat, 27 Apr 2024 03:24:18 +0100 From: Daniel Golle To: arinc.unal@arinc9.com Cc: DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH net-next v2 07/15] net: dsa: mt7530: move MT753X_MTRAP operations for MT7530 Message-ID: References: <20240422-for-netnext-mt7530-improvements-4-v2-0-a75157ba76ad@arinc9.com> <20240422-for-netnext-mt7530-improvements-4-v2-7-a75157ba76ad@arinc9.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240422-for-netnext-mt7530-improvements-4-v2-7-a75157ba76ad@arinc9.com> Hi Arınç, On Mon, Apr 22, 2024 at 10:15:14AM +0300, Arınç ÜNAL via B4 Relay wrote: > From: Arınç ÜNAL > > On MT7530, the media-independent interfaces of port 5 and 6 are controlled > by the MT7530_P5_DIS and MT7530_P6_DIS bits of the hardware trap. Deal with > these bits only when the relevant port is being enabled or disabled. This > ensures that these ports will be disabled when they are not in use. > > Do not set MT7530_CHG_TRAP on mt7530_setup_port5() as that's already being > done on mt7530_setup(). Multiple users reported ([1], [2]) that after I've imported the series to OpenWrt they noticed that WAN connection on MT7621 boards using PHY-muxing to hook up either port 0 or port 4 to GMAC1 no longer works. The link still seems to come up, but no data flows. I went ahead and confirmed the bug, then started bisecting the patches of this series, and ended up identifying this very patch being the culprit. I can't exclude that what ever the issue may be is caused by other downstream patches we have, but can confirm that removing this patch of your series [3] in OpenWrt fixes the issue. Please take a look and as the cover letter states you have tested this on some MT7621 board, please make sure traffic actually flows on the PHY-muxed port on that board after this patch is applied, and if not, please figure out why and repost a fixed version of this patch. Cheers Daniel [1]: https://github.com/openwrt/openwrt/issues/15273 [2]: https://github.com/openwrt/openwrt/issues/15279 [3]: https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=a8dde7e5bd6d289db6485cf57d3512ea62eaa827 > > Instead of globally setting MT7530_P5_MAC_SEL, clear it, then set it only > on the appropriate case. > > If PHY muxing is detected, clear MT7530_P5_DIS before calling > mt7530_setup_port5(). > > Signed-off-by: Arınç ÜNAL > --- > drivers/net/dsa/mt7530.c | 38 +++++++++++++++++++++++++++----------- > 1 file changed, 27 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c > index 606516206fb9..83436723cb16 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -880,8 +880,7 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) > > val = mt7530_read(priv, MT753X_MTRAP); > > - val |= MT7530_CHG_TRAP | MT7530_P5_MAC_SEL | MT7530_P5_DIS; > - val &= ~MT7530_P5_RGMII_MODE & ~MT7530_P5_PHY0_SEL; > + val &= ~MT7530_P5_PHY0_SEL & ~MT7530_P5_MAC_SEL & ~MT7530_P5_RGMII_MODE; > > switch (priv->p5_mode) { > /* MUX_PHY_P0: P0 -> P5 -> SoC MAC */ > @@ -891,15 +890,13 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) > > /* MUX_PHY_P4: P4 -> P5 -> SoC MAC */ > case MUX_PHY_P4: > - val &= ~MT7530_P5_MAC_SEL & ~MT7530_P5_DIS; > - > /* Setup the MAC by default for the cpu port */ > mt7530_write(priv, MT753X_PMCR_P(5), 0x56300); > break; > > /* GMAC5: P5 -> SoC MAC or external PHY */ > default: > - val &= ~MT7530_P5_DIS; > + val |= MT7530_P5_MAC_SEL; > break; > } > > @@ -1193,6 +1190,14 @@ mt7530_port_enable(struct dsa_switch *ds, int port, > > mutex_unlock(&priv->reg_mutex); > > + if (priv->id != ID_MT7530 && priv->id != ID_MT7621) > + return 0; > + > + if (port == 5) > + mt7530_clear(priv, MT753X_MTRAP, MT7530_P5_DIS); > + else if (port == 6) > + mt7530_clear(priv, MT753X_MTRAP, MT7530_P6_DIS); > + > return 0; > } > > @@ -1211,6 +1216,14 @@ mt7530_port_disable(struct dsa_switch *ds, int port) > PCR_MATRIX_CLR); > > mutex_unlock(&priv->reg_mutex); > + > + if (priv->id != ID_MT7530 && priv->id != ID_MT7621) > + return; > + > + if (port == 5) > + mt7530_set(priv, MT753X_MTRAP, MT7530_P5_DIS); > + else if (port == 6) > + mt7530_set(priv, MT753X_MTRAP, MT7530_P6_DIS); > } > > static int > @@ -2401,11 +2414,11 @@ mt7530_setup(struct dsa_switch *ds) > mt7530_rmw(priv, MT7530_TRGMII_RD(i), > RD_TAP_MASK, RD_TAP(16)); > > - /* Enable port 6 */ > - val = mt7530_read(priv, MT753X_MTRAP); > - val &= ~MT7530_P6_DIS & ~MT7530_PHY_INDIRECT_ACCESS; > - val |= MT7530_CHG_TRAP; > - mt7530_write(priv, MT753X_MTRAP, val); > + /* Allow modifying the trap and directly access PHY registers via the > + * MDIO bus the switch is on. > + */ > + mt7530_rmw(priv, MT753X_MTRAP, MT7530_CHG_TRAP | > + MT7530_PHY_INDIRECT_ACCESS, MT7530_CHG_TRAP); > > if ((val & MT7530_XTAL_MASK) == MT7530_XTAL_40MHZ) > mt7530_pll_setup(priv); > @@ -2488,8 +2501,11 @@ mt7530_setup(struct dsa_switch *ds) > break; > } > > - if (priv->p5_mode == MUX_PHY_P0 || priv->p5_mode == MUX_PHY_P4) > + if (priv->p5_mode == MUX_PHY_P0 || > + priv->p5_mode == MUX_PHY_P4) { > + mt7530_clear(priv, MT753X_MTRAP, MT7530_P5_DIS); > mt7530_setup_port5(ds, interface); > + } > } > > #ifdef CONFIG_GPIOLIB > > -- > 2.40.1 > >