patch-2.4.26 linux-2.4.26/arch/x86_64/kernel/pci-gart.c

Next file: linux-2.4.26/arch/x86_64/kernel/pci-pc.c
Previous file: linux-2.4.26/arch/x86_64/kernel/nmi.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.25/arch/x86_64/kernel/pci-gart.c linux-2.4.26/arch/x86_64/kernel/pci-gart.c
@@ -8,7 +8,7 @@
  * See Documentation/DMA-mapping.txt for the interface specification.
  * 
  * Copyright 2002 Andi Kleen, SuSE Labs.
- * $Id: pci-gart.c,v 1.30 2004/01/13 09:09:32 ak Exp $
+ * $Id: pci-gart.c,v 1.32 2004/02/27 18:30:19 ak Exp $
  */
 
 #include <linux/config.h>
@@ -220,7 +220,7 @@
 	unsigned long iommu_page;
 
 	size = round_up(size, PAGE_SIZE); 
-	if (bus >= iommu_bus_base && bus <= iommu_bus_base + iommu_size) { 
+	if (bus >= iommu_bus_base && bus < iommu_bus_base + iommu_size) { 
 		unsigned pages = size >> PAGE_SHIFT;
 		iommu_page = (bus - iommu_bus_base) >> PAGE_SHIFT;
 		vaddr = __va(GPTE_DECODE(iommu_gatt_base[iommu_page]));
@@ -310,6 +310,12 @@
 
 	BUG_ON(dir == PCI_DMA_NONE);
 
+#ifdef CONFIG_SWIOTLB
+       if (swiotlb)
+               return swiotlb_map_single(dev,addr,size,dir);
+#endif
+
+
 	phys_mem = virt_to_phys(addr); 
 	if (!need_iommu(dev, phys_mem, size))
 		return phys_mem; 
@@ -352,8 +358,17 @@
 {
 	unsigned long iommu_page; 
 	int npages;
+
+#ifdef CONFIG_SWIOTLB
+       if (swiotlb) {
+               swiotlb_unmap_single(hwdev,dma_addr,size,direction);
+              return;
+       }
+#endif
+
+
 	if (dma_addr < iommu_bus_base + EMERGENCY_PAGES*PAGE_SIZE || 
-	    dma_addr > iommu_bus_base + iommu_size)
+	    dma_addr >= iommu_bus_base + iommu_size)
 		return;
 	iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT;	
 	npages = round_up(size + (dma_addr & ~PAGE_MASK), PAGE_SIZE) >> PAGE_SHIFT;
@@ -488,7 +503,14 @@
 	no_agp = no_agp || (agp_init() < 0) || (agp_copy_info(&info) < 0); 
 #endif	
 
-	if (no_iommu || (!force_mmu && end_pfn < 0xffffffff>>PAGE_SHIFT)) { 
+	if (swiotlb) { 
+		no_iommu = 1;
+		printk(KERN_INFO "PCI-DMA: Using SWIOTLB\n"); 
+		return; 
+	} 
+
+
+	if (no_iommu || (!force_mmu && end_pfn < 0xffffffff>>PAGE_SHIFT) || !iommu_aperture) { 
 		printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n"); 
 		no_iommu = 1;
 		return;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)