diff options
| author | Chris Wright <chrisw@sous-sol.org> | 2009-12-04 15:15:21 -0500 |
|---|---|---|
| committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-12-04 19:19:24 -0500 |
| commit | 5d990b627537e59a3a2f039ff588a4750e9c1a6a (patch) | |
| tree | 8c0e723c3f9146da52b30c087a80fc417df2b41b | |
| parent | b26a34aa4792b3db2500b8a98cb7702765c1a92e (diff) | |
PCI: add pci_request_acs
Commit ae21ee65e8bc228416bbcc8a1da01c56a847a60c "PCI: acs p2p upsteram
forwarding enabling" doesn't actually enable ACS.
Add a function to pci core to allow an IOMMU to request that ACS
be enabled. The existing mechanism of using iommu_found() in the pci
core to know when ACS should be enabled doesn't actually work due to
initialization order; iommu has only been detected not initialized.
Have Intel and AMD IOMMUs request ACS, and Xen does as well during early
init of dom0.
Cc: Allen Kay <allen.m.kay@intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
| -rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 2 | ||||
| -rw-r--r-- | arch/x86/xen/enlighten.c | 5 | ||||
| -rw-r--r-- | drivers/pci/dmar.c | 5 | ||||
| -rw-r--r-- | drivers/pci/pci.c | 13 | ||||
| -rw-r--r-- | drivers/pci/probe.c | 5 | ||||
| -rw-r--r-- | include/linux/pci.h | 2 |
6 files changed, 27 insertions, 5 deletions
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index b4b61d462dcc..e60530a5f524 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
| @@ -1330,6 +1330,8 @@ void __init amd_iommu_detect(void) | |||
| 1330 | gart_iommu_aperture_disabled = 1; | 1330 | gart_iommu_aperture_disabled = 1; |
| 1331 | gart_iommu_aperture = 0; | 1331 | gart_iommu_aperture = 0; |
| 1332 | #endif | 1332 | #endif |
| 1333 | /* Make sure ACS will be enabled */ | ||
| 1334 | pci_request_acs(); | ||
| 1333 | } | 1335 | } |
| 1334 | } | 1336 | } |
| 1335 | 1337 | ||
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 5bccd706232c..e2511bccbc8d 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/page-flags.h> | 27 | #include <linux/page-flags.h> |
| 28 | #include <linux/highmem.h> | 28 | #include <linux/highmem.h> |
| 29 | #include <linux/console.h> | 29 | #include <linux/console.h> |
| 30 | #include <linux/pci.h> | ||
| 30 | 31 | ||
| 31 | #include <xen/xen.h> | 32 | #include <xen/xen.h> |
| 32 | #include <xen/interface/xen.h> | 33 | #include <xen/interface/xen.h> |
| @@ -1170,7 +1171,11 @@ asmlinkage void __init xen_start_kernel(void) | |||
| 1170 | add_preferred_console("xenboot", 0, NULL); | 1171 | add_preferred_console("xenboot", 0, NULL); |
| 1171 | add_preferred_console("tty", 0, NULL); | 1172 | add_preferred_console("tty", 0, NULL); |
| 1172 | add_preferred_console("hvc", 0, NULL); | 1173 | add_preferred_console("hvc", 0, NULL); |
| 1174 | } else { | ||
| 1175 | /* Make sure ACS will be enabled */ | ||
| 1176 | pci_request_acs(); | ||
| 1173 | } | 1177 | } |
| 1178 | |||
| 1174 | 1179 | ||
| 1175 | xen_raw_console_write("about to get started...\n"); | 1180 | xen_raw_console_write("about to get started...\n"); |
| 1176 | 1181 | ||
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index e01ca4d6b3e6..0e98f6b6f515 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
| @@ -614,8 +614,11 @@ void __init detect_intel_iommu(void) | |||
| 614 | #endif | 614 | #endif |
| 615 | #ifdef CONFIG_DMAR | 615 | #ifdef CONFIG_DMAR |
| 616 | if (ret && !no_iommu && !iommu_detected && !swiotlb && | 616 | if (ret && !no_iommu && !iommu_detected && !swiotlb && |
| 617 | !dmar_disabled) | 617 | !dmar_disabled) { |
| 618 | iommu_detected = 1; | 618 | iommu_detected = 1; |
| 619 | /* Make sure ACS will be enabled */ | ||
| 620 | pci_request_acs(); | ||
| 621 | } | ||
| 619 | #endif | 622 | #endif |
| 620 | } | 623 | } |
| 621 | early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size); | 624 | early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size); |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6af212c509c5..cd9b375f49d5 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
| @@ -1550,6 +1550,16 @@ void pci_enable_ari(struct pci_dev *dev) | |||
| 1550 | bridge->ari_enabled = 1; | 1550 | bridge->ari_enabled = 1; |
| 1551 | } | 1551 | } |
| 1552 | 1552 | ||
| 1553 | static int pci_acs_enable; | ||
| 1554 | |||
| 1555 | /** | ||
| 1556 | * pci_request_acs - ask for ACS to be enabled if supported | ||
| 1557 | */ | ||
| 1558 | void pci_request_acs(void) | ||
| 1559 | { | ||
| 1560 | pci_acs_enable = 1; | ||
| 1561 | } | ||
| 1562 | |||
| 1553 | /** | 1563 | /** |
| 1554 | * pci_enable_acs - enable ACS if hardware support it | 1564 | * pci_enable_acs - enable ACS if hardware support it |
| 1555 | * @dev: the PCI device | 1565 | * @dev: the PCI device |
| @@ -1560,6 +1570,9 @@ void pci_enable_acs(struct pci_dev *dev) | |||
| 1560 | u16 cap; | 1570 | u16 cap; |
| 1561 | u16 ctrl; | 1571 | u16 ctrl; |
| 1562 | 1572 | ||
| 1573 | if (!pci_acs_enable) | ||
| 1574 | return; | ||
| 1575 | |||
| 1563 | if (!pci_is_pcie(dev)) | 1576 | if (!pci_is_pcie(dev)) |
| 1564 | return; | 1577 | return; |
| 1565 | 1578 | ||
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2fdffc02a308..98ffb2de22e9 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -10,9 +10,7 @@ | |||
| 10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| 11 | #include <linux/cpumask.h> | 11 | #include <linux/cpumask.h> |
| 12 | #include <linux/pci-aspm.h> | 12 | #include <linux/pci-aspm.h> |
| 13 | #include <linux/iommu.h> | ||
| 14 | #include <acpi/acpi_hest.h> | 13 | #include <acpi/acpi_hest.h> |
| 15 | #include <xen/xen.h> | ||
| 16 | #include "pci.h" | 14 | #include "pci.h" |
| 17 | 15 | ||
| 18 | #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ | 16 | #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ |
| @@ -1029,8 +1027,7 @@ static void pci_init_capabilities(struct pci_dev *dev) | |||
| 1029 | pci_iov_init(dev); | 1027 | pci_iov_init(dev); |
| 1030 | 1028 | ||
| 1031 | /* Enable ACS P2P upstream forwarding */ | 1029 | /* Enable ACS P2P upstream forwarding */ |
| 1032 | if (iommu_found() || xen_initial_domain()) | 1030 | pci_enable_acs(dev); |
| 1033 | pci_enable_acs(dev); | ||
| 1034 | } | 1031 | } |
| 1035 | 1032 | ||
| 1036 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | 1033 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 2891c3d3e51a..04771b9c3316 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -1328,5 +1328,7 @@ static inline bool pci_is_pcie(struct pci_dev *dev) | |||
| 1328 | return !!pci_pcie_cap(dev); | 1328 | return !!pci_pcie_cap(dev); |
| 1329 | } | 1329 | } |
| 1330 | 1330 | ||
| 1331 | void pci_request_acs(void); | ||
| 1332 | |||
| 1331 | #endif /* __KERNEL__ */ | 1333 | #endif /* __KERNEL__ */ |
| 1332 | #endif /* LINUX_PCI_H */ | 1334 | #endif /* LINUX_PCI_H */ |
