diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-09-15 11:08:16 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2017-09-17 11:20:02 -0400 |
commit | 6d57339890c9a9dfcd4ba4f8931b911b962968e3 (patch) | |
tree | 11af5efc5550b5a67d6ef618dd49d1cb07a7d9e0 | |
parent | 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e (diff) |
dma-coherent: fix rmem_dma_device_init regression
My recent bug fix introduced another bug, which caused rmem_dma_device_init
to always fail, as rmem->priv is never set to anything.
This restores the previous behavior, calling dma_init_coherent_memory()
whenever ->priv is NULL.
Fixes: d35b0996fef3 ("dma-coherent: fix dma_declare_coherent_memory() logic error")
Reported-by: Roy Pledge <roy.pledge@nxp.com>
Tested-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | drivers/base/dma-coherent.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index a39b2166b145..744f64f43454 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c | |||
@@ -348,16 +348,15 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) | |||
348 | struct dma_coherent_mem *mem = rmem->priv; | 348 | struct dma_coherent_mem *mem = rmem->priv; |
349 | int ret; | 349 | int ret; |
350 | 350 | ||
351 | if (!mem) | 351 | if (!mem) { |
352 | return -ENODEV; | 352 | ret = dma_init_coherent_memory(rmem->base, rmem->base, |
353 | 353 | rmem->size, | |
354 | ret = dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, | 354 | DMA_MEMORY_EXCLUSIVE, &mem); |
355 | DMA_MEMORY_EXCLUSIVE, &mem); | 355 | if (ret) { |
356 | 356 | pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n", | |
357 | if (ret) { | 357 | &rmem->base, (unsigned long)rmem->size / SZ_1M); |
358 | pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n", | 358 | return ret; |
359 | &rmem->base, (unsigned long)rmem->size / SZ_1M); | 359 | } |
360 | return ret; | ||
361 | } | 360 | } |
362 | mem->use_dev_dma_pfn_offset = true; | 361 | mem->use_dev_dma_pfn_offset = true; |
363 | rmem->priv = mem; | 362 | rmem->priv = mem; |