ALSA: hda: Allow HDA to be runtime suspended when dGPU is not bound to a driver
[linux-2.6-block.git] / sound / pci / hda / hda_intel.c
index 240f4ca76391fbefa80074a182dc9ab88f4394e9..e63b871343e59ee02d68e9133faa02b8d9413a32 100644 (file)
@@ -1280,11 +1280,17 @@ static void init_vga_switcheroo(struct azx *chip)
 {
        struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
        struct pci_dev *p = get_bound_vga(chip->pci);
+       struct pci_dev *parent;
        if (p) {
                dev_info(chip->card->dev,
                         "Handle vga_switcheroo audio client\n");
                hda->use_vga_switcheroo = 1;
-               chip->bus.keep_power = 1; /* cleared in either gpu_bound op or codec probe */
+
+               /* cleared in either gpu_bound op or codec probe, or when its
+                * upstream port has _PR3 (i.e. dGPU).
+                */
+               parent = pci_upstream_bridge(p);
+               chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1;
                chip->driver_caps |= AZX_DCAPS_PM_RUNTIME;
                pci_dev_put(p);
        }