Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2575968rwr; Fri, 21 Apr 2023 10:42:13 -0700 (PDT) X-Google-Smtp-Source: AKy350YE7Vv8Nt8ZscBhh/5DQb84xbXQYDVtOgV9ZijlHZII8+JI6pkseVxnWSBc89E72Fs40ebP X-Received: by 2002:a17:903:2447:b0:1a6:b196:619d with SMTP id l7-20020a170903244700b001a6b196619dmr6981711pls.6.1682098933322; Fri, 21 Apr 2023 10:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682098933; cv=none; d=google.com; s=arc-20160816; b=ZwQPtmX2XcbYRGruqxUSutGVyJ+WgJOc+9DrKgn001LasoyIfRjiZ4oal+92KWbvGy EDB/jg8c/uIwfhyFiSfddhQqt1EK3xAzkTDpJdt18L7eWsmEdi72uUjLz40pWyB8FYn3 WqXLIzimUW7vLt0C/oHQdIw1FLuFsZo970Wyd8iSB6TmMNip7DK8D+Z1ccbYl234lejW UU2wuTHABN545eB2o3IXH7zwLhDVq7MHrt5Y076cUM4CUcmilKMcGXvA6lcdJ+oPUPb9 yHVrwVmZYLkKEU1b+cdv/HOZCzhE4MO+B4tu3HyVLeDcTQe27KZpBY//p1OySAR+sLMQ alfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Xqf7VzXV95MBG4E7+Hs6pSQ8aagzF59Caahs7T58YgI=; b=r1QUby/I3DkBOemkBRr81fj/rIabl9+FdwCwvVUL3/d5RIXXpADS+s6JZcWHNv03aD 9QTXDKnZBAk5wGdYnjWNBjCoJLGFfh5jfeFMJTm1Zv9Mfj9UJAz0rFVEZ9gPkqlUhZFx m5a8UBjvotq/abu+XP33jwL2ckDZ/ZwTHo4UoZW0ZOHTqKdWNWeHT4IF+lGPLQm2+atk BnJNPMQrZuJrmrZy320Sju4VjcXw1hNATtZRwoudu4/siVmRGt/OTH2VJeeUmPJDnrSq uZIyS0k4q9W4+0a9pBGtCJ/xq5R92QnWCA9eT2od7h3Q8CAurxv+y3jB1eEB5eZZbGop Ow8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt6-20020a170903088600b001a6555fb909si4475666plb.183.2023.04.21.10.41.59; Fri, 21 Apr 2023 10:42:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbjDUR33 (ORCPT + 99 others); Fri, 21 Apr 2023 13:29:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjDUR31 (ORCPT ); Fri, 21 Apr 2023 13:29:27 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A300B12C96; Fri, 21 Apr 2023 10:29:26 -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 1ppuZB-0002Ee-23; Fri, 21 Apr 2023 19:29:01 +0200 Date: Fri, 21 Apr 2023 18:28:57 +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 08/22] net: dsa: mt7530: change p{5,6}_interface to p{5,6}_configured Message-ID: References: <20230421143648.87889-1-arinc.unal@arinc9.com> <20230421143648.87889-9-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-9-arinc.unal@arinc9.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 21, 2023 at 05:36:34PM +0300, arinc9.unal@gmail.com wrote: > From: Arınç ÜNAL > > The idea of p5_interface and p6_interface pointers is to prevent > mt753x_mac_config() from running twice for MT7531, as it's already run with > mt753x_cpu_port_enable() from mt7531_setup_common(), if the port is used as > a CPU port. > > Change p5_interface and p6_interface to p5_configured and p6_configured. > Make them boolean. > > Do not set them for any other reason. > > The priv->p5_intf_sel check is useless as in this code path, it will always > be P5_INTF_SEL_GMAC5. > > There was also no need to set priv->p5_interface and priv->p6_interface to > PHY_INTERFACE_MODE_NA on mt7530_setup() and mt7531_setup() as they would > already be set to that when "priv" is allocated. The pointers were of the > phy_interface_t enumeration type, and the first element of the enum is > PHY_INTERFACE_MODE_NA. There was nothing in between that would change this > beforehand. > > Tested-by: Arınç ÜNAL > Signed-off-by: Arınç ÜNAL NACK. This assumes that a user port is configured exactly once. However, interface mode may change because of mode-changing PHYs (e.g. often using Cisco SGMII for 10M/100M/1000M but using 2500Base-X for 2500M, ie. depending on actual link speed). Also when using SFP modules (which can be hotplugged) the interface mode may change after initially setting up the driver, e.g. when SFP driver is loaded or a module is plugged or replaced. > --- > drivers/net/dsa/mt7530.c | 19 ++++--------------- > drivers/net/dsa/mt7530.h | 10 ++++++---- > 2 files changed, 10 insertions(+), 19 deletions(-) > > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c > index bac2388319a3..2f670e512415 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -2237,8 +2237,6 @@ mt7530_setup(struct dsa_switch *ds) > val |= MHWTRAP_MANUAL; > mt7530_write(priv, MT7530_MHWTRAP, val); > > - priv->p6_interface = PHY_INTERFACE_MODE_NA; > - > /* Enable and reset MIB counters */ > mt7530_mib_reset(ds); > > @@ -2460,10 +2458,6 @@ mt7531_setup(struct dsa_switch *ds) > mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK, > MT7531_GPIO0_INTERRUPT); > > - /* Let phylink decide the interface later. */ > - priv->p5_interface = PHY_INTERFACE_MODE_NA; > - priv->p6_interface = PHY_INTERFACE_MODE_NA; > - > /* Enable PHY core PLL, since phy_device has not yet been created > * provided for phy_[read,write]_mmd_indirect is called, we provide > * our own mt7531_ind_mmd_phy_[read,write] to complete this > @@ -2733,25 +2727,20 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, > goto unsupported; > break; > case 5: /* Port 5, can be used as a CPU port. */ > - if (priv->p5_interface == state->interface) > + if (priv->p5_configured) > break; > > if (mt753x_mac_config(ds, port, mode, state) < 0) > goto unsupported; > - > - if (priv->p5_intf_sel != P5_DISABLED) > - priv->p5_interface = state->interface; > break; > case 6: /* Port 6, can be used as a CPU port. */ > - if (priv->p6_interface == state->interface) > + if (priv->p6_configured) > break; > > mt753x_pad_setup(ds, state); > > if (mt753x_mac_config(ds, port, mode, state) < 0) > goto unsupported; > - > - priv->p6_interface = state->interface; > break; > default: > unsupported: > @@ -2859,12 +2848,12 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) > else > interface = PHY_INTERFACE_MODE_2500BASEX; > > - priv->p5_interface = interface; > + priv->p5_configured = true; > break; > case 6: > interface = PHY_INTERFACE_MODE_2500BASEX; > > - priv->p6_interface = interface; > + priv->p6_configured = true; > break; > default: > return -EINVAL; > diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h > index f58828577520..c3a37a0f4843 100644 > --- a/drivers/net/dsa/mt7530.h > +++ b/drivers/net/dsa/mt7530.h > @@ -745,8 +745,10 @@ struct mt753x_info { > * @ports: Holding the state among ports > * @reg_mutex: The lock for protecting among process accessing > * registers > - * @p6_interface: Holding the current port 6 interface > - * @p5_interface: Holding the current port 5 interface > + * @p6_configured: Flag for distinguishing if port 6 of the MT7531 switch > + * is already configured > + * @p5_configured: Flag for distinguishing if port 5 of the MT7531 switch > + * is already configured > * @p5_intf_sel: Holding the current port 5 interface select > * @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch > * has got SGMII > @@ -767,8 +769,8 @@ struct mt7530_priv { > const struct mt753x_info *info; > unsigned int id; > bool mcm; > - phy_interface_t p6_interface; > - phy_interface_t p5_interface; > + bool p6_configured; > + bool p5_configured; > p5_interface_select p5_intf_sel; > bool p5_sgmii; > u8 mirror_rx; > -- > 2.37.2 >