Skip to content

Commit 580ccca

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/pages: Move the __GFP_HIGHMEM checks into the common code
The entire allocator API is built around using the kernel virtual address, it is illegal to pass GFP_HIGHMEM in as a GFP flag. Block it in the common code. Remove the duplicated checks from drivers. Reviewed-by: Lu Baolu <[email protected]> Reviewed-by: Mostafa Saleh <[email protected]> Tested-by: Nicolin Chen <[email protected]> Tested-by: Alejandro Jimenez <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 212fcf3 commit 580ccca

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp,
267267
dma_addr_t dma;
268268
void *pages;
269269

270-
VM_BUG_ON((gfp & __GFP_HIGHMEM));
271-
272270
if (cfg->alloc)
273271
pages = cfg->alloc(cookie, size, gfp);
274272
else

drivers/iommu/io-pgtable-dart.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ static void *__dart_alloc_pages(size_t size, gfp_t gfp)
111111
{
112112
int order = get_order(size);
113113

114-
VM_BUG_ON((gfp & __GFP_HIGHMEM));
115114
return iommu_alloc_pages(gfp, order);
116115
}
117116

drivers/iommu/iommu-pages.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ void *iommu_alloc_pages_node(int nid, gfp_t gfp, unsigned int order)
3737
const unsigned long pgcnt = 1UL << order;
3838
struct folio *folio;
3939

40+
/* This uses page_address() on the memory. */
41+
if (WARN_ON(gfp & __GFP_HIGHMEM))
42+
return NULL;
43+
4044
/*
4145
* __folio_alloc_node() does not handle NUMA_NO_NODE like
4246
* alloc_pages_node() did.

0 commit comments

Comments
 (0)