From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6BD4C77B76 for ; Fri, 21 Apr 2023 18:42:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbjDUSmq (ORCPT ); Fri, 21 Apr 2023 14:42:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbjDUSmj (ORCPT ); Fri, 21 Apr 2023 14:42:39 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7B810C; Fri, 21 Apr 2023 11:42:36 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ppvi0-0002fM-1F; Fri, 21 Apr 2023 20:42:12 +0200 Date: Fri, 21 Apr 2023 19:42:09 +0100 From: Daniel Golle To: arinc9.unal@gmail.com Cc: Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King , =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= , Richard van Schagen , Richard van Schagen , Frank Wunderlich , 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: [RFC PATCH net-next 20/22] net: dsa: mt7530: force link-down on MACs before reset on MT7530 Message-ID: References: <20230421143648.87889-1-arinc.unal@arinc9.com> <20230421143648.87889-21-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230421143648.87889-21-arinc.unal@arinc9.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 21, 2023 at 05:36:46PM +0300, arinc9.unal@gmail.com wrote: > From: Arınç ÜNAL > > Force link-down on all MACs before internal reset. Let's follow suit commit > 728c2af6ad8c ("net: mt7531: ensure all MACs are powered down before > reset"). > > Tested-by: Arınç ÜNAL > Signed-off-by: Arınç ÜNAL > --- > drivers/net/dsa/mt7530.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c > index ac1e3c58aaac..8ece3d0d820c 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -2203,6 +2203,10 @@ mt7530_setup(struct dsa_switch *ds) > return -EINVAL; > } > > + /* Force link-down on all MACs before internal reset */ > + for (i = 0; i < MT7530_NUM_PORTS; i++) > + mt7530_write(priv, MT7530_PMCR_P(i), PMCR_FORCE_LNK); > + Moving this part to mt753x_setup just before calling priv->info->sw_setup(ds); is probably better. Though it isn't documented I assume that the requirement to have the ports in force-link-down may also apply to MT7988, and for sure it doesn't do any harm. Hence I suggest to squash this change: diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index a2cb7e296165e..998c4e8930cd3 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2203,10 +2203,6 @@ mt7530_setup(struct dsa_switch *ds) return -EINVAL; } - /* Force link-down on all MACs before internal reset */ - for (i = 0; i < MT7530_NUM_PORTS; i++) - mt7530_write(priv, MT7530_PMCR_P(i), PMCR_FORCE_LNK); - /* Reset the switch through internal reset */ mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST | @@ -2423,10 +2419,6 @@ mt7531_setup(struct dsa_switch *ds) dev_info(priv->dev, "found MT7531BE\n"); } - /* all MACs must be forced link-down before sw reset */ - for (i = 0; i < MT7530_NUM_PORTS; i++) - mt7530_write(priv, MT7530_PMCR_P(i), MT7531_FORCE_LNK); - /* Reset the switch through internal reset */ mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST | @@ -2907,6 +2899,10 @@ mt753x_setup(struct dsa_switch *ds) priv->pcs[i].port = i; } + /* Force link-down on all MACs before setup */ + for (i = 0; i < MT7530_NUM_PORTS; i++) + mt7530_write(priv, MT7530_PMCR_P(i), PMCR_FORCE_LNK); + ret = priv->info->sw_setup(ds); if (ret) return ret;