Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp501641imn; Wed, 27 Jul 2022 12:00:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tR5ZxyWmGKM8LnxISb7ZE0gujNtgij0QUhkv1HonbWoe/6Xnznl4CxtFtjT6/rBiy1b1Oi X-Received: by 2002:a50:ee13:0:b0:43b:aadb:a8cd with SMTP id g19-20020a50ee13000000b0043baadba8cdmr24587284eds.206.1658948427345; Wed, 27 Jul 2022 12:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658948427; cv=none; d=google.com; s=arc-20160816; b=v5xJc6ywy6iPRcoyii3AOS+W3HBhjqH8TQbYQYP3DyRKvxUm3EEOVZ/8yXKYEMmSEP 7Del9MIlpfS4FgmL61NOF7NIuHAy9uF6RSeJiQ8qgctQY7G+78PScS9zXdtxgdj6S/JL Uga5timpqqeaBd0Pn8KdANRLma9I0uVpAclLdq0CEE91XUd8M2zet7XI4+rMpCUTirjL svkdA5V1DLjCIJ7K3flXamG1KjL82DzyqeJCYBM6sCLa3FeVZ09dSF46q8XCWEBJvLqz ThQEy8WoYd4mbAF/l1WMKGKS1wbzVOQtQOzodweCflieoMqcOYms9Odwvf6xMvK4JA1V Yq1w== 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=auHRXEOVurCyZQ+OD7PQkEunz1CClGN/q8cW3ry8A/g=; b=SOkUqUkzbnPRf3nRdb8hxiESWGcej89ZElgKDVwcAy/Ks7v9fKI07QvfjYStjnJZMa aKRYmrCCMHOcDm6QQXZUwD/p4lxlX15nIONngv9GvLr/59qezxYoopwYKm6nUDAo6LzA 68MPeI3J9jCByREF5d5oF8dY7HZ+XRIjMuWodB/QmJGpTwwlJo1pmUnTJH574m1p3f+n zikHQzbEKq0F1vZ+/G/8ygFHVJXxC+S6fR1rnQel66wE3g5Q7B2bUIs5PN2h2+wHke1E q9fdUNVM2p4GHnZXDE/LuVaIr3l2+oyXdG/VeD0AEb0OHD+yRTvpfCHjnpcdI2Ad2Jqk mm0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=akCwbqOs; 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 i18-20020a0564020f1200b0043c96460dbfsi3264667eda.62.2022.07.27.12.00.00; Wed, 27 Jul 2022 12:00:27 -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=akCwbqOs; 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 S239367AbiG0SnM (ORCPT + 99 others); Wed, 27 Jul 2022 14:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239094AbiG0Sms (ORCPT ); Wed, 27 Jul 2022 14:42:48 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E3A513CCE for ; Wed, 27 Jul 2022 10:40:13 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id u9so21591424oiv.12 for ; Wed, 27 Jul 2022 10:40:13 -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=auHRXEOVurCyZQ+OD7PQkEunz1CClGN/q8cW3ry8A/g=; b=akCwbqOsMLF9KceYPsH4teUTmTLQJm9UmCBAtjLicHsInsBvGqYezvSQ7Vq/DLgJMh JaMrPsWCtssM6IJjbvwzpQGnOvwF10M7JqDIOvJLH/ZEBkayv0rbTQ5U9Q0fzE0qMaQa ujphGuNbPVj/jV8bmrH0778cavVEpkTM1FgZZZrUIoCZGLfBp/lp6x38VkwFC4q4MZzn hpetGpid8YOeWrW6XhpilDqQjtWyv+SBQeor7hjSo40dju6z9S6yJCy5WM7BD/IJZOVQ qWLBVAzv5fEclDkjni97HZAexI7xc00wO+kFrsW+ieELPQc7D13hfaFph9u7k40FGJ0S fpow== 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=auHRXEOVurCyZQ+OD7PQkEunz1CClGN/q8cW3ry8A/g=; b=HqqloonBrDXryBGk3pdBL9oX7YneLp/vJ+tiSWuFfXjwk3IF91ZzbNqLlo6DpmcHLe J0CLtGMcg0IfCvwxJhXh2DztLDCcLMYoXgPuHJAXJUlZiECeY2RvQdK7ktjQ7faNu6xo wFvDvT+AXamkZ5aFBYItaOvo589Hv9prXjvAR+ih2DHn6z+1frxGRK2REAX00YgKtKun SjXbm7J55TQt0zMjfr0kr2G/5XzhQDOy8QvJalkWIjsavon8WzdhmsVRx74dSxG8UzAm 0lgMhK6E1ve6XbEOCBZgUfs/GNiV+TYkEp6SvGUzCAfTcE0dcaN7w9vimsHkMLAGwv1b huyQ== X-Gm-Message-State: AJIora9b/WmL8Wdbg+oEQJjXnG5meoQNcySJjvTLGDN1aJkHOCkgNB4b r7RLWipkzccyH28AV6lzA/HluLbvkDWzeIY9i58DTw== X-Received: by 2002:aca:ba86:0:b0:33a:c6f7:3001 with SMTP id k128-20020acaba86000000b0033ac6f73001mr2382818oif.5.1658943612325; Wed, 27 Jul 2022 10:40:12 -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: <20220727163848.f4e2b263zz3vl2hc@skbuf> From: Marcin Wojtas Date: Wed, 27 Jul 2022 19:40:00 +0200 Message-ID: Subject: Re: [net-next: PATCH v3 6/8] net: core: switch to fwnode_find_net_device_by_node() To: Vladimir Oltean Cc: 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 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 make > anyway. I see that mvpp2 also needed commit c4053ef32208 ("net: mvpp2: > initialize port of_node pointer"), but that isn't needed in general, and > 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 enetc)= . > > > 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 matter= . > The point is that you'd be mistaken to think that only the drivers which > 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. 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; } return 0; } EXPORT_SYMBOL_GPL(fwnode_find_parent_dev_match); Thanks for the review and test. Marcin