[PATCH 0/2] Let userspace know when snd-hda-intel needs i915
Currently, kernel/module annotates module dependencies when request_symbol is used, but it doesn't cover more complex inter-driver dependencies that are subsystem and/or driver-specific.
In the case of hdmi sound, depending on the CPU/GPU, sometimes the snd_hda_driver can talk directly with the hardware, but sometimes, it uses the i915 driver. When the snd_hda_driver uses i915, it should first be unbind/rmmod, as otherwise trying to unbind/rmmod the i915 driver cause driver issues, as as reported by CI tools with different GPU models:
https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6415/fi-tgl-1115g4/igt@core_hot... https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11495/bat-adlm-1/igt@i915_mo...
In the past, just a few CPUs were doing such bindings, but this issue now applies to all "modern" Intel CPUs that have onboard graphics, as well as to the newer discrete GPUs.
With the discrete GPU case, the HDA controller is physically separate and requires i915 to power on the hardware for all hardware access. In this case, the issue is hit basicly 100% of the time.
With on-board graphics, i915 driver is needed only when the display codec is accessed. If i915 is unbind during runtime suspend, while snd-hda-intel is still bound, nothing bad happens, but unbinding i915 on other situations may also cause issues.
So, add support at kernel/modules to allow snd-hda drivers to properly annotate when a dependency on a DRM driver dependencies exists, and add a call to such new function at the snd-hda driver when it successfully binds into the DRM driver.
This would allow userspace tools to check and properly remove the audio driver before trying to remove or unbind the GPU driver.
It should be noticed that this series conveys the hidden module dependencies. Other changes are needed in order to allow removing or unbinding the i915 driver while keeping the snd-hda-intel driver loaded/bound. With that regards, there are some discussions on how to improve this at alsa-devel a while back:
https://mailman.alsa-project.org/pipermail/alsa-devel/2021-September/190099....
So, future improvements on both in i915 and the audio drivers could be made. E.g. with discrete GPUs, it's the only codec of the card, so it seems feasible to detach the ALSA card if i915 is bound (using infra made for VGA switcheroo), but, until these improvements are done and land in upstream, audio drivers needs to be unbound if i915 driver goes unbind.
Yet, even if such fixes got merged, this series is still needed, as it makes such dependencies more explicit and easier to debug.
PS.: This series was generated against next-20220428.
Luis/Takashi/Daniel/David,
If OK for you, I would prefer to have such patches applied via the drm-tip tree once reviewed, in order to make easier to use them by some patches I'm preparing to improve the CI tests that use i915 unbind logic.
Mauro Carvalho Chehab (2): module: add a function to add module references ALSA: hda - identify when audio is provided by a video driver
include/linux/module.h | 7 +++++++ kernel/module/main.c | 31 +++++++++++++++++++++++++++++++ sound/hda/hdac_component.c | 8 ++++++++ 3 files changed, 46 insertions(+)
On some devices, the hda driver needs to hook into a video driver, in order to be able to properly access the audio hardware and/or the power management function.
That's the case of several snd_hda_intel devices that depends on i915 driver.
Currently, this dependency is hidden from /proc/modules and from lsmod, making harder to identify the need to unbind the audio driver before being able to unbind the i915 driver.
Add a reference for it at the module dependency, in order to allow userspace to identify it, and print a message on such cases.
Signed-off-by: Mauro Carvalho Chehab mchehab@kernel.org ---
See [PATCH 0/2] at: https://lore.kernel.org/all/cover.1651212016.git.mchehab@kernel.org/
sound/hda/hdac_component.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/sound/hda/hdac_component.c b/sound/hda/hdac_component.c index bb37e7e0bd79..103c6be8be1e 100644 --- a/sound/hda/hdac_component.c +++ b/sound/hda/hdac_component.c @@ -211,6 +211,14 @@ static int hdac_component_master_bind(struct device *dev) }
complete_all(&acomp->master_bind_complete); + + if (acomp->ops->owner && acomp->ops->owner->name) { + dev_info(dev, "audio component provided by %s driver\n", + acomp->ops->owner->name); + module_add_named_dependency(acomp->ops->owner->name, + dev->driver->owner); + } + return 0;
module_put:
participants (1)
-
Mauro Carvalho Chehab