From d15513be2cd436e0f7ab02ee8c67a322fccdf59a Mon Sep 17 00:00:00 2001 From: Ding Wei Date: Mon, 15 Mar 2021 15:19:46 +0800 Subject: [PATCH] video: rockchip: mpp: Modify mpp_dma interface Change-Id: Ia7b45daaa120a1f3bbb3adf9c2decda4f71d8c60 Signed-off-by: Ding Wei Signed-off-by: Herman Chen --- drivers/video/rockchip/mpp/mpp_iommu.c | 19 +++++++++---------- drivers/video/rockchip/mpp/mpp_iommu.h | 7 ++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/video/rockchip/mpp/mpp_iommu.c b/drivers/video/rockchip/mpp/mpp_iommu.c index aa4603c96017..37f6293da871 100644 --- a/drivers/video/rockchip/mpp/mpp_iommu.c +++ b/drivers/video/rockchip/mpp/mpp_iommu.c @@ -125,7 +125,7 @@ int mpp_dma_release_fd(struct mpp_dma_session *dma, int fd) } struct mpp_dma_buffer * -mpp_dma_alloc(struct mpp_dma_session *dma, size_t size) +mpp_dma_alloc(struct device *dev, size_t size) { size_t align_size; dma_addr_t iova; @@ -136,15 +136,13 @@ mpp_dma_alloc(struct mpp_dma_session *dma, size_t size) return NULL; align_size = PAGE_ALIGN(size); - buffer->vaddr = dma_alloc_coherent(dma->dev, - align_size, - &iova, - GFP_KERNEL); + buffer->vaddr = dma_alloc_coherent(dev, align_size, &iova, GFP_KERNEL); if (!buffer->vaddr) goto fail_dma_alloc; - buffer->size = PAGE_ALIGN(size); + buffer->size = align_size; buffer->iova = iova; + buffer->dev = dev; return buffer; fail_dma_alloc: @@ -152,14 +150,15 @@ fail_dma_alloc: return NULL; } -int mpp_dma_free(struct mpp_dma_session *dma, - struct mpp_dma_buffer *buffer) +int mpp_dma_free(struct mpp_dma_buffer *buffer) { - dma_free_coherent(dma->dev, buffer->size, - buffer->vaddr, buffer->iova); + dma_free_coherent(buffer->dev, buffer->size, + buffer->vaddr, buffer->iova); buffer->vaddr = NULL; buffer->iova = 0; buffer->size = 0; + buffer->dev = NULL; + kfree(buffer); return 0; } diff --git a/drivers/video/rockchip/mpp/mpp_iommu.h b/drivers/video/rockchip/mpp/mpp_iommu.h index e2a738d5d988..9663ce9bf612 100644 --- a/drivers/video/rockchip/mpp/mpp_iommu.h +++ b/drivers/video/rockchip/mpp/mpp_iommu.h @@ -33,6 +33,8 @@ struct mpp_dma_buffer { struct kref ref; ktime_t last_used; + /* alloc by device */ + struct device *dev; }; struct mpp_dma_session { @@ -74,9 +76,8 @@ mpp_dma_session_create(struct device *dev); int mpp_dma_session_destroy(struct mpp_dma_session *dma); struct mpp_dma_buffer * -mpp_dma_alloc(struct mpp_dma_session *dma, size_t size); -int mpp_dma_free(struct mpp_dma_session *dma, - struct mpp_dma_buffer *buffer); +mpp_dma_alloc(struct device *dev, size_t size); +int mpp_dma_free(struct mpp_dma_buffer *buffer); struct mpp_dma_buffer * mpp_dma_import_fd(struct mpp_iommu_info *iommu_info,