Skip to contentSkip to conversation

make sure dma_map_single doesn't sleep

PATCH New Chris Wright 1 participant 1 message Aug 10, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make sure dma_map_single doesn't sleep

dma_map_single can't sleep since it may be called with locks held, or
interrupts off, etc. Thus it shouldn't make sleeping allocations.

linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c +2 -2
diff -r 38c7c25b3cb9 linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c
@@ -182,8 +182,8 @@
 	if ((((unsigned int)ptr & ~PAGE_MASK) + size) <= PAGE_SIZE) {
 		dma = virt_to_bus(ptr);
 	} else {
-		BUG_ON((bnc = dma_alloc_coherent(dev, size, &dma, 0)) == NULL);
-		BUG_ON((ent = kmalloc(sizeof(*ent), GFP_KERNEL)) == NULL);
+		BUG_ON((bnc = dma_alloc_coherent(dev, size, &dma, GFP_ATOMIC)) == NULL);
+		BUG_ON((ent = kmalloc(sizeof(*ent), GFP_ATOMIC)) == NULL);
 		if (direction != DMA_FROM_DEVICE)
 			memcpy(bnc, ptr, size);
 		ent->dma    = dma;
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c +2 -2
diff -r 38c7c25b3cb9 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c
@@ -234,8 +234,8 @@
 	if (((((unsigned long)ptr) & ~PAGE_MASK) + size) <= PAGE_SIZE) {
 		dma = virt_to_bus(ptr);
 	} else {
-		BUG_ON((bnc = dma_alloc_coherent(dev, size, &dma, 0)) == NULL);
-		BUG_ON((ent = kmalloc(sizeof(*ent), GFP_KERNEL)) == NULL);
+		BUG_ON((bnc = dma_alloc_coherent(dev, size, &dma, GFP_ATOMIC)) == NULL);
+		BUG_ON((ent = kmalloc(sizeof(*ent), GFP_ATOMIC)) == NULL);
 		if (direction != DMA_FROM_DEVICE)
 			memcpy(bnc, ptr, size);
 		ent->dma    = dma;