hook-functions: sys_walk_mod_add: Add devlink suppliers as dependencies
With MODULES=dep
, we walk through sysfs to add device-specific modules, and their dependencies based on modprobe --show-depends
. However in embedded systems, a lot dependency relations ended up being expressed only in device-tree instead of in the usual ways.
This dependency information is exposed in sysfs as a "devlink", where each involved driver is a "consumer" or "supplier" of the link. Not including suppliers for a driver in initramfs can make it defer probing indefinitely, leading to breakage. This led to dracut including them as well.
While walking sysfs for modules we want to add, also walk their suppliers and add those as well. The supplier dependencies can have
cycles in them, so we can't recursively call sys_walk_mod_add
. Instead, do an iterative traversal of the dependency graph to collect all device paths we need to look into, then actually add the modules for those.