diff options
author | Jon Mason <jdmason@us.ibm.com> | 2006-06-26 07:58:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-26 13:48:18 -0400 |
commit | 0dc243ae10c8309c170a3af9f1adad1924a9f217 (patch) | |
tree | f550a8097913728ce96322d5f799329489db85a1 /arch/x86_64 | |
parent | a3c042a0f022dade8e02bf6c9be5d2379d7e133c (diff) |
[PATCH] x86_64: Calgary IOMMU - IOMMU abstractions
This patch creates a new interface for IOMMUs by adding a centralized
location for IOMMU allocation (for translation tables/apertures) and
IOMMU initialization. In creating these, code was moved around for
abstraction, uniformity, and consiceness.
Take note of the move of the iommu_setup bootarg parsing code to
__setup. This is enabled by moving back the location of the aperture
allocation/detection to mem init (which while ugly, was already the
location of the swiotlb_init).
While a slight departure from the previous patch, I belive this provides
the true intention of the previous versions of the patch which changed
this code. It also makes the addition of the upcoming calgary code much
cleaner than previous patches.
[AK: Removed one broken change. iommu_setup still has to be called
early]
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: Jon Mason <jdmason@us.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64')
-rw-r--r-- | arch/x86_64/kernel/pci-dma.c | 29 | ||||
-rw-r--r-- | arch/x86_64/kernel/pci-gart.c | 13 | ||||
-rw-r--r-- | arch/x86_64/kernel/setup.c | 5 | ||||
-rw-r--r-- | arch/x86_64/mm/init.c | 7 |
4 files changed, 36 insertions, 18 deletions
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c index 7edd1a40fab3..a45844c7e3a3 100644 --- a/arch/x86_64/kernel/pci-dma.c +++ b/arch/x86_64/kernel/pci-dma.c | |||
@@ -279,3 +279,32 @@ __init int iommu_setup(char *p) | |||
279 | } | 279 | } |
280 | return 1; | 280 | return 1; |
281 | } | 281 | } |
282 | __setup("iommu=", iommu_setup); | ||
283 | |||
284 | void __init pci_iommu_alloc(void) | ||
285 | { | ||
286 | /* | ||
287 | * The order of these functions is important for | ||
288 | * fall-back/fail-over reasons | ||
289 | */ | ||
290 | #ifdef CONFIG_IOMMU | ||
291 | iommu_hole_init(); | ||
292 | #endif | ||
293 | |||
294 | #ifdef CONFIG_SWIOTLB | ||
295 | pci_swiotlb_init(); | ||
296 | #endif | ||
297 | } | ||
298 | |||
299 | static int __init pci_iommu_init(void) | ||
300 | { | ||
301 | #ifdef CONFIG_IOMMU | ||
302 | gart_iommu_init(); | ||
303 | #endif | ||
304 | |||
305 | no_iommu_init(); | ||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | /* Must execute after PCI subsystem */ | ||
310 | fs_initcall(pci_iommu_init); | ||
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c index 4f67957d2b42..9a93954bed37 100644 --- a/arch/x86_64/kernel/pci-gart.c +++ b/arch/x86_64/kernel/pci-gart.c | |||
@@ -571,7 +571,7 @@ static struct dma_mapping_ops gart_dma_ops = { | |||
571 | .unmap_sg = gart_unmap_sg, | 571 | .unmap_sg = gart_unmap_sg, |
572 | }; | 572 | }; |
573 | 573 | ||
574 | static int __init pci_iommu_init(void) | 574 | void __init gart_iommu_init(void) |
575 | { | 575 | { |
576 | struct agp_kern_info info; | 576 | struct agp_kern_info info; |
577 | unsigned long aper_size; | 577 | unsigned long aper_size; |
@@ -581,7 +581,7 @@ static int __init pci_iommu_init(void) | |||
581 | 581 | ||
582 | if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0) { | 582 | if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0) { |
583 | printk(KERN_INFO "PCI-GART: No AMD northbridge found.\n"); | 583 | printk(KERN_INFO "PCI-GART: No AMD northbridge found.\n"); |
584 | return -ENODEV; | 584 | return; |
585 | } | 585 | } |
586 | 586 | ||
587 | #ifndef CONFIG_AGP_AMD64 | 587 | #ifndef CONFIG_AGP_AMD64 |
@@ -595,11 +595,11 @@ static int __init pci_iommu_init(void) | |||
595 | #endif | 595 | #endif |
596 | 596 | ||
597 | if (swiotlb) | 597 | if (swiotlb) |
598 | return -ENODEV; | 598 | return; |
599 | 599 | ||
600 | /* Did we detect a different HW IOMMU? */ | 600 | /* Did we detect a different HW IOMMU? */ |
601 | if (iommu_detected && !iommu_aperture) | 601 | if (iommu_detected && !iommu_aperture) |
602 | return -1; | 602 | return; |
603 | 603 | ||
604 | if (no_iommu || | 604 | if (no_iommu || |
605 | (!force_iommu && end_pfn <= MAX_DMA32_PFN) || | 605 | (!force_iommu && end_pfn <= MAX_DMA32_PFN) || |
@@ -611,7 +611,7 @@ static int __init pci_iommu_init(void) | |||
611 | "but IOMMU not available.\n" | 611 | "but IOMMU not available.\n" |
612 | KERN_ERR "WARNING 32bit PCI may malfunction.\n"); | 612 | KERN_ERR "WARNING 32bit PCI may malfunction.\n"); |
613 | } | 613 | } |
614 | return -ENODEV; | 614 | return; |
615 | } | 615 | } |
616 | 616 | ||
617 | printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n"); | 617 | printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n"); |
@@ -678,11 +678,10 @@ static int __init pci_iommu_init(void) | |||
678 | 678 | ||
679 | flush_gart(); | 679 | flush_gart(); |
680 | dma_ops = &gart_dma_ops; | 680 | dma_ops = &gart_dma_ops; |
681 | return 0; | ||
682 | } | 681 | } |
683 | 682 | ||
684 | /* Must execute after PCI subsystem */ | 683 | /* Must execute after PCI subsystem */ |
685 | fs_initcall(pci_iommu_init); | 684 | fs_initcall(gart_iommu_init); |
686 | 685 | ||
687 | void gart_parse_options(char *p) | 686 | void gart_parse_options(char *p) |
688 | { | 687 | { |
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c index a9de8f02671f..04b2d7b92d17 100644 --- a/arch/x86_64/kernel/setup.c +++ b/arch/x86_64/kernel/setup.c | |||
@@ -63,7 +63,6 @@ | |||
63 | #include <asm/setup.h> | 63 | #include <asm/setup.h> |
64 | #include <asm/mach_apic.h> | 64 | #include <asm/mach_apic.h> |
65 | #include <asm/numa.h> | 65 | #include <asm/numa.h> |
66 | #include <asm/swiotlb.h> | ||
67 | #include <asm/sections.h> | 66 | #include <asm/sections.h> |
68 | #include <asm/dmi.h> | 67 | #include <asm/dmi.h> |
69 | 68 | ||
@@ -702,10 +701,6 @@ void __init setup_arch(char **cmdline_p) | |||
702 | 701 | ||
703 | e820_setup_gap(); | 702 | e820_setup_gap(); |
704 | 703 | ||
705 | #ifdef CONFIG_IOMMU | ||
706 | iommu_hole_init(); | ||
707 | #endif | ||
708 | |||
709 | #ifdef CONFIG_VT | 704 | #ifdef CONFIG_VT |
710 | #if defined(CONFIG_VGA_CONSOLE) | 705 | #if defined(CONFIG_VGA_CONSOLE) |
711 | conswitchp = &vga_con; | 706 | conswitchp = &vga_con; |
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c index b83645a2e02d..2f5f5b11e9d0 100644 --- a/arch/x86_64/mm/init.c +++ b/arch/x86_64/mm/init.c | |||
@@ -41,8 +41,6 @@ | |||
41 | #include <asm/proto.h> | 41 | #include <asm/proto.h> |
42 | #include <asm/smp.h> | 42 | #include <asm/smp.h> |
43 | #include <asm/sections.h> | 43 | #include <asm/sections.h> |
44 | #include <asm/dma-mapping.h> | ||
45 | #include <asm/swiotlb.h> | ||
46 | 44 | ||
47 | #ifndef Dprintk | 45 | #ifndef Dprintk |
48 | #define Dprintk(x...) | 46 | #define Dprintk(x...) |
@@ -587,10 +585,7 @@ void __init mem_init(void) | |||
587 | { | 585 | { |
588 | long codesize, reservedpages, datasize, initsize; | 586 | long codesize, reservedpages, datasize, initsize; |
589 | 587 | ||
590 | #ifdef CONFIG_SWIOTLB | 588 | pci_iommu_alloc(); |
591 | pci_swiotlb_init(); | ||
592 | #endif | ||
593 | no_iommu_init(); | ||
594 | 589 | ||
595 | /* How many end-of-memory variables you have, grandma! */ | 590 | /* How many end-of-memory variables you have, grandma! */ |
596 | max_low_pfn = end_pfn; | 591 | max_low_pfn = end_pfn; |