On Thu, Sep 2, 2021 at 7:24 AM Rob Herring <robh+dt@xxxxxxxxxx> wrote: > > On Wed, Sep 1, 2021 at 9:55 PM Saravana Kannan <saravanak@xxxxxxxxxx> wrote: > > > > We don't want fw_devlink creating device links for bus devices as > > they'll never probe. So mark those device node with this flag. > > > > Signed-off-by: Saravana Kannan <saravanak@xxxxxxxxxx> > > --- > > drivers/of/platform.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/drivers/of/platform.c b/drivers/of/platform.c > > index 74afbb7a4f5e..42b3936d204a 100644 > > --- a/drivers/of/platform.c > > +++ b/drivers/of/platform.c > > @@ -392,6 +392,22 @@ static int of_platform_bus_create(struct device_node *bus, > > if (!dev || !of_match_node(matches, bus)) > > return 0; > > > > + /* > > + * If the bus node has only one compatible string value and it has > > + * matched as a bus node, it's never going to get probed by a device > > + * driver. So flag it as such so that fw_devlink knows not to create > > + * device links with this device. > > + * > > + * This doesn't catch all devices that'll never probe, but this is good > > + * enough for now. > > + * > > + * This doesn't really work for PPC because of how it uses > > + * of_platform_bus_probe() to add normal devices. So ignore PPC cases. > > + */ > > + if (!IS_ENABLED(CONFIG_PPC) && > > + of_property_count_strings(bus, "compatible") == 1) > > + bus->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE; > > This looks fragile relying on 1 compatible string, and the DT flags in > this code have been fragile too. I'm pretty sure we have cases of > simple-bus or simple-mfd that also have another compatible. > > Couldn't we solve this with a simple driver? Oh, I didn't think you'd like that. I'd lean towards that option too if we can address some of the other concerns below. > Make 'simple-pm-bus' > driver work for other cases? > BTW, this patch doesn't even work for > simple-pm-bus. How do you mean? Because simple-pm-bus already has a driver and doesn't set "matches" param when it calls of_platform_populate() and this flag won't be set. So at least for simple-pm-bus I don't see any issue. I was trying to reuse of_default_bus_match_table without explicitly referring to it, but if it's confusing I can add a separate list of compatible strings and use those here instead of using "matches". > A driver for simple-bus may cause issues if there's a > more specific driver to bind to as we don't handle that. It's simply > whichever matches first. Right, this is my worry. Especially for devices like this (there are plenty of cases like this) which have a driver that probes them but also lists simple-bus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/arm-realview-pb11mp.dts?id=73f3af7b4611d77bdaea303fb639333eb28e37d7#n299 So as long as there's a compatible string that's not one of the "transparent" busses, this driver shouldn't match. So, I don't think I can get away from checking the compatible strings. How about I check here to make sure all the "compatible" strings are from an approved transparent bus list, and if it's true, I use driver_override to force match it to a transparent bus driver? Would you be okay with that? -Saravana