Skip to contentSkip to conversation

add runtime pm support for AMD display audio

PATCH In review Alex Deucher 2 participants 11 messages Nov 22, 2019 – Nov 26, 2019 Sound

lore
Share & tools
lore
#0 lore raw

cover add runtime pm support for AMD display audio

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Thanks,

Alex

[1]: https://patchwork.freedesktop.org/series/67885/

Alex Deucher (4):
ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio
ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by
default

 sound/pci/hda/hda_intel.c  | 80 +++++++++++++++++++++++++++++++++++---
 sound/pci/hda/patch_hdmi.c |  1 +
 2 files changed, 76 insertions(+), 5 deletions(-)
Signature · 6 lines
2.23.0

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

PATCH 1/4 ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD

Only enable the vga_switcheroo logic on systems with the ATPX ACPI method. This logic is not needed for asics that are not part of a PX (PowerXpress)/HG (Hybrid Graphics) platform.

---
 sound/pci/hda/hda_intel.c | 45 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
sound/pci/hda/hda_intel.c +45 -0
index 240f4ca76391..3ebc7b2a897f 100644
@@ -35,6 +35,7 @@
 #include <linux/clocksource.h>
 #include <linux/time.h>
 #include <linux/completion.h>
+#include <linux/acpi.h>
 
 #ifdef CONFIG_X86
 /* for snoop control */
@@ -1393,6 +1394,34 @@ static int azx_dev_free(struct snd_device *device)
 }
 
 #ifdef SUPPORT_VGA_SWITCHEROO
+#ifdef CONFIG_ACPI
+/* ATPX is in the integrated GPU's namespace */
+static bool atpx_present(void)
+{
+	struct pci_dev *pdev = NULL;
+	acpi_handle dhandle, atpx_handle;
+	acpi_status status;
+
+	while ((pdev = pci_get_class(PCI_BASE_CLASS_DISPLAY << 16, pdev)) != NULL) {
+		dhandle = ACPI_HANDLE(&pdev->dev);
+		if (dhandle) {
+			status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
+			if (!ACPI_FAILURE(status)) {
+				pci_dev_put(pdev);
+				return true;
+			}
+		}
+		pci_dev_put(pdev);
+	}
+	return false;
+}
+#else
+static bool atpx_present(void)
+{
+	return false;
+}
+#endif
+
 /*
  * Check of disabled HDMI controller by vga_switcheroo
  */
@@ -1404,6 +1433,22 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
 	switch (pci->vendor) {
 	case PCI_VENDOR_ID_ATI:
 	case PCI_VENDOR_ID_AMD:
+		if (pci->devfn == 1) {
+			p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
+							pci->bus->number, 0);
+			if (p) {
+				/* ATPX is in the integrated GPU's ACPI namespace
+				 * rather than the dGPU's namespace. However,
+				 * the dGPU is the one who is involved in
+				 * vgaswitcheroo.
+				 */
+				if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
+				    atpx_present())
+					return p;
+				pci_dev_put(p);
+			}
+		}
+		break;
 	case PCI_VENDOR_ID_NVIDIA:
 		if (pci->devfn == 1) {
 			p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
Signature · 6 lines
2.23.0

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

PATCH 2/4 ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio

In reply to Alex Deucher

These are needed so we can enable runtime pm in a subsequent patch.

---
 sound/pci/hda/hda_intel.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/pci/hda/hda_intel.c +14 -0
index 3ebc7b2a897f..79ca97d6c811 100644
@@ -2606,6 +2606,20 @@ static const struct pci_device_id azx_ids[] = {
 	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
 	{ PCI_DEVICE(0x1002, 0xaaf0),
 	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xaaf8),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xab00),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xab08),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xab10),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xab18),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xab20),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	{ PCI_DEVICE(0x1002, 0xab38),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
 	/* VIA VT8251/VT8237A */
 	{ PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
 	/* VIA GFX VT7122/VX900 */
Signature · 6 lines
2.23.0

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

PATCH 3/4 ALSA: hda/hdmi - enable runtime pm for newer AMD display audio

In reply to Alex Deucher

We are able to power down the GPU and audio via the GPU driver so flag these asics as supporting runtime pm.

---
 sound/pci/hda/hda_intel.c | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)
sound/pci/hda/hda_intel.c +23 -12
index 79ca97d6c811..111b9a869162 100644
@@ -2599,27 +2599,38 @@ static const struct pci_device_id azx_ids[] = {
 	{ PCI_DEVICE(0x1002, 0xaac8),
 	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
 	{ PCI_DEVICE(0x1002, 0xaad8),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
-	{ PCI_DEVICE(0x1002, 0xaae8),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xaae0),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
+	{ PCI_DEVICE(0x1002, 0xaae8),
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xaaf0),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xaaf8),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xab00),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xab08),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xab10),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xab18),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xab20),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	{ PCI_DEVICE(0x1002, 0xab38),
-	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
+	  .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+	  AZX_DCAPS_PM_RUNTIME },
 	/* VIA VT8251/VT8237A */
 	{ PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
 	/* VIA GFX VT7122/VX900 */
Signature · 6 lines
2.23.0

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

PATCH 4/4 ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default

In reply to Alex Deucher

So that we can power down the GPU and audio to save power.

---
 sound/pci/hda/patch_hdmi.c | 1 +
 1 file changed, 1 insertion(+)
sound/pci/hda/patch_hdmi.c +1 -0
index 795cbda32cbb..8785fcc850b9 100644
@@ -3961,6 +3961,7 @@ static int atihdmi_init(struct hda_codec *codec)
 					    ATI_VERB_SET_MULTICHANNEL_MODE,
 					    ATI_MULTICHANNEL_MODE_SINGLE);
 	}
+	codec->auto_runtime_pm = 1;
 
 	return 0;
 }
Signature · 6 lines
2.23.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#5 lore raw
In reply to Alex Deucher
Quoted 7 lines · Alex Deucher

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Do you mean that these can go into 5.5-rc1, or they need waiting until 5.5-rc1 release? I guess these won't break things even without the runtime PM support in GPU side, as the ELD notification is done via audio component, so I'm fine to apply them at any time.

thanks,

Takashi

Quoted 14 lines

Thanks,

Alex

[1]: https://patchwork.freedesktop.org/series/67885/

Alex Deucher (4):
ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio
ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by
default

Quoted 7 lines
 sound/pci/hda/hda_intel.c  | 80 +++++++++++++++++++++++++++++++++++---
 sound/pci/hda/patch_hdmi.c |  1 +
 2 files changed, 76 insertions(+), 5 deletions(-)
Signature · 1 line
2.23.0

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

#6 lore raw
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Alex Deucher

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Quoted 4 lines

Do you mean that these can go into 5.5-rc1, or they need waiting until 5.5-rc1 release? I guess these won't break things even without the runtime PM support in GPU side, as the ELD notification is done via audio component, so I'm fine to apply them at any time.

Up to you. I'm ok to wait for the next merge window if you'd prefer.

Alex

Quoted 28 lines

thanks,

Takashi

Quoted 21 lines

Thanks,

Alex

[1]: https://patchwork.freedesktop.org/series/67885/

Alex Deucher (4):
ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio
ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by
default

 sound/pci/hda/hda_intel.c  | 80 +++++++++++++++++++++++++++++++++++---
 sound/pci/hda/patch_hdmi.c |  1 +
 2 files changed, 76 insertions(+), 5 deletions(-)

--
2.23.0

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

#7 lore raw
Quoted 13 lines · Alex Deucher
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Alex Deucher

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Quoted 6 lines
Quoted 4 lines

Do you mean that these can go into 5.5-rc1, or they need waiting until 5.5-rc1 release? I guess these won't break things even without the runtime PM support in GPU side, as the ELD notification is done via audio component, so I'm fine to apply them at any time.

Up to you. I'm ok to wait for the next merge window if you'd prefer.

OK, I'm going to apply them for 5.5-rc1 inclusion.

BTW, should I apply these patches with your gmail address as author (while sign-off is AMD address)? Or should I align both to your AMD address?

It's nothing wrong to have different addresses in the commit, but if unintended, it's better to align both.

thanks,

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

#8 lore raw
Quoted 23 lines · Takashi Iwai
Quoted 13 lines · Alex Deucher
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Alex Deucher

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Quoted 6 lines
Quoted 4 lines

Do you mean that these can go into 5.5-rc1, or they need waiting until 5.5-rc1 release? I guess these won't break things even without the runtime PM support in GPU side, as the ELD notification is done via audio component, so I'm fine to apply them at any time.

Up to you. I'm ok to wait for the next merge window if you'd prefer.

Quoted 8 lines

OK, I'm going to apply them for 5.5-rc1 inclusion.

BTW, should I apply these patches with your gmail address as author (while sign-off is AMD address)? Or should I align both to your AMD address?

It's nothing wrong to have different addresses in the commit, but if unintended, it's better to align both.

I guess my AMD address. I usually use my gmail address for sending patches out of laziness.

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

#9 lore raw
Quoted 31 lines · Alex Deucher
Quoted 29 lines · Takashi Iwai
Quoted 13 lines · Alex Deucher
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Alex Deucher

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Quoted 6 lines
Quoted 4 lines

Do you mean that these can go into 5.5-rc1, or they need waiting until 5.5-rc1 release? I guess these won't break things even without the runtime PM support in GPU side, as the ELD notification is done via audio component, so I'm fine to apply them at any time.

Up to you. I'm ok to wait for the next merge window if you'd prefer.

OK, I'm going to apply them for 5.5-rc1 inclusion.

BTW, should I apply these patches with your gmail address as author (while sign-off is AMD address)? Or should I align both to your AMD address?

Quoted 5 lines
Quoted 2 lines

It's nothing wrong to have different addresses in the commit, but if unintended, it's better to align both.

I guess my AMD address. I usually use my gmail address for sending patches out of laziness.

OK, now merged all four patches.

thanks,

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

#10 lore raw
Quoted 34 lines · Takashi Iwai
Quoted 31 lines · Alex Deucher
Quoted 29 lines · Takashi Iwai
Quoted 13 lines · Alex Deucher
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Alex Deucher

These patches were originally part of a larger set of patches to enabled runtime pm support on the GPU side[1]. However, the patches are useful on their own there are really no dependencies, other than the fact that you need both for runtime pm to kick in on the GPU side. The GPU side will be landing for 5.6; I'd like to land the audio side as well.

Quoted 6 lines
Quoted 4 lines

Do you mean that these can go into 5.5-rc1, or they need waiting until 5.5-rc1 release? I guess these won't break things even without the runtime PM support in GPU side, as the ELD notification is done via audio component, so I'm fine to apply them at any time.

Up to you. I'm ok to wait for the next merge window if you'd prefer.

OK, I'm going to apply them for 5.5-rc1 inclusion.

BTW, should I apply these patches with your gmail address as author (while sign-off is AMD address)? Or should I align both to your AMD address?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

It's nothing wrong to have different addresses in the commit, but if unintended, it's better to align both.

I guess my AMD address. I usually use my gmail address for sending patches out of laziness.

OK, now merged all four patches.

Thanks!

Alex

Quoted 4 lines

thanks,

Takashi

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