gpu: update video texture [2/3]
authorJiyu Yang <jiyu.yang@amlogic.com>
Fri, 24 Apr 2020 06:37:48 +0000 (14:37 +0800)
committerJiyu Yang <jiyu.yang@amlogic.com>
Fri, 24 Apr 2020 11:30:12 +0000 (19:30 +0800)
PD#SWPL-24168

Problem:
no video texture update

Solution:
update it before gpu read

Verify:
P212BT15501

Change-Id: Id578f2df126f9051489aa6ff01ddb40f103b9860
Signed-off-by: Jiyu Yang <jiyu.yang@amlogic.com>
gpu-build.sh [new file with mode: 0755]
mali/include/linux/mali/mali_utgard_ioctl.h
mali/include/linux/mali/mali_utgard_uk_types.h
mali/linux/mali_kernel_linux.c
mali/linux/mali_memory_dma_buf.c
mali/linux/mali_memory_dma_buf.h
mali/linux/mali_memory_manager.c
mali/linux/mali_memory_manager.h
mali/linux/mali_ukk_mem.c
mali/linux/mali_ukk_wrappers.h

diff --git a/gpu-build.sh b/gpu-build.sh
new file mode 100755 (executable)
index 0000000..c78b57e
--- /dev/null
@@ -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
index dfe152bae8651e23fc09564623d8f838a0ef1809..5d022939ded53242d30e53339bb0c2208c9dc1bb 100755 (executable)
@@ -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)
index 99835a5c9daaeab392b91a8216594d5927d03268..dc0dfa12ab3c4ed16ddaed1257d0ff03cd6fecf5 100755 (executable)
@@ -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 */
index 4a0b9e81fc3d16d471d2436dfa507d201fc1719e..78f08e771809592b8198e58bd1603a6ba7501c91 100644 (file)
@@ -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);
index 59107fa5df95aef81455a607b259cf890fa3d1b2..d4f79ae671a9f629cf9b64f6e04bb270709bf53a 100755 (executable)
@@ -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;
+}
index 37b6f6b4368062ed2ae844ed82483c163d749586..4110ef60082c6a2f81f5478276b3eed4d20d89ad 100755 (executable)
@@ -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,
index 10d367ec64c8d3b68f30556932b923323b2668b5..621ff153e928251fd1d5eb3951728b1246f7b12e 100644 (file)
@@ -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
index caccd9efacd997a29e71fce27149c469ae631e8a..dd535aa48fd6eace1acccd9af79ee98b2ea4af89 100644 (file)
@@ -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);
index 440b4777c4446a85168b2a0ecf8841c029948460..40189bd938473f02f46ff59834cc9d28d1b0e247 100755 (executable)
@@ -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;
index 7e59346facace2488a16bc6f7b0243817c171cc4..b94c7644ffa30d9fbdf5493989243f59e635a2ef 100755 (executable)
@@ -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);