Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1570105rdb; Sat, 2 Dec 2023 00:51:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAoCNpuYkfL3CNU++m0FO8RUCFulAY88zTuiaIApv/uspR4tvCr9fpSHzxZGTJtJZatoHA X-Received: by 2002:a05:6870:cb9c:b0:1fb:75a:de76 with SMTP id ov28-20020a056870cb9c00b001fb075ade76mr1404289oab.100.1701507067860; Sat, 02 Dec 2023 00:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701507067; cv=none; d=google.com; s=arc-20160816; b=WWIBc2NkCsFjQoypyYW6dyazTE5EwwH8Hxjua9/bN4+o+8nWIPE2lu5LDOXb/bKhbv QK3IbMySIIFrUcPzrVJHBXMjkuaPPYZcc0SfFnbYBGb9KgTxpGxESdlPOHPoEQELPhy2 XF8kC9WIAaCo0rl/foEVY9ACVUXXioYt7v9080urqAPHmYqPNx120XlZLoFtlkbHjyNE 2m8X5TtOtzEteC/7Ef7hn+P6YlERWq9J50mVTpo8sWt9p3ISW6X3gDDIk+K09OAvHt/6 E6Gjp5EEcede/anTuW0eHJVO8MbUIHa8D6A0QrNt9jBVWgpvu0nTVcVBapSzmvB2zEKA +KCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=N3Cgz/RmVnXRaNyY/Ku+4ixDljoP++5AapC1K6OMFqY=; fh=R0OGAjESsvv0u3Tm5DgRyKwqKsmx5lEDiSMvd7dHC/g=; b=nt7RxhhiR9dWbay22a5fhl5UnA368jt+32hKn+ezzB0gSIfNoAogUsbcLFaQuHtVXI CA05T1pOkT6xBP4nOStFVrBaViERHeTusHeiMw9HCL9G3GrXEUIQ07kU8jeE+hokUPnK zDJt+4Nv54a33sm81v64hnWi+xprEx+XDNbX0doL2G7fc3xhuHF5ivg9IrZg0T2OZnGt o+cFVgfeyyY49b4aNG/XaPIfx9ZIPDAXF/1+43cPQdoiIKn60XuVxoBwGr8PM5XemizS V47BeWPnMdOuwfCC6YpxgLoo/d5sgvuPoAFLvs7Fdm/UQqzj/ScioStebrEc3K+zsbUM T7QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arinc9.com header.s=gm1 header.b=VN8OzUDC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arinc9.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l70-20020a639149000000b005c662c8da8csi474862pge.210.2023.12.02.00.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 00:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@arinc9.com header.s=gm1 header.b=VN8OzUDC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arinc9.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 82A3F8066674; Sat, 2 Dec 2023 00:50:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbjLBIqR (ORCPT + 99 others); Sat, 2 Dec 2023 03:46:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjLBIqQ (ORCPT ); Sat, 2 Dec 2023 03:46:16 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1A9313D; Sat, 2 Dec 2023 00:46:21 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 32C6BE0002; Sat, 2 Dec 2023 08:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arinc9.com; s=gm1; t=1701506780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3Cgz/RmVnXRaNyY/Ku+4ixDljoP++5AapC1K6OMFqY=; b=VN8OzUDCzkX2EwouK6RVqpAm1WMb/E2SxB+XQ9odyRUXx1f4MW6Srr0UzflTGIbL0+e7Pz yddypq6Hv6svDddCpBSIX2VGG2pIGQMenRwfXXv7jxvzvs68IVc8wZP+FST3N4pN7fJKyH U7+geOCU/iS4Smg2TOjkrwSCTNSRcF+hYrQDNRPOICDBrepKFLw7toluY0sciyvTPLKFhQ Qu6+cXck5UN8ZhBiK9zBaN4qNwUTxJ208m9xnTNTQkR+8X/UCWRgRqTP8eYgQxnL1z6z1y ck4JCS8QVK/DFsl/WhLgberYcK2p3evk8jER/W/kj4aPoMR/KB/uNi4584vIUw== Message-ID: Date: Sat, 2 Dec 2023 11:45:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 07/15] net: dsa: mt7530: do not run mt7530_setup_port5() if port 5 is disabled Content-Language: en-US To: Simon Horman Cc: 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 , Russell King , 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 References: <20231118123205.266819-1-arinc.unal@arinc9.com> <20231118123205.266819-8-arinc.unal@arinc9.com> <20231121185358.GA16629@kernel.org> From: =?UTF-8?B?QXLEsW7DpyDDnE5BTA==?= In-Reply-To: <20231121185358.GA16629@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: arinc.unal@arinc9.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 02 Dec 2023 00:50:45 -0800 (PST) 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. for_each_child_of_node(dn, mac_np) { if (!of_device_is_compatible(mac_np, "mediatek,eth-mac")) continue; ret = of_property_read_u32(mac_np, "reg", &id); if (ret < 0 || id != 1) continue; phy_node = of_parse_phandle(mac_np, "phy-handle", 0); if (!phy_node) continue; if (phy_node->parent == priv->dev->of_node->parent) { ret = of_get_phy_mode(mac_np, &interface); if (ret && ret != -ENODEV) { of_node_put(mac_np); of_node_put(phy_node); return ret; } id = of_mdio_parse_addr(ds->dev, phy_node); if (id == 0) priv->p5_intf_sel = P5_INTF_SEL_PHY_P0; if (id == 4) priv->p5_intf_sel = P5_INTF_SEL_PHY_P4; } of_node_put(mac_np); of_node_put(phy_node); break; } if (priv->p5_intf_sel == P5_INTF_SEL_PHY_P0 || priv->p5_intf_sel == P5_INTF_SEL_PHY_P4) mt7530_setup_port5(ds, interface); Arınç