On Sat, Nov 27 2021 at 13:32, Greg Kroah-Hartman wrote: > On Sat, Nov 27, 2021 at 02:23:15AM +0100, Thomas Gleixner wrote: >> The sysfs handling for MSI is a convoluted maze and it is in the way of >> supporting dynamic expansion of the MSI-X vectors because it only supports >> a one off bulk population/free of the sysfs entries. >> >> Change it to do: >> >> 1) Creating an empty sysfs attribute group when msi_device_data is >> allocated >> >> 2) Populate the entries when the MSI descriptor is initialized > > How much later does this happen? Can it happen while the device has a > driver bound to it? That's not later than before. It's when the driver initializes the MSI[X] interrupts, which usually happens in the probe() function. The difference is that the group, (i.e.) directory is created slightly earlier. >> + >> +static inline int msi_sysfs_create_group(struct device *dev) >> +{ >> + return devm_device_add_group(dev, &msi_irqs_group); > > Much nicer, but you changed the lifetime rules of when these attributes > will be removed, is that ok? The msi entries are removed at the same place as they are removed in the current mainline code, i.e. when the device driver shuts the device down and disables MSI[X], which happens usually during remove() What's different now is that the empty group stays around a bit longer. I don't see how that matters. > I still worry that these attributes show up "after" the device is > registered with the driver core, but hey, it's no worse than it > currently is, so that's not caused by this patch series... Happens that register before or after driver->probe()? >> - } >> + desc->sysfs_attrs = NULL; >> + for (i = 0; i < desc->nvec_used; i++) { >> + if (attrs[i].show) >> + sysfs_remove_file_from_group(&dev->kobj, &attrs[i].attr, msi_irqs_group.name); >> + kfree(attrs[i].attr.name); > > That's a cute hack, but should be documented somewhere in the code (that > if there is no show function, that means no attribute was registered > here). > > If you add a comment for this (either here or when you register the > attribute), feel free to add: Will do. Thanks, tglx