Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp288193imn; Thu, 28 Jul 2022 00:04:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tnHBE2EYrvpPQ3fRmM2FQm/g/+dzTkvCvd5o9IbDTw5J/efj4e8nqLRi8re/jTVqkhyZkh X-Received: by 2002:a17:903:2d0:b0:16c:39bc:876 with SMTP id s16-20020a17090302d000b0016c39bc0876mr25178555plk.42.1658991882464; Thu, 28 Jul 2022 00:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658991882; cv=none; d=google.com; s=arc-20160816; b=C04rMJBfHelDbt1bbR+by7LEJyJ7y9n+v2c8K9NIAy8JwtRsQGEsrpNAo3RHCRdcyb fOCQuDQi/Ylx5rCAEfvHR2yGK1l9IzxyWDnD5Ew9B2nPcdZjgS8xa777kSfCI8BOBGDa v9NmG0xTWiQyRd6+5+QUS7HH3etj+rnf5bikN8rFbAr3Js+ugjaHaClMvThyUI4Cqjtp 9yX82CJkG+8ocquxjYe6rhDG7FrM4VCgNTsrRLebYciv9+wjIatrsg5SOiL6O/Pfr4J2 yTvGoIiqFQIVHFuj5ebysk27tCAfxP/lcJ06WoJm9F4uF1yb/MjOdZ++JkfC1i0CGl6z cmWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GVYKTeZOs73kMVOGScvV1WQYPWwqW1DUKJOIJsaQhHs=; b=JgT7jcyDPAmeJhXC1MzmxVrSXCX1yro2/gfw3nYMp785/icArHM53MXiZQzpv8rVCj GFvPw0p8KN7U1OaxqCC0ZGNdbW1ArNHBpHdtbMkU98Ay6GMGuT4kxQ8zVOVFAAfo5Z9r TOGf7cs2OIRluivBHrjIlALDZy5lYvzRojJCRym07x1Zia5y7G7qVCBfZZixNWNX3Z3a BJnG70gHnj/Euc54qzRIe8zvdvTW0nF9s10icbXhW7pVn3q+iMWAte8mwxwe23lw3GVo m2gJy9sBkYCvTnxeHZvkzFCVynKOL+VtjA/DENgsZPMnIWBXYTMt4tUI8UzWlcv4fkYk 039w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=siEYlYcR; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170903234d00b0016d2dd7a6casi275378plh.182.2022.07.28.00.04.27; Thu, 28 Jul 2022 00:04:42 -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=@semihalf.com header.s=google header.b=siEYlYcR; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234328AbiG1GwT (ORCPT + 99 others); Thu, 28 Jul 2022 02:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233104AbiG1GwR (ORCPT ); Thu, 28 Jul 2022 02:52:17 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 164FC5C353 for ; Wed, 27 Jul 2022 23:52:16 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id u9so1429800oiv.12 for ; Wed, 27 Jul 2022 23:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GVYKTeZOs73kMVOGScvV1WQYPWwqW1DUKJOIJsaQhHs=; b=siEYlYcRE/DOMiSGZuRXKfgmHEV2pjykwMIZlOkXroO5b9WzXOaRAxHMIiJygjQqE8 R5plCuxLTaJ1gCTQSsHaIvU46lcB8i4dAqAD4SqiaGER94W+M6f7yo1ekmlDrFzpqckd KfW5EQ32E58zt/RYXeRs2sL30qso+Jq8MYM5LSZwV+mZl+12QDBGl+BIhMxCiN9DzDxj Z5v2+45yBXjQn/vzABUFS+oCjgMOMT8ntN6K3KReILhbqsG/XVAT82E+YFg2SV1AxFKs ASoJfBKxW/n58C7M995Lgmy3Pk+4qy9qdlYmmOKMa/w09ACxXJMzTn3hgBcAnQcIXWpL 88XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GVYKTeZOs73kMVOGScvV1WQYPWwqW1DUKJOIJsaQhHs=; b=lKAo6hDAl2B3UAmrl4KVwshB5DGIQQogc4PD1YbJW6bN+xvSf4qrMWvN1YGeI0GKT0 mDsK0pTtGtLkNnbfPwQsjKN/MXOMP3DAEmUQgLWMlQ1mpArLd5gbhzDlBVTwB2ky2l0/ tgQFEXUAo0UX75o2pnofnSRLgAugn+Ilrjx+VN6e3+a6j9booflkJOPsAXB87jjmtEiv s6sJZLBHqvz58ieeYcdm5hrtLdpXpNSQQBVwqaglp1PGqF+WqU8Vcid2vX1Ka9NA9Sdi ffGnan10jb0hQ5EK6QeFxIE5Mw3zzKkyhtRRTtPcbhgxrqKkvoGVxgO3ilhgMKQy/KYJ ucbg== X-Gm-Message-State: AJIora/CXizhSCyOgwTBir+j/JGm/dkISL/h9RgJHps2ObkChn2YFYs0 EFlcR6ru9vrVaArWcXqkvrSAXbpAhgucQWw3KU7SQA== X-Received: by 2002:a05:6808:4d7:b0:33a:9437:32d with SMTP id a23-20020a05680804d700b0033a9437032dmr3356302oie.97.1658991134942; Wed, 27 Jul 2022 23:52:14 -0700 (PDT) MIME-Version: 1.0 References: <20220727064321.2953971-1-mw@semihalf.com> <20220727064321.2953971-7-mw@semihalf.com> <20220727143147.u6yd6wqslilspyhw@skbuf> <20220727163848.f4e2b263zz3vl2hc@skbuf> In-Reply-To: From: Marcin Wojtas Date: Thu, 28 Jul 2022 08:52:04 +0200 Message-ID: Subject: Re: [net-next: PATCH v3 6/8] net: core: switch to fwnode_find_net_device_by_node() To: Andy Shevchenko Cc: Vladimir Oltean , Linux Kernel Mailing List , ACPI Devel Maling List , netdev , "Rafael J. Wysocki" , Andy Shevchenko , Sean Wang , Landen Chao , Linus Walleij , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King - ARM Linux , Heiner Kallweit , Grzegorz Bernacki , Grzegorz Jaszczyk , Tomasz Nowicki , Samer El-Haj-Mahmoud , "upstream@semihalf.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 =C5=9Br., 27 lip 2022 o 23:15 Andy Shevchenko n= apisa=C5=82(a): > > > > On Wednesday, July 27, 2022, Marcin Wojtas wrote: >> >> =C5=9Br., 27 lip 2022 o 18:38 Vladimir Oltean napisa= =C5=82(a): >> > >> > On Wed, Jul 27, 2022 at 05:18:16PM +0200, Marcin Wojtas wrote: >> > > Do you mean a situation analogous to what I addressed in: >> > > [net-next: PATCH v3 4/8] net: mvpp2: initialize port fwnode pointer >> > > ? >> > >> > Not sure if "analogous" is the right word. My estimation is that the >> > overwhelmingly vast majority of DSA masters can be found by DSA simply >> > due to the SET_NETDEV_DEV() call that the Ethernet drivers need to mak= e >> > anyway. I see that mvpp2 also needed commit c4053ef32208 ("net: mvpp2= : >> > initialize port of_node pointer"), but that isn't needed in general, a= nd >> > I can't tell you exactly why it is needed there, I don't know enough >> > about the mvpp2 driver. >> >> SET_NETDEV_DEV() fills net_device->dev.parent with &pdev->dev >> and in most cases it is sufficient apparently it is sufficient for >> fwnode_find_parent_dev_match (at least tests with mvneta case proves >> it's fine). >> >> We have some corner cases though: >> * mvpp2 -> single controller can handle up to 3 net_devices and >> therefore we need device_set_node() to make this work. I think dpaa2 >> is a similar case >> * PCIE drivers with extra DT description (I think that's the case of ene= tc). >> >> > >> > > I found indeed a couple of drivers that may require a similar change >> > > (e.g. dpaa2). >> > >> > There I can tell you why the dpaa2-mac code mangles with net_dev->dev.= of_node, >> > but I'd rather not go into an explanation that essentially doesn't mat= ter. >> > The point is that you'd be mistaken to think that only the drivers whi= ch >> > touch the net device's ->dev->of_node are the ones that need updating >> > for your series to not cause regressions. >> >> As above - SET_NETDEV_DEV() should be fine in most cases, but we can >> never be 100% sure untils it's verified. >> >> > >> > > IMO we have 2 options: >> > > - update these drivers >> > > - add some kind of fallback? If yes, I am wondering about an elegant >> > > solution - maybe add an extra check inside >> > > fwnode_find_parent_dev_match? >> > > >> > > What would you suggest? >> > >> > Fixing fwnode_find_parent_dev_match(), of course. > > > > Fixing how?! > > >> >> >> This change broke DSA >> > on my LS1028A system (master in drivers/net/ethernet/freescale/enetc/) >> > and LS1021A (master in drivers/net/ethernet/freescale/gianfar.c). >> >> Can you please check applying following diff: >> >> --- a/drivers/base/property.c >> +++ b/drivers/base/property.c >> @@ -695,20 +695,22 @@ EXPORT_SYMBOL_GPL(fwnode_get_nth_parent); >> * The routine can be used e.g. as a callback for class_find_device(). >> * >> * Returns: %1 - match is found >> * %0 - match not found >> */ >> int fwnode_find_parent_dev_match(struct device *dev, const void *data) >> { >> for (; dev; dev =3D dev->parent) { >> if (device_match_fwnode(dev, data)) >> return 1; >> + else if (device_match_of_node(dev, to_of_node(data)) >> + return 1; >> } >> > > This adds a piece of dead code. device_match_fwnode() covers this already= . > Yes, indeed. After recent update, I think we can assume the current implementation of fwnode_find_parent_dev_match should work fine with all existing cases. Thank you for all remarks and comments, I'll address them in v4 later today= . Best regards, Marcin