From 2129b72396568a8932bab25b6d9b37fe1ccc88cc Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Fri, 26 Jan 2018 14:28:34 +0900 Subject: [PATCH] media: mfc: support kernel 4.14 - add VIDEOBUF2_DMA_SG dependency - remove videobuf2_ion - remove unnecessary cache control - change vb2_memops - remove vb2_ion_buf_prepare/finish - use __dma_map_area for clean/invalidate - use vb2_dma_sg_plane_dma_addr to get daddr Change-Id: I46e70140df56435060469ebbfab45e9a2226d1a1 Signed-off-by: Jeonghee Kim --- drivers/media/platform/exynos/mfc/Kconfig | 1 + .../media/platform/exynos/mfc/s5p_mfc_buf.c | 6 --- .../platform/exynos/mfc/s5p_mfc_common.h | 3 ++ .../platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c | 9 +--- .../platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c | 4 -- .../media/platform/exynos/mfc/s5p_mfc_mem.c | 44 ++----------------- .../media/platform/exynos/mfc/s5p_mfc_mem.h | 20 ++------- 7 files changed, 12 insertions(+), 75 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/Kconfig b/drivers/media/platform/exynos/mfc/Kconfig index 4f9629054558..9cf647720113 100644 --- a/drivers/media/platform/exynos/mfc/Kconfig +++ b/drivers/media/platform/exynos/mfc/Kconfig @@ -3,6 +3,7 @@ config VIDEO_EXYNOS_MFC default n depends on VIDEO_EXYNOS select VIDEOBUF2_CORE + select VIDEOBUF2_DMA_SG select EXYNOS_MFC_V12 ---help--- MFC driver for V4L2. diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c b/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c index cc633c59811c..e02581d0a5dc 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c @@ -528,7 +528,6 @@ static int mfc_alloc_enc_roi_buffer(struct s5p_mfc_ctx *ctx, struct s5p_mfc_spec } memset(roi_buf->vaddr, 0, buf_size->shared_buf); - s5p_mfc_mem_clean(dev, roi_buf, 0, roi_buf->size); return 0; } @@ -586,7 +585,6 @@ int s5p_mfc_otf_alloc_stream_buf(struct s5p_mfc_ctx *ctx) return -EINVAL; } memset(buf->vaddr, 0, raw->total_plane_size); - s5p_mfc_mem_clean(dev, buf, 0, buf->size); } mfc_debug_leave(); @@ -722,13 +720,9 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev) } memcpy(dev->fw_buf.vaddr, fw_blob->data, fw_blob->size); - s5p_mfc_mem_clean(dev, &dev->fw_buf, 0, fw_blob->size); - s5p_mfc_mem_invalidate(dev, &dev->fw_buf, 0, fw_blob->size); if (dev->drm_fw_buf.vaddr) { memcpy(dev->drm_fw_buf.vaddr, fw_blob->data, fw_blob->size); mfc_debug(2, "copy firmware to secure region\n"); - s5p_mfc_mem_clean(dev, &dev->drm_fw_buf, 0, fw_blob->size); - s5p_mfc_mem_invalidate(dev, &dev->drm_fw_buf, 0, fw_blob->size); } release_firmware(fw_blob); trace_mfc_loadfw_end(dev->fw.size, firmware_size); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h index 218fc9c6a8f6..063e26f4f060 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include #include "s5p_mfc_regs_v10.h" #include "s5p_mfc_macros.h" diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c index f3e77bb27529..b545fdeef2be 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c @@ -279,8 +279,6 @@ static int s5p_mfc_dec_buf_prepare(struct vb2_buffer *vb) mfc_err_ctx("failed in to_buf_ctrls\n"); } - s5p_mfc_mem_buf_prepare(vb); - return 0; } @@ -302,8 +300,6 @@ static void s5p_mfc_dec_buf_finish(struct vb2_buffer *vb) if (call_cop(ctx, to_ctx_ctrls, ctx, &ctx->src_ctrls[index]) < 0) mfc_err_ctx("failed in to_ctx_ctrls\n"); } - - s5p_mfc_mem_buf_finish(vb); } static void s5p_mfc_dec_buf_cleanup(struct vb2_buffer *vb) @@ -586,10 +582,9 @@ static void s5p_mfc_dec_buf_queue(struct vb2_buffer *vb) s5p_mfc_mem_get_daddr_vb(vb, 0), buf->addr[0]); if (dec->dst_memtype == V4L2_MEMORY_DMABUF && - ctx->state < MFCINST_HEAD_PARSED && !ctx->is_drm) { + ctx->state < MFCINST_HEAD_PARSED && !ctx->is_drm) stream_vir = vb2_plane_vaddr(vb, 0); - s5p_mfc_mem_inv_vb(vb, 1); - } + buf->vir_addr = stream_vir; s5p_mfc_add_tail_buf(&ctx->buf_queue_lock, &ctx->src_buf_queue, buf); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c index cb4d4c9a1ec3..0a87654fd8c6 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c @@ -238,8 +238,6 @@ static int s5p_mfc_enc_buf_prepare(struct vb2_buffer *vb) return -EINVAL; } - s5p_mfc_mem_buf_prepare(vb); - mfc_debug_leave(); return 0; @@ -259,8 +257,6 @@ static void s5p_mfc_enc_buf_finish(struct vb2_buffer *vb) if (call_cop(ctx, to_ctx_ctrls, ctx, &ctx->src_ctrls[index]) < 0) mfc_err_ctx("failed in to_ctx_ctrls\n"); } - - s5p_mfc_mem_buf_finish(vb); } static void s5p_mfc_enc_buf_cleanup(struct vb2_buffer *vb) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_mem.c b/drivers/media/platform/exynos/mfc/s5p_mfc_mem.c index ace5b48f4e77..4e36bd09d165 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_mem.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_mem.c @@ -14,15 +14,14 @@ struct vb2_mem_ops *s5p_mfc_mem_ops(void) { - return (struct vb2_mem_ops *)&vb2_ion_memops; + return (struct vb2_mem_ops *)&vb2_dma_sg_memops; } void s5p_mfc_mem_clean(struct s5p_mfc_dev *dev, struct s5p_mfc_special_buf *special_buf, off_t offset, size_t size) { - exynos_ion_sync_vaddr_for_device(dev->device, special_buf->dma_buf, - special_buf->vaddr, size, offset, DMA_TO_DEVICE); + __dma_map_area(special_buf->vaddr + offset, size, DMA_TO_DEVICE); return; } @@ -30,47 +29,10 @@ void s5p_mfc_mem_invalidate(struct s5p_mfc_dev *dev, struct s5p_mfc_special_buf *special_buf, off_t offset, size_t size) { - exynos_ion_sync_vaddr_for_device(dev->device, special_buf->dma_buf, - special_buf->vaddr, size, offset, DMA_FROM_DEVICE); + __dma_map_area(special_buf->vaddr + offset, size, DMA_FROM_DEVICE); return; } -int s5p_mfc_mem_clean_vb(struct vb2_buffer *vb, u32 num_planes) -{ - struct vb2_ion_cookie *cookie; - int i; - size_t size; - - for (i = 0; i < num_planes; i++) { - cookie = vb2_plane_cookie(vb, i); - if (!cookie) - continue; - - size = vb->planes[i].length; - vb2_ion_sync_for_device(cookie, 0, size, DMA_TO_DEVICE); - } - - return 0; -} - -int s5p_mfc_mem_inv_vb(struct vb2_buffer *vb, u32 num_planes) -{ - struct vb2_ion_cookie *cookie; - int i; - size_t size; - - for (i = 0; i < num_planes; i++) { - cookie = vb2_plane_cookie(vb, i); - if (!cookie) - continue; - - size = vb->planes[i].length; - vb2_ion_sync_for_device(cookie, 0, size, DMA_FROM_DEVICE); - } - - return 0; -} - int s5p_mfc_mem_get_user_shared_handle(struct s5p_mfc_ctx *ctx, struct mfc_user_shared_handle *handle) { diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_mem.h b/drivers/media/platform/exynos/mfc/s5p_mfc_mem.h index 18f0020482d8..add0548296fb 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_mem.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_mem.h @@ -13,8 +13,6 @@ #ifndef __S5P_MFC_MEM_H #define __S5P_MFC_MEM_H __FILE__ -#include - #include "s5p_mfc_common.h" /* Offset base used to differentiate between CAPTURE and OUTPUT @@ -22,26 +20,16 @@ #define DST_QUEUE_OFF_BASE (TASK_SIZE / 2) static inline dma_addr_t s5p_mfc_mem_get_daddr_vb( - struct vb2_buffer *v, unsigned int n) + struct vb2_buffer *vb, unsigned int n) { - void *cookie = vb2_plane_cookie(v, n); dma_addr_t addr = 0; - WARN_ON(vb2_ion_dma_address(cookie, &addr) != 0); + addr = vb2_dma_sg_plane_dma_addr(vb, n); + WARN_ON((addr == 0) || IS_ERR_VALUE(addr)); return addr; } -static inline int s5p_mfc_mem_buf_prepare(struct vb2_buffer *vb) -{ - return vb2_ion_buf_prepare(vb); -} - -static inline void s5p_mfc_mem_buf_finish(struct vb2_buffer *vb) -{ - vb2_ion_buf_finish(vb); -} - struct vb2_mem_ops *s5p_mfc_mem_ops(void); void s5p_mfc_mem_set_cacheable(bool cacheable); @@ -51,8 +39,6 @@ void s5p_mfc_mem_clean(struct s5p_mfc_dev *dev, void s5p_mfc_mem_invalidate(struct s5p_mfc_dev *dev, struct s5p_mfc_special_buf *specail_buf, off_t offset, size_t size); -int s5p_mfc_mem_clean_vb(struct vb2_buffer *vb, u32 num_planes); -int s5p_mfc_mem_inv_vb(struct vb2_buffer *vb, u32 num_planes); int s5p_mfc_mem_get_user_shared_handle(struct s5p_mfc_ctx *ctx, struct mfc_user_shared_handle *handle); -- 2.20.1