From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD38C433F5 for ; Thu, 9 Sep 2021 01:41:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1256261178 for ; Thu, 9 Sep 2021 01:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238333AbhIIBmP (ORCPT ); Wed, 8 Sep 2021 21:42:15 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:33422 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350046AbhIIBlL (ORCPT ); Wed, 8 Sep 2021 21:41:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=1fHEkR5k+Jdu65pUoUQvmgXn1dPzE2m99xMmkzV4JqU=; b=miXMqy7Z7y0fLKbOETUtmyt8tO mQS6WNeIFFgUMs4zYNUsRnjxWQjpfWM9okgcyCYlCeBM3y2hyBe9G50oDEqiJJCRgkOoq6puRLrIj IZc22INp6IhKBQilqFLhx8haWz+EC1pkJ8k6txKzak7OCF0G81ewqa5TGsrQFyY8pHFI=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mO92I-005pSx-Va; Thu, 09 Sep 2021 03:39:30 +0200 Date: Thu, 9 Sep 2021 03:39:30 +0200 From: Andrew Lunn To: Saravana Kannan Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Linus Walleij , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Len Brown , Alvin Sipraga , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v1 1/2] driver core: fw_devlink: Add support for FWNODE_FLAG_BROKEN_PARENT Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org > --- a/net/dsa/dsa2.c > +++ b/net/dsa/dsa2.c > @@ -1286,6 +1286,17 @@ static int dsa_switch_parse_of(struct > dsa_switch *ds, struct device_node *dn) > { > int err; > > + /* A lot of switch devices have their PHYs as child devices and have > + * the PHYs depend on the switch as a supplier (Eg: interrupt > + * controller). With fw_devlink=on, that means the PHYs will defer > + * probe until the probe() of the switch completes. However, the way > + * the DSA framework is designed, the PHYs are expected to be probed > + * successfully before the probe() of the switch completes. > + * > + * So, mark the switch devices as a "broken parent" so that fw_devlink > + * knows not to create device links between PHYs and the parent switch. > + */ > + np->fwnode.flags |= FWNODE_FLAG_BROKEN_PARENT; > err = dsa_switch_parse_member_of(ds, dn); > if (err) > return err; This does not work. First off, its dn, not np. But with that fixed, it still does not work. This is too late, the mdio busses have already been registered and probed, the PHYs have been found on the busses, and the PHYs would of been probed, if not for fw_devlink. What did work was: diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index c45ca2473743..45d67d50e35f 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -6249,8 +6249,10 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev) if (!np && !pdata) return -EINVAL; - if (np) + if (np) { compat_info = of_device_get_match_data(dev); + np->fwnode.flags |= FWNODE_FLAG_BROKEN_PARENT; + } if (pdata) { compat_info = pdata_device_get_match_data(dev); This will fix it for mv88e6xxx. But if the same problem occurs in any of the other DSA drivers, they will still be broken: ~/linux/drivers/net/dsa$ grep -r mdiobus_register * bcm_sf2.c: err = mdiobus_register(priv->slave_mii_bus); dsa_loop_bdinfo.c: return mdiobus_register_board_info(&bdinfo, 1); lantiq_gswip.c: return of_mdiobus_register(ds->slave_mii_bus, mdio_np); mt7530.c: ret = mdiobus_register(bus); mv88e6xxx/chip.c: err = of_mdiobus_register(bus, np); grep: mv88e6xxx/chip.o: binary file matches ocelot/seville_vsc9953.c: rc = mdiobus_register(bus); ocelot/felix_vsc9959.c: rc = mdiobus_register(bus); qca/ar9331.c: ret = of_mdiobus_register(mbus, mnp); qca8k.c: return devm_of_mdiobus_register(priv->dev, bus, mdio); realtek-smi-core.c: ret = of_mdiobus_register(smi->slave_mii_bus, mdio_np); sja1105/sja1105_mdio.c: rc = of_mdiobus_register(bus, np); sja1105/sja1105_mdio.c: rc = of_mdiobus_register(bus, np); sja1105/sja1105_mdio.c: rc = mdiobus_register(bus); sja1105/sja1105_mdio.c:int sja1105_mdiobus_register(struct dsa_switch *ds) sja1105/sja1105.h:int sja1105_mdiobus_register(struct dsa_switch *ds); sja1105/sja1105_main.c: rc = sja1105_mdiobus_register(ds); If you are happy to use a big hammer: diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 53f034fc2ef7..7ecd910f7fb8 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -525,6 +525,9 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) NULL == bus->read || NULL == bus->write) return -EINVAL; + if (bus->parent && bus->parent->of_node) + bus->parent->of_node->fwnode.flags |= FWNODE_FLAG_BROKEN_PARENT; + BUG_ON(bus->state != MDIOBUS_ALLOCATED && bus->state != MDIOBUS_UNREGISTERED); So basically saying all MDIO busses potentially have a problem. I also don't like the name FWNODE_FLAG_BROKEN_PARENT. The parents are not broken, they work fine, if fw_devlink gets out of the way and allows them to do their job. You also asked about why the component framework is not used. DSA has been around for a while, the first commit dates back to October 2008. Russell Kings first commit for the component framework is January 2014. The plain driver model has worked for the last 13 years, so there has not been any need to change. Andrew