Fix off by one in IOMMU check 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 Noticed by Jon Mason. Cc: jdmason@us.ibm.com Signed-off-by: Andi Kleen Index: linux/arch/x86_64/kernel/aperture.c =================================================================== --- linux.orig/arch/x86_64/kernel/aperture.c +++ linux/arch/x86_64/kernel/aperture.c @@ -247,7 +247,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-1) >= 0xffffffff>>PAGE_SHIFT) || force_iommu || valid_agp || fallback_aper_force) { Index: linux/arch/x86_64/kernel/pci-gart.c =================================================================== --- linux.orig/arch/x86_64/kernel/pci-gart.c +++ linux/arch/x86_64/kernel/pci-gart.c @@ -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: linux/arch/x86_64/mm/init.c =================================================================== --- linux.orig/arch/x86_64/mm/init.c +++ linux/arch/x86_64/mm/init.c @@ -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();