forked from Minki/linux
dma-direct: warn if there is no pool for force unencrypted allocations
Instead of blindly running into a blocking operation for a non-blocking gfp, return NULL and spew an error. Note that Kconfig prevents this for all currently relevant platforms, and this is just a debug check. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
This commit is contained in:
parent
955f58f740
commit
78bc72787a
@ -159,6 +159,9 @@ static void *dma_direct_alloc_from_pool(struct device *dev, size_t size,
|
||||
u64 phys_mask;
|
||||
void *ret;
|
||||
|
||||
if (WARN_ON_ONCE(!IS_ENABLED(CONFIG_DMA_COHERENT_POOL)))
|
||||
return NULL;
|
||||
|
||||
gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
|
||||
&phys_mask);
|
||||
page = dma_alloc_from_pool(dev, size, &ret, gfp, dma_coherent_ok);
|
||||
@ -243,8 +246,7 @@ void *dma_direct_alloc(struct device *dev, size_t size,
|
||||
* Decrypting memory may block, so allocate the memory from the atomic
|
||||
* pools if we can't block.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) &&
|
||||
force_dma_unencrypted(dev) && !gfpflags_allow_blocking(gfp) &&
|
||||
if (force_dma_unencrypted(dev) && !gfpflags_allow_blocking(gfp) &&
|
||||
!is_swiotlb_for_alloc(dev))
|
||||
return dma_direct_alloc_from_pool(dev, size, dma_handle, gfp);
|
||||
|
||||
@ -354,8 +356,7 @@ struct page *dma_direct_alloc_pages(struct device *dev, size_t size,
|
||||
struct page *page;
|
||||
void *ret;
|
||||
|
||||
if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) &&
|
||||
force_dma_unencrypted(dev) && !gfpflags_allow_blocking(gfp) &&
|
||||
if (force_dma_unencrypted(dev) && !gfpflags_allow_blocking(gfp) &&
|
||||
!is_swiotlb_for_alloc(dev))
|
||||
return dma_direct_alloc_from_pool(dev, size, dma_handle, gfp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user