Skip to content

Commit d01501f

Browse files
Maciej W. Rozyckipaulburton
authored andcommitted
MIPS: Fix `dma_alloc_coherent' returning a non-coherent allocation
Fix a MIPS `dma_alloc_coherent' regression from commit bc3ec75 ("dma-mapping: merge direct and noncoherent ops") that causes a cached allocation to be returned on noncoherent cache systems. This is due to an inverted check now used in the MIPS implementation of `arch_dma_alloc' on the result from `dma_direct_alloc_pages' before doing the cached-to-uncached mapping of the allocation address obtained. The mapping has to be done for a non-NULL rather than NULL result, because a NULL result means the allocation has failed. Invert the check for correct operation then. Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Signed-off-by: Paul Burton <paul.burton@mips.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Fixes: bc3ec75 ("dma-mapping: merge direct and noncoherent ops") Patchwork: https://patchwork.linux-mips.org/patch/20965/
1 parent c0fae7e commit d01501f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/mips/mm/dma-noncoherent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void *arch_dma_alloc(struct device *dev, size_t size,
5050
void *ret;
5151

5252
ret = dma_direct_alloc_pages(dev, size, dma_handle, gfp, attrs);
53-
if (!ret && !(attrs & DMA_ATTR_NON_CONSISTENT)) {
53+
if (ret && !(attrs & DMA_ATTR_NON_CONSISTENT)) {
5454
dma_cache_wback_inv((unsigned long) ret, size);
5555
ret = (void *)UNCAC_ADDR(ret);
5656
}

0 commit comments

Comments
 (0)