On Fri, 2025-09-12 at 15:59 -0700, Brian Norris wrote: > The PCI framework supports "quirks" for PCI devices via several > DECLARE_PCI_FIXUP_*() macros. These macros allow arch or driver code to > match device IDs to provide customizations or workarounds for broken > devices. > > This mechanism is generally used in code that can only be built into the > kernel, but there are a few occasions where this mechanism is used in > drivers that can be modules. For example, see commit 574f29036fce ("PCI: > iproc: Apply quirk_paxc_bridge() for module as well as built-in"). > > The PCI fixup mechanism only works for built-in code, however, because > pci_fixup_device() only scans the ".pci_fixup_*" linker sections found > in the main kernel; it never touches modules. > > Extend the fixup approach to modules.
This _feels_ a bit odd to me - what if you reload a module, should the fixup be done twice? Right now this was not possible in a module, which is a bit of a gotcha, but at least that's only one for developers, not for users (unless someone messes up and puts it into modular code, as in the example you gave.) Although, come to think of it, you don't even apply the fixup when the module is loaded, so what I just wrote isn't really true. That almost seems like an oversight though, now the module has to be loaded before the PCI device is enumerated, which is unlikely to happen in practice? But then we get the next gotcha - the device is already enumerated, so the fixups cannot be applied at the various enumeration stages, and you're back to having to load the module before PCI enumeration, which could be tricky, or somehow forcing re-enumeration of a given device from userspace, but then you're firmly in "gotcha for the user" territory again ... I don't really have any skin in this game, but overall I'd probably argue it's better to occasionally have to fix things such as in the commit you point out but have a predictable system, than apply things from modules. Perhaps it'd be better to extend the section checking infrastructure to catch and error out on these sections in modules instead, so we catch it at build time, rather than finding things missing at runtime? And yeah, now I've totally ignored the kunit angle, but ... not sure how to combine the two requirements if they are, as I think, conflicting. johannes