Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/build.sh b/build.sh
- index e36f3a4..e6fde2a 100755
- --- a/build.sh
- +++ b/build.sh
- @@ -3,6 +3,10 @@
- # Takem from https://github.com/mripard/sunxi-mali/blob/master/build.sh
- # Thanks Maxime !
- +export KDIR=/home/andreas/nfs/opipc2/linux
- +export CROSS_COMPILE=aarch64-linux-gnu-
- +export ARCH=arm64
- +
- DRIVER_DIR=$(pwd)/driver/src/devicedrv/mali/
- -USING_UMP=0 BUILD=debug MALI_DMA_BUF_MAP_ON_ATTACH=1 USING_PROFILING=0 MALI_PLATFORM=meson USING_DVFS=0 make -C $DRIVER_DIR
- +USING_UMP=0 BUILD=debug MALI_DMA_BUF_MAP_ON_ATTACH=1 USING_PROFILING=0 MALI_PLATFORM=sunxi USING_DVFS=0 make -C $DRIVER_DIR
- cp $DRIVER_DIR/mali.ko .
- diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
- index d7893a3..35cacde 100755
- --- a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
- +++ b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
- @@ -1125,6 +1125,14 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- return err;
- }
- +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
- +int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
- + unsigned long pfn)
- +{
- + return vm_fault_to_errno(vmf_insert_pfn(vma, addr, pfn), 0xffff);
- +}
- +#endif
- +
- module_init(mali_module_init);
- module_exit(mali_module_exit);
- diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.h b/driver/src/devicedrv/mali/linux/mali_kernel_linux.h
- index be754cb..f9fd8f3 100755
- --- a/driver/src/devicedrv/mali/linux/mali_kernel_linux.h
- +++ b/driver/src/devicedrv/mali/linux/mali_kernel_linux.h
- @@ -16,6 +16,7 @@ extern "C" {
- #endif
- #include <linux/cdev.h> /* character device definitions */
- +#include <linux/mm.h>
- #include <linux/idr.h>
- #include <linux/rbtree.h>
- #include "mali_kernel_license.h"
- @@ -29,6 +30,17 @@ extern struct platform_device *mali_platform_device;
- #define CONFIG_PM_RUNTIME 1
- #endif
- +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
- +extern int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
- + unsigned long pfn);
- +#endif
- +
- +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
- +#define _access_ok(TYPE, BUF, SIZE) access_ok(BUF, SIZE)
- +#else
- +#define _access_ok(TYPE, BUF, SIZE) access_ok(TYPE, BUF, SIZE)
- +#endif
- +
- #ifdef __cplusplus
- }
- #endif
- diff --git a/driver/src/devicedrv/mali/linux/mali_memory.c b/driver/src/devicedrv/mali/linux/mali_memory.c
- index bfef4a8..641f30a 100755
- --- a/driver/src/devicedrv/mali/linux/mali_memory.c
- +++ b/driver/src/devicedrv/mali/linux/mali_memory.c
- @@ -57,7 +57,9 @@ static void mali_mem_vma_close(struct vm_area_struct *vma)
- vma->vm_private_data = NULL;
- }
- -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
- +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
- +static vm_fault_t mali_mem_vma_fault(struct vm_fault *vmf)
- +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
- static int mali_mem_vma_fault(struct vm_fault *vmf)
- #else
- static int mali_mem_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
- @@ -267,17 +269,21 @@ int mali_mmap(struct file *filp, struct vm_area_struct *vma)
- if (mem_bkend->type == MALI_MEM_OS) {
- ret = mali_mem_os_cpu_map(mem_bkend, vma);
- + MALI_DEBUG_PRINT(1, ("mali_mem_os_cpu_map\n"));
- } else if (mem_bkend->type == MALI_MEM_COW &&
- (MALI_MEM_BACKEND_FLAG_SWAP_COWED != (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED))) {
- ret = mali_mem_cow_cpu_map(mem_bkend, vma);
- + MALI_DEBUG_PRINT(1, ("mali_mem_cow_cpu_map\n"));
- } else if (mem_bkend->type == MALI_MEM_BLOCK) {
- ret = mali_mem_block_cpu_map(mem_bkend, vma);
- + MALI_DEBUG_PRINT(1, ("mali_mem_block_cpu_map\n"));
- } else if ((mem_bkend->type == MALI_MEM_SWAP) || (mem_bkend->type == MALI_MEM_COW &&
- (MALI_MEM_BACKEND_FLAG_SWAP_COWED == (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED)))) {
- /*For swappable memory, CPU page table will be created by page fault handler. */
- ret = 0;
- } else if (mem_bkend->type == MALI_MEM_SECURE) {
- #if defined(CONFIG_DMA_SHARED_BUFFER)
- + MALI_DEBUG_PRINT(1, ("mali_mem_secure_cpu_map\n"));
- ret = mali_mem_secure_cpu_map(mem_bkend, vma);
- #else
- MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory\n"));
- diff --git a/driver/src/devicedrv/mali/linux/mali_osk_time.c b/driver/src/devicedrv/mali/linux/mali_osk_time.c
- index 0be37a8..d941146 100755
- --- a/driver/src/devicedrv/mali/linux/mali_osk_time.c
- +++ b/driver/src/devicedrv/mali/linux/mali_osk_time.c
- @@ -58,7 +58,9 @@ u64 _mali_osk_time_get_ns(void)
- u64 _mali_osk_boot_time_get_ns(void)
- {
- -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
- +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0))
- + return ktime_get_boottime_ns();
- +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
- return ktime_get_boot_ns();
- #else
- struct timespec tsval;
- diff --git a/driver/src/devicedrv/mali/linux/mali_ukk_mem.c b/driver/src/devicedrv/mali/linux/mali_ukk_mem.c
- index 508b7d1..d3561b7 100755
- --- a/driver/src/devicedrv/mali/linux/mali_ukk_mem.c
- +++ b/driver/src/devicedrv/mali/linux/mali_ukk_mem.c
- @@ -202,8 +202,8 @@ int mem_write_safe_wrapper(struct mali_session_data *session_data, _mali_uk_mem_
- kargs.ctx = (uintptr_t)session_data;
- /* Check if we can access the buffers */
- - if (!access_ok(VERIFY_WRITE, kargs.dest, kargs.size)
- - || !access_ok(VERIFY_READ, kargs.src, kargs.size)) {
- + if (!_access_ok(VERIFY_WRITE, kargs.dest, kargs.size)
- + || !_access_ok(VERIFY_READ, kargs.src, kargs.size)) {
- return -EINVAL;
- }
- @@ -261,7 +261,7 @@ int mem_dump_mmu_page_table_wrapper(struct mali_session_data *session_data, _mal
- goto err_exit;
- user_buffer = (void __user *)(uintptr_t)kargs.buffer;
- - if (!access_ok(VERIFY_WRITE, user_buffer, kargs.size))
- + if (!_access_ok(VERIFY_WRITE, user_buffer, kargs.size))
- goto err_exit;
- /* allocate temporary buffer (kernel side) to store mmu page table info */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement