From 175b3f1ca1cf45d85d32c9f1acb1f23741fb4ec3 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Thu, 12 Jul 2012 09:28:07 +0800 Subject: [PATCH] hda: Disable "No Snoop" on PCI express chips Tested-by: ftigeot@ --- sys/dev/sound/pci/hda/hdac.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 92982a5..60e0715 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -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 -- 1.7.7.2