śr., 27 lip 2022 o 23:11 Vladimir Oltean <olteanv@xxxxxxxxx> napisał(a): > > On Wed, Jul 27, 2022 at 07:40:00PM +0200, Marcin Wojtas wrote: > > 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). > > Indeed, mvneta works, which is a plain old platform device that hasn't > even been converted to fwnode, so why don't the others? > > Well, as it turns out, it's one of the cases where I spoke to soon, > thinking I knew what was the problem why probing failed, before actually > debugging. > > I thought there was no dmesg output from DSA at all, which would have > indicated an eternal -EPROBE_DEFER situation. But there's one tiny line > I had overlooked: > > [ 5.094013] mscc_felix 0000:00:00.5: error -EINVAL: Failed to register DSA switch > > This comes from here: > > static int dsa_port_parse_fw(struct dsa_port *dp, struct fwnode_handle *fwnode) > { > struct fwnode_handle *ethernet = fwnode_find_reference(fwnode, "ethernet", 0); > bool link = fwnode_property_present(fwnode, "link"); > const char *name = NULL; > int ret; > > ret = fwnode_property_read_string(fwnode, "label", &name); > // if (ret) > // return ret; > > dp->fwnode = fwnode; > > The 'label' property of a port was optional, you've made it mandatory by accident. > It is used only by DSA drivers that register using platform data. Thanks for spotting that, I will make it optional again. > > (side note, I can't believe you actually have a 'label' property for the > CPU port and how many people are in the same situation as you; you know > it isn't used for anything, right? how do we stop the cargo cult?) > Well, given these results: ~/git/linux : git grep 'label = \"cpu\"' arch/arm/boot/dts/ | wc -l 79 ~/git/linux : git grep 'label = \"cpu\"' arch/arm64/boot/dts/ | wc -l 14 It's not a surprise I also have it defined in the platforms I test. I agree it doesn't serve any purpose in terms of creating the devices in DSA with DT, but it IMO increases readability of the description at least. > > 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 = 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); > > So, nothing to do with device_match_fwnode() failing, that would have > been strange, come to think about it. Sorry for the noise here. > Great, thank you for confirmation. > But looking at the deeper implementation of dev_fwnode() as: > > struct fwnode_handle *dev_fwnode(struct device *dev) > { > return IS_ENABLED(CONFIG_OF) && dev->of_node ? > of_fwnode_handle(dev->of_node) : dev->fwnode; > } > > I wonder, why did you have to modify mvpp2? It looks at dev->of_node > prior to returning dev->fwnode. It should work. When I boot with ACPI, the dev->of_node becomes NULL. With DT it's fine as-is. Best regards, Marcin