Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1584386rdb; Sat, 2 Dec 2023 01:31:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFB6F1zVplGFOlb5dvuIgh8HV1O5SmLHuMnaqUvVov46bEHhtI6cImsHrEfr40q3AciUFIB X-Received: by 2002:a05:6808:2196:b0:3ae:18c0:dd8e with SMTP id be22-20020a056808219600b003ae18c0dd8emr1454975oib.27.1701509489343; Sat, 02 Dec 2023 01:31:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701509489; cv=none; d=google.com; s=arc-20160816; b=DgAKVGEY2BNOJ9//z6ya0ODMw4GLRuM9SJUvDmSxXDcDYjFjzJAtYw1VdVomH7yxyJ 4SAvziPd8r8x0SMzfu36uBvFNHRZodubupnI85GDSdmx/3G+4C3iPUDv6vnVSooL0JXb 9CG1HEi9GZ+dgVxwJJlfuE+Xx78oNWXKAbHJSrg1JE4FWHL2Gve8JzLDXjBc04X4Qhpg BXTbz/+v+MQS586Y+K79A147zCt6a7nbKxv2tkGH+RyPqpZ38ErwwSymtekw8fKiPwXk kcRoLkOEeu+8YhHeSq/SWrD32jFHJjAfHAyOSOuJlelVFv88peMyvLg8GJaI83bwKhas axpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cJLjF77y4SxHEjhOXmOD85mb2tXiT1lNxpnlYkZDglQ=; fh=1t7X2k95x5cU8aKyE/d+Rz6X+vaeUHbLAJUysXfvSdM=; b=Q0mQ4PsPl3Cnkx+D1MoA+Cy2RmtDkjIkw8vI8bXJBPc0KP9TDoG5lOdrM5YCclORXU wS4+SMhQQ3jNzJhiJPe8KB8eqKrgkCO4ZZKUM3dlbnISxxSKv1+jDPnEhsEp6lBq2O9k JypHEsyo2UkMHWvXQ3BKmyQe/qoBUGMvSctTdTsTFycx1q1A0MKjbjOWsyQWMdrBbnLq WLqNL06ojWLr10HPFK9fj3lqIx3krZUQCglrTlLTuOZf7QUv3iTno2VC0vh5gItFCJ3O Hm2jA002c48q8NF+YxUqRTsifP3ysnfHZyoV2OURlK78RHjk9kygeJT5Moq9TjouMH9s tphw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=PV3qkCYH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id g9-20020a056a000b8900b006cdf15ae390si4049599pfj.325.2023.12.02.01.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 01:31:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=PV3qkCYH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 591B580AC375; Sat, 2 Dec 2023 01:30:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231984AbjLBJah (ORCPT + 99 others); Sat, 2 Dec 2023 04:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbjLBJag (ORCPT ); Sat, 2 Dec 2023 04:30:36 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 434ED129; Sat, 2 Dec 2023 01:30:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cJLjF77y4SxHEjhOXmOD85mb2tXiT1lNxpnlYkZDglQ=; b=PV3qkCYHbGLiIITrG9RmdVBpGt dZM+/IuzIBJsIhispOgoPrWvFxw0DTPbZGEm5CtaF0Qs2Ep3N+gsw0lOiKrWZH0CC6cHPENHUcycP LYjXjV8dJHRM6XIxLqVrf0aunHcAC/o4Lz7CGJrMtTTRABiQwnN35QNhl6dWTt2nl5OwohIh+/GB7 5MotVL2W4IVGe+suBjtekgHICGTClzxiF2pQJeLSVBybGgTLt/2enbborcxowEaaKq1NYVLomTMeX ftnt37kMGJlxW5Zmn7K7bnzLPdvcZc6QTEbYMoWyKUuts2+L8sNMF0fjJzvi07+2tQ0+ta/EhMcnc W5a8JLhQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:53892) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r9MKT-0003yv-03; Sat, 02 Dec 2023 09:30:29 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r9MKQ-0006xW-U6; Sat, 02 Dec 2023 09:30:26 +0000 Date: Sat, 2 Dec 2023 09:30:26 +0000 From: "Russell King (Oracle)" To: =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= Cc: Simon Horman , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Frank Wunderlich , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com Subject: Re: [PATCH net-next 07/15] net: dsa: mt7530: do not run mt7530_setup_port5() if port 5 is disabled Message-ID: References: <20231118123205.266819-1-arinc.unal@arinc9.com> <20231118123205.266819-8-arinc.unal@arinc9.com> <20231121185358.GA16629@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 02 Dec 2023 01:30:57 -0800 (PST) On Sat, Dec 02, 2023 at 11:45:42AM +0300, Arınç ÜNAL wrote: > Hi Simon. > > On 21.11.2023 21:53, Simon Horman wrote: > > On Sat, Nov 18, 2023 at 03:31:57PM +0300, Arınç ÜNAL wrote: > > > There's no need to run all the code on mt7530_setup_port5() if port 5 is > > > disabled. The only case for calling mt7530_setup_port5() from > > > mt7530_setup() is when PHY muxing is enabled. That is because port 5 is not > > > defined as a port on the devicetree, therefore, it cannot be controlled by > > > phylink. > > > > > > Because of this, run mt7530_setup_port5() if priv->p5_intf_sel is > > > P5_INTF_SEL_PHY_P0 or P5_INTF_SEL_PHY_P4. Remove the P5_DISABLED case from > > > mt7530_setup_port5(). > > > > > > Stop initialising the interface variable as the remaining cases will always > > > call mt7530_setup_port5() with it initialised. > > > > > > Signed-off-by: Arınç ÜNAL > > > Reviewed-by: Vladimir Oltean > > > --- > > > drivers/net/dsa/mt7530.c | 9 +++------ > > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c > > > index fc87ec817672..1aab4c3f28b0 100644 > > > --- a/drivers/net/dsa/mt7530.c > > > +++ b/drivers/net/dsa/mt7530.c > > > @@ -942,9 +942,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) > > > /* MT7530_P5_MODE_GMAC: P5 -> External phy or 2nd GMAC */ > > > val &= ~MHWTRAP_P5_DIS; > > > break; > > > - case P5_DISABLED: > > > - interface = PHY_INTERFACE_MODE_NA; > > > - break; > > > default: > > > dev_err(ds->dev, "Unsupported p5_intf_sel %d\n", > > > priv->p5_intf_sel); > > > @@ -2313,8 +2310,6 @@ mt7530_setup(struct dsa_switch *ds) > > > * Set priv->p5_intf_sel to the appropriate value if PHY muxing > > > * is detected. > > > */ > > > - interface = PHY_INTERFACE_MODE_NA; > > > - > > > for_each_child_of_node(dn, mac_np) { > > > if (!of_device_is_compatible(mac_np, > > > "mediatek,eth-mac")) > > > @@ -2346,7 +2341,9 @@ mt7530_setup(struct dsa_switch *ds) > > > break; > > > } > > > - mt7530_setup_port5(ds, interface); > > > + if (priv->p5_intf_sel == P5_INTF_SEL_PHY_P0 || > > > + priv->p5_intf_sel == P5_INTF_SEL_PHY_P4) > > > + mt7530_setup_port5(ds, interface); > > > > Hi Arınç, > > > > It appears that interface is now uninitialised here. > > > > Flagged by Smatch. > > I'm not sure why it doesn't catch that for mt7530_setup_port5() to run > here, priv->p5_intf_sel must be either P5_INTF_SEL_PHY_P0 or > P5_INTF_SEL_PHY_P4. And for that to happen, the interface variable will be > initialised. It's probably due to the complexities involved in analysing the values of variables, especially when they're in structures that are passed in. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!