[PATCH] x86_64: Fix off by one in IOMMU check
authorAndi Kleen <ak@suse.de>
Wed, 11 Jan 2006 21:44:27 +0000 (22:44 +0100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 12 Jan 2006 03:04:54 +0000 (19:04 -0800)
Fix off by one when checking if the machine has enougn memory to need IOMMU
This caused the IOMMUs to be needlessly enabled for mem=4G

Based on a patch from Jon Mason

Signed-off-by: jdmason@us.ibm.com
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/x86_64/kernel/aperture.c
arch/x86_64/kernel/io_apic.c
arch/x86_64/kernel/pci-gart.c
arch/x86_64/mm/init.c

index c7f4fdd20f05ff78ee731054170de372f9c0cf40..e4e2b7d01f8914c67cba5ad3bf5201db76b9ef96 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/io.h>
 #include <asm/proto.h>
 #include <asm/pci-direct.h>
+#include <asm/dma.h>
 
 int iommu_aperture;
 int iommu_aperture_disabled __initdata = 0;
@@ -247,7 +248,7 @@ void __init iommu_hole_init(void)
                /* Got the aperture from the AGP bridge */
        } else if (swiotlb && !valid_agp) {
                /* Do nothing */
-       } else if ((!no_iommu && end_pfn >= 0xffffffff>>PAGE_SHIFT) ||
+       } else if ((!no_iommu && end_pfn >= MAX_DMA32_PFN) ||
                   force_iommu ||
                   valid_agp ||
                   fallback_aper_force) { 
index bdc589924b104d2eaaa170e16340632a918bb00e..83ea86e0633a975d3033041785a598064932d4fd 100644 (file)
@@ -37,6 +37,7 @@
 #include <asm/proto.h>
 #include <asm/mach_apic.h>
 #include <asm/acpi.h>
+#include <asm/dma.h>
 
 #define __apicdebuginit  __init
 
@@ -281,7 +282,7 @@ void __init check_ioapic(void)
                                switch (vendor) { 
                                case PCI_VENDOR_ID_VIA:
 #ifdef CONFIG_GART_IOMMU
-                                       if ((end_pfn >= (0xffffffff>>PAGE_SHIFT) ||
+                                       if ((end_pfn > MAX_DMA32_PFN ||
                                             force_iommu) &&
                                            !iommu_aperture_allowed) {
                                                printk(KERN_INFO
index 2b865c90b0414b2a33f652333fa34881cc817de5..116e00f1bb7b5267643e1486b8c825c8f4eedf03 100644 (file)
@@ -804,7 +804,7 @@ static int __init pci_iommu_init(void)
        } 
        
        if (no_iommu ||
-           (!force_iommu && end_pfn < 0xffffffff>>PAGE_SHIFT) ||
+           (!force_iommu && (end_pfn-1) < 0xffffffff>>PAGE_SHIFT) ||
            !iommu_aperture ||
            (no_agp && init_k8_gatt(&info) < 0)) {
                printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n"); 
index 1faae5fc1c01c35c5e7cd7b1458bc34b5f63dd05..5337ca0ea7b9733b0ac91c6a323362079ba88f4b 100644 (file)
@@ -424,7 +424,7 @@ void __init mem_init(void)
 
 #ifdef CONFIG_SWIOTLB
        if (!iommu_aperture &&
-           (end_pfn >= 0xffffffff>>PAGE_SHIFT || force_iommu))
+           ((end_pfn-1) >= 0xffffffff>>PAGE_SHIFT || force_iommu))
               swiotlb = 1;
        if (swiotlb)
                swiotlb_init();