Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1469273rdb; Wed, 6 Dec 2023 22:52:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IESNlNOWiob1or9qY1yLqtoiRyn9L55Iv3NqwQ/g2umYp3Ho01f2N2bcl5cEMtXfijiNDLN X-Received: by 2002:a17:902:7842:b0:1d0:6ffe:1e6e with SMTP id e2-20020a170902784200b001d06ffe1e6emr1569899pln.81.1701931939155; Wed, 06 Dec 2023 22:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701931939; cv=none; d=google.com; s=arc-20160816; b=yqSKJlCZZ87pQ6TttTsg+yDm9mj4hKAaapo3w0qGdn3SakauysFBIBYRhpa30og7Dg s44oLabzvNnDzWtYfN22vcxNfOxVJT5B477BOdWzUZcpUa5fvHqJFKZozqmBPtb2lIQH n7nHAnpDhIW0pD2x2lusTBlz1gRh4MZ9cwqARLqc0aErOMpzEu7RU/iByOoOJlsl42Yj 5h8ZZk3QMg5zaSLkp5x41xJiXy2mr0c8HTRNejxUs7g/4XoX0bE+nmS8mCmCZqGQkaBa yqRxH4UaSBQQgT1mnZJtGnfwHZiwxVNYYHy7bOJsVM4t8xMbeERj9FsU9OwMP6woO0gC q8pQ== 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:dkim-signature; bh=P021h3HtosWIlf7YJKZvwxMCdUSfZ2ZSmafpEm4qnvY=; fh=bpfWTH0v8env0+tb2tXSKZcv5uAZWZXm27MnbeLPudI=; b=j5JR2F5WI8eQGokPJoEoZEpO9AjYPzUDS57vZEjsd63URqzeZiLd1FHSRCVcLGpzDn r4mn4cCtw24Q8ACcpTgey+ZoOyeVxE9lkEshhrVMy3Sr1b+egtL/gzBGo6kK3/voWZOH nYc1oWDkVsRxMWQgqo4Z2fLq05oOzcC6kjuCBe9DoTkd5J2Fp1lG49SpgrvIaR0yjJ3t i6aJzTkdbBvs8+pRu67O/g8EZVTTYKRdV/IL7VYG+IeKfvdh+pyn6lvuCyzeIIzm8L7K x7nL1lyTTpkP3NR/ponJ3DT8SECRVvv6l4u9lsJI5RWBgxSb7rTu8eg5DvFfWzjmEO5w YZJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZrCGOR01; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id a3-20020a170902ecc300b001cfe02fa89esi642175plh.117.2023.12.06.22.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 22:52:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZrCGOR01; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 723A080F6D34; Wed, 6 Dec 2023 22:52:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbjLGGvu (ORCPT + 99 others); Thu, 7 Dec 2023 01:51:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377838AbjLGGvb (ORCPT ); Thu, 7 Dec 2023 01:51:31 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12BC3173C for ; Wed, 6 Dec 2023 22:51:15 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40c05ce04a8so7481525e9.0 for ; Wed, 06 Dec 2023 22:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701931873; x=1702536673; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=P021h3HtosWIlf7YJKZvwxMCdUSfZ2ZSmafpEm4qnvY=; b=ZrCGOR01tsI06Nb1os2hQQrqqiSCuUqdkELAwFnzK/ap2QRXiZeykSRSbf5ZWEkCx6 /OslsH/efWxu0ergjii0L81MxHfKURFDI5Fg0H/IMcR0xDSXaw42C/v3lUSbhGc8z94J CodYqEAYhcGmn6Cb9mVHJFyCQUOST2ZvhGy/1Er7l/k0KhMRVn9soCiI2K8fuvppYPED x6rSQ8XbpEH3eP8p7xMzaKiStTzbZCy5fsHLZMHZlQsMx21Dw3y9vh378KuW70kdQAVw ytQsQ7V/omBLuH8sIVQ8Ea2pz4Xmi7bUNf2zLQiuEdtHx4vnXwS+0ZqsVd/rGgua3Sb1 A8Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701931873; x=1702536673; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P021h3HtosWIlf7YJKZvwxMCdUSfZ2ZSmafpEm4qnvY=; b=ARGahVghCewp02bwhvX9qPRQCxX6vqSbTGVB12BAn2bd79Jt5GBjrdk5ed2eKmBJuu +X66SfqiX1RjIX/dLBWt/vSMcarIJGcb22gr1M0xhk134kMFKAVFh0LVDxGUJt+ENX64 Z36qUitcYg8pmsiXQsIOlILHnunI287OIOL1kY2UhmdgYKhtywmvdKAyAb41RrlsScWm rIqf64+cPeF5AX9n1DHwhpGdofEEbthF/Vyx84wT5qxgko/nxy15i8fW2kr4isyT3kES scAFxuQhvvmlMjZEs6N3DWn7G10VnYHD7dO63yy7/PCOMNiErizBAoP+hQ/nJyEKEYXZ 8UJg== X-Gm-Message-State: AOJu0YxtultiN9VA/VqkVizO/E2lcuOvmwohKXYGW+LIiJz5RBFghk+C m/3fBzY5QA5vYkK0UWfxW3S+6Q== X-Received: by 2002:a05:600c:3381:b0:40b:5f03:b3f6 with SMTP id o1-20020a05600c338100b0040b5f03b3f6mr670880wmp.280.1701931873077; Wed, 06 Dec 2023 22:51:13 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id l7-20020a1c7907000000b0040b4562ee20sm450698wme.0.2023.12.06.22.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 22:51:12 -0800 (PST) Date: Thu, 7 Dec 2023 09:51:07 +0300 From: Dan Carpenter 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 , 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 Subject: Re: [PATCH net-next 07/15] net: dsa: mt7530: do not run mt7530_setup_port5() if port 5 is disabled Message-ID: <90fde560-054e-4188-b15c-df2e082d3e33@moroto.mountain> 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: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 22:52:16 -0800 (PST) On Sat, Dec 02, 2023 at 11:45:42AM +0300, Arınç ÜNAL wrote: > > 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); Smatch doesn't know: 1) What the value of priv->p5_intf_sel is going into this function 2) We enter the for_each_child_of_node() loop 3) That if (phy_node->parent == priv->dev->of_node->parent) { is definitely true for one element on the list. Looking at how Smatch parses this code, I could probably improve problem #1 a bit. Right now Smatch sees "struct mt7530_priv *priv = ds->priv;" and "priv->p5_intf_sel" is unknown, but I could probably improve it to where it says that it's in the 1-3 range. But that doesn't help here and it doesn't address problems 2 and 3. It's a hard problem. regards, dan carpenter