lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080307090720.AEE1B1B419C@basil.firstfloor.org>
Date:	Fri,  7 Mar 2008 10:07:20 +0100 (CET)
From:	Andi Kleen <andi@...stfloor.org>
To:	linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: [PATCH] [10/13] Switch the 32bit dma_alloc_coherent functions over to use the maskable allocator


Signed-off-by: Andi Kleen <ak@...e.de>

---
 arch/x86/kernel/pci-dma_32.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Index: linux/arch/x86/kernel/pci-dma_32.c
===================================================================
--- linux.orig/arch/x86/kernel/pci-dma_32.c
+++ linux/arch/x86/kernel/pci-dma_32.c
@@ -27,11 +27,12 @@ void *dma_alloc_coherent(struct device *
 {
 	void *ret;
 	struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
-	int order = get_order(size);
+	u64 mask;
 	/* ignore region specifiers */
-	gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
+	gfp &= ~__GFP_HIGHMEM;
 
 	if (mem) {
+		int order = get_order(size);
 		int page = bitmap_find_free_region(mem->bitmap, mem->size,
 						     order);
 		if (page >= 0) {
@@ -44,10 +45,12 @@ void *dma_alloc_coherent(struct device *
 			return NULL;
 	}
 
-	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
-		gfp |= GFP_DMA;
+	if (dev == NULL)
+		mask = TRAD_DMA_MASK;
+	else
+		mask = dev->coherent_dma_mask;
 
-	ret = (void *)__get_free_pages(gfp, order);
+	ret = get_pages_mask(gfp, size, mask);
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
@@ -61,15 +64,15 @@ void dma_free_coherent(struct device *de
 			 void *vaddr, dma_addr_t dma_handle)
 {
 	struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
-	int order = get_order(size);
 
 	WARN_ON(irqs_disabled());	/* for portability */
 	if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size << PAGE_SHIFT))) {
+		int order = get_order(size);
 		int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
 
 		bitmap_release_region(mem->bitmap, page, order);
 	} else
-		free_pages((unsigned long)vaddr, order);
+		free_pages_mask(vaddr, size);
 }
 EXPORT_SYMBOL(dma_free_coherent);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ