lkml.org 
[lkml]   [2008]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] x86: set gfp flag properly for swiotlb_alloc_coherent
Date
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@lab.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


\
 
 \ /
  Last update: 2008-09-03 20:17    [W:0.116 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site