diff options
author | Christoph Hellwig <hch@lst.de> | 2022-11-09 08:37:17 +0100 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2022-11-21 09:37:20 +0100 |
commit | ffcb754584603adf7039d7972564fbf6febdc542 (patch) | |
tree | ffcb4184b490a6559a16baea06020804da298c80 /kernel/dma | |
parent | 3306877aff07363f9bede7f9edf2c4ea4f5b20be (diff) | |
download | linux-stable-ffcb754584603adf7039d7972564fbf6febdc542.tar.gz linux-stable-ffcb754584603adf7039d7972564fbf6febdc542.tar.bz2 linux-stable-ffcb754584603adf7039d7972564fbf6febdc542.zip |
dma-mapping: reject __GFP_COMP in dma_alloc_attrs
DMA allocations can never be turned back into a page pointer, so
requesting compound pages doesn't make sense and it can't even be
supported at all by various backends.
Reject __GFP_COMP with a warning in dma_alloc_attrs, and stop clearing
the flag in the arm dma ops and dma-iommu.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'kernel/dma')
-rw-r--r-- | kernel/dma/mapping.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index 33437d620644..c026a5a5e046 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -498,6 +498,14 @@ void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, WARN_ON_ONCE(!dev->coherent_dma_mask); + /* + * DMA allocations can never be turned back into a page pointer, so + * requesting compound pages doesn't make sense (and can't even be + * supported at all by various backends). + */ + if (WARN_ON_ONCE(flag & __GFP_COMP)) + return NULL; + if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr)) return cpu_addr; |