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]
Date:	Thu,  4 Sep 2008 03:04:24 +0900
From:	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
To:	linux-kernel@...r.kernel.org
Cc:	joerg.roedel@....com, mingo@...hat.com, tony.luck@...el.com,
	kamezawa.hiroyu@...fujitsu.com, iommu@...ts.linux-foundation.org,
	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
Subject: [PATCH 2/3] x86: set gfp flag properly for swiotlb_alloc_coherent

This tries to avoid GFP_DMA zone unless absolutely needed (and set gfp
flag to use GFP_DMA zone properly if necessary).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
---
 arch/x86/kernel/pci-swiotlb_64.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c
index f3d8d0e..3f4d9b4 100644
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -23,11 +23,29 @@ swiotlb_map_single_phys(struct device *hwdev, phys_addr_t paddr, size_t size,
 static void *x86_swiotlb_alloc_coherent(struct device *dev, size_t size,
 					dma_addr_t *dma_handle, gfp_t gfp)
 {
+	unsigned long dma_mask;
+
+	gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
+
 	if (!dev) {
 		dev = &x86_dma_fallback_dev;
 		gfp |= GFP_DMA;
 	}
 
+	if (!dev->dma_mask)
+		return NULL;
+
+	dma_mask = dev->coherent_dma_mask;
+	if (!dma_mask)
+		dma_mask = gfp & GFP_DMA ? DMA_24BIT_MASK : DMA_32BIT_MASK;
+
+	if (!(gfp & GFP_DMA)) {
+		if (dma_mask <= DMA_24BIT_MASK)
+			gfp |= GFP_DMA;
+		else if (dma_mask <= DMA_32BIT_MASK)
+			gfp |= GFP_DMA32;
+	}
+
 	return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
 }
 
-- 
1.5.5.GIT

--
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