hda: Disable "No Snoop" on PCI express chips
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 12 Jul 2012 01:28:07 +0000 (09:28 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 12 Jul 2012 01:36:37 +0000 (09:36 +0800)
Tested-by: ftigeot@
sys/dev/sound/pci/hda/hdac.c

index 92982a5..60e0715 100644 (file)
@@ -3813,6 +3813,8 @@ hdac_attach(device_t dev)
 #else
        sc->flags &= ~HDAC_F_DMA_NOCACHE;
 #endif
+
+#if 0
                /*
                 * Try to enable PCIe snoop to avoid messing around with
                 * uncacheable DMA attribute. Since PCIe snoop register
@@ -3850,6 +3852,30 @@ hdac_attach(device_t dev)
                        }
                        break;
                }
+#endif
+
+               if (pci_is_pcie(dev)) {
+                       int pcie_cap = pci_get_pciecap_ptr(dev);
+                       uint16_t dev_ctl;
+
+                       dev_ctl = pci_read_config(dev,
+                           pcie_cap + PCIER_DEVCTRL, 2);
+                       if (bootverbose) {
+                               device_printf(dev, "device ctrl %#x\n",
+                                   dev_ctl);
+                       }
+
+                       if (dev_ctl & PCIEM_DEVCTL_NOSNOOP) {
+                               dev_ctl &= ~PCIEM_DEVCTL_NOSNOOP;
+                               pci_write_config(dev,
+                                   pcie_cap + PCIER_DEVCTRL, dev_ctl, 2);
+
+                               if (bootverbose)
+                                       device_printf(dev, "disable nosnoop\n");
+                       }
+                       sc->flags &= ~HDAC_F_DMA_NOCACHE;
+               }
+
 #if 0 /* TODO: No uncacheable DMA support in DragonFly. */
        }
 #endif