Skip to contentSkip to conversation

vgaswitchroo: set audio client id according to bound gpu client id

PATCH Superseded Jim Qu 13 participants 60 messages Jun 28, 2018 – Jul 16, 2018 34 messages not in the archive

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jim Qu

author
#0 lore raw

PATCH 1/1 vgaswitchroo: set audio client id according to bound gpu client id

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
 drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
 include/linux/vga_switcheroo.h   |  4 ++--
 sound/pci/hda/hda_intel.c        | 15 +++++++++------
 3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +9 -2
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
  * vga_switcheroo_register_audio_client - register audio client
  * @pdev: client pci device
  * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
  *
  * Register audio client (audio device on a GPU). The client is assumed
  * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
  */
 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 			const struct vga_switcheroo_client_ops *ops,
-			enum vga_switcheroo_client_id id)
+			struct pci_dev *bound_vga)
 {
+	enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+	if (bound_vga) {
+		if (vgasr_priv.handler->get_client_id)
+			id = vgasr_priv.handler->get_client_id(bound_vga);
+	}
+
 	return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
 }
 EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +2 -2
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev *dev,
 				   bool driver_power_control);
 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 					 const struct vga_switcheroo_client_ops *ops,
-					 enum vga_switcheroo_client_id id);
+					 struct pci_dev *bound_vga);
 
 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
 				  struct fb_info *info);
@@ -180,7 +180,7 @@ static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_ha
 		enum vga_switcheroo_handler_flags_t handler_flags) { return 0; }
 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 	const struct vga_switcheroo_client_ops *ops,
-	enum vga_switcheroo_client_id id) { return 0; }
+	struct pci_dev *bound_vga) { return 0; }
 static inline void vga_switcheroo_unregister_handler(void) {}
 static inline enum vga_switcheroo_handler_flags_t vga_switcheroo_handler_flags(void) { return 0; }
 static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return -ENODEV; }
sound/pci/hda/hda_intel.c +9 -6
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = {
 static int register_vga_switcheroo(struct azx *chip)
 {
 	struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
+	struct pci_dev *p;
 	int err;
 
 	if (!hda->use_vga_switcheroo)
 		return 0;
-	/* FIXME: currently only handling DIS controller
-	 * is there any machine with two switchable HDMI audio controllers?
-	 */
-	err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-						   VGA_SWITCHEROO_DIS);
+
+	p = get_bound_vga(chip->pci);
+	err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p);
+
+	if (p)
+		pci_dev_put(p);
 	if (err < 0)
 		return err;
 	hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
 			p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
 							pci->bus->number, 0);
 			if (p) {
-				if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+				if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+				(p->class >> 8) == PCI_CLASS_DISPLAY_OTHER)
 					return p;
 				pci_dev_put(p);
 			}
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 20 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

The patch also combine the HDA change to avoid break building.

Quoted 9 lines
Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
 drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
 include/linux/vga_switcheroo.h   |  4 ++--
 sound/pci/hda/hda_intel.c        | 15 +++++++++------
 3 files changed, 20 insertions(+), 10 deletions(-)

Please resend and send it to dri-devel and [email protected] since this patch touches multiple subsystems. I would propose we merge this through the drm tree if possible.

Alex

Quoted 92 lines
drivers/gpu/vga/vga_switcheroo.c +9 -2
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
  * vga_switcheroo_register_audio_client - register audio client
  * @pdev: client pci device
  * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
  *
  * Register audio client (audio device on a GPU). The client is assumed
  * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
  */
 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                        const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
 {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
        return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
 }
 EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +2 -2
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev *dev,
                                   bool driver_power_control);
 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                         const struct vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id id);
+                                        struct pci_dev *bound_vga);
 
 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
                                  struct fb_info *info);
@@ -180,7 +180,7 @@ static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_ha
                enum vga_switcheroo_handler_flags_t handler_flags) { return 0; }
 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
        const struct vga_switcheroo_client_ops *ops,
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
 static inline void vga_switcheroo_unregister_handler(void) {}
 static inline enum vga_switcheroo_handler_flags_t vga_switcheroo_handler_flags(void) { return 0; }
 static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return -ENODEV; }
sound/pci/hda/hda_intel.c +9 -7
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = {
 static int register_vga_switcheroo(struct azx *chip)
 {
        struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
+       struct pci_dev *p;
        int err;
 
        if (!hda->use_vga_switcheroo)
                return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio controllers?
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p);
+
+       if (p)
+               pci_dev_put(p);
        if (err < 0)
                return err;
        hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
                        p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                        pci->bus->number, 0);
                        if (p) {
-                               if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+                               if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+                               (p->class >> 8) == PCI_CLASS_DISPLAY_OTHER)
                                        return p;
                                pci_dev_put(p);
                        }
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CADnq5_NcNfMD9UDN17c-513rD--kQY7nzw6OTgimV0pVqLjbOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#3 lore raw

HI,

Any comments for the patch?

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月28日 20:43
收件人: Qu, Jim; [email protected]; Maling list - DRI developers 抄送: amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 20 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

The patch also combine the HDA change to avoid break building.

Quoted 9 lines
Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
 drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
 include/linux/vga_switcheroo.h   |  4 ++--
 sound/pci/hda/hda_intel.c        | 15 +++++++++------
 3 files changed, 20 insertions(+), 10 deletions(-)

Please resend and send it to dri-devel and [email protected] since this patch touches multiple subsystems. I would propose we merge this through the drm tree if possible.

Alex

Quoted 92 lines
drivers/gpu/vga/vga_switcheroo.c +9 -2
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
  * vga_switcheroo_register_audio_client - register audio client
  * @pdev: client pci device
  * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
  *
  * Register audio client (audio device on a GPU). The client is assumed
  * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
  */
 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                        const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
 {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
        return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
 }
 EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +2 -2
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev *dev,
                                   bool driver_power_control);
 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                         const struct vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id id);
+                                        struct pci_dev *bound_vga);
 
 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
                                  struct fb_info *info);
@@ -180,7 +180,7 @@ static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_ha
                enum vga_switcheroo_handler_flags_t handler_flags) { return 0; }
 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
        const struct vga_switcheroo_client_ops *ops,
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
 static inline void vga_switcheroo_unregister_handler(void) {}
 static inline enum vga_switcheroo_handler_flags_t vga_switcheroo_handler_flags(void) { return 0; }
 static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return -ENODEV; }
sound/pci/hda/hda_intel.c +9 -7
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = {
 static int register_vga_switcheroo(struct azx *chip)
 {
        struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
+       struct pci_dev *p;
        int err;
 
        if (!hda->use_vga_switcheroo)
                return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio controllers?
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p);
+
+       if (p)
+               pci_dev_put(p);
        if (err < 0)
                return err;
        hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
                        p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                        pci->bus->number, 0);
                        if (p) {
-                               if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+                               if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+                               (p->class >> 8) == PCI_CLASS_DISPLAY_OTHER)
                                        return p;
                                pci_dev_put(p);
                        }
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

reviewer
#4 lore raw
Quoted 9 lines · Jim Qu
Quoted 8 lines

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

Please explain what you mean by UMA here. Are you referring to dual GPU systems where both GPUs are by AMD? And the integrated GPU is incorrectly assigned VGA_SWITCHEROO_DIS?

Starting with v4.17, the only reason the audio driver registers with vga_switcheroo is because it can be powered down if manual power control is used. However manual power control is not the default, it's primary use case nowadays is MacBook Pros, and there are no MacBook Pros with dual AMD GPUs. So I don't understand what real world use case you're trying to fix. Please explain.

Quoted 3 lines
Quoted 3 lines

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Unlike the other changes in your patch, this one would seem perfectly valid to me. However it's a separate issue, so please put it in a separate patch.

Instead of adding a check for PCI_CLASS_DISPLAY_OTHER, I'd prefer you replacing the existing check for PCI_CLASS_DISPLAY_VGA with a check for PCI_BASE_CLASS_DISPLAY, like so:

- if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY)

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20180629080634.GA7357-JFq808J9C/[email protected]

author
#6 lore raw

Hi Lukas,

Thanks to your response, please see comments in line.

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年6月29日 16:06
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 14 lines
Quoted 9 lines · Jim Qu
Quoted 8 lines

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

Please explain what you mean by UMA here. Are you referring to dual GPU systems where both GPUs are by AMD? And the integrated GPU is incorrectly assigned VGA_SWITCHEROO_DIS?

Quoted 7 lines

Starting with v4.17, the only reason the audio driver registers with vga_switcheroo is because it can be powered down if manual power control is used. However manual power control is not the default, it's primary use case nowadays is MacBook Pros, and there are no MacBook Pros with dual AMD GPUs. So I don't understand what real world use case you're trying to fix. Please explain.

Jim: Yeah, this a laptop which has two GPUs, iGPU has a HD audio for HDMI output. dGPU is headless which is only for offload render. This is a grapchis offloading solution for hybird GFX.

When our dGPU does suspend by runtime pm. amdgpu driver for dgpu will also call vgaswtichroo to power off its audio. vgaswitchroo driver will find audio codec by vgaswitchroo dgpu client id(VGA_SWITCHEROO_DIS).

Current HDA driver will register iGPU's audio client to vgaswitchroo as VGA_SWITCHEROO_DIS. so iGPU's audio has been powered off. It causes the issue that no sound on the HDMI device.

I think the issue should be observed on both Intel+AMD or AMD+AMD platform which has the same HW configuration.

1.if dGPU has no audio codec. the issue should be always observed.
2.if both iGPU and dGPU has audio codecs, the issue should be random, it depends on the first audio found by vgaswitchroo driver is on iGPU or dGPU.

Quoted 12 lines
Quoted 3 lines

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Unlike the other changes in your patch, this one would seem perfectly valid to me. However it's a separate issue, so please put it in a separate patch.

Instead of adding a check for PCI_CLASS_DISPLAY_OTHER, I'd prefer you replacing the existing check for PCI_CLASS_DISPLAY_VGA with a check for PCI_BASE_CLASS_DISPLAY, like so:

Review

Quoted 2 lines
(quoted diff) +1 -1
-                               if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+                               if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY)

Jim: That is fine, will update it.

Thanks,

Lukas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB08737DC9FB94BB6F3AEF5634994E0-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#8 lore raw
Quoted 3 lines · Jim

When our dGPU does suspend by runtime pm. amdgpu driver for dgpu will also call vgaswtichroo to power off its audio. vgaswitchroo driver will find audio codec by vgaswitchroo dgpu client id(VGA_SWITCHEROO_DIS).

That is no longer the case since v4.17. The HDA controller now runtime suspends autonomously, see commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").

Your patch appears to be geared towards an older kernel version. Please retest on the laptop in question with a v4.17+ kernel.

Quoted 7 lines

I think the issue should be observed on both Intel+AMD or AMD+AMD platform which has the same HW configuration.

1.if dGPU has no audio codec. the issue should be always observed. 2.if both iGPU and dGPU has audio codecs, the issue should be random, it depends on the first audio found by vgaswitchroo driver is on iGPU or dGPU.

On discrete AMD and Nvidia GPUs, the HDA controller is function 1 and the GPU is function 0 in the same PCI slot.

On Intel chipsets, the HDA controller and the GPU have completely different PCI device numbers, e.g. the GPU might be 0000:00:02.0 and the HDA controller might be 0000:00:1b.0.

get_bound_vga() checks that the HDA controller is function 1 and there's a GPU in function 0 of the same slot.

Thus get_bound_vga() always returns NULL for an Intel HDA controller and the controller is never registered with vga_switcheroo (which is fine).

Thanks,

Lukas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180629092138.GA11849-JFq808J9C/[email protected]

author
#10 lore raw

indeed?I used 4.13 on the platform. let me have a try with the patch you mentioned

thinks
jimqu

?? Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Lukas Wunner <lukas-JFq808J9C/[email protected]>
Sent: Friday, June 29, 2018 5:21:38 PM
To: Qu, Jim
Cc: alsa-devel-K7yf7f+aM1XWsZ/[email protected]; [email protected]; Deucher, Alexander; [email protected]
Subject: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 3 lines · Jim

When our dGPU does suspend by runtime pm. amdgpu driver for dgpu will also call vgaswtichroo to power off its audio. vgaswitchroo driver will find audio codec by vgaswitchroo dgpu client id(VGA_SWITCHEROO_DIS).

That is no longer the case since v4.17. The HDA controller now runtime suspends autonomously, see commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").

Your patch appears to be geared towards an older kernel version. Please retest on the laptop in question with a v4.17+ kernel.

Quoted 7 lines

I think the issue should be observed on both Intel+AMD or AMD+AMD platform which has the same HW configuration.

1.if dGPU has no audio codec. the issue should be always observed. 2.if both iGPU and dGPU has audio codecs, the issue should be random, it depends on the first audio found by vgaswitchroo driver is on iGPU or dGPU.

On discrete AMD and Nvidia GPUs, the HDA controller is function 1 and the GPU is function 0 in the same PCI slot.

On Intel chipsets, the HDA controller and the GPU have completely different PCI device numbers, e.g. the GPU might be 0000:00:02.0 and the HDA controller might be 0000:00:1b.0.

get_bound_vga() checks that the HDA controller is function 1 and there's a GPU in function 0 of the same slot.

Thus get_bound_vga() always returns NULL for an Intel HDA controller and the controller is never registered with vga_switcheroo (which is fine).

Thanks,

Lukas

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

reviewer
#11 lore raw
Quoted 9 lines · Jim
Quoted 6 lines

That is no longer the case since v4.17. The HDA controller now runtime suspends autonomously, see commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").

Your patch appears to be geared towards an older kernel version. Please retest on the laptop in question with a v4.17+ kernel.

indeed? I used 4.13 on the platform. let me have a try with the patch you mentioned

The commit can't be cherry-picked by itself onto v4.13, it was part of a larger series. It's best to use a stock v4.17 kernel.

Note, a fix went into Linus' tree yesterday, commit 57cb54e53bdd ("ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI"). Not sure if it's needed on your machine.

Thanks,

Lukas

#12 lore raw

Hi Lukas,

Our OEM report the issue also can be observed with v4.17rc7 of test platform, and I also backported these 7 patches to v4.15, have confirmed the issue.

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Device links help us handle two things:

1. make the audio/gpu suspend/resume/poweroff processing in an orderly way with the DL_FLAG_STATELESS flag.
2. it can guarantee the audio can be accessed if gpu is poweroffed by setting the DL_FLAG_PM_RUNTIME flag.

So, in my opinion, audio's suspend/resume should be processed with gpu suspend/resume.

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年6月29日 19:11
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 9 lines · Jim
Quoted 6 lines

That is no longer the case since v4.17. The HDA controller now runtime suspends autonomously, see commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").

Your patch appears to be geared towards an older kernel version. Please retest on the laptop in question with a v4.17+ kernel.

indeed? I used 4.13 on the platform. let me have a try with the patch you mentioned

The commit can't be cherry-picked by itself onto v4.13, it was part of a larger series. It's best to use a stock v4.17 kernel.

Note, a fix went into Linus' tree yesterday, commit 57cb54e53bdd ("ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI"). Not sure if it's needed on your machine.

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB0873FEC702770190057B49F799440-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#14 lore raw
Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180709092759.GA3649-JFq808J9C/[email protected]

author
#16 lore raw

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB087309CBC2CD3A934327EBCE99440-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#18 lore raw
Quoted 10 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

Quoted 7 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Alex

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_OpZz=AgNomX7+5BzeN77CRZT7mXDT7kn620TE-OjqS0w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#20 lore raw
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

(Though, it will cause another mess wrt the weak module dependency,
but it's another story :)

thanks,

Takashi

Quoted 43 lines

Alex

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

reviewer
#21 lore raw

Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#22 lore raw

Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 25 lines · Lukas Wunner
Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 8 lines

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.

That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).

Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#23 lore raw

Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 43 lines · Takashi Iwai
Quoted 25 lines · Lukas Wunner
Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 8 lines

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.

Quoted 3 lines

That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).

Well for display detection, we don't actually have to wake the GPU, we get the notification from the embedded controller via ACPI if the GPU is powered down, so in the GPU driver we just pass the event along to userspace if the GPU is asleep. I think if we wanted to pass the info along to the audio driver, we'd need to wake both the GPU and the audio to update the audio connect status.

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#24 lore raw

Re: ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 49 lines · Alex Deucher
Quoted 43 lines · Takashi Iwai
Quoted 25 lines · Lukas Wunner
Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 8 lines

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.

Quoted 3 lines

That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).

Quoted 6 lines

Well for display detection, we don't actually have to wake the GPU, we get the notification from the embedded controller via ACPI if the GPU is powered down, so in the GPU driver we just pass the event along to userspace if the GPU is asleep. I think if we wanted to pass the info along to the audio driver, we'd need to wake both the GPU and the audio to update the audio connect status.

I guess that It's not enough to have an ACPI event but we need to read ELD upon hotplugging (not at unplugging, of course, though). So a GPU wakeup would be mandatory, if I'm not mistaken.

Takashi

A message that is not in the archive (sent off-list or not yet received): [email protected]

#26 lore raw

Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 17 lines · Takashi Iwai
Quoted 8 lines · Lukas Wunner

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.

Quoted 3 lines

That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).

Okay. If amdgpu triggers the event on the HDA bus, it should call pm_runtime_get_sync() on the HDA device beforehand. Which device needs to be resumed exactly to ensure ELD reception, the PCI one or the codec?

Thanks,

Lukas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#27 lore raw

Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 18 lines · Lukas Wunner
Quoted 17 lines · Takashi Iwai
Quoted 8 lines · Lukas Wunner

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.

Quoted 8 lines
Quoted 3 lines

That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).

Okay. If amdgpu triggers the event on the HDA bus, it should call pm_runtime_get_sync() on the HDA device beforehand. Which device needs to be resumed exactly to ensure ELD reception, the PCI one or the codec?

I don't think it makes sense to power up anything until the user wants to do something with the event. On AMD hardware, the ELD is not actually used. The gpu passes the ELD info internally via shared registers. So as soon as the GPU driver parses the EDID and updates the shared registers, the audio driver will know the state just by reading back the shared registers. That said, there no reason to act on the event unless the user actually wants to do something with it. E.g., the desktop manager sees the event and decides to call down to the kernel to query the display topology (or not). At which point the hw can be powered up, etc.

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CADnq5_OqsZyMJx5TCqdr4iydzVyb3UHtqadvuq0szG+kNPe9dg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#29 lore raw

Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 29 lines · Alex Deucher
Quoted 18 lines · Lukas Wunner
Quoted 17 lines · Takashi Iwai
Quoted 8 lines · Lukas Wunner

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.

Quoted 8 lines
Quoted 3 lines

That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).

Okay. If amdgpu triggers the event on the HDA bus, it should call pm_runtime_get_sync() on the HDA device beforehand. Which device needs to be resumed exactly to ensure ELD reception, the PCI one or the codec?

Quoted 10 lines

I don't think it makes sense to power up anything until the user wants to do something with the event. On AMD hardware, the ELD is not actually used. The gpu passes the ELD info internally via shared registers. So as soon as the GPU driver parses the EDID and updates the shared registers, the audio driver will know the state just by reading back the shared registers. That said, there no reason to act on the event unless the user actually wants to do something with it. E.g., the desktop manager sees the event and decides to call down to the kernel to query the display topology (or not). At which point the hw can be powered up, etc.

It needs to power up to read even the shared registers; they are accessed via HD-audio verbs, so we need the whole runtime resume of the bus & codec just for reading ELD information that are stored by GPU.

And, ELD info is mandatory for informing the hotplug information to user-space, not only the connection/disconnection state.

If ELD and hoptlug info are passed directly from GPU by other means, we can avoid the power up/down in the audio side, indeed. That's what Intel driver serves, after all.

Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180709154734.GA30496-JFq808J9C/[email protected]

author
#31 lore raw

答复: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Hi All,

Here, I want to clarify the audio device is bound to iGPU. There is no audio codec for dGPU.

Thanks
JimQu

-----邮件原件-----
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 23:48
收件人: Takashi Iwai <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

Thanks,

Lukas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#32 lore raw

Re: 答复: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 4 lines · Jim

Hi All,

Here, I want to clarify the audio device is bound to iGPU. There is no audio codec for dGPU.

I'm confused. So you mean that the HDMI detection on Intel GPU doesn't work with the hybrid GPUs? And no audio codec on discrete GPU...? Why do we need vga_switcheroo at all, then?

Takashi

Quoted 35 lines

Thanks
JimQu

-----邮件原件-----
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 23:48
收件人: Takashi Iwai <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 8 lines

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

Thanks,

Lukas

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#33 lore raw

Re: 答复: ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 10 lines · Takashi Iwai
Quoted 4 lines · Jim

Hi All,

Here, I want to clarify the audio device is bound to iGPU. There is no audio codec for dGPU.

I'm confused. So you mean that the HDMI detection on Intel GPU doesn't work with the hybrid GPUs? And no audio codec on discrete GPU...? Why do we need vga_switcheroo at all, then?

The original problem is the audio codec is getting associated with dGPU rather than the iGPU so switcheroo tries to power down the audio codec when it powers down the dGPU. We got a bit sidetracked in the discussion however.

Alex

Quoted 48 lines

Takashi

Quoted 43 lines

Thanks
JimQu

-----邮件原件-----
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 23:48
收件人: Takashi Iwai <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

Thanks,

Lukas

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

#34 lore raw

Re: 答复: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 9 lines · Alex Deucher
Quoted 7 lines · Takashi Iwai
Quoted 4 lines · Jim

Hi All,

Here, I want to clarify the audio device is bound to iGPU. There is no audio codec for dGPU.

Quoted 8 lines
Quoted 3 lines

I'm confused. So you mean that the HDMI detection on Intel GPU doesn't work with the hybrid GPUs? And no audio codec on discrete GPU...? Why do we need vga_switcheroo at all, then?

The original problem is the audio codec is getting associated with dGPU rather than the iGPU so switcheroo tries to power down the audio codec when it powers down the dGPU. We got a bit sidetracked in the discussion however.

Ah, thanks, that clarifies better, but still I'm lost about what's going on...

Can anyone summarize the problem and the results with the recent (>= 4.17) Linux kernel...?

thanks,

Takashi

Quoted 51 lines

Alex

Quoted 48 lines

Takashi

Quoted 43 lines

Thanks
JimQu

-----邮件原件-----
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 23:48
收件人: Takashi Iwai <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 18 lines · Takashi Iwai
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Jim
Quoted 5 lines

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Quoted 5 lines

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 4 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)

If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.

Thanks,

Lukas

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#36 lore raw
Quoted 28 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

Quoted 7 lines

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

(Though, it will cause another mess wrt the weak module dependency,
but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)
-Daniel

Quoted 58 lines

thanks,

Takashi

Quoted 43 lines

Alex

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180709155643.GE3008-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org

#38 lore raw
Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 5 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency,
but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

A patch is welcome :)

thanks,

Takashi

Quoted 52 lines

-Daniel

Quoted 50 lines

thanks,

Takashi

Quoted 43 lines

Alex

Quoted 40 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 14 lines
Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#39 lore raw

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 5 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

A patch is welcome :)

thanks,

Takashi

Quoted 64 lines

-Daniel

Quoted 53 lines

thanks,

Takashi

Quoted 46 lines

Alex

Quoted 43 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 5 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB0873E9DD8B7448CB8A6829DA99440-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#41 lore raw
Quoted 8 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 54 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 5 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

Quoted 76 lines

A patch is welcome :)

thanks,

Takashi

Quoted 69 lines

-Daniel

Quoted 53 lines

thanks,

Takashi

Quoted 46 lines

Alex

Quoted 43 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#42 lore raw

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period. Therefore, upper software could not get HDMI ELD info, can select a available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

Thanks
JimQu

________________________________________
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月10日 1:09
收件人: Qu, Jim
抄送: Daniel Vetter; Alex Deucher; [email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 8 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 54 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 5 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

Quoted 76 lines

A patch is welcome :)

thanks,

Takashi

Quoted 69 lines

-Daniel

Quoted 53 lines

thanks,

Takashi

Quoted 46 lines

Alex

Quoted 43 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#43 lore raw

Sorry, correct the typo.

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period. Therefore, upper software could not get HDMI ELD info, it can not select an available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

Thanks
JimQu

________________________________________
发件人: Qu, Jim
发送时间: 2018年7月10日 15:44:42
收件人: Takashi Iwai
抄送: Daniel Vetter; Alex Deucher; [email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: 答复: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period. Therefore, upper software could not get HDMI ELD info, can select a available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

Thanks
JimQu

________________________________________
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月10日 1:09
收件人: Qu, Jim
抄送: Daniel Vetter; Alex Deucher; [email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 8 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 54 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 5 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

Quoted 76 lines

A patch is welcome :)

thanks,

Takashi

Quoted 69 lines

-Daniel

Quoted 53 lines

thanks,

Takashi

Quoted 46 lines

Alex

Quoted 43 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB0873205E27A9241DB3B10EA5995B0-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#45 lore raw
Quoted 6 lines · Jim

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

What does this mean? Is it the stock 4.17.x (or 4.18-rc)? Please clarify your test environment at first: which kernel, which hardware setup.

Quoted 7 lines

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

Quoted 5 lines

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period.

Sorry, not understood. Why they don't access the audio hardware?

Quoted 2 lines

Therefore, upper software could not get HDMI ELD info, can select a available card/output sink.
I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

As long as it's i915 and HD-audio, the hotplug and ELD info transfer doesn't trigger the runtime PM since it's done via the direct callback. And ELD value is cached in HD-audio side.

The exception is that if the notification is done during the PM operation. But, the connection and ELD query is performed at the end of codec resume, hence it'll be covered there.

So in theory, ELD information should be passed from the GPU to HD-audio no matter whether runtime PM is enabled or not.

BTW, please stop top-posting. It makes the thread readability awfully worse.

thanks,

Takashi

Quoted 159 lines

Thanks
JimQu

________________________________________
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月10日 1:09
收件人: Qu, Jim
抄送: Daniel Vetter; Alex Deucher; [email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 8 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 125 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 5 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

A patch is welcome :)

thanks,

Takashi

Quoted 64 lines

-Daniel

Quoted 61 lines

thanks,

Takashi

Quoted 46 lines

Alex

Quoted 36 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[2 pactl_with_runtimepm <application/octet-stream (base64)>]

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#47 lore raw
Quoted 11 lines · Takashi Iwai
Quoted 5 lines · Jim

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

What does this mean? Is it the stock 4.17.x (or 4.18-rc)? Please clarify your test environment at first: which kernel, which hardware setup.

This is v4.15 which backport Lukas' patches and also one bug fix https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=57cb54e53bdd.
The platform is AMDAPU(with audio) + AMD dGPU , it is a hybird GFX platform. In generic, dGPU will always be suspended.

Quoted 7 lines
Quoted 7 lines

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

Quoted 6 lines
Quoted 5 lines

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period.

Sorry, not understood. Why they don't access the audio hardware?

This is my guess, since I do not get azx_runtime_resume() print info which I added. it maybe access HW during this period, but do not trigger audio resume progress.
<https://elixir.bootlin.com/linux/v4.18-rc3/ident/azx_runtime_resume>

Quoted 5 lines
Quoted 2 lines

Therefore, upper software could not get HDMI ELD info, can select a available card/output sink.
I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

As long as it's i915 and HD-audio, the hotplug and ELD info transfer doesn't trigger the runtime PM since it's done via the direct callback. And ELD value is cached in HD-audio side.

Yeah, I have reviewed these code, it constructs ELD after reading EDID, and write them into HW buffer when set display mode.

Quoted 11 lines

The exception is that if the notification is done during the PM operation. But, the connection and ELD query is performed at the end of codec resume, hence it'll be covered there.

So in theory, ELD information should be passed from the GPU to HD-audio no matter whether runtime PM is enabled or not.

BTW, please stop top-posting. It makes the thread readability awfully worse.

Sorry, I justed used outlook client.

Quoted 155 lines

thanks,

Takashi

Quoted 151 lines

Thanks
JimQu

________________________________________
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月10日 1:09
收件人: Qu, Jim
抄送: Daniel Vetter; Alex Deucher; alsa-devel-K7yf7f+aM1XWsZ/[email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 7 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 45 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <daniel-/[email protected]>
抄送: Alex Deucher <[email protected]>; alsa-devel-K7yf7f+aM1XWsZ/[email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 33 lines · Daniel Vetter
Quoted 32 lines · Takashi Iwai
Quoted 17 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 6 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Quoted 73 lines
Quoted 2 lines

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

A patch is welcome :)

thanks,

Takashi

Quoted 64 lines

-Daniel

Quoted 49 lines

thanks,

Takashi

Quoted 43 lines

Alex

Quoted 41 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <lukas-JFq808J9C/[email protected]> 发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: alsa-devel-K7yf7f+aM1XWsZ/[email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[2 pactl_with_runtimepm <application/octet-stream (base64)>]

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a37f08e7-734e-977c-597f-46d5c3ec34bc-5C7GfCeVMHo@public.gmane.org

#49 lore raw
Quoted 11 lines · jimqu
Quoted 7 lines · Takashi Iwai
Quoted 5 lines · Jim

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

Quoted 8 lines
Quoted 4 lines

What does this mean? Is it the stock 4.17.x (or 4.18-rc)? Please clarify your test environment at first: which kernel, which hardware setup.

This is v4.15 which backport Lukas' patches and also one bug fix
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=57cb54e53bdd.
The platform is AMDAPU(with audio) + AMD dGPU , it is a hybird GFX platform. In generic, dGPU will always be suspended.

Ah, so it's AMD+AMD, not Intel+AMD combo. Now I understand the situation better, thanks.

Quoted 17 lines
Quoted 7 lines
Quoted 7 lines

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

Quoted 6 lines
Quoted 5 lines

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period.

Sorry, not understood. Why they don't access the audio hardware?

This is my guess, since I do not get azx_runtime_resume() print info which I added. it maybe access HW during this period, but do not trigger audio resume progress.
<https://elixir.bootlin.com/linux/v4.18-rc3/ident/azx_runtime_resume>

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Therefore, upper software could not get HDMI ELD info, can select a available card/output sink.
I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

As long as it's i915 and HD-audio, the hotplug and ELD info transfer doesn't trigger the runtime PM since it's done via the direct callback. And ELD value is cached in HD-audio side.

Yeah, I have reviewed these code, it constructs ELD after reading EDID, and write them into HW buffer when set display mode.

If the controller chip supports "wake-enable" feature (HD-audio WAKEEN register), it could be woken up at unsolicited event even during the link power down. But, your report implies that AMD controller doesn't do this, or something missing there. That's the likely cause of the missing hotplug event.

So, if my understanding is right, the situation won't be different even if you have a single AMD GPU. And possibly a side-effect of the latest fix to force link-down for AMD GPU. Need to check it...

Takashi

Quoted 165 lines
Quoted 11 lines

The exception is that if the notification is done during the PM operation. But, the connection and ELD query is performed at the end of codec resume, hence it'll be covered there.

So in theory, ELD information should be passed from the GPU to HD-audio no matter whether runtime PM is enabled or not.

BTW, please stop top-posting. It makes the thread readability awfully worse.

Sorry, I justed used outlook client.

Quoted 153 lines

thanks,

Takashi

Quoted 149 lines

Thanks
JimQu

________________________________________
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月10日 1:09
收件人: Qu, Jim
抄送: Daniel Vetter; Alex Deucher; [email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 7 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 118 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 31 lines · Daniel Vetter
Quoted 30 lines · Takashi Iwai
Quoted 17 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 6 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

Quoted 4 lines
Quoted 2 lines

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

A patch is welcome :)

thanks,

Takashi

Quoted 64 lines

-Daniel

Quoted 49 lines

thanks,

Takashi

Quoted 43 lines

Alex

Quoted 41 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

[2 pactl_with_runtimepm <application/octet-stream (base64)>]

[2 <text/html; utf-8 (8bit)>]

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#50 lore raw
Quoted 45 lines · Takashi Iwai
Quoted 10 lines · jimqu
Quoted 7 lines · Takashi Iwai
Quoted 5 lines · Jim

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

Quoted 8 lines
Quoted 4 lines

What does this mean? Is it the stock 4.17.x (or 4.18-rc)? Please clarify your test environment at first: which kernel, which hardware setup.

This is v4.15 which backport Lukas' patches and also one bug fix
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=57cb54e53bdd.
The platform is AMDAPU(with audio) + AMD dGPU , it is a hybird GFX platform. In generic, dGPU will always be suspended.

Ah, so it's AMD+AMD, not Intel+AMD combo. Now I understand the situation better, thanks.

Quoted 22 lines
Quoted 7 lines
Quoted 7 lines

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

Quoted 6 lines
Quoted 5 lines

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period.

Sorry, not understood. Why they don't access the audio hardware?

This is my guess, since I do not get azx_runtime_resume() print info which I added. it maybe access HW during this period, but do not trigger audio resume progress.
<https://elixir.bootlin.com/linux/v4.18-rc3/ident/azx_runtime_resume>

Quoted 5 lines
Quoted 2 lines

Therefore, upper software could not get HDMI ELD info, can select a available card/output sink.
I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

As long as it's i915 and HD-audio, the hotplug and ELD info transfer doesn't trigger the runtime PM since it's done via the direct callback. And ELD value is cached in HD-audio side.

Quoted 7 lines
Quoted 2 lines

Yeah, I have reviewed these code, it constructs ELD after reading EDID, and write them into HW buffer when set display mode.

If the controller chip supports "wake-enable" feature (HD-audio WAKEEN register), it could be woken up at unsolicited event even during the link power down. But, your report implies that AMD controller doesn't do this, or something missing there. That's the likely cause of the missing hotplug event.

Is there any method to confirm it?

Quoted 3 lines

So, if my understanding is right, the situation won't be different even if you have a single AMD GPU. And possibly a side-effect of the latest fix to force link-down for AMD GPU. Need to check it...

Before Lukas' patches, it is relative with dGPU, because audio power is controlled by vgaswitchreroo and GFX driver, but now it won't. revert the fix of amdgpu suspend issue, audio issue also can be observed.

Quoted 171 lines

Takashi

Quoted 168 lines
Quoted 11 lines

The exception is that if the notification is done during the PM operation. But, the connection and ELD query is performed at the end of codec resume, hence it'll be covered there.

So in theory, ELD information should be passed from the GPU to HD-audio no matter whether runtime PM is enabled or not.

BTW, please stop top-posting. It makes the thread readability awfully worse.

Sorry, I justed used outlook client.

Quoted 154 lines

thanks,

Takashi

Quoted 150 lines

Thanks
JimQu

________________________________________
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月10日 1:09
收件人: Qu, Jim
抄送: Daniel Vetter; Alex Deucher; [email protected]; [email protected]; [email protected]; Deucher, Alexander
主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 7 lines · Jim

Hi Takashi,

Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.

Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.

Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.

OK, and it has all necessary patches including the one Lukas suggested, right?

If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?

Takashi

Quoted 45 lines

Thanks
JimQu

-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2018年7月9日 23:58
收件人: Daniel Vetter <[email protected]>
抄送: Alex Deucher <[email protected]>; [email protected]; [email protected]; Qu, Jim <[email protected]>; [email protected]; Deucher, Alexander <[email protected]> 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 33 lines · Daniel Vetter
Quoted 32 lines · Takashi Iwai
Quoted 17 lines · Alex Deucher
Quoted 16 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 6 lines
Quoted 1 line

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached
while the dGPU is powered down. I suppose the gfx driver could
call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.

IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.

(Though, it will cause another mess wrt the weak module dependency, but it's another story :)

Quoted 72 lines
Quoted 2 lines

Just don't do what snd-hda-intel did and instead implement the component stuff properly :-)

A patch is welcome :)

thanks,

Takashi

Quoted 63 lines

-Daniel

Quoted 48 lines

thanks,

Takashi

Quoted 43 lines

Alex

Quoted 41 lines

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected]
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to
attached displays, user space opens the codec device and this
causes the HDA controller to runtime resume. If the discrete
GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime
resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a
runtime PM ref on HPD, but maybe it's necessary. Or maybe the
code is there but somehow no HPD interrupt is received by the HDA driver?

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines
Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[2 pactl_with_runtimepm <application/octet-stream (base64)>]

[2 <text/html; utf-8 (8bit)>]

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 733011b9-1880-76a8-d00f-076591e93c53-5C7GfCeVMHo@public.gmane.org

#52 lore raw
Quoted 51 lines · jimqu
Quoted 47 lines · Takashi Iwai
Quoted 10 lines · jimqu
Quoted 7 lines · Takashi Iwai
Quoted 5 lines · Jim

Hi Takashi,

I am not expert in audio driver, so I just update some test result, please help triage the issue.

With audio runtime pm:

Quoted 8 lines
Quoted 4 lines

What does this mean? Is it the stock 4.17.x (or 4.18-rc)? Please clarify your test environment at first: which kernel, which hardware setup.

This is v4.15 which backport Lukas' patches and also one bug fix
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=57cb54e53bdd.
The platform is AMDAPU(with audio) + AMD dGPU , it is a hybird GFX platform. In generic, dGPU will always be suspended.

Ah, so it's AMD+AMD, not Intel+AMD combo. Now I understand the situation better, thanks.

Quoted 24 lines
Quoted 7 lines
Quoted 7 lines

1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm.
2. cat /proc/asound/card0/eld* can get nothing.

Without audio runtime pm:
1. pactl can get available audio output/sink
2. can get eld info from eld#0.1

Quoted 6 lines
Quoted 5 lines

IMO, the issue should be:

Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period.

Sorry, not understood. Why they don't access the audio hardware?

This is my guess, since I do not get azx_runtime_resume() print info which I added. it maybe access HW during this period, but do not trigger audio resume progress.
<https://elixir.bootlin.com/linux/v4.18-rc3/ident/azx_runtime_resume>

Quoted 5 lines
Quoted 2 lines

Therefore, upper software could not get HDMI ELD info, can select a available card/output sink.
I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.

As long as it's i915 and HD-audio, the hotplug and ELD info transfer doesn't trigger the runtime PM since it's done via the direct callback. And ELD value is cached in HD-audio side.

Yeah, I have reviewed these code, it constructs ELD after reading EDID, and write them into HW buffer when set display mode.

Quoted 7 lines
Quoted 5 lines

If the controller chip supports "wake-enable" feature (HD-audio WAKEEN register), it could be woken up at unsolicited event even during the link power down. But, your report implies that AMD controller doesn't do this, or something missing there. That's the likely cause of the missing hotplug event.

Is there any method to confirm it?

The driver always sets WAKEEN bit, see azx_runtime_suspend() in hda_intel.c. If it still doesn't behave as expected, it means that the feature isn't supported on that chip :)

Quoted 6 lines
Quoted 3 lines

So, if my understanding is right, the situation won't be different even if you have a single AMD GPU. And possibly a side-effect of the latest fix to force link-down for AMD GPU. Need to check it...

Before Lukas' patches, it is relative with dGPU, because audio power is controlled by vgaswitchreroo and GFX driver, but now it won't.

Right, and this is the correct behavior.

Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#53 lore raw
Quoted 5 lines · Takashi Iwai
Quoted 2 lines

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

At best, give the full dmesg output and the lspci -nv output.

thanks,

Takashi

A message that is not in the archive (sent off-list or not yet received): [email protected]

#55 lore raw
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai
Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.

This is a feedback got from our OEM developer, it is the overview of audio detect process.

Quoted 7 lines

First, the kernel audio driver will be triggered to read ELD, if the

Quoted 6 lines

ELD is valid, it will report a jack event (on or available) to sound core driver; the pulseaudio subscribe all jack events, if it is told that the hdmi jack is plugged in (on), the pulseaudio will set this port to available, then the pa-card or pa-sink has available port, it can be selected (manually, some daemons or policy in /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink.

If the description is correct. I think there are maybe two problems.

1. audio will auto power off after setup device link duo to usage_count=0.
2. duo to audio is power down, it could not get the HDMI jack insert event.

How do you think?

Quoted 3 lines

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

[    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client [    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3) 06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1) 06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]

Thanks
JimQu

Quoted 6 lines

At best, give the full dmesg output and the lspci -nv output.

thanks,

Takashi

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1936c752-f858-2caf-35e7-98bea431fb7c-5C7GfCeVMHo@public.gmane.org

#57 lore raw
Quoted 50 lines · jimqu
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai
Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about
vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.

This is a feedback got from our OEM developer, it is the overview of audio detect process.

Quoted 7 lines

First, the kernel audio driver will be triggered to read ELD, if the

Quoted 6 lines

ELD is valid, it will report a jack event (on or available) to sound core driver; the pulseaudio subscribe all jack events, if it is told that the hdmi jack is plugged in (on), the pulseaudio will set this port to available, then the pa-card or pa-sink has available port, it can be selected (manually, some daemons or policy in /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink.

If the description is correct. I think there are maybe two problems.

1. audio will auto power off after setup device link duo to usage_count=0.
2. duo to audio is power down, it could not get the HDMI jack insert event.

How do you think?

Quoted 3 lines

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

[    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client
[    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)

Quoted 6 lines

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3)
06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1)
06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]

OK this sheds a brighter light, finally.

If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU.

Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong.

Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI.

Takashi

---

sound/pci/hda/hda_intel.c +10 -0
@@ -1418,8 +1418,18 @@ static int azx_dev_free(struct snd_device *device)
  */
 static struct pci_dev *get_bound_vga(struct pci_dev *pci)
 {
+	static const struct pci_device_id ids[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
+		  .class = PCI_BASE_CLASS_DISPLAY << 16,
+		  .class_mask = 0xff << 16 },
+		{}
+	};
 	struct pci_dev *p;
 
+	/* check whether Intel graphics is present as primary GPU */
+	if (!pci_dev_present(ids))
+		return NULL;
+
 	/* check only discrete GPU */
 	switch (pci->vendor) {
 	case PCI_VENDOR_ID_ATI:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#59 lore raw
Quoted 60 lines · Takashi Iwai
Quoted 46 lines · jimqu
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai
Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about
vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.

This is a feedback got from our OEM developer, it is the overview of audio detect process.

Quoted 7 lines

First, the kernel audio driver will be triggered to read ELD, if the

Quoted 6 lines

ELD is valid, it will report a jack event (on or available) to sound core driver; the pulseaudio subscribe all jack events, if it is told that the hdmi jack is plugged in (on), the pulseaudio will set this port to available, then the pa-card or pa-sink has available port, it can be selected (manually, some daemons or policy in /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink.

If the description is correct. I think there are maybe two problems.

1. audio will auto power off after setup device link duo to usage_count=0.
2. duo to audio is power down, it could not get the HDMI jack insert event.

How do you think?

Quoted 3 lines

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

[    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client
[    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)

Quoted 6 lines

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3)
06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1)
06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]

OK this sheds a brighter light, finally.

If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU.

Quoted 7 lines

Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong.

Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI.

This is no issue about this topic, in amdgpu driver, both iGPU/dGPU will register as VGA_SWITCHEROO_UNKNOWN_ID, and the client id will be re-initialized in vgaswitchreoo_enable() via ATPX call. Then, iGPU will set as VGA_SWITCHEROO_IGD, and dGPU will set as VGA_SWITCHEROO_DIS.

I think current focus should be how to detect HDMI audio device under audio suspend state.

Thanks
JimQu

Quoted 15 lines

Takashi

---

sound/pci/hda/hda_intel.c +5 -0
@@ -1418,8 +1418,18 @@ static int azx_dev_free(struct snd_device *device)
   */
  static struct pci_dev *get_bound_vga(struct pci_dev *pci)
  {
+	static const struct pci_device_id ids[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
+		  .class = PCI_BASE_CLASS_DISPLAY << 16,
+		  .class_mask = 0xff << 16 },
+		{}

sound/pci/hda/hda_intel.c static int azx_dev_free(struct snd_device *device) · line 1435

Quoted 10 lines
sound/pci/hda/hda_intel.c +5 -0
+	};
  	struct pci_dev *p;
 
+	/* check whether Intel graphics is present as primary GPU */
+	if (!pci_dev_present(ids))
+		return NULL;
+
  	/* check only discrete GPU */
  	switch (pci->vendor) {
  	case PCI_VENDOR_ID_ATI:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#60 lore raw
Quoted 72 lines · jimqu
Quoted 60 lines · Takashi Iwai
Quoted 46 lines · jimqu
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai
Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about
vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.

This is a feedback got from our OEM developer, it is the overview of audio detect process.

Quoted 7 lines

First, the kernel audio driver will be triggered to read ELD, if the

Quoted 6 lines

ELD is valid, it will report a jack event (on or available) to sound core driver; the pulseaudio subscribe all jack events, if it is told that the hdmi jack is plugged in (on), the pulseaudio will set this port to available, then the pa-card or pa-sink has available port, it can be selected (manually, some daemons or policy in /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink.

If the description is correct. I think there are maybe two problems.

1. audio will auto power off after setup device link duo to usage_count=0.
2. duo to audio is power down, it could not get the HDMI jack insert event.

How do you think?

Quoted 3 lines

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

[    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client
[    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)

Quoted 6 lines

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3)
06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1)
06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]

OK this sheds a brighter light, finally.

If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU.

Quoted 7 lines

Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong.

Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI.

Quoted 5 lines

This is no issue about this topic, in amdgpu driver, both iGPU/dGPU will register as VGA_SWITCHEROO_UNKNOWN_ID, and the client id will be re-initialized in vgaswitchreoo_enable() via ATPX call. Then, iGPU will set as VGA_SWITCHEROO_IGD, and dGPU will set as VGA_SWITCHEROO_DIS.

Please check the patch. It's not about AMDGPU driver but the vga switcheroo detection in HD-audio driver. Not the GPU side but the audio side.

The issues are two folds:
- We register each AMD controller associated with a GPU always as a discrete GPU vga_switcheroo audio.
- And when it's registered as a vga_switcheroo client, we forcibly enable runtime PM of the controller, since discrete GPU needs the runtime suspend.

So a workaround in your case is just not to register as a vga switcheroo audio client. Then the runtime PM isn't enabled in the AMD HDMI audio controller, and the HDMI detection remains active.

Takashi

Quoted 19 lines

Thanks
JimQu

Quoted 16 lines

Takashi

---

sound/pci/hda/hda_intel.c +6 -0
@@ -1418,8 +1418,18 @@ static int azx_dev_free(struct snd_device *device)
   */
  static struct pci_dev *get_bound_vga(struct pci_dev *pci)
  {
+	static const struct pci_device_id ids[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
+		  .class = PCI_BASE_CLASS_DISPLAY << 16,
+		  .class_mask = 0xff << 16 },
+		{}
+	};
Quoted 9 lines

sound/pci/hda/hda_intel.c static int azx_dev_free(struct snd_device *device) · line 1435

Quoted 8 lines
sound/pci/hda/hda_intel.c +3 -0
  	struct pci_dev *p;
  +	/* check whether Intel graphics is present as primary GPU */
+	if (!pci_dev_present(ids))
+		return NULL;
+
  	/* check only discrete GPU */
  	switch (pci->vendor) {
  	case PCI_VENDOR_ID_ATI:

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#62 lore raw
Quoted 87 lines · Takashi Iwai
Quoted 66 lines · jimqu
Quoted 63 lines · Takashi Iwai
Quoted 45 lines · jimqu
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai
Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about
vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.

This is a feedback got from our OEM developer, it is the overview of audio detect process.

Quoted 7 lines

First, the kernel audio driver will be triggered to read ELD, if the

Quoted 6 lines

ELD is valid, it will report a jack event (on or available) to sound core driver; the pulseaudio subscribe all jack events, if it is told that the hdmi jack is plugged in (on), the pulseaudio will set this port to available, then the pa-card or pa-sink has available port, it can be selected (manually, some daemons or policy in /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink.

If the description is correct. I think there are maybe two problems.

1. audio will auto power off after setup device link duo to usage_count=0.
2. duo to audio is power down, it could not get the HDMI jack insert event.

How do you think?

Quoted 3 lines

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

[    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client
[    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)

Quoted 6 lines

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3)
06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1)
06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]

OK this sheds a brighter light, finally.

If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU.

Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong.

Quoted 8 lines
Quoted 3 lines

Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI.

This is no issue about this topic, in amdgpu driver, both iGPU/dGPU will register as VGA_SWITCHEROO_UNKNOWN_ID, and the client id will be re-initialized in vgaswitchreoo_enable() via ATPX call. Then, iGPU will set as VGA_SWITCHEROO_IGD, and dGPU will set as VGA_SWITCHEROO_DIS.

Please check the patch. It's not about AMDGPU driver but the vga switcheroo detection in HD-audio driver. Not the GPU side but the audio side.

The issues are two folds:
- We register each AMD controller associated with a GPU always as a discrete GPU vga_switcheroo audio.
- And when it's registered as a vga_switcheroo client, we forcibly enable runtime PM of the controller, since discrete GPU needs the runtime suspend.

Quoted 6 lines

So a workaround in your case is just not to register as a vga switcheroo audio client. Then the runtime PM isn't enabled in the AMD HDMI audio controller, and the HDMI detection remains active.

Takashi

OK, I got your point. Let me have a try.

BTW, what about the patch in this thread, I think it is also need for current code. although audio power is not controlled by vgaswitchreoo, we also can encounter the issue(audio which is bound to iGPU will suspend with dGPU) if user debugfs to control the client power.

Thanks
JimQu

Quoted 17 lines
Quoted 17 lines

Thanks
JimQu

Quoted 15 lines

Takashi

---

sound/pci/hda/hda_intel.c +6 -0
@@ -1418,8 +1418,18 @@ static int azx_dev_free(struct snd_device *device)
    */
   static struct pci_dev *get_bound_vga(struct pci_dev *pci)
   {
+	static const struct pci_device_id ids[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
+		  .class = PCI_BASE_CLASS_DISPLAY << 16,
+		  .class_mask = 0xff << 16 },
+		{}
+	};
Quoted 8 lines
Quoted 8 lines

sound/pci/hda/hda_intel.c static int azx_dev_free(struct snd_device *device) · line 1435

Quoted 8 lines
sound/pci/hda/hda_intel.c +3 -0
   	struct pci_dev *p;
   +	/* check whether Intel graphics is present as primary GPU */
+	if (!pci_dev_present(ids))
+		return NULL;
+
   	/* check only discrete GPU */
   	switch (pci->vendor) {
   	case PCI_VENDOR_ID_ATI:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#63 lore raw
Quoted 96 lines · jimqu
Quoted 92 lines · Takashi Iwai
Quoted 66 lines · jimqu
Quoted 63 lines · Takashi Iwai
Quoted 45 lines · jimqu
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai
Quoted 1 line

revert the fix of amdgpu suspend issue, audio issue also can be observed.

Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.

... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.

Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about
vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.

This is a feedback got from our OEM developer, it is the overview of audio detect process.

Quoted 7 lines

First, the kernel audio driver will be triggered to read ELD, if the

Quoted 6 lines

ELD is valid, it will report a jack event (on or available) to sound core driver; the pulseaudio subscribe all jack events, if it is told that the hdmi jack is plugged in (on), the pulseaudio will set this port to available, then the pa-card or pa-sink has available port, it can be selected (manually, some daemons or policy in /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink.

If the description is correct. I think there are maybe two problems.

1. audio will auto power off after setup device link duo to usage_count=0.
2. duo to audio is power down, it could not get the HDMI jack insert event.

How do you think?

Quoted 3 lines

Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".

[    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client
[    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)

Quoted 6 lines

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3)
06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1)
06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]

OK this sheds a brighter light, finally.

If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU.

Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong.

Quoted 8 lines
Quoted 3 lines

Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI.

This is no issue about this topic, in amdgpu driver, both iGPU/dGPU will register as VGA_SWITCHEROO_UNKNOWN_ID, and the client id will be re-initialized in vgaswitchreoo_enable() via ATPX call. Then, iGPU will set as VGA_SWITCHEROO_IGD, and dGPU will set as VGA_SWITCHEROO_DIS.

Please check the patch. It's not about AMDGPU driver but the vga switcheroo detection in HD-audio driver. Not the GPU side but the audio side.

The issues are two folds:
- We register each AMD controller associated with a GPU always as a discrete GPU vga_switcheroo audio.
- And when it's registered as a vga_switcheroo client, we forcibly enable runtime PM of the controller, since discrete GPU needs the runtime suspend.

So a workaround in your case is just not to register as a vga switcheroo audio client. Then the runtime PM isn't enabled in the AMD HDMI audio controller, and the HDMI detection remains active.

Quoted 8 lines
Quoted 1 line

Takashi

OK, I got your point. Let me have a try.

BTW, what about the patch in this thread, I think it is also need for current code. although audio power is not controlled by vgaswitchreoo, we also can encounter the issue(audio which is bound to iGPU will suspend with dGPU) if user debugfs to control the client power.

That'd do a trick in most cases, too, but I guess one scenario is
overseen: when HD-audio driver is probed / registered before the graphics driver, it may get a false client id, too.

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#65 lore raw
Quoted 4 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

The branch should be cleanly pullable onto the latest 4.18-rc.

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

thanks,

Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#66 lore raw
Quoted 24 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

Quoted 6 lines

The branch should be cleanly pullable onto the latest 4.18-rc.

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

That is really wonderful work. I will check it on our AMD platform. BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.

Thanks
JimQu

Quoted 4 lines

thanks,

Takashi

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#67 lore raw
Quoted 30 lines · jimqu
Quoted 26 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

The branch should be cleanly pullable onto the latest 4.18-rc.

Quoted 7 lines
Quoted 4 lines

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

That is really wonderful work. I will check it on our AMD platform.

Thanks, it'll be great if you can check whether the current code works or not. I'd love to push the stuff for 4.19. Hopefully I'll start submitting the preparation patches in the next week.

Basically this also opens the door of the similar capability for nouveau, and I guess it's also trivial enough.

Quoted 2 lines

BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.

Could you give a more hint? I'll try adapt the code if such a change is already in upstream tree.

Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#69 lore raw
Quoted 44 lines · Takashi Iwai
Quoted 30 lines · jimqu
Quoted 26 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

The branch should be cleanly pullable onto the latest 4.18-rc.

Quoted 7 lines
Quoted 4 lines

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

That is really wonderful work. I will check it on our AMD platform.

Thanks, it'll be great if you can check whether the current code works or not. I'd love to push the stuff for 4.19. Hopefully I'll start submitting the preparation patches in the next week.

Quoted 8 lines

Basically this also opens the door of the similar capability for nouveau, and I guess it's also trivial enough.

Quoted 2 lines

BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.

Could you give a more hint? I'll try adapt the code if such a change is already in upstream tree.

The new code is in drivers/gpu/drm/amd/display.

Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#70 lore raw
Quoted 48 lines · Alex Deucher
Quoted 47 lines · Takashi Iwai
Quoted 30 lines · jimqu
Quoted 26 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

The branch should be cleanly pullable onto the latest 4.18-rc.

Quoted 7 lines
Quoted 4 lines

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

That is really wonderful work. I will check it on our AMD platform.

Thanks, it'll be great if you can check whether the current code works or not. I'd love to push the stuff for 4.19. Hopefully I'll start submitting the preparation patches in the next week.

Basically this also opens the door of the similar capability for nouveau, and I guess it's also trivial enough.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.

Could you give a more hint? I'll try adapt the code if such a change is already in upstream tree.

The new code is in drivers/gpu/drm/amd/display.

In particular, I imagine all you need should be in display/amdgpu_dm, although there's chance you might have to touch display/dc/dce/dce_audio.c if you have to do anything with the unsolicited event.

I see you're using the GPL license, rather than MIT in amdgpu_audio.c. Since the code in display/dc is shared with other OSes and internal test frameworks it has to be MIT. Not entirely sure about display/amdgpu_dm, but if GPL is fine in amd/amdgpu it's probably fine there as well.

Harry

Quoted 6 lines

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 84b8615e-9de1-a279-e103-55367e2f0f85-5C7GfCeVMHo@public.gmane.org

#72 lore raw
Quoted 55 lines · Harry Wentland
Quoted 51 lines · Alex Deucher
Quoted 50 lines · Takashi Iwai
Quoted 30 lines · jimqu
Quoted 26 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

The branch should be cleanly pullable onto the latest 4.18-rc.

Quoted 7 lines
Quoted 4 lines

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

That is really wonderful work. I will check it on our AMD platform.

Thanks, it'll be great if you can check whether the current code works or not. I'd love to push the stuff for 4.19. Hopefully I'll start submitting the preparation patches in the next week.

Basically this also opens the door of the similar capability for nouveau, and I guess it's also trivial enough.

Quoted 2 lines

BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Could you give a more hint? I'll try adapt the code if such a change is already in upstream tree.

The new code is in drivers/gpu/drm/amd/display.

In particular, I imagine all you need should be in display/amdgpu_dm, although there's chance you might have to touch display/dc/dce/dce_audio.c if you have to do anything with the unsolicited event.

Thanks, I'm currently struggling to read down the whole complex DC code tree, and it's a very helpful hint.

How is the audio enable/disable call associated with the pipe index? IOW, if I add a hook to call a notifier callback to pass the pipe index that is enabled/disabled, how can it be deduced?

Similarly, when DC driver gets the query about the ELD on the given pipe, where can I convert it to which object?

DC is quite another beast, so I still haven't figured out the structures yet...

Quoted 1 line

I see you're using the GPL license, rather than MIT in amdgpu_audio.c. Since the code in display/dc is shared with other OSes and internal test frameworks it has to be MIT. Not entirely sure about display/amdgpu_dm, but if GPL is fine in amd/amdgpu it's probably fine there as well.

Oh I just didn't know that amdgpu code was with MIT. Indeed the driver module is provided via "GPL and additional rights".

I'm fine to change the license to follow other code bits there. What exactly SPDX tag should be put there?

thanks,

Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#73 lore raw
Quoted 79 lines · Takashi Iwai
Quoted 55 lines · Harry Wentland
Quoted 51 lines · Alex Deucher
Quoted 50 lines · Takashi Iwai
Quoted 30 lines · jimqu
Quoted 26 lines · Takashi Iwai
Quoted 3 lines · Takashi Iwai

And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.

Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.

The patches are found in topic/hda-acomp branch of my sound.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The following commits are relevant:
drm/i915: Split audio component to a generic type
ALSA: hda/i915: Allow delayed i915 audio component binding
ALSA: hda/i915: Associate audio component with devres
ALSA: hda: Make audio component support more generic
ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI
ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support

The branch should be cleanly pullable onto the latest 4.18-rc.

Quoted 7 lines
Quoted 4 lines

I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.

Please give it a try.

That is really wonderful work. I will check it on our AMD platform.

Thanks, it'll be great if you can check whether the current code works or not. I'd love to push the stuff for 4.19. Hopefully I'll start submitting the preparation patches in the next week.

Basically this also opens the door of the similar capability for nouveau, and I guess it's also trivial enough.

Quoted 2 lines

BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Could you give a more hint? I'll try adapt the code if such a change is already in upstream tree.

The new code is in drivers/gpu/drm/amd/display.

In particular, I imagine all you need should be in display/amdgpu_dm, although there's chance you might have to touch display/dc/dce/dce_audio.c if you have to do anything with the unsolicited event.

Thanks, I'm currently struggling to read down the whole complex DC code tree, and it's a very helpful hint.

How is the audio enable/disable call associated with the pipe index? IOW, if I add a hook to call a notifier callback to pass the pipe index that is enabled/disabled, how can it be deduced?

Similarly, when DC driver gets the query about the ELD on the given pipe, where can I convert it to which object?

DC is quite another beast, so I still haven't figured out the structures yet...

Quoted 7 lines
Quoted 1 line

I see you're using the GPL license, rather than MIT in amdgpu_audio.c. Since the code in display/dc is shared with other OSes and internal test frameworks it has to be MIT. Not entirely sure about display/amdgpu_dm, but if GPL is fine in amd/amdgpu it's probably fine there as well.

Oh I just didn't know that amdgpu code was with MIT. Indeed the driver module is provided via "GPL and additional rights".

I'm fine to change the license to follow other code bits there. What exactly SPDX tag should be put there?

Preferably:
SPDX-License-Identifier: MIT
or I suppose dual licensing (MIT or GPL 2.0) is ok too.

Alex

Quoted 5 lines

thanks,

Takashi

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#74 lore raw
In reply to a message not in the archive
Quoted 9 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

Sounds like a bug in the HDA driver. The HDA driver should cache what it needs or power it back up when there is an ioctl/etc. that requires something that can't be cached.

Alex

Quoted 41 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_PS_ZO2Y35HHnp3DcvN9wopQGavpDtMNCuuz4A1mDnD7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#76 lore raw
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Jim

Hi Lukas,

Thanks to your explanation, and see comments in line.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

Quoted 6 lines
Quoted 1 line

Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.

Sounds like a bug in the HDA driver. The HDA driver should cache what it needs or power it back up when there is an ioctl/etc. that requires something that can't be cached.

Actually I'm not sure whether the analysis above is correct. If PA shows it's unavailable, it implies rather that the HDMI is seen as unconnected. PA doesn't matter about the runtime PM state. If a runtime PM fails, it'd result in a "failure", not "unavailable".

Takashi

Quoted 51 lines

Alex

Quoted 41 lines

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.

Thanks
JimQu

________________________________________
发件人: Lukas Wunner <[email protected]>
发送时间: 2018年7月9日 17:27
收件人: Qu, Jim
抄送: [email protected]; [email protected]; Deucher, Alexander; [email protected] 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 6 lines · Jim

Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.

1. Did you encounter similar issue before?
2. audio will auto suspend as default at beginning of boot, is it expect behaviour?

Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.

Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?

You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?

Quoted 7 lines

Thanks,

Lukas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1530166933-21655-1-git-send-email-Jim.Qu-5C7GfCeVMHo@public.gmane.org

Reviewed-by Junwei Zhang
#78 lore raw
Quoted 9 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

Quoted 7 lines

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

Quoted 27 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
  drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
  include/linux/vga_switcheroo.h   |  4 ++--
  sound/pci/hda/hda_intel.c        | 15 +++++++++------
  3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
   * vga_switcheroo_register_audio_client - register audio client
   * @pdev: client pci device
   * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
   *
   * Register audio client (audio device on a GPU). The client is assumed
   * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
   */
  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
  			const struct vga_switcheroo_client_ops *ops,
-			enum vga_switcheroo_client_id id)
+			struct pci_dev *bound_vga)
  {
+	enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+	if (bound_vga) {
+		if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 57 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+			id = vgasr_priv.handler->get_client_id(bound_vga);
+	}
+
  	return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
  }
  EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +2 -2
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev *dev,
  				   bool driver_power_control);
  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
  					 const struct vga_switcheroo_client_ops *ops,
-					 enum vga_switcheroo_client_id id);
+					 struct pci_dev *bound_vga);
 
  void vga_switcheroo_client_fb_set(struct pci_dev *dev,
  				  struct fb_info *info);
@@ -180,7 +180,7 @@ static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_ha
  		enum vga_switcheroo_handler_flags_t handler_flags) { return 0; }
  static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
  	const struct vga_switcheroo_client_ops *ops,
-	enum vga_switcheroo_client_id id) { return 0; }
+	struct pci_dev *bound_vga) { return 0; }
  static inline void vga_switcheroo_unregister_handler(void) {}
  static inline enum vga_switcheroo_handler_flags_t vga_switcheroo_handler_flags(void) { return 0; }
  static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return -ENODEV; }
sound/pci/hda/hda_intel.c +7 -5
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = {
  static int register_vga_switcheroo(struct azx *chip)
  {
  	struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
+	struct pci_dev *p;
  	int err;
 
  	if (!hda->use_vga_switcheroo)
  		return 0;
-	/* FIXME: currently only handling DIS controller
-	 * is there any machine with two switchable HDMI audio controllers?
-	 */
-	err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-						   VGA_SWITCHEROO_DIS);
+
+	p = get_bound_vga(chip->pci);
+	err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p);
+
+	if (p)
+		pci_dev_put(p);
  	if (err < 0)
  		return err;
  	hda->vga_switcheroo_registered = 1;

sound/pci/hda/hda_intel.c static struct pci_dev *get_bound_vga(struct pci_dev *pci) · line 1438

Quoted 9 lines
sound/pci/hda/hda_intel.c +2 -1
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
  			p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
  							pci->bus->number, 0);
  			if (p) {
-				if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+				if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+				(p->class >> 8) == PCI_CLASS_DISPLAY_OTHER)
  					return p;
  				pci_dev_put(p);
  			}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#80 lore raw
Quoted 15 lines · Jerry (Junwei)
Quoted 14 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Quoted 7 lines
Quoted 3 lines

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 135 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
  drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
  include/linux/vga_switcheroo.h   |  4 ++--
  sound/pci/hda/hda_intel.c        | 15 +++++++++------
  3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
   * vga_switcheroo_register_audio_client - register audio client
   * @pdev: client pci device
   * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
   *
   * Register audio client (audio device on a GPU). The client is assumed
   * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
   */
  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                        const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
  {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
        return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
  }
  EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                   bool driver_power_control);
  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                         const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,

                                  struct fb_info *info);
include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
  static inline void vga_switcheroo_unregister_handler(void) {}
  static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
  static int register_vga_switcheroo(struct azx *chip)
  {
        struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
        int err;
 
        if (!hda->use_vga_switcheroo)
                return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
        if (err < 0)
                return err;
        hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                        p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                        pci->bus->number,
 0);
                        if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 8 lines
Quoted 4 lines
                                        return p;
                                pci_dev_put(p);
                        }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_PTsyc9HFsGrvTsjnPOJKF3B_nzgVsp_wZWguTb6e3F0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#82 lore raw

If the GFX is headless, the audio codec should be disabled on PCIE bus. the the HDA driver will never probe the audio. right?

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月29日 12:01
收件人: Zhang, Jerry
抄送: Qu, Jim; amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 15 lines · Jerry (Junwei)
Quoted 14 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Quoted 7 lines
Quoted 3 lines

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 135 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
  drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
  include/linux/vga_switcheroo.h   |  4 ++--
  sound/pci/hda/hda_intel.c        | 15 +++++++++------
  3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
   * vga_switcheroo_register_audio_client - register audio client
   * @pdev: client pci device
   * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
   *
   * Register audio client (audio device on a GPU). The client is assumed
   * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
   */
  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                        const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
  {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
        return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
  }
  EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                   bool driver_power_control);
  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                         const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,

                                  struct fb_info *info);
include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
  static inline void vga_switcheroo_unregister_handler(void) {}
  static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
  static int register_vga_switcheroo(struct azx *chip)
  {
        struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
        int err;
 
        if (!hda->use_vga_switcheroo)
                return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
        if (err < 0)
                return err;
        hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                        p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                        pci->bus->number,
 0);
                        if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 8 lines
Quoted 4 lines
                                        return p;
                                pci_dev_put(p);
                        }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB0873339C6A535584C2C787B3994E0-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#84 lore raw
Quoted 1 line · Jim

If the GFX is headless, the audio codec should be disabled on PCIE bus. the the HDA driver will never probe the audio. right?

After checking the HDA a little, looks HDA could also handle many other audio devices. In this case, HDA may probe other audio device, e.g. from Braswell.

Just a guess.

Jerry

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月29日 12:01
收件人: Zhang, Jerry
抄送: Qu, Jim; amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 20 lines · Jerry (Junwei)
Quoted 17 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Quoted 152 lines
Quoted 2 lines

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 143 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
   drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
   include/linux/vga_switcheroo.h   |  4 ++--
   sound/pci/hda/hda_intel.c        | 15 +++++++++------
   3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
    * vga_switcheroo_register_audio_client - register audio client
    * @pdev: client pci device
    * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
    *
    * Register audio client (audio device on a GPU). The client is assumed
    * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
    */
   int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                         const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
   {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
         return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
   }
   EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                    bool driver_power_control);
   int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                          const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,

                                   struct fb_info *info);
include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                 enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
   static inline void vga_switcheroo_unregister_handler(void) {}
   static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
   static int register_vga_switcheroo(struct azx *chip)
   {
         struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
         int err;
 
         if (!hda->use_vga_switcheroo)
                 return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
         if (err < 0)
                 return err;
         hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                         p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                         pci->bus->number,
 0);
                         if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 4 lines
                                         return p;
                                 pci_dev_put(p);
                         }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#86 lore raw

I mean if the VGA_OTHER is only for headless, and there is no audio on the headless GFX. therefore, the PCI_CLASS_DISPLAY_OTHER is unnecessary in get_bound_gpu() on this case.

The Key pointer is the problem: does it exist the GFX device is defined as PCI_CLASS_DISPLAY_OTHER with audio codec.

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Zhang, Jerry (Junwei) <[email protected]> 发送时间: 2018年6月29日 15:40:14
收件人: Qu, Jim; Alex Deucher
抄送: Deucher, Alexander; amd-gfx list
主题: Re: 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 1 line · Jim

If the GFX is headless, the audio codec should be disabled on PCIE bus. the the HDA driver will never probe the audio. right?

After checking the HDA a little, looks HDA could also handle many other audio devices. In this case, HDA may probe other audio device, e.g. from Braswell.

Just a guess.

Jerry

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月29日 12:01
收件人: Zhang, Jerry
抄送: Qu, Jim; amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 20 lines · Jerry (Junwei)
Quoted 17 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Quoted 152 lines
Quoted 2 lines

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 143 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
   drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
   include/linux/vga_switcheroo.h   |  4 ++--
   sound/pci/hda/hda_intel.c        | 15 +++++++++------
   3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
    * vga_switcheroo_register_audio_client - register audio client
    * @pdev: client pci device
    * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
    *
    * Register audio client (audio device on a GPU). The client is assumed
    * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
    */
   int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                         const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
   {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
         return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
   }
   EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                    bool driver_power_control);
   int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                          const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,

                                   struct fb_info *info);
include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                 enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
   static inline void vga_switcheroo_unregister_handler(void) {}
   static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
   static int register_vga_switcheroo(struct azx *chip)
   {
         struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
         int err;
 
         if (!hda->use_vga_switcheroo)
                 return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
         if (err < 0)
                 return err;
         hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                         p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                         pci->bus->number,
 0);
                         if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 4 lines
                                         return p;
                                 pci_dev_put(p);
                         }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB08739DC1ADB8BBF9AE6E8B0D994E0-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#88 lore raw
Quoted 3 lines · Jim

I mean if the VGA_OTHER is only for headless, and there is no audio on the headless GFX. therefore, the PCI_CLASS_DISPLAY_OTHER is unnecessary in get_bound_gpu() on this case.

The Key pointer is the problem: does it exist the GFX device is defined as PCI_CLASS_DISPLAY_OTHER with audio codec.

In my view, headless is likely to have no audio,
while dGPU with display could be registered as OTHER, in this case, audio is controlled by HDA driver.

To my understanding, this issue is about the dGPU has audio codec registered as OTHER, right?

Jerry

Quoted 206 lines

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Zhang, Jerry (Junwei) <[email protected]> 发送时间: 2018年6月29日 15:40:14
收件人: Qu, Jim; Alex Deucher
抄送: Deucher, Alexander; amd-gfx list
主题: Re: 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 1 line · Jim

If the GFX is headless, the audio codec should be disabled on PCIE bus. the the HDA driver will never probe the audio. right?

After checking the HDA a little, looks HDA could also handle many other audio devices. In this case, HDA may probe other audio device, e.g. from Braswell.

Just a guess.

Jerry

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月29日 12:01
收件人: Zhang, Jerry
抄送: Qu, Jim; amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 20 lines · Jerry (Junwei)
Quoted 17 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Quoted 152 lines
Quoted 2 lines

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 143 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
    drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
    include/linux/vga_switcheroo.h   |  4 ++--
    sound/pci/hda/hda_intel.c        | 15 +++++++++------
    3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
     * vga_switcheroo_register_audio_client - register audio client
     * @pdev: client pci device
     * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
     *
     * Register audio client (audio device on a GPU). The client is assumed
     * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
     */
    int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                          const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
    {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
          return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
    }
    EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                     bool driver_power_control);
    int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                           const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,
struct fb_info *info);

include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                  enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
    static inline void vga_switcheroo_unregister_handler(void) {}
    static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
    static int register_vga_switcheroo(struct azx *chip)
    {
          struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
          int err;
 
          if (!hda->use_vga_switcheroo)
                  return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
          if (err < 0)
                  return err;
          hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                          p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                          pci->bus->number,
 0);
                          if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 4 lines
                                          return p;
                                  pci_dev_put(p);
                          }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#90 lore raw

Hi Jerry,

No, the issue is dGPU has no audio. and the HDA driver register iGPU audio as VGA_SWITCHEROO_DIS. So when dGPU suspend by runtime pm, iGPU audio will be powerd off, since its has the same client id with dGPU.

Thanks
JimQu

________________________________________
发件人: Zhang, Jerry
发送时间: 2018年6月29日 16:54
收件人: Qu, Jim; Alex Deucher
抄送: Deucher, Alexander; amd-gfx list
主题: Re: 答复: 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 3 lines · Jim

I mean if the VGA_OTHER is only for headless, and there is no audio on the headless GFX. therefore, the PCI_CLASS_DISPLAY_OTHER is unnecessary in get_bound_gpu() on this case.

The Key pointer is the problem: does it exist the GFX device is defined as PCI_CLASS_DISPLAY_OTHER with audio codec.

In my view, headless is likely to have no audio,
while dGPU with display could be registered as OTHER, in this case, audio is controlled by HDA driver.

To my understanding, this issue is about the dGPU has audio codec registered as OTHER, right?

Jerry

Quoted 206 lines

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Zhang, Jerry (Junwei) <[email protected]> 发送时间: 2018年6月29日 15:40:14
收件人: Qu, Jim; Alex Deucher
抄送: Deucher, Alexander; amd-gfx list
主题: Re: 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 1 line · Jim

If the GFX is headless, the audio codec should be disabled on PCIE bus. the the HDA driver will never probe the audio. right?

After checking the HDA a little, looks HDA could also handle many other audio devices. In this case, HDA may probe other audio device, e.g. from Braswell.

Just a guess.

Jerry

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月29日 12:01
收件人: Zhang, Jerry
抄送: Qu, Jim; amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 20 lines · Jerry (Junwei)
Quoted 17 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Quoted 152 lines
Quoted 2 lines

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 143 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
    drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
    include/linux/vga_switcheroo.h   |  4 ++--
    sound/pci/hda/hda_intel.c        | 15 +++++++++------
    3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
     * vga_switcheroo_register_audio_client - register audio client
     * @pdev: client pci device
     * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
     *
     * Register audio client (audio device on a GPU). The client is assumed
     * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
     */
    int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                          const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
    {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
          return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
    }
    EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                     bool driver_power_control);
    int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                           const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,
struct fb_info *info);

include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                  enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
    static inline void vga_switcheroo_unregister_handler(void) {}
    static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
    static int register_vga_switcheroo(struct azx *chip)
    {
          struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
          int err;
 
          if (!hda->use_vga_switcheroo)
                  return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
          if (err < 0)
                  return err;
          hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                          p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                          pci->bus->number,
 0);
                          if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 4 lines
                                          return p;
                                  pci_dev_put(p);
                          }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): DM3PR12MB0873E459AC9D7F6CECDDBAB3994E0-4hRkV8tDpBiYEITDcfEJ8AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#92 lore raw
Quoted 3 lines · Jim

Hi Jerry,

No, the issue is dGPU has no audio. and the HDA driver register iGPU audio as VGA_SWITCHEROO_DIS. So when dGPU suspend by runtime pm, iGPU audio will be powerd off, since its has the same client id with dGPU.

Thanks to clarify the situation.
anyway, HDA should separate audio from iGPU and dGPU.

Quoted 1 line
Quoted 1 line

The Key pointer is the problem: does it exist the GFX device is defined as PCI_CLASS_DISPLAY_OTHER with audio codec.

IIRC, for HG case, the dGPU will be registered as OTHER. if it has audio codec, suppose yes.

Jerry

Quoted 14 lines

Thanks
JimQu

________________________________________
发件人: Zhang, Jerry
发送时间: 2018年6月29日 16:54
收件人: Qu, Jim; Alex Deucher
抄送: Deucher, Alexander; amd-gfx list
主题: Re: 答复: 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 2 lines · Jim

I mean if the VGA_OTHER is only for headless, and there is no audio on the headless GFX. therefore, the PCI_CLASS_DISPLAY_OTHER is unnecessary in get_bound_gpu() on this case.

Quoted 220 lines
Quoted 1 line

The Key pointer is the problem: does it exist the GFX device is defined as PCI_CLASS_DISPLAY_OTHER with audio codec.

In my view, headless is likely to have no audio,
while dGPU with display could be registered as OTHER, in this case, audio is controlled by HDA driver.

To my understanding, this issue is about the dGPU has audio codec registered as OTHER, right?

Jerry

Quoted 211 lines

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Zhang, Jerry (Junwei) <[email protected]> 发送时间: 2018年6月29日 15:40:14
收件人: Qu, Jim; Alex Deucher
抄送: Deucher, Alexander; amd-gfx list
主题: Re: 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 1 line · Jim

If the GFX is headless, the audio codec should be disabled on PCIE bus. the the HDA driver will never probe the audio. right?

After checking the HDA a little, looks HDA could also handle many other audio devices. In this case, HDA may probe other audio device, e.g. from Braswell.

Just a guess.

Jerry

Quoted 33 lines

Thanks
JimQu

________________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2018年6月29日 12:01
收件人: Zhang, Jerry
抄送: Qu, Jim; amd-gfx list; Deucher, Alexander
主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id

Quoted 20 lines · Jerry (Junwei)
Quoted 17 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Quoted 152 lines
Quoted 2 lines

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Alex

Quoted 143 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
     drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
     include/linux/vga_switcheroo.h   |  4 ++--
     sound/pci/hda/hda_intel.c        | 15 +++++++++------
     3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
      * vga_switcheroo_register_audio_client - register audio client
      * @pdev: client pci device
      * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
      *
      * Register audio client (audio device on a GPU). The client is assumed
      * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
      */
     int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                           const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
     {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
           return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
     }
     EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                      bool driver_power_control);
     int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                            const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,
struct fb_info *info);

include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                   enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
     static inline void vga_switcheroo_unregister_handler(void) {}
     static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
     static int register_vga_switcheroo(struct azx *chip)
     {
           struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
           int err;
 
           if (!hda->use_vga_switcheroo)
                   return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
           if (err < 0)
                   return err;
           hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                           p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                           pci->bus->number,
 0);
                           if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 4 lines
                                           return p;
                                   pci_dev_put(p);
                           }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#93 lore raw
In reply to a message not in the archive
Quoted 22 lines · Alex Deucher
Quoted 20 lines · Jerry (Junwei)
Quoted 17 lines · Jim Qu

On modern laptop, there are more and more platforms have two GPUs, and each of them maybe have audio codec for HDMP/DP output. For some dGPU which is no output, audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as VGA_SWITCHEROO_DIS, so if system runtime pm is enabled, the audio which is binded to UMA will be suspended.

In HDA driver side, it is difficult to know which GPU the audio has binded to. So set the bound gpu pci dev to vgaswitchroo, let vgaswitchroo make decision.

Newer dGPUs use PCI_CLASS_DISPLAY_OTHER rather than PCI_CLASS_DISPLAY_VGA. Make sure we check for both when checking for the dGPU in get_bound_vga()

Quoted 6 lines
Quoted 2 lines

IIRC, VGA is for iGPU, OTHER is for dGPU.
if not, please correct me.

I think the dGPU can be either VGA or OTHER depending on whether there are displays wired to it. E.g., iceland and hainan don't even have VGA hw on them since they are headless.

Yeah, I can get that.

While the atpx detection also confuse me then.
It seems must have one VGA and one OTHER, but OTHER(dGPU) could also be connected to a external display(e.g. via HDMI).
Or should we say OTHER could has display but not default one?

Jerry

Quoted 146 lines

Alex

Quoted 143 lines
Quoted 30 lines

The patch also combine the HDA change to avoid break building.

Change-Id I9906c1bd4dd5b36108d7133bb1cf724d13f1cd6d
---
   drivers/gpu/vga/vga_switcheroo.c | 11 +++++++++--
   include/linux/vga_switcheroo.h   |  4 ++--
   sound/pci/hda/hda_intel.c        | 15 +++++++++------
   3 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +1 -1
index fc4adf3..7b7b0fd 100644
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
    * vga_switcheroo_register_audio_client - register audio client
    * @pdev: client pci device
    * @ops: client callbacks
- * @id: client identifier
+ * @bound_vga: client bound vga pci device
    *
    * Register audio client (audio device on a GPU). The client is assumed
    * to use runtime PM. Beforehand, vga_switcheroo_client_probe_defer()

drivers/gpu/vga/vga_switcheroo.c EXPORT_SYMBOL(vga_switcheroo_register_client); · line 347

Quoted 10 lines
drivers/gpu/vga/vga_switcheroo.c +5 -1
@@ -339,8 +339,15 @@ EXPORT_SYMBOL(vga_switcheroo_register_client);
    */
   int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                         const struct vga_switcheroo_client_ops *ops,
-                       enum vga_switcheroo_client_id id)
+                       struct pci_dev *bound_vga)
   {
+       enum vga_switcheroo_client_id id = VGA_SWITCHEROO_DIS;
+
+       if (bound_vga) {
+               if (vgasr_priv.handler->get_client_id)

We may combine 2 "if" together.

Anyway, the patch looks fine for me.

Additionally, better to includes Intel guys mail list and sound mail list if any.

Jerry

Quoted 81 lines
drivers/gpu/vga/vga_switcheroo.c +3 -0
+                       id = vgasr_priv.handler->get_client_id(bound_vga);
+       }
+
         return register_client(pdev, ops, id | ID_BIT_AUDIO, false, true);
   }
   EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
include/linux/vga_switcheroo.h +1 -1
index 77f0f0a..a0c7b86 100644
@@ -151,7 +151,7 @@ int vga_switcheroo_register_client(struct pci_dev
 *dev,
                                    bool driver_power_control);
   int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
                                          const struct
 vga_switcheroo_client_ops *ops,
-                                        enum vga_switcheroo_client_id
 id);
+                                        struct pci_dev *bound_vga);

void vga_switcheroo_client_fb_set(struct pci_dev *dev,

                                   struct fb_info *info);
include/linux/vga_switcheroo.h +0 -0
@@ -180,7 +180,7 @@ static inline int

vga_switcheroo_register_handler(const struct vga_switcheroo_ha

                 enum vga_switcheroo_handler_flags_t handler_flags) {

return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev
*pdev,
const struct vga_switcheroo_client_ops *ops,

include/linux/vga_switcheroo.h +1 -1
-       enum vga_switcheroo_client_id id) { return 0; }
+       struct pci_dev *bound_vga) { return 0; }
   static inline void vga_switcheroo_unregister_handler(void) {}
   static inline enum vga_switcheroo_handler_flags_t

vga_switcheroo_handler_flags(void) { return 0; }
static inline int vga_switcheroo_lock_ddc(struct pci_dev *pdev) { return

include/linux/vga_switcheroo.h +0 -1
-ENODEV; }
sound/pci/hda/hda_intel.c +1 -2
index 1ae1850..8f992e6 100644
@@ -1319,15 +1319,17 @@ static const struct vga_switcheroo_client_ops
 azx_vs_ops = {
   static int register_vga_switcheroo(struct azx *chip)
   {
         struct hda_intel *hda = container_of(chip, struct hda_intel,
 chip);
+       struct pci_dev *p;
         int err;
 
         if (!hda->use_vga_switcheroo)
                 return 0;
-       /* FIXME: currently only handling DIS controller
-        * is there any machine with two switchable HDMI audio

controllers?

sound/pci/hda/hda_intel.c +3 -3
-        */
-       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
-                                                  VGA_SWITCHEROO_DIS);
+
+       p = get_bound_vga(chip->pci);
+       err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,

p);

sound/pci/hda/hda_intel.c +3 -1
+
+       if (p)
+               pci_dev_put(p);
         if (err < 0)
                 return err;
         hda->vga_switcheroo_registered = 1;
@@ -1429,7 +1431,8 @@ static struct pci_dev *get_bound_vga(struct pci_dev
 *pci)
                         p =
 pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
                                                         pci->bus->number,
 0);
                         if (p) {
-                               if ((p->class >> 8) ==

PCI_CLASS_DISPLAY_VGA)
+ if ((p->class >> 8) ==
PCI_CLASS_DISPLAY_VGA ||
+ (p->class >> 8) ==
PCI_CLASS_DISPLAY_OTHER)

Quoted 4 lines
                                         return p;
                                 pci_dev_put(p);
                         }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx