Просмотр исходного кода

x86: return conditional to mmu

Just return our allocation if we don't have an mmu. For i386, where this patch
is being applied, we never have. So our goal is just to have the code to look like
x86_64's.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Glauber Costa 17 лет назад
Родитель
Сommit
da60cab4dd
1 измененных файлов с 32 добавлено и 2 удалено
  1. 32 2
      arch/x86/kernel/pci-dma_32.c

+ 32 - 2
arch/x86/kernel/pci-dma_32.c

@@ -116,12 +116,42 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 				gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
 				gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
 				goto again;
 				goto again;
 			}
 			}
+
+			/* Let low level make its own zone decisions */
+			gfp &= ~(GFP_DMA32|GFP_DMA);
+
+			if (dma_ops->alloc_coherent)
+				return dma_ops->alloc_coherent(dev, size,
+							   dma_handle, gfp);
+			return NULL;
+
 		}
 		}
 		memset(ret, 0, size);
 		memset(ret, 0, size);
-		*dma_handle = bus;
+		if (!mmu) {
+			*dma_handle = bus;
+			return ret;
+		}
+	}
+
+	if (dma_ops->alloc_coherent) {
+		free_pages((unsigned long)ret, get_order(size));
+		gfp &= ~(GFP_DMA|GFP_DMA32);
+		return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+	}
+
+	if (dma_ops->map_simple) {
+		*dma_handle = dma_ops->map_simple(dev, virt_to_phys(ret),
+					      size,
+					      PCI_DMA_BIDIRECTIONAL);
+		if (*dma_handle != bad_dma_address)
+			return ret;
 	}
 	}
 
 
-	return ret;
+	if (panic_on_overflow)
+		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",
+		      (unsigned long)size);
+	free_pages((unsigned long)ret, get_order(size));
+	return NULL;
 }
 }
 EXPORT_SYMBOL(dma_alloc_coherent);
 EXPORT_SYMBOL(dma_alloc_coherent);