mirror of
https://github.com/torvalds/linux
synced 2024-09-06 18:01:05 +00:00
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>
This commit is contained in:
parent
61afafe8b9
commit
e61c451476
|
@ -166,6 +166,7 @@ static inline void dma_pernuma_cma_reserve(void) { }
|
|||
#ifdef CONFIG_DMA_DECLARE_COHERENT
|
||||
int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
|
||||
dma_addr_t device_addr, size_t size);
|
||||
void dma_release_coherent_memory(struct device *dev);
|
||||
int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size,
|
||||
dma_addr_t *dma_handle, void **ret);
|
||||
int dma_release_from_dev_coherent(struct device *dev, int order, void *vaddr);
|
||||
|
@ -177,6 +178,8 @@ static inline int dma_declare_coherent_memory(struct device *dev,
|
|||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
#define dma_release_coherent_memory(dev) (0)
|
||||
#define dma_alloc_from_dev_coherent(dev, size, handle, ret) (0)
|
||||
#define dma_release_from_dev_coherent(dev, order, vaddr) (0)
|
||||
#define dma_mmap_from_dev_coherent(dev, vma, vaddr, order, ret) (0)
|
||||
|
|
|
@ -74,7 +74,7 @@ static struct dma_coherent_mem *dma_init_coherent_memory(phys_addr_t phys_addr,
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue