From 269d8c86e90d9bcd333a715541a638b8a6db775a Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 17 Feb 2017 13:31:11 +0000 Subject: [PATCH] Implement GFP_DMA32 flag in the LinuxKPI. Define all FreeBSD native GFP bits as GFP_NATIVE_MASK. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/include/linux/dma-mapping.h | 4 +++- sys/compat/linuxkpi/common/include/linux/gfp.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h index 87bc25ed3906..1b486ec80908 100644 --- a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h +++ b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h @@ -129,8 +129,10 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, if (dev->dma_mask) high = *dev->dma_mask; - else + else if (flag & GFP_DMA32) high = BUS_SPACE_MAXADDR_32BIT; + else + high = BUS_SPACE_MAXADDR; align = PAGE_SIZE << get_order(size); mem = (void *)kmem_alloc_contig(kmem_arena, size, flag, 0, high, align, 0, VM_MEMATTR_DEFAULT); diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h index 1c73022ff13f..7840919864ea 100644 --- a/sys/compat/linuxkpi/common/include/linux/gfp.h +++ b/sys/compat/linuxkpi/common/include/linux/gfp.h @@ -53,7 +53,7 @@ #define __GFP_IO 0 #define __GFP_NO_KSWAPD 0 #define __GFP_WAIT M_WAITOK -#define __GFP_DMA32 0 +#define __GFP_DMA32 (1U << 24) /* LinuxKPI only */ #define GFP_NOWAIT M_NOWAIT #define GFP_ATOMIC (M_NOWAIT | M_USE_RESERVE) @@ -63,8 +63,9 @@ #define GFP_HIGHUSER_MOVABLE M_WAITOK #define GFP_IOFS M_NOWAIT #define GFP_NOIO M_NOWAIT -#define GFP_DMA32 0 +#define GFP_DMA32 __GFP_DMA32 #define GFP_TEMPORARY M_NOWAIT +#define GFP_NATIVE_MASK (M_NOWAIT | M_WAITOK | M_USE_RESERVE | M_ZERO) static inline void * page_address(struct page *page)