Skip to contentSkip to conversation

dell-led: Change dell-led.h to dell-common.h

PATCH In review Kai-Heng Feng 5 participants 15 messages Apr 20, 2018 – May 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/3 dell-led: Change dell-led.h to dell-common.h

This header will be used for more than just led. Change it to a more generic name.

Cc Mario Limonciello <[email protected]>

---
v4: Change the commit message to clarify there's no more runtime pm
warning.
Also skip the check for thunderbolt attached devices.

v3: Simplify dell_switchable_gfx_is_enabled() by returning bool instead
of error code.
Use DMI_DEV_TYPE_OEM_STRING to match Dell System.

v2: Mario suggested to squash the HDA part into the same series.

 drivers/platform/x86/dell-laptop.c          | 2 +-
 include/linux/{dell-led.h => dell-common.h} | 4 ++--
 sound/pci/hda/dell_wmi_helper.c             | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
 rename include/linux/{dell-led.h => dell-common.h} (61%)
drivers/platform/x86/dell-laptop.c +1 -1
index c52c6723374b..8ba820e6c3d0 100644
@@ -29,7 +29,7 @@
 #include <linux/mm.h>
 #include <linux/i8042.h>
 #include <linux/debugfs.h>
-#include <linux/dell-led.h>
+#include <linux/dell-common.h>
 #include <linux/seq_file.h>
 #include <acpi/video.h>
 #include "dell-rbtn.h"
include/linux/dell-common.h renamed from include/linux/dell-led.h +2 -2
similarity index 61%
rename from include/linux/dell-led.h
rename to include/linux/dell-common.h
index 92521471517f..37e4b614dd74 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __DELL_LED_H__
-#define __DELL_LED_H__
+#ifndef __DELL_COMMON_H__
+#define __DELL_COMMON_H__
 
 int dell_micmute_led_set(int on);
 
sound/pci/hda/dell_wmi_helper.c +1 -1
index 1b48a8c19d28..56050cc3c0ee 100644
@@ -4,7 +4,7 @@
  */
 
 #if IS_ENABLED(CONFIG_DELL_LAPTOP)
-#include <linux/dell-led.h>
+#include <linux/dell-common.h>
 
 enum {
 	MICMUTE_LED_ON,
Signature · 1 line
2.17.0
#1 lore raw

PATCH v4 2/3 platform/x86: dell-*: Add interface for switchable graphics status query

On some Dell platforms, there's a BIOS option "Enable Switchable Graphics". This information is useful if we want to do different things based on this value, e.g. disable unused audio controller that comes with the discrete graphics.

Cc Mario Limonciello <[email protected]>

---
v4: Change the commit message to clarify there's no more runtime pm
warning.
Also skip the check for thunderbolt attached devices.

v3: Simplify dell_switchable_gfx_is_enabled() by returning bool instead
of error code.
Use DMI_DEV_TYPE_OEM_STRING to match Dell System.

v2: Mario suggested to squash the HDA part into the same series.

 drivers/platform/x86/dell-laptop.c      | 17 +++++++++++++++++
 drivers/platform/x86/dell-smbios-base.c |  2 ++
 drivers/platform/x86/dell-smbios.h      |  2 ++
 include/linux/dell-common.h             |  1 +
 4 files changed, 22 insertions(+)
drivers/platform/x86/dell-laptop.c +17 -0
index 8ba820e6c3d0..033a27b190cc 100644
@@ -2116,6 +2116,23 @@ int dell_micmute_led_set(int state)
 }
 EXPORT_SYMBOL_GPL(dell_micmute_led_set);
 
+bool dell_switchable_gfx_is_enabled(void)
+{
+	struct calling_interface_buffer buffer;
+	struct calling_interface_token *token;
+
+	token = dell_smbios_find_token(SWITCHABLE_GRAPHICS_ENABLE);
+	if (!token)
+		return false;
+
+	dell_fill_request(&buffer, token->location, 0, 0, 0);
+	if (dell_send_request(&buffer, CLASS_TOKEN_READ, SELECT_TOKEN_STD))
+		return false;
+
+	return !!buffer.output[1];
+}
+EXPORT_SYMBOL_GPL(dell_switchable_gfx_is_enabled);
+
 static int __init dell_init(void)
 {
 	struct calling_interface_token *token;
drivers/platform/x86/dell-smbios-base.c +2 -0
index 33fb2a20458a..881ce42f0ca7 100644
@@ -86,6 +86,8 @@ struct token_range {
 static struct token_range token_whitelist[] = {
 	/* used by userspace: fwupdate */
 	{CAP_SYS_ADMIN,	CAPSULE_EN_TOKEN,	CAPSULE_DIS_TOKEN},
+	/* can indicate to userspace Switchable Graphics enable status */
+	{CAP_SYS_ADMIN,	SWITCHABLE_GRAPHICS_ENABLE,	SWITCHABLE_GRAPHICS_DISABLE},
 	/* can indicate to userspace that WMI is needed */
 	{0x0000,	WSMT_EN_TOKEN,		WSMT_DIS_TOKEN}
 };
drivers/platform/x86/dell-smbios.h +2 -0
index d8adaf959740..7863e6a7cff8 100644
@@ -37,6 +37,8 @@
 #define KBD_LED_AUTO_100_TOKEN	0x02F6
 #define GLOBAL_MIC_MUTE_ENABLE	0x0364
 #define GLOBAL_MIC_MUTE_DISABLE	0x0365
+#define SWITCHABLE_GRAPHICS_ENABLE	0x037A
+#define SWITCHABLE_GRAPHICS_DISABLE	0x037B
 
 struct notifier_block;
 
include/linux/dell-common.h +1 -0
index 37e4b614dd74..1a90bc9a3bea 100644
@@ -3,5 +3,6 @@
 #define __DELL_COMMON_H__
 
 int dell_micmute_led_set(int on);
+bool dell_switchable_gfx_is_enabled(void);
 
 #endif
Signature · 1 line
2.17.0
#2 lore raw

Re: [PATCH v4 2/3] platform/x86: dell-*: Add interface for switchable graphics status query

Quoted 7 lines · Kai-Heng Feng

On some Dell platforms, there's a BIOS option "Enable Switchable Graphics". This information is useful if we want to do different things based on this value, e.g. disable unused audio controller that comes with the discrete graphics.

int dell_micmute_led_set(int on);
+bool dell_switchable_gfx_is_enabled(void);

I would rather preserve existing API, i.e.
- prototype int func(void), where return either state or negative error code.
- naming: dell_switchable_gfx_get()

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH v4 3/3 ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

In reply to Kai-Heng Feng

Some Dell platforms (Preicsion 7510/7710/7520/7720) have a BIOS option "Switchable Graphics" (SG).

When SG is enabled, we have:
00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04) 00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31) 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Polaris10] 01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]

The Intel Audio outputs all the sound, including HDMI audio. The audio controller comes with AMD graphics doesn't get used.

When SG is disabled, we have:
00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31) 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Polaris10] 01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Since the discrete audio controller isn't useful when SG is enabled, we should just disable the device.

---
v4: Change the commit message to clarify there's no more runtime pm
warning.
Also skip the check for thunderbolt attached devices.

v3: Simplify dell_switchable_gfx_is_enabled() by returning bool instead
of error code.
Use DMI_DEV_TYPE_OEM_STRING to match Dell System.

v2: Mario suggested to squash the HDA part into the same series.

 sound/pci/hda/hda_intel.c | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
sound/pci/hda/hda_intel.c +43 -0
index 7a111a1b5836..3981193c8d29 100644
@@ -49,6 +49,8 @@
 #include <linux/clocksource.h>
 #include <linux/time.h>
 #include <linux/completion.h>
+#include <linux/dell-common.h>
+#include <linux/dmi.h>
 
 #ifdef CONFIG_X86
 /* for snoop control */
@@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)
+{
+	bool (*dell_switchable_gfx_is_enabled_func)(void);
+	bool enabled;
+
+	/* Thunderbolt devices won't be switchable */
+	if (pci_is_thunderbolt_attached(pdev))
+		return false;
+
+	/* Only check for Dell laptops and AIOs */
+	if (!dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL) ||
+	    !(dmi_match(DMI_CHASSIS_TYPE, "10") ||
+	      dmi_match(DMI_CHASSIS_TYPE, "13")) ||
+	    !(pdev->vendor == PCI_VENDOR_ID_ATI ||
+	      pdev->vendor == PCI_VENDOR_ID_NVIDIA))
+		return false;
+
+	dell_switchable_gfx_is_enabled_func =
+		symbol_request(dell_switchable_gfx_is_enabled);
+	if (!dell_switchable_gfx_is_enabled_func)
+		return false;
+
+	enabled = dell_switchable_gfx_is_enabled_func();
+
+	symbol_put(dell_switchable_gfx_is_enabled);
+
+	return enabled;
+}
+#else
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)
+{
+	return false;
+}
+#endif
+
 /* check the snoop mode availability */
 static void azx_check_snoop_available(struct azx *chip)
 {
@@ -1709,6 +1747,11 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
 	if (err < 0)
 		return err;
 
+	if (check_dell_switchable_gfx(pci)) {
+		pci_disable_device(pci);
+		return -ENODEV;
+	}
+
 	hda = kzalloc(sizeof(*hda), GFP_KERNEL);
 	if (!hda) {
 		pci_disable_device(pci);
Signature · 1 line
2.17.0
#4 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 7 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1632

Quoted 5 lines
sound/pci/hda/hda_intel.c +1 -0
@@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)

This should be IS_REACHABLE(), as both dell-laptop and HD-audio are tristate.

Review static void check_msi(struct azx *chip) · line 1633

Quoted 1 line
(quoted diff) +1 -0
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

I'd remove "_dell" word here. Such a check would be likely needed for other vendors, and it's quite possible that the function will be extended to cover a wider DMI table.

thanks,

Takashi

#5 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 14 lines · Takashi Iwai
Quoted 6 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.
Quoted 10 lines

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1632

Quoted 7 lines
sound/pci/hda/hda_intel.c +1 -0
@@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)

This should be IS_REACHABLE(), as both dell-laptop and HD-audio are tristate.

Thanks, will update in next version.

Quoted 6 lines

Review static void check_msi(struct azx *chip) · line 1633

Quoted 2 lines
(quoted diff) +1 -0
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

I'd remove "_dell" word here. Such a check would be likely needed for other vendors, and it's quite possible that the function will be extended to cover a wider DMI table.

Makes sense. Will also update this one.

Kai-Heng

Quoted 5 lines

thanks,

Takashi

#6 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 13 lines · On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
Quoted 13 lines · Takashi Iwai
Quoted 6 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Quoted 6 lines
Quoted 1 line

Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.

So userspace process cannot be killed at all? Then it is different bug in kernel and disabling pci device is just a workaround. Not a real fix.

I would propose to find out what happen and why it cannot be killed (probably it stuck somewhere in kernel) and fix it properly.

Quoted 29 lines
Quoted 10 lines

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1632

Quoted 7 lines
sound/pci/hda/hda_intel.c +1 -0
@@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)

This should be IS_REACHABLE(), as both dell-laptop and HD-audio are tristate.

Thanks, will update in next version.

Quoted 6 lines

Review static void check_msi(struct azx *chip) · line 1633

Quoted 2 lines
(quoted diff) +1 -0
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

I'd remove "_dell" word here. Such a check would be likely needed for other vendors, and it's quite possible that the function will be extended to cover a wider DMI table.

Makes sense. Will also update this one.

Kai-Heng

Quoted 5 lines

thanks,

Takashi

Signature · 6 lines
Pali Rohár
[email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#7 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 20 lines · Pali Rohár
Quoted 15 lines · On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
Quoted 12 lines · Takashi Iwai
Quoted 6 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

Quoted 8 lines
Quoted 2 lines
$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.

So userspace process cannot be killed at all? Then it is different bug in kernel and disabling pci device is just a workaround. Not a real fix.

I would propose to find out what happen and why it cannot be killed (probably it stuck somewhere in kernel) and fix it properly.

That's because the audio device got runtime suspended by the graphics.

In this case, if we really want to use the the discrete audio, then we also need to wake up the graphics. The discrete audio is totally useless when SG is enabled, so my approach is just to disable it.

Kai-Heng

Quoted 18 lines
Quoted 18 lines
Quoted 9 lines

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1632

Quoted 6 lines
sound/pci/hda/hda_intel.c +1 -0
@@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)

This should be IS_REACHABLE(), as both dell-laptop and HD-audio are tristate.

Thanks, will update in next version.

Quoted 5 lines

Review static void check_msi(struct azx *chip) · line 1633

Quoted 1 line
(quoted diff) +1 -0
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

I'd remove "_dell" word here. Such a check would be likely needed for other vendors, and it's quite possible that the function will be extended to cover a wider DMI table.

Quoted 11 lines
Quoted 7 lines

Makes sense. Will also update this one.

Kai-Heng

Quoted 3 lines

thanks,

Takashi

Signature · 2 lines
Pali Rohár
[email protected]

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#8 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 29 lines · On Monday 23 April 2018 16:18:35 Kai Heng Feng wrote:
Quoted 20 lines · Pali Rohár
Quoted 15 lines · On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
Quoted 12 lines · Takashi Iwai
Quoted 6 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

Quoted 8 lines
Quoted 2 lines
$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.

So userspace process cannot be killed at all? Then it is different bug in kernel and disabling pci device is just a workaround. Not a real fix.

I would propose to find out what happen and why it cannot be killed (probably it stuck somewhere in kernel) and fix it properly.

Quoted 6 lines

That's because the audio device got runtime suspended by the graphics.

In this case, if we really want to use the the discrete audio, then we also need to wake up the graphics.
The discrete audio is totally useless when SG is enabled, so my approach is just to disable it.

I'm not saying that disabling PCI should not be done.

I'm saying that if userspace process which opened that audio device cannot be killed, then you found different kernel bug and that should be fixed.

Quoted 31 lines

Kai-Heng

Quoted 29 lines
Quoted 25 lines
Quoted 9 lines

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1632

Quoted 6 lines
sound/pci/hda/hda_intel.c +1 -0
@@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)

This should be IS_REACHABLE(), as both dell-laptop and HD-audio are tristate.

Thanks, will update in next version.

Quoted 5 lines

Review static void check_msi(struct azx *chip) · line 1633

Quoted 1 line
(quoted diff) +1 -0
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

I'd remove "_dell" word here. Such a check would be likely needed for other vendors, and it's quite possible that the function will be extended to cover a wider DMI table.

Makes sense. Will also update this one.

Kai-Heng

Quoted 3 lines

thanks,

Takashi

Signature · 2 lines
Pali Rohár
[email protected]
Signature · 2 lines
Pali Rohár
[email protected]
#9 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

In reply to Kai Heng Feng
Quoted 24 lines · Kai Heng Feng
Quoted 15 lines · Pali Rohár
Quoted 13 lines · On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
Quoted 10 lines · Takashi Iwai
Quoted 6 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

Quoted 8 lines
Quoted 2 lines
$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.

So userspace process cannot be killed at all? Then it is different bug in kernel and disabling pci device is just a workaround. Not a real fix.

I would propose to find out what happen and why it cannot be killed (probably it stuck somewhere in kernel) and fix it properly.

Quoted 6 lines

That's because the audio device got runtime suspended by the graphics.

In this case, if we really want to use the the discrete audio, then we also need to wake up the graphics.
The discrete audio is totally useless when SG is enabled, so my approach is just to disable it.

I don't quite follow, that should be fixed by commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller") which landed in v4.17-rc1.

My understanding was that with SG enabled, the external DP/HDMI ports are muxed to the Intel GPU, so audio can only be streamed to external displays by the Intel HDA, not by the HDA integrated into the discrete AMD/Nvidia GPU. Audio streamed to the latter would essentially end up in a blackhole. And preventing the user from seeing such useless audio devices was the sole purpose of this commit. Am I missing something?

Thanks,

Lukas

#10 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 30 lines · Lukas Wunner
Quoted 26 lines · Kai Heng Feng
Quoted 15 lines · Pali Rohár
Quoted 13 lines · On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
Quoted 10 lines · Takashi Iwai
Quoted 6 lines · Kai-Heng Feng

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

Quoted 8 lines
Quoted 2 lines
$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.

So userspace process cannot be killed at all? Then it is different bug in kernel and disabling pci device is just a workaround. Not a real fix.

I would propose to find out what happen and why it cannot be killed (probably it stuck somewhere in kernel) and fix it properly.

That's because the audio device got runtime suspended by the graphics.

Quoted 8 lines
Quoted 4 lines

In this case, if we really want to use the the discrete audio, then we also need to wake up the graphics.
The discrete audio is totally useless when SG is enabled, so my approach is just to disable it.

I don't quite follow, that should be fixed by commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller") which landed in v4.17-rc1.

Looks like I hit a new bug: the discrete GFX and its audio controller never enters to D3. The GFX can enter to D3 with my prosed patch.

Quoted 7 lines

My understanding was that with SG enabled, the external DP/HDMI ports are muxed to the Intel GPU, so audio can only be streamed to external displays by the Intel HDA, not by the HDA integrated into the discrete AMD/Nvidia GPU. Audio streamed to the latter would essentially end up in a blackhole. And preventing the user from seeing such useless audio devices was the sole purpose of this commit. Am I missing something?

Yes this is the intention.

Kai-Heng

Quoted 4 lines

Thanks,

Lukas

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#11 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Quoted 9 lines · Kai Heng Feng
Quoted 9 lines · Lukas Wunner
Quoted 6 lines · Kai Heng Feng

That's because the audio device got runtime suspended by the graphics.

In this case, if we really want to use the the discrete audio, then we also need to wake up the graphics.
The discrete audio is totally useless when SG is enabled, so my approach is just to disable it.

Quoted 7 lines
Quoted 3 lines

I don't quite follow, that should be fixed by commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller") which landed in v4.17-rc1.

Looks like I hit a new bug: the discrete GFX and its audio controller never enters to D3.
The GFX can enter to D3 with my prosed patch.

Can you find out why? Does the HDA controller have a codec as child device that doesn't runtime suspend, perhaps because it failed to initialize correctly? If a codec device fails to runtime suspend, the HDA controller (as parent) and by extension the GPU (via the device link) are also kept runtime active.

Do you see anything in dmesg when the AMD HDA controller probes? If you look in /sys/bus/pci/devices/0000:01:00.1/power/, does the HDA controller have active kids and what is its usage count?

Quoted 8 lines
Quoted 6 lines

My understanding was that with SG enabled, the external DP/HDMI ports are muxed to the Intel GPU, so audio can only be streamed to external displays by the Intel HDA, not by the HDA integrated into the discrete AMD/Nvidia GPU. Audio streamed to the latter would essentially end up in a blackhole. And preventing the user from seeing such useless audio devices was the sole purpose of this commit. Am I missing something?

Yes this is the intention.

Could you add this information to the commit message then?

Thanks,

Lukas

#12 lore raw

Re: [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

In reply to Kai-Heng Feng
Quoted 20 lines · Kai-Heng Feng

Some Dell platforms (Preicsion 7510/7710/7520/7720) have a BIOS option "Switchable Graphics" (SG).

When SG is enabled, we have:
00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04) 00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31) 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Polaris10] 01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]

The Intel Audio outputs all the sound, including HDMI audio. The audio controller comes with AMD graphics doesn't get used.

When SG is disabled, we have:
00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31) 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Polaris10] 01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]

Now it's a typical discrete-only system. HDMI audio comes from AMD audio controller, others from Intel audio controller.

Quoted 8 lines

When SG is enabled, the unused AMD audio contoller still exposes its sysfs, so userspace still opens the control file and stream. If userspace tries to output sound through the stream, it hangs the system.

Since the discrete audio controller isn't useful when SG is enabled, we should just disable the device.

+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

Yeah, as following existing naming scheme in the driver (check_hdmi_disabled(), for example)
I would rather call it similar:

check_switchable_gfx_enabled()

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1645

Quoted 13 lines
sound/pci/hda/hda_intel.c +12 -0
+{
+       bool (*dell_switchable_gfx_is_enabled_func)(void);
+       bool enabled;
+
+       /* Thunderbolt devices won't be switchable */
+       if (pci_is_thunderbolt_attached(pdev))
+               return false;
+
+       /* Only check for Dell laptops and AIOs */
 
+       if (!dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL) ||
+           !(dmi_match(DMI_CHASSIS_TYPE, "10") ||
+             dmi_match(DMI_CHASSIS_TYPE, "13")) ||

Can't we do it in more flexible way, i.e. using struct dmi_system_id table and dmi_check_system() ?

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1648

Quoted 3 lines
sound/pci/hda/hda_intel.c +3 -0
+           !(pdev->vendor == PCI_VENDOR_ID_ATI ||
+             pdev->vendor == PCI_VENDOR_ID_NVIDIA))
+               return false;

I would rather split DMI and PCI checks.

Quoted 4 lines
sound/pci/hda/hda_intel.c +4 -0
+
+       dell_switchable_gfx_is_enabled_func =
+               symbol_request(dell_switchable_gfx_is_enabled);
+       if (!dell_switchable_gfx_is_enabled_func)

sound/pci/hda/hda_intel.c static void check_msi(struct azx *chip) · line 1662

Quoted 10 lines
sound/pci/hda/hda_intel.c +10 -0
+               return false;
+
+       enabled = dell_switchable_gfx_is_enabled_func();
+
+       symbol_put(dell_switchable_gfx_is_enabled);
+
+       return enabled;
+}
+#else
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)

inline

Quoted 4 lines
sound/pci/hda/hda_intel.c +4 -0
+{
+       return false;
+}
+#endif
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw
In reply to Kai-Heng Feng
Quoted 6 lines · Kai-Heng Feng

This header will be used for more than just led. Change it to a more generic name.

Cc Mario Limonciello <[email protected]>

BTW, wouldn't it be better postpone the rename? Renaming a file in a cross-tree patchset makes harder to apply in general.

thanks,

Takashi

Quoted 63 lines

---
v4: Change the commit message to clarify there's no more runtime pm
warning.
Also skip the check for thunderbolt attached devices.

v3: Simplify dell_switchable_gfx_is_enabled() by returning bool instead
of error code.
Use DMI_DEV_TYPE_OEM_STRING to match Dell System.

v2: Mario suggested to squash the HDA part into the same series.

 drivers/platform/x86/dell-laptop.c          | 2 +-
 include/linux/{dell-led.h => dell-common.h} | 4 ++--
 sound/pci/hda/dell_wmi_helper.c             | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
 rename include/linux/{dell-led.h => dell-common.h} (61%)
drivers/platform/x86/dell-laptop.c +1 -1
index c52c6723374b..8ba820e6c3d0 100644
@@ -29,7 +29,7 @@
 #include <linux/mm.h>
 #include <linux/i8042.h>
 #include <linux/debugfs.h>
-#include <linux/dell-led.h>
+#include <linux/dell-common.h>
 #include <linux/seq_file.h>
 #include <acpi/video.h>
 #include "dell-rbtn.h"
include/linux/dell-common.h renamed from include/linux/dell-led.h +2 -2
similarity index 61%
rename from include/linux/dell-led.h
rename to include/linux/dell-common.h
index 92521471517f..37e4b614dd74 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __DELL_LED_H__
-#define __DELL_LED_H__
+#ifndef __DELL_COMMON_H__
+#define __DELL_COMMON_H__
 
 int dell_micmute_led_set(int on);
 
sound/pci/hda/dell_wmi_helper.c +1 -1
index 1b48a8c19d28..56050cc3c0ee 100644
@@ -4,7 +4,7 @@
  */
 
 #if IS_ENABLED(CONFIG_DELL_LAPTOP)
-#include <linux/dell-led.h>
+#include <linux/dell-common.h>
 
 enum {
 	MICMUTE_LED_ON,
Signature · 1 line
2.17.0
#14 lore raw
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Kai-Heng Feng

This header will be used for more than just led. Change it to a more generic name.

Quoted 7 lines
Quoted 2 lines
Cc Mario Limonciello <[email protected]>

BTW, wouldn't it be better postpone the rename? Renaming a file in a cross-tree patchset makes harder to apply in general.

You are right, I'll keep the original filename in next version.

Kai-Heng

Quoted 66 lines

thanks,

Takashi

Quoted 61 lines

---
v4: Change the commit message to clarify there's no more runtime pm
warning.
Also skip the check for thunderbolt attached devices.

v3: Simplify dell_switchable_gfx_is_enabled() by returning bool instead
of error code.
Use DMI_DEV_TYPE_OEM_STRING to match Dell System.

v2: Mario suggested to squash the HDA part into the same series.

 drivers/platform/x86/dell-laptop.c          | 2 +-
 include/linux/{dell-led.h => dell-common.h} | 4 ++--
 sound/pci/hda/dell_wmi_helper.c             | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
 rename include/linux/{dell-led.h => dell-common.h} (61%)
drivers/platform/x86/dell-laptop.c +1 -1
index c52c6723374b..8ba820e6c3d0 100644
@@ -29,7 +29,7 @@
 #include <linux/mm.h>
 #include <linux/i8042.h>
 #include <linux/debugfs.h>
-#include <linux/dell-led.h>
+#include <linux/dell-common.h>
 #include <linux/seq_file.h>
 #include <acpi/video.h>
 #include "dell-rbtn.h"
include/linux/dell-common.h renamed from include/linux/dell-led.h +2 -2
similarity index 61%
rename from include/linux/dell-led.h
rename to include/linux/dell-common.h
index 92521471517f..37e4b614dd74 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __DELL_LED_H__
-#define __DELL_LED_H__
+#ifndef __DELL_COMMON_H__
+#define __DELL_COMMON_H__
 
 int dell_micmute_led_set(int on);
 
sound/pci/hda/dell_wmi_helper.c +1 -1
index 1b48a8c19d28..56050cc3c0ee 100644
@@ -4,7 +4,7 @@
  */
 
 #if IS_ENABLED(CONFIG_DELL_LAPTOP)
-#include <linux/dell-led.h>
+#include <linux/dell-common.h>
 
 enum {
 	MICMUTE_LED_ON,
Signature · 1 line
2.17.0