public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix Optimus when GPU has no sound
@ 2025-02-08 21:46 Maxim Mikityanskiy
  2025-02-08 21:46 ` [PATCH v2 1/2] ALSA: hda: intel: " Maxim Mikityanskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maxim Mikityanskiy @ 2025-02-08 21:46 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: Bard Liao, Peter Ujfalusi, Pierre-Louis Bossart, Heiner Kallweit,
	WangYuli, linux-sound, linux-kernel, Maxim Mikityanskiy

See the commit descriptions.

As agreed in the previous discussion [1], this series adds the
non-functional NVIDIA HDA controller on Lenovo IdeaPad Z570 to the
denylist, and includes the runtime PM workaround from v1, which now
prints a warning to dmesg asking the user to add the device to the
denylist if it's affected and not already there.

[1]: https://lore.kernel.org/linux-sound/877catiffo.wl-tiwai@suse.de/

Maxim Mikityanskiy (2):
  ALSA: hda: intel: Fix Optimus when GPU has no sound
  ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist

 sound/pci/hda/hda_intel.c | 44 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

-- 
2.43.0


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

* [PATCH v2 1/2] ALSA: hda: intel: Fix Optimus when GPU has no sound
  2025-02-08 21:46 [PATCH v2 0/2] Fix Optimus when GPU has no sound Maxim Mikityanskiy
@ 2025-02-08 21:46 ` Maxim Mikityanskiy
  2025-02-08 21:46 ` [PATCH v2 2/2] ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist Maxim Mikityanskiy
  2025-02-10  8:46 ` [PATCH v2 0/2] Fix Optimus when GPU has no sound Takashi Iwai
  2 siblings, 0 replies; 4+ messages in thread
From: Maxim Mikityanskiy @ 2025-02-08 21:46 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: Bard Liao, Peter Ujfalusi, Pierre-Louis Bossart, Heiner Kallweit,
	WangYuli, linux-sound, linux-kernel, Maxim Mikityanskiy

quirk_nvidia_hda() forcefully enables HDA controller on all NVIDIA GPUs,
because some buggy BIOSes leave it disabled. However, some dual-GPU
laptops do not have a functional HDA controller in DGPU, and BIOS
disables it on purpose. After quirk_nvidia_hda() reenables this dummy
HDA controller, attempting to probe it fails at azx_first_init(), which
is too late to cancel the probe, as it happens in azx_probe_continue().

The sna_hda_intel driver calls azx_free() and stops the chip, however,
it stays probed, and from the runtime PM point of view, the device
remains active (it was set as active by the PCI subsystem on probe). It
prevents vga_switcheroo from turning off the DGPU, because
pci_create_device_link() syncs power management for video and audio
devices.

Affected devices should be added to driver_denylist to prevent them from
probing early. This patch helps identify such devices by printing a
warning, and also forces the device to the suspended state to allow
vga_switcheroo turn off DGPU.

Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
---
 sound/pci/hda/hda_intel.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 7d7f9aac50a9..4155e010064b 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1352,8 +1352,21 @@ static void azx_free(struct azx *chip)
 	if (use_vga_switcheroo(hda)) {
 		if (chip->disabled && hda->probe_continued)
 			snd_hda_unlock_devices(&chip->bus);
-		if (hda->vga_switcheroo_registered)
+		if (hda->vga_switcheroo_registered) {
 			vga_switcheroo_unregister_client(chip->pci);
+
+			/* Some GPUs don't have sound, and azx_first_init fails,
+			 * leaving the device probed but non-functional. As long
+			 * as it's probed, the PCI subsystem keeps its runtime
+			 * PM status as active. Force it to suspended (as we
+			 * actually stop the chip) to allow GPU to suspend via
+			 * vga_switcheroo, and print a warning.
+			 */
+			dev_warn(&pci->dev, "GPU sound probed, but not operational: please add a quirk to driver_denylist\n");
+			pm_runtime_disable(&pci->dev);
+			pm_runtime_set_suspended(&pci->dev);
+			pm_runtime_enable(&pci->dev);
+		}
 	}
 
 	if (bus->chip_init) {
-- 
2.43.0


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

* [PATCH v2 2/2] ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist
  2025-02-08 21:46 [PATCH v2 0/2] Fix Optimus when GPU has no sound Maxim Mikityanskiy
  2025-02-08 21:46 ` [PATCH v2 1/2] ALSA: hda: intel: " Maxim Mikityanskiy
@ 2025-02-08 21:46 ` Maxim Mikityanskiy
  2025-02-10  8:46 ` [PATCH v2 0/2] Fix Optimus when GPU has no sound Takashi Iwai
  2 siblings, 0 replies; 4+ messages in thread
From: Maxim Mikityanskiy @ 2025-02-08 21:46 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: Bard Liao, Peter Ujfalusi, Pierre-Louis Bossart, Heiner Kallweit,
	WangYuli, linux-sound, linux-kernel, Maxim Mikityanskiy

Lenovo IdeaPad Z570 with NVIDIA GeForce Ge 540M doesn't have sound on
the discrete GPU. The HDA controller in DGPU is disabled by BIOS, but
then reenabled by quirk_nvidia_hda(). The probe fails and ends up with
the "GPU sound probed, but not operational" error.

Add this laptop to DMI-based denylist to prevent probe early. DMI is
used, because the audio device has zero subsystem IDs, and this entry
would be too much, blocking all 540M chips:
    PCI_DEVICE_SUB(0x10de, 0x0bea, 0x0000, 0x0000)
Also, this laptop comes in a variety of modifications with different
NVIDIA GPUs, so the DMI check will cover them all.

Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
---
 sound/pci/hda/hda_intel.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 4155e010064b..3f11f169fe4a 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -37,6 +37,7 @@
 #include <linux/completion.h>
 #include <linux/acpi.h>
 #include <linux/pgtable.h>
+#include <linux/dmi.h>
 
 #ifdef CONFIG_X86
 /* for snoop control */
@@ -2074,6 +2075,27 @@ static const struct pci_device_id driver_denylist[] = {
 	{}
 };
 
+static struct pci_device_id driver_denylist_ideapad_z570[] = {
+	{ PCI_DEVICE_SUB(0x10de, 0x0bea, 0x0000, 0x0000) }, /* NVIDIA GF108 HDA */
+	{}
+};
+
+/* DMI-based denylist, to be used when:
+ *  - PCI subsystem IDs are zero, impossible to distinguish from valid sound cards.
+ *  - Different modifications of the same laptop use different GPU models.
+ */
+static const struct dmi_system_id driver_denylist_dmi[] = {
+	{
+		/* No HDA in NVIDIA DGPU. BIOS disables it, but quirk_nvidia_hda() reenables. */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
+		},
+		.driver_data = &driver_denylist_ideapad_z570,
+	},
+	{}
+};
+
 static const struct hda_controller_ops pci_hda_ops = {
 	.disable_msi_reset_irq = disable_msi_reset_irq,
 	.position_check = azx_position_check,
@@ -2084,6 +2106,7 @@ static DECLARE_BITMAP(probed_devs, SNDRV_CARDS);
 static int azx_probe(struct pci_dev *pci,
 		     const struct pci_device_id *pci_id)
 {
+	const struct dmi_system_id *dmi;
 	struct snd_card *card;
 	struct hda_intel *hda;
 	struct azx *chip;
@@ -2096,6 +2119,12 @@ static int azx_probe(struct pci_dev *pci,
 		return -ENODEV;
 	}
 
+	dmi = dmi_first_match(driver_denylist_dmi);
+	if (dmi && pci_match_id(dmi->driver_data, pci)) {
+		dev_info(&pci->dev, "Skipping the device on the DMI denylist\n");
+		return -ENODEV;
+	}
+
 	dev = find_first_zero_bit(probed_devs, SNDRV_CARDS);
 	if (dev >= SNDRV_CARDS)
 		return -ENODEV;
-- 
2.43.0


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

* Re: [PATCH v2 0/2] Fix Optimus when GPU has no sound
  2025-02-08 21:46 [PATCH v2 0/2] Fix Optimus when GPU has no sound Maxim Mikityanskiy
  2025-02-08 21:46 ` [PATCH v2 1/2] ALSA: hda: intel: " Maxim Mikityanskiy
  2025-02-08 21:46 ` [PATCH v2 2/2] ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist Maxim Mikityanskiy
@ 2025-02-10  8:46 ` Takashi Iwai
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2025-02-10  8:46 UTC (permalink / raw)
  To: Maxim Mikityanskiy
  Cc: Takashi Iwai, Jaroslav Kysela, Bard Liao, Peter Ujfalusi,
	Pierre-Louis Bossart, Heiner Kallweit, WangYuli, linux-sound,
	linux-kernel

On Sat, 08 Feb 2025 22:46:00 +0100,
Maxim Mikityanskiy wrote:
> 
> See the commit descriptions.
> 
> As agreed in the previous discussion [1], this series adds the
> non-functional NVIDIA HDA controller on Lenovo IdeaPad Z570 to the
> denylist, and includes the runtime PM workaround from v1, which now
> prints a warning to dmesg asking the user to add the device to the
> denylist if it's affected and not already there.
> 
> [1]: https://lore.kernel.org/linux-sound/877catiffo.wl-tiwai@suse.de/
> 
> Maxim Mikityanskiy (2):
>   ALSA: hda: intel: Fix Optimus when GPU has no sound
>   ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist

Applied both patches to for-next branch now.


thanks,

Takashi

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

end of thread, other threads:[~2025-02-10  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-08 21:46 [PATCH v2 0/2] Fix Optimus when GPU has no sound Maxim Mikityanskiy
2025-02-08 21:46 ` [PATCH v2 1/2] ALSA: hda: intel: " Maxim Mikityanskiy
2025-02-08 21:46 ` [PATCH v2 2/2] ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist Maxim Mikityanskiy
2025-02-10  8:46 ` [PATCH v2 0/2] Fix Optimus when GPU has no sound Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox