All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/4] Let userspace know when snd-hda-intel needs i915
@ 2022-05-09 16:23 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 47+ messages in thread
From: Mauro Carvalho Chehab @ 2022-05-09 16:23 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: Mauro Carvalho Chehab, mauro.chehab, Greg KH, intel-gfx,
	dri-devel, Lucas De Marchi, Kai Vehmanen, Pierre-Louis Bossart,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel,
	linux-modules, Daniel Vetter, David Airlie, Christophe JAILLET,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd

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.

That's because module_try_get() and symbol_get() doesn't try to
setup the module owner.

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_hotunplug@unbind-rebind.html
	https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11495/bat-adlm-1/igt@i915_module_load@reload.html

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 properly set the holders when
try_module_get() and symbol_get() are used.

This allow allow audio 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.

With that, userspace tools can now 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.html

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-20220506.

---

v6:
- dropped an unused function prototype for __symbol_get_gpl();
- addressed several issues that were noticed while testing the series on
  an slow atom machine;
- also add holders when symbol_get() is used.

v5:
- while v4 works fine, it ends calling try_module_format() recursively, which
  is not what it it was supposed to do. So, change the logic to avoid such
  recursion, by adding a static __try_module_format() and renaming the
  new version that takes two arguments as try_module_format_owner().

v4:
 - fix a compilation warning reported by Intel's Kernel robot when
   !CONFIG_MODULE_UNLOAD or !CONFIG_MODULE.

v3: minor fixes:
 - fixed a checkpatch warning;
 - use a single line for the new function prototype.

v2:
 - the dependencies are now handled directly at try_module_get().
Mauro Carvalho Chehab (4):
  module: drop prototype for non-existing __symbol_get_gpl()
  module: update dependencies at try_module_get()
  module: set holders when symbol_get() is used
  ALSA: hda - identify when audio is provided by a video driver

 drivers/mtd/chips/gen_probe.c           |  4 +-
 include/linux/module.h                  | 13 +++--
 kernel/module/main.c                    | 76 ++++++++++++++++++++-----
 samples/hw_breakpoint/data_breakpoint.c |  2 +-
 sound/hda/hdac_component.c              |  2 +-
 5 files changed, 72 insertions(+), 25 deletions(-)

-- 
2.35.3



^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2022-09-27 23:33 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 16:23 [PATCH v6 0/4] Let userspace know when snd-hda-intel needs i915 Mauro Carvalho Chehab
2022-05-09 16:23 ` Mauro Carvalho Chehab
2022-05-09 16:23 ` [Intel-gfx] " Mauro Carvalho Chehab
2022-05-09 16:23 ` Mauro Carvalho Chehab
2022-05-09 16:23 ` Mauro Carvalho Chehab
2022-05-09 16:23 ` [PATCH v6 1/4] module: drop prototype for non-existing __symbol_get_gpl() Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23   ` [Intel-gfx] " Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23 ` [PATCH v6 2/4] module: update dependencies at try_module_get() Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23   ` [Intel-gfx] " Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-15  8:22   ` [module] a1f1245bef: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c kernel test robot
2022-05-15  8:22     ` kernel test robot
2022-05-15  8:22     ` kernel test robot
2022-05-15  8:22     ` [Intel-gfx] " kernel test robot
2022-05-15  8:22     ` kernel test robot
2022-05-09 16:23 ` [PATCH v6 3/4] module: set holders when symbol_get() is used Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23   ` [Intel-gfx] " Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23 ` [PATCH v6 4/4] ALSA: hda - identify when audio is provided by a video driver Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-09 16:23   ` [Intel-gfx] " Mauro Carvalho Chehab
2022-05-09 16:23   ` Mauro Carvalho Chehab
2022-05-11 19:51   ` Daniel Vetter
2022-05-11 19:51     ` Daniel Vetter
2022-05-11 19:51     ` [Intel-gfx] " Daniel Vetter
2022-05-11 19:51     ` Daniel Vetter
2022-05-09 20:07 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for Let userspace know when snd-hda-intel needs i915 Patchwork
2022-05-09 20:38 ` [PATCH v6 0/4] " Luis Chamberlain
2022-05-09 20:38   ` Luis Chamberlain
2022-05-09 20:38   ` Luis Chamberlain
2022-05-09 20:38   ` [Intel-gfx] " Luis Chamberlain
2022-05-09 20:38   ` Luis Chamberlain
2022-09-20  5:24   ` Mauro Carvalho Chehab
2022-09-20  5:24     ` Mauro Carvalho Chehab
2022-09-20  5:24     ` Mauro Carvalho Chehab
2022-09-20  5:24     ` Mauro Carvalho Chehab
2022-09-20  5:24     ` [Intel-gfx] " Mauro Carvalho Chehab
2022-09-27 23:31     ` Luis Chamberlain
2022-09-27 23:31       ` Luis Chamberlain
2022-09-27 23:31       ` [Intel-gfx] " Luis Chamberlain
2022-09-27 23:31       ` Luis Chamberlain
2022-09-27 23:31       ` Luis Chamberlain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.