summaryrefslogtreecommitdiffstats
path: root/kernel/dma
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-11-09 15:47:56 +0100
committerChristoph Hellwig <hch@lst.de>2021-12-07 12:50:06 +0100
commit955f58f7406ad912825fc344c7825fd904b124a0 (patch)
treea23e035d3fd7886c708f7bb0937990e0d30267bd /kernel/dma
parentdma-direct: refactor the !coherent checks in dma_direct_alloc (diff)
downloadlinux-955f58f7406ad912825fc344c7825fd904b124a0.tar.xz
linux-955f58f7406ad912825fc344c7825fd904b124a0.zip
dma-direct: fail allocations that can't be made coherent
If the architecture can't remap or set an address uncached there is no way to fullfill a request for a coherent allocation. Return NULL in that case. Note that this case currently does not happen, so this is a theoretical fixup and/or a preparation for eventually supporting platforms that can't support coherent allocations with the generic code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Diffstat (limited to 'kernel/dma')
-rw-r--r--kernel/dma/direct.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index f9658fe18498..a13017656eca 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -233,8 +233,9 @@ void *dma_direct_alloc(struct device *dev, size_t size,
return dma_direct_alloc_from_pool(dev, size,
dma_handle, gfp);
} else {
- if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED))
- set_uncached = true;
+ if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED))
+ return NULL;
+ set_uncached = true;
}
}