From 7320d348ef89d88b207137a7ef33dac592cfa9d0 Mon Sep 17 00:00:00 2001 From: Jiyu Yang Date: Fri, 24 Apr 2020 14:37:48 +0800 Subject: [PATCH] gpu: update video texture [2/3] PD#SWPL-24168 Problem: no video texture update Solution: update it before gpu read Verify: P212BT15501 Change-Id: Id578f2df126f9051489aa6ff01ddb40f103b9860 Signed-off-by: Jiyu Yang --- gpu-build.sh | 31 ++++++++++++++++ mali/include/linux/mali/mali_utgard_ioctl.h | 1 + .../include/linux/mali/mali_utgard_uk_types.h | 6 ++++ mali/linux/mali_kernel_linux.c | 5 +++ mali/linux/mali_memory_dma_buf.c | 36 +++++++++++++++++++ mali/linux/mali_memory_dma_buf.h | 1 + mali/linux/mali_memory_manager.c | 8 +++++ mali/linux/mali_memory_manager.h | 1 + mali/linux/mali_ukk_mem.c | 22 ++++++++++++ mali/linux/mali_ukk_wrappers.h | 1 + 10 files changed, 112 insertions(+) create mode 100755 gpu-build.sh diff --git a/gpu-build.sh b/gpu-build.sh new file mode 100755 index 0000000..c78b57e --- /dev/null +++ b/gpu-build.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +PRODUCT_OUT=${OUT} +SOURCE_CODE=utgard/r10p0 +MESON_GPU_DIR=./ +PREFIX_CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- +KERNEL_ARCH=arm64 +GPU_MODS_OUT=obj/lib_vendor/ + + rm ${PRODUCT_OUT}/obj/mali -rf + mkdir -p ${PRODUCT_OUT}/obj/mali + cp ${SOURCE_CODE}/* ${PRODUCT_OUT}/obj/mali -airf + cp ${MESON_GPU_DIR}/utgard/platform ${PRODUCT_OUT}/obj/mali/ -airf + echo "make mali module KERNEL_ARCH is ${KERNEL_ARCH}" + echo "make mali module MALI_OUT is ${PRODUCT_OUT}/obj/mali ${MALI_OUT}" + PATH=${TARGET_HOST_TOOL_PATH}:$PATH + make -C ${PRODUCT_OUT}/obj/KERNEL_OBJ M=${PRODUCT_OUT}/obj/mali \ + ARCH=${KERNEL_ARCH} CROSS_COMPILE=${PREFIX_CROSS_COMPILE} CONFIG_MALI400=m CONFIG_MALI450=m \ + CONFIG_MALI_DMA_BUF_LAZY_MAP=y \ + EXTRA_CFLAGS="-DCONFIG_MALI400=m -DCONFIG_MALI450=m -DCONFIG_MALI_DMA_BUF_LAZY_MAP=y" \ + EXTRA_LDFLAGS+="--strip-debug" \ + CONFIG_AM_VDEC_H264_4K2K=y 2>&1 | tee mali.txt + + echo "GPU_MODS_OUT is ${GPU_MODS_OUT}" + mkdir -p ${PRODUCT_OUT}/${GPU_MODS_OUT} + cp ${PRODUCT_OUT}/obj/mali/mali.ko ${PRODUCT_OUT}/${GPU_MODS_OUT}/mali.ko + + cp ${PRODUCT_OUT}/${GPU_MODS_OUT}/mali.ko ${PRODUCT_OUT}/obj/lib_vendor/mali.ko + echo "${GPU_ARCH}.ko build finished" + +exit diff --git a/mali/include/linux/mali/mali_utgard_ioctl.h b/mali/include/linux/mali/mali_utgard_ioctl.h index dfe152b..5d02293 100755 --- a/mali/include/linux/mali/mali_utgard_ioctl.h +++ b/mali/include/linux/mali/mali_utgard_ioctl.h @@ -73,6 +73,7 @@ extern "C" { #define MALI_IOC_MEM_QUERY_MMU_PAGE_TABLE_DUMP_SIZE _IOR (MALI_IOC_MEMORY_BASE, _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, _mali_uk_query_mmu_page_table_dump_size_s) #define MALI_IOC_MEM_DUMP_MMU_PAGE_TABLE _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_DUMP_MMU_PAGE_TABLE, _mali_uk_dump_mmu_page_table_s) #define MALI_IOC_MEM_WRITE_SAFE _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_MEM_WRITE_SAFE, _mali_uk_mem_write_safe_s) +#define MALI_IOC_MESON_UPDATE_VIDEO_TEXTURE _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_MESON_UPDATE_VIDEO_TEXTURE, _meson_update_video_texture_s) #define MALI_IOC_PP_START_JOB _IOWR(MALI_IOC_PP_BASE, _MALI_UK_PP_START_JOB, _mali_uk_pp_start_job_s) #define MALI_IOC_PP_AND_GP_START_JOB _IOWR(MALI_IOC_PP_BASE, _MALI_UK_PP_AND_GP_START_JOB, _mali_uk_pp_and_gp_start_job_s) diff --git a/mali/include/linux/mali/mali_utgard_uk_types.h b/mali/include/linux/mali/mali_utgard_uk_types.h index 99835a5..dc0dfa1 100755 --- a/mali/include/linux/mali/mali_utgard_uk_types.h +++ b/mali/include/linux/mali/mali_utgard_uk_types.h @@ -108,6 +108,7 @@ typedef enum { _MALI_UK_DUMP_MMU_PAGE_TABLE, /**< _mali_ukk_mem_dump_mmu_page_table() */ _MALI_UK_DMA_BUF_GET_SIZE, /**< _mali_ukk_dma_buf_get_size() */ _MALI_UK_MEM_WRITE_SAFE, /**< _mali_uku_mem_write_safe() */ + _MALI_UK_MESON_UPDATE_VIDEO_TEXTURE, /**< _mali_uku_meson_update_video_texture() */ /** Common functions for each core */ @@ -824,6 +825,11 @@ typedef struct { u32 vaddr; /**< [in] identifier for mapped memory object in kernel space */ } _mali_uk_unbind_mem_s; +typedef struct { + u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ + s32 fd; /**< [in] dma fd */ +} _meson_update_video_texture_s; + typedef struct { u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ u32 target_handle; /**< [in] handle of allocation need to do COW */ diff --git a/mali/linux/mali_kernel_linux.c b/mali/linux/mali_kernel_linux.c index 4a0b9e8..78f08e7 100644 --- a/mali/linux/mali_kernel_linux.c +++ b/mali/linux/mali_kernel_linux.c @@ -1011,6 +1011,11 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, err = mem_free_wrapper(session_data, (_mali_uk_free_mem_s __user *)arg); break; + case MALI_IOC_MESON_UPDATE_VIDEO_TEXTURE: + BUILD_BUG_ON(!IS_ALIGNED(sizeof(_meson_update_video_texture_s), sizeof(s32))); + err = meson_mem_start_wrapper(session_data, (_meson_update_video_texture_s __user *)arg); + break; + case MALI_IOC_MEM_BIND: BUILD_BUG_ON(!IS_ALIGNED(sizeof(_mali_uk_bind_mem_s), sizeof(u64))); err = mem_bind_wrapper(session_data, (_mali_uk_bind_mem_s __user *)arg); diff --git a/mali/linux/mali_memory_dma_buf.c b/mali/linux/mali_memory_dma_buf.c index 59107fa..d4f79ae 100755 --- a/mali/linux/mali_memory_dma_buf.c +++ b/mali/linux/mali_memory_dma_buf.c @@ -401,3 +401,39 @@ void mali_mem_unbind_dma_buf(mali_mem_backend *mem_backend) _mali_osk_free(mem); mali_session_memory_unlock(session); } + +_mali_osk_errcode_t meson_update_video_texture(struct mali_session_data *session, int fd) +{ + struct dma_buf *buf; + struct dma_buf_attachment *attachment; + struct sg_table *sgt; + _mali_osk_errcode_t ret = _MALI_OSK_ERR_OK; + + /* get dma buffer */ + buf = dma_buf_get(fd); + if (IS_ERR_OR_NULL(buf)) { + return _MALI_OSK_ERR_FAULT; + } + + attachment = dma_buf_attach(buf, &mali_platform_device->dev); + if (NULL == attachment) { + ret = _MALI_OSK_ERR_FAULT; + goto failed_dma_attach; + } + + sgt = dma_buf_map_attachment(attachment, DMA_BIDIRECTIONAL); + if (IS_ERR_OR_NULL(sgt)) { + MALI_DEBUG_PRINT_ERROR(("Failed to map dma-buf attachment\n")); + ret = _MALI_OSK_ERR_FAULT; + return -EFAULT; + } + + dma_buf_unmap_attachment(attachment, sgt, DMA_BIDIRECTIONAL); + sgt = NULL; + + dma_buf_detach(buf, attachment); +failed_dma_attach: + dma_buf_put(buf); + + return ret; +} diff --git a/mali/linux/mali_memory_dma_buf.h b/mali/linux/mali_memory_dma_buf.h index 37b6f6b..4110ef6 100755 --- a/mali/linux/mali_memory_dma_buf.h +++ b/mali/linux/mali_memory_dma_buf.h @@ -36,6 +36,7 @@ struct mali_dma_buf_attachment { int mali_dma_buf_get_size(struct mali_session_data *session, _mali_uk_dma_buf_get_size_s __user *arg); void mali_mem_unbind_dma_buf(mali_mem_backend *mem_backend); +_mali_osk_errcode_t meson_update_video_texture(struct mali_session_data *session, int fd); _mali_osk_errcode_t mali_mem_bind_dma_buf(mali_mem_allocation *alloc, mali_mem_backend *mem_backend, diff --git a/mali/linux/mali_memory_manager.c b/mali/linux/mali_memory_manager.c index 10d367e..621ff15 100644 --- a/mali/linux/mali_memory_manager.c +++ b/mali/linux/mali_memory_manager.c @@ -810,6 +810,14 @@ _mali_osk_errcode_t _mali_ukk_mem_unbind(_mali_uk_unbind_mem_s *args) return _MALI_OSK_ERR_OK; } +_mali_osk_errcode_t _meson_update_video_texture(_meson_update_video_texture_s *args) +{ + struct mali_session_data *session = (struct mali_session_data *)(uintptr_t)args->ctx; + int fd = args->fd; + + return meson_update_video_texture(session, fd); +} + /* * Function _mali_ukk_mem_cow -- COW for an allocation * This function allocate new pages for a range (range, range+size) of allocation diff --git a/mali/linux/mali_memory_manager.h b/mali/linux/mali_memory_manager.h index caccd9e..dd535aa 100644 --- a/mali/linux/mali_memory_manager.h +++ b/mali/linux/mali_memory_manager.h @@ -43,6 +43,7 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args); _mali_osk_errcode_t _mali_ukk_mem_free(_mali_uk_free_mem_s *args); _mali_osk_errcode_t _mali_ukk_mem_bind(_mali_uk_bind_mem_s *args); _mali_osk_errcode_t _mali_ukk_mem_unbind(_mali_uk_unbind_mem_s *args); +_mali_osk_errcode_t _meson_update_video_texture(_meson_update_video_texture_s *args); _mali_osk_errcode_t _mali_ukk_mem_cow(_mali_uk_cow_mem_s *args); _mali_osk_errcode_t _mali_ukk_mem_cow_modify_range(_mali_uk_cow_modify_range_s *args); _mali_osk_errcode_t _mali_ukk_mem_usage_get(_mali_uk_profiling_memory_usage_get_s *args); diff --git a/mali/linux/mali_ukk_mem.c b/mali/linux/mali_ukk_mem.c index 440b477..40189bd 100755 --- a/mali/linux/mali_ukk_mem.c +++ b/mali/linux/mali_ukk_mem.c @@ -74,6 +74,28 @@ int mem_free_wrapper(struct mali_session_data *session_data, _mali_uk_free_mem_s return 0; } +int meson_mem_start_wrapper(struct mali_session_data *session_data, _meson_update_video_texture_s __user *uargs) +{ + _meson_update_video_texture_s kargs; + _mali_osk_errcode_t err; + + MALI_CHECK_NON_NULL(uargs, -EINVAL); + MALI_CHECK_NON_NULL(session_data, -EINVAL); + + if (0 != copy_from_user(&kargs, uargs, sizeof(_meson_update_video_texture_s))) { + return -EFAULT; + } + kargs.ctx = (uintptr_t)session_data; + + err = _meson_update_video_texture(&kargs); + + if (_MALI_OSK_ERR_OK != err) { + return map_errcode(err); + } + + return 0; +} + int mem_bind_wrapper(struct mali_session_data *session_data, _mali_uk_bind_mem_s __user *uargs) { _mali_uk_bind_mem_s kargs; diff --git a/mali/linux/mali_ukk_wrappers.h b/mali/linux/mali_ukk_wrappers.h index 7e59346..b94c764 100755 --- a/mali/linux/mali_ukk_wrappers.h +++ b/mali/linux/mali_ukk_wrappers.h @@ -33,6 +33,7 @@ int pending_submit_wrapper(struct mali_session_data *session_data, _mali_uk_pend int mem_alloc_wrapper(struct mali_session_data *session_data, _mali_uk_alloc_mem_s __user *uargs); int mem_free_wrapper(struct mali_session_data *session_data, _mali_uk_free_mem_s __user *uargs); +int meson_mem_start_wrapper(struct mali_session_data *session_data, _meson_update_video_texture_s __user *uargs); int mem_bind_wrapper(struct mali_session_data *session_data, _mali_uk_bind_mem_s __user *uargs); int mem_unbind_wrapper(struct mali_session_data *session_data, _mali_uk_unbind_mem_s __user *uargs); int mem_cow_wrapper(struct mali_session_data *session_data, _mali_uk_cow_mem_s __user *uargs); -- 2.20.1