Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3990738iog; Tue, 28 Jun 2022 07:00:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t9nbC95VIeLA6xBOXVW3iYh3bDp5E2ffuYGlQRlFMXsItj/+vwsEKwz6JbVaP0074FDcXk X-Received: by 2002:a17:903:22c2:b0:16a:3039:adb1 with SMTP id y2-20020a17090322c200b0016a3039adb1mr3809227plg.28.1656424809966; Tue, 28 Jun 2022 07:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656424809; cv=none; d=google.com; s=arc-20160816; b=ECOV+kHugXENYy62K/G9AH8WYt46EWvJxF0JRXUFG9dpZf2dGorLya6fm4T8aivatQ 9/Nwfl1RobFmZOGipq8d3+T+jJj0zL3v8eL0+5HRTQQhqiWHsXpzNXE/qCj1lf80UdKU xuzLCkG9fpzuH/j8PgrWpSiDDFOrr+Q65dRIpg7bPVveF1/DD/BHd4FotkFnmTPnQlo8 vMo7uxmeX3DpuZbaBTfDSzz14o9f/xH2FJLDV26n4DAL69pM3/2lDytt0XAR09EMkrh7 sd6CfpydazJWsi0GOSQJWwJxJ2Yupoz+klXgoUzMpZub22E12SPOkPsZz2nfT59cD2X3 ByjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=mvU588fHhLDk/FSFjMsTn0jfhxkTBTaysnF8j0/C2xI=; b=Yj3ib9AD45lwCpFbN0buss3YljSmP0yBMiHwIWWMpA8Tzevd1KPAlPLWJpa5dAYy2W 3jzW41JGfWs8LpuWEgTFKzJq0Stc7tZu4AcAXLVdaL/cjr1B4OVNjMhJI/LoXxWPqacJ 6+YhXfbY/I5xBuc1W7wC//N14wbV1yOD74SQwtmcAZv4FIBapLYykL06elIM8ARXDaa8 o3PvNAN38hBuCiMnp5dZrv1IzW3uwbP3EV2TJuacI8YI1M3Lnr69Du+jNTcFiW3gOkf8 kCDF98npyW6Bmym74JggLDuAVjVlZSeGqOP0jmK4bl/rJ+OmYT+hs3UbqyPIQ3fzCyub 0ZwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=A84TCTJU; 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 p2-20020a056a000b4200b00518a0f3ba68si15867026pfo.347.2022.06.28.06.59.56; Tue, 28 Jun 2022 07:00:09 -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; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=A84TCTJU; 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 S1346876AbiF1NsH (ORCPT + 99 others); Tue, 28 Jun 2022 09:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346884AbiF1NsD (ORCPT ); Tue, 28 Jun 2022 09:48:03 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F6B2A966; Tue, 28 Jun 2022 06:48:02 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id E1B4522246; Tue, 28 Jun 2022 15:47:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656424080; 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=mvU588fHhLDk/FSFjMsTn0jfhxkTBTaysnF8j0/C2xI=; b=A84TCTJU719Ug8WU3XD4Yne89LJC6YZr+gkybgqwpjDiSB4njGiAzm5Qm8v1UEZjCwc8Ok NP2ljMffsEG5fWv6cDo7kDQxFWqcpsZKO28C4vhMLVip9NHmN19hc/WSp96p6ORgo5i+ho PCcWo1sCd52JVsCXwFtS9tUqH97nvf0= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 28 Jun 2022 15:47:59 +0200 From: Michael Walle To: Andy Shevchenko Cc: Andy Shevchenko , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , ACPI Devel Maling List , devicetree , Linux Kernel Mailing List , Horatiu Vultur Subject: Re: fwnode_for_each_child_node() and OF backend discrepancy In-Reply-To: References: <4e1d5db9dea68d82c94336a1d6aac404@walle.cc> <2f2d7685e0e43194270a310034004970@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <9e58f421c27121977d11381530757a6e@walle.cc> X-Sender: michael@walle.cc X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 [adding Horatiu Vultur, because we now digress to the bug in the switch, rather than that odd OF behavior] Am 2022-06-28 15:29, schrieb Andy Shevchenko: > On Tue, Jun 28, 2022 at 3:23 PM Michael Walle wrote: >> >> >> I was trying to fix the lan966x driver [1] which doesn't work if there >> >> are disabled nodes in between. >> > >> > Can you elaborate what's wrong now in the behaviour of the driver? In >> > the code it uses twice the _available variant. >> >> Imagine the following device tree snippet: >> port0 { >> reg = <0>; >> status = "okay"; >> } >> port1 { >> reg = <1>; >> status = "disabled"; >> } >> port@2 { >> reg = <2>; >> status = "okay"; >> } >> >> The driver will set num_phys_ports to 2. When port@2 is probed, it >> will have the (correct!) physical port number 2. That will then >> trigger various EINVAL checks with "port_num >= num_phys_ports" or >> WARN()s. > > It means the above mentioned condition is wrong: it should be > > "port_idx >= num_phys_ports" (if the port_idx doesn't exists, that's > the bug in the first place) I can't follow you here. Please note, that you need the actual physical port number. It's not a made up number, but corresponds to a physical port on that ethernet switch. So you can't just skip the disabled ones. port@2 must have port number 2. >> So the easiest fix would be to actual count all the child nodes >> (regardless if they are available or not), assuming there are as >> many nodes as physical ports. >> >> But num_phys_ports being a property of the hardware > > So, name is wrong, that's how I read it, it should be > num_of_acrive_phys_ports (or alike). See above, it is not just an iterator but corresponds to a hardware property. >> I don't >> think it's good to deduce it by counting the child nodes anyway, > > Right. > >> but it should rather be a (hardcoded) property of the driver. > > Also good to update. Horatiu, can we determine the actual number of ports (or maybe determine if its a LAN9668 or a LAN9662) from the hardware itself in an easy way? That way we wouldn't need a new compatible string, but could use the generic "lan966x" one. -michael [1] https://elixir.bootlin.com/linux/v5.19-rc4/source/drivers/net/ethernet/microchip/lan966x/lan966x_main.c