lkml.org 
[lkml]   [2022]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 1/2] dma-mapping: check dma_mask for streaming mapping allocs
For newly added streaming mapping APIs, the internal core function
__dma_alloc_pages() should check dev->dma_mask, but not
ev->coherent_dma_mask which is for coherent mapping.

Meanwhile, just filter out gfp flags if they are any of
__GFP_DMA, __GFP_DMA32 and __GFP_HIGHMEM, but not fail it. This change
makes it consistent with coherent mapping allocs.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
kernel/dma/mapping.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 9478eccd1c8e..e66847aeac67 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -543,10 +543,11 @@ static struct page *__dma_alloc_pages(struct device *dev, size_t size,
{
const struct dma_map_ops *ops = get_dma_ops(dev);

- if (WARN_ON_ONCE(!dev->coherent_dma_mask))
- return NULL;
- if (WARN_ON_ONCE(gfp & (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM)))
- return NULL;
+ if (WARN_ON_ONCE(!dev->dma_mask))
+ return NULL;
+
+ /* let the implementation decide on the zone to allocate from: */
+ gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);

size = PAGE_ALIGN(size);
if (dma_alloc_direct(dev, ops))
--
2.31.1
\
 
 \ /
  Last update: 2022-02-22 14:42    [W:2.621 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site