Commit ee1f284f authored by Konrad Rzeszutek Wilk's avatar Konrad Rzeszutek Wilk Committed by H. Peter Anvin

x86, iommu: Utilize the IOMMU_INIT macros functionality.

We remove all of the sub-platform detection/init routines and instead
use on the .iommu_table array of structs to call the .early_init if
.detect returned a positive value. Also we can stop detecting other
IOMMUs if the IOMMU used the _FINISH type macro. During the
'pci_iommu_init' stage, we call .init for the second-stage
initialization if it was defined. Currently only SWIOTLB has this
defined and it used to de-allocate the SWIOTLB if the other detected
IOMMUs have deemed it unnecessary to use SWIOTLB.
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
LKML-Reference: <1282845485-8991-11-git-send-email-konrad.wilk@oracle.com>
CC: Fujita Tomonori <fujita.tomonori@lab.ntt.co.jp>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 4db77ff3
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
#include <asm/iommu.h> #include <asm/iommu.h>
#include <asm/gart.h> #include <asm/gart.h>
#include <asm/calgary.h> #include <asm/calgary.h>
#include <asm/amd_iommu.h>
#include <asm/x86_init.h> #include <asm/x86_init.h>
#include <asm/xen/swiotlb-xen.h> #include <asm/iommu_table.h>
static int forbid_dac __read_mostly; static int forbid_dac __read_mostly;
...@@ -45,6 +44,8 @@ int iommu_detected __read_mostly = 0; ...@@ -45,6 +44,8 @@ int iommu_detected __read_mostly = 0;
*/ */
int iommu_pass_through __read_mostly; int iommu_pass_through __read_mostly;
extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
/* Dummy device used for NULL arguments (normally ISA). */ /* Dummy device used for NULL arguments (normally ISA). */
struct device x86_dma_fallback_dev = { struct device x86_dma_fallback_dev = {
.init_name = "fallback device", .init_name = "fallback device",
...@@ -130,28 +131,24 @@ static void __init dma32_free_bootmem(void) ...@@ -130,28 +131,24 @@ static void __init dma32_free_bootmem(void)
void __init pci_iommu_alloc(void) void __init pci_iommu_alloc(void)
{ {
struct iommu_table_entry *p;
/* free the range so iommu could get some range less than 4G */ /* free the range so iommu could get some range less than 4G */
dma32_free_bootmem(); dma32_free_bootmem();
if (pci_xen_swiotlb_detect() || pci_swiotlb_detect_override()) sort_iommu_table(__iommu_table, __iommu_table_end);
goto out; check_iommu_entries(__iommu_table, __iommu_table_end);
pci_swiotlb_detect_4gb();
gart_iommu_hole_init();
detect_calgary();
detect_intel_iommu();
/* needs to be called after gart_iommu_hole_init */ for (p = __iommu_table; p < __iommu_table_end; p++) {
amd_iommu_detect(); if (p && p->detect && p->detect() > 0) {
out: p->flags |= IOMMU_DETECTED;
pci_xen_swiotlb_init(); if (p->early_init)
p->early_init();
pci_swiotlb_init(); if (p->flags & IOMMU_FINISH_IF_DETECTED)
break;
}
}
} }
void *dma_generic_alloc_coherent(struct device *dev, size_t size, void *dma_generic_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_addr, gfp_t flag) dma_addr_t *dma_addr, gfp_t flag)
{ {
...@@ -294,6 +291,7 @@ EXPORT_SYMBOL(dma_supported); ...@@ -294,6 +291,7 @@ EXPORT_SYMBOL(dma_supported);
static int __init pci_iommu_init(void) static int __init pci_iommu_init(void)
{ {
struct iommu_table_entry *p;
dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
...@@ -301,12 +299,10 @@ static int __init pci_iommu_init(void) ...@@ -301,12 +299,10 @@ static int __init pci_iommu_init(void)
#endif #endif
x86_init.iommu.iommu_init(); x86_init.iommu.iommu_init();
if (swiotlb || xen_swiotlb) { for (p = __iommu_table; p < __iommu_table_end; p++) {
printk(KERN_INFO "PCI-DMA: " if (p && (p->flags & IOMMU_DETECTED) && p->late_init)
"Using software bounce buffering for IO (SWIOTLB)\n"); p->late_init();
swiotlb_print_info(); }
} else
swiotlb_free();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment