Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.21 KB | None | 0 0
  1. diff --git a/build.sh b/build.sh
  2. index e36f3a4..e6fde2a 100755
  3. --- a/build.sh
  4. +++ b/build.sh
  5. @@ -3,6 +3,10 @@
  6.  # Takem from https://github.com/mripard/sunxi-mali/blob/master/build.sh
  7.  # Thanks Maxime !
  8.  
  9. +export KDIR=/home/andreas/nfs/opipc2/linux
  10. +export CROSS_COMPILE=aarch64-linux-gnu-
  11. +export ARCH=arm64
  12. +
  13.  DRIVER_DIR=$(pwd)/driver/src/devicedrv/mali/
  14. -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
  15. +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
  16.  cp $DRIVER_DIR/mali.ko .
  17. diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
  18. index d7893a3..35cacde 100755
  19. --- a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
  20. +++ b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
  21. @@ -1125,6 +1125,14 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
  22.         return err;
  23.  }
  24.  
  25. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
  26. +int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
  27. +                  unsigned long pfn)
  28. +{
  29. +       return vm_fault_to_errno(vmf_insert_pfn(vma, addr, pfn), 0xffff);
  30. +}
  31. +#endif
  32. +
  33.  
  34.  module_init(mali_module_init);
  35.  module_exit(mali_module_exit);
  36. diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.h b/driver/src/devicedrv/mali/linux/mali_kernel_linux.h
  37. index be754cb..f9fd8f3 100755
  38. --- a/driver/src/devicedrv/mali/linux/mali_kernel_linux.h
  39. +++ b/driver/src/devicedrv/mali/linux/mali_kernel_linux.h
  40. @@ -16,6 +16,7 @@ extern "C" {
  41.  #endif
  42.  
  43.  #include <linux/cdev.h>     /* character device definitions */
  44. +#include <linux/mm.h>
  45.  #include <linux/idr.h>
  46.  #include <linux/rbtree.h>
  47.  #include "mali_kernel_license.h"
  48. @@ -29,6 +30,17 @@ extern struct platform_device *mali_platform_device;
  49.  #define CONFIG_PM_RUNTIME 1
  50.  #endif
  51.  
  52. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
  53. +extern int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
  54. +                        unsigned long pfn);
  55. +#endif
  56. +
  57. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
  58. +#define _access_ok(TYPE, BUF, SIZE) access_ok(BUF, SIZE)
  59. +#else
  60. +#define _access_ok(TYPE, BUF, SIZE) access_ok(TYPE, BUF, SIZE)
  61. +#endif
  62. +
  63.  #ifdef __cplusplus
  64.  }
  65.  #endif
  66. diff --git a/driver/src/devicedrv/mali/linux/mali_memory.c b/driver/src/devicedrv/mali/linux/mali_memory.c
  67. index bfef4a8..641f30a 100755
  68. --- a/driver/src/devicedrv/mali/linux/mali_memory.c
  69. +++ b/driver/src/devicedrv/mali/linux/mali_memory.c
  70. @@ -57,7 +57,9 @@ static void mali_mem_vma_close(struct vm_area_struct *vma)
  71.         vma->vm_private_data = NULL;
  72.  }
  73.  
  74. -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
  75. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
  76. +static vm_fault_t mali_mem_vma_fault(struct vm_fault *vmf)
  77. +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
  78.  static int mali_mem_vma_fault(struct vm_fault *vmf)
  79.  #else
  80.  static int mali_mem_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  81. @@ -267,17 +269,21 @@ int mali_mmap(struct file *filp, struct vm_area_struct *vma)
  82.  
  83.         if (mem_bkend->type == MALI_MEM_OS) {
  84.                 ret = mali_mem_os_cpu_map(mem_bkend, vma);
  85. +               MALI_DEBUG_PRINT(1, ("mali_mem_os_cpu_map\n"));
  86.         } else if (mem_bkend->type == MALI_MEM_COW &&
  87.                    (MALI_MEM_BACKEND_FLAG_SWAP_COWED != (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED))) {
  88.                 ret = mali_mem_cow_cpu_map(mem_bkend, vma);
  89. +               MALI_DEBUG_PRINT(1, ("mali_mem_cow_cpu_map\n"));
  90.         } else if (mem_bkend->type == MALI_MEM_BLOCK) {
  91.                 ret = mali_mem_block_cpu_map(mem_bkend, vma);
  92. +               MALI_DEBUG_PRINT(1, ("mali_mem_block_cpu_map\n"));
  93.         } else if ((mem_bkend->type == MALI_MEM_SWAP) || (mem_bkend->type == MALI_MEM_COW &&
  94.                         (MALI_MEM_BACKEND_FLAG_SWAP_COWED == (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED)))) {
  95.                 /*For swappable memory, CPU page table will be created by page fault handler. */
  96.                 ret = 0;
  97.         } else if (mem_bkend->type == MALI_MEM_SECURE) {
  98.  #if defined(CONFIG_DMA_SHARED_BUFFER)
  99. +               MALI_DEBUG_PRINT(1, ("mali_mem_secure_cpu_map\n"));
  100.                 ret = mali_mem_secure_cpu_map(mem_bkend, vma);
  101.  #else
  102.                 MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory\n"));
  103. diff --git a/driver/src/devicedrv/mali/linux/mali_osk_time.c b/driver/src/devicedrv/mali/linux/mali_osk_time.c
  104. index 0be37a8..d941146 100755
  105. --- a/driver/src/devicedrv/mali/linux/mali_osk_time.c
  106. +++ b/driver/src/devicedrv/mali/linux/mali_osk_time.c
  107. @@ -58,7 +58,9 @@ u64 _mali_osk_time_get_ns(void)
  108.  
  109.  u64 _mali_osk_boot_time_get_ns(void)
  110.  {
  111. -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
  112. +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0))
  113. +       return ktime_get_boottime_ns();
  114. +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
  115.         return ktime_get_boot_ns();
  116.  #else
  117.         struct timespec tsval;
  118. diff --git a/driver/src/devicedrv/mali/linux/mali_ukk_mem.c b/driver/src/devicedrv/mali/linux/mali_ukk_mem.c
  119. index 508b7d1..d3561b7 100755
  120. --- a/driver/src/devicedrv/mali/linux/mali_ukk_mem.c
  121. +++ b/driver/src/devicedrv/mali/linux/mali_ukk_mem.c
  122. @@ -202,8 +202,8 @@ int mem_write_safe_wrapper(struct mali_session_data *session_data, _mali_uk_mem_
  123.         kargs.ctx = (uintptr_t)session_data;
  124.  
  125.         /* Check if we can access the buffers */
  126. -       if (!access_ok(VERIFY_WRITE, kargs.dest, kargs.size)
  127. -           || !access_ok(VERIFY_READ, kargs.src, kargs.size)) {
  128. +       if (!_access_ok(VERIFY_WRITE, kargs.dest, kargs.size)
  129. +           || !_access_ok(VERIFY_READ, kargs.src, kargs.size)) {
  130.                 return -EINVAL;
  131.         }
  132.  
  133. @@ -261,7 +261,7 @@ int mem_dump_mmu_page_table_wrapper(struct mali_session_data *session_data, _mal
  134.                 goto err_exit;
  135.  
  136.         user_buffer = (void __user *)(uintptr_t)kargs.buffer;
  137. -       if (!access_ok(VERIFY_WRITE, user_buffer, kargs.size))
  138. +       if (!_access_ok(VERIFY_WRITE, user_buffer, kargs.size))
  139.                 goto err_exit;
  140.  
  141.         /* allocate temporary buffer (kernel side) to store mmu page table info */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement