diff options
author | Mark-PK Tsai <mark-pk.tsai@mediatek.com> | 2022-04-22 14:24:35 +0800 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2022-06-24 09:30:54 -0600 |
commit | e61c451476e61450f6771ce03bbc01210a09be16 (patch) | |
tree | 7347f4d88b007cd396b20aeed9037b94e4b9bfe1 /kernel/dma | |
parent | 61afafe8b938bc74841cf4b1a73dd08b9d287c5a (diff) |
dma-mapping: Add dma_release_coherent_memory to DMA API
Add dma_release_coherent_memory to DMA API to allow dma
user call it to release dev->dma_mem when the device is
removed.
Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220422062436.14384-2-mark-pk.tsai@mediatek.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'kernel/dma')
-rw-r--r-- | kernel/dma/coherent.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c index 375fb3c9538d..c21abc77c53e 100644 --- a/kernel/dma/coherent.c +++ b/kernel/dma/coherent.c @@ -74,7 +74,7 @@ out_unmap_membase: return ERR_PTR(-ENOMEM); } -static void dma_release_coherent_memory(struct dma_coherent_mem *mem) +static void _dma_release_coherent_memory(struct dma_coherent_mem *mem) { if (!mem) return; @@ -126,10 +126,16 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, ret = dma_assign_coherent_memory(dev, mem); if (ret) - dma_release_coherent_memory(mem); + _dma_release_coherent_memory(mem); return ret; } +void dma_release_coherent_memory(struct device *dev) +{ + if (dev) + _dma_release_coherent_memory(dev->dma_mem); +} + static void *__dma_alloc_from_coherent(struct device *dev, struct dma_coherent_mem *mem, ssize_t size, dma_addr_t *dma_handle) |