Skip to content

Commit

Permalink
dma-direct: fail allocations that can't be made coherent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig committed Dec 7, 2021
1 parent a86d109 commit 955f58f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 955f58f

Please sign in to comment.