From f5f907a67f249c11e732ecf4fba19800131fef0e Mon Sep 17 00:00:00 2001 From: Zhen Chen Date: Thu, 8 Jul 2021 15:11:01 +0800 Subject: [PATCH] MALI: mali400: Fix all compile errors under kernel 5.10 Change-Id: Iee1e5bc609e703de0c1e7c1f781ba7059c4aa6ae Signed-off-by: Zhen Chen --- .../arm/mali400/mali/linux/mali_kernel_linux.c | 17 ----------------- .../gpu/arm/mali400/mali/linux/mali_memory.c | 2 +- .../mali/linux/mali_memory_block_alloc.c | 2 +- .../arm/mali400/mali/linux/mali_memory_cow.c | 6 +++--- .../mali400/mali/linux/mali_memory_os_alloc.c | 8 ++++---- .../arm/mali400/mali/linux/mali_memory_secure.c | 2 +- .../gpu/arm/mali400/mali/linux/mali_osk_time.c | 12 ++++++------ .../gpu/arm/mali400/mali/linux/mali_ukk_mem.c | 6 +++--- .../mali400/ump/linux/ump_osk_low_level_mem.c | 2 +- 9 files changed, 20 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c b/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c index 08df33df5d21..e45c7d2f2b1e 100755 --- a/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c @@ -177,11 +177,7 @@ static void mali_miscdevice_unregister(void); static int mali_open(struct inode *inode, struct file *filp); static int mali_release(struct inode *inode, struct file *filp); -#ifdef HAVE_UNLOCKED_IOCTL static long mali_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); -#else -static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -#endif static int mali_probe(struct platform_device *pdev); static int mali_remove(struct platform_device *pdev); @@ -275,11 +271,7 @@ struct file_operations mali_fops = { .owner = THIS_MODULE, .open = mali_open, .release = mali_release, -#ifdef HAVE_UNLOCKED_IOCTL .unlocked_ioctl = mali_ioctl, -#else - .ioctl = mali_ioctl, -#endif .compat_ioctl = mali_ioctl, .mmap = mali_mmap }; @@ -917,20 +909,11 @@ int map_errcode(_mali_osk_errcode_t err) } } -#ifdef HAVE_UNLOCKED_IOCTL static long mali_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -#else -static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) -#endif { int err; struct mali_session_data *session_data; -#ifndef HAVE_UNLOCKED_IOCTL - /* inode not used */ - (void)inode; -#endif - MALI_DEBUG_PRINT(7, ("Ioctl received 0x%08X 0x%08lX\n", cmd, arg)); session_data = (struct mali_session_data *)filp->private_data; diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory.c b/drivers/gpu/arm/mali400/mali/linux/mali_memory.c index 8fa841de786c..dfc769e6cc40 100755 --- a/drivers/gpu/arm/mali400/mali/linux/mali_memory.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_memory.c @@ -57,7 +57,7 @@ static void mali_mem_vma_close(struct vm_area_struct *vma) vma->vm_private_data = NULL; } -static int mali_mem_vma_fault(struct vm_fault *vmf) +static vm_fault_t mali_mem_vma_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; mali_mem_allocation *alloc = (mali_mem_allocation *)vma->vm_private_data; diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory_block_alloc.c b/drivers/gpu/arm/mali400/mali/linux/mali_memory_block_alloc.c index 3bd01926df38..bccef3576914 100755 --- a/drivers/gpu/arm/mali400/mali/linux/mali_memory_block_alloc.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_memory_block_alloc.c @@ -309,7 +309,7 @@ int mali_mem_block_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *v list_for_each_entry(m_page, &block_mem->pfns, list) { MALI_DEBUG_ASSERT(m_page->type == MALI_PAGE_NODE_BLOCK); - ret = vm_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page)); + ret = vmf_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page)); if (unlikely(0 != ret)) { return -EFAULT; diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory_cow.c b/drivers/gpu/arm/mali400/mali/linux/mali_memory_cow.c index b4b57e0f0a74..0bdf90b167d6 100644 --- a/drivers/gpu/arm/mali400/mali/linux/mali_memory_cow.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_memory_cow.c @@ -529,10 +529,10 @@ int mali_mem_cow_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma list_for_each_entry(m_page, &cow->pages, list) { /* We should use vm_insert_page, but it does a dcache - * flush which makes it way slower than remap_pfn_range or vm_insert_pfn. + * flush which makes it way slower than remap_pfn_range or vmf_insert_pfn. ret = vm_insert_page(vma, addr, page); */ - ret = vm_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page)); + ret = vmf_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page)); if (unlikely(0 != ret)) { return ret; @@ -569,7 +569,7 @@ _mali_osk_errcode_t mali_mem_cow_cpu_map_pages_locked(mali_mem_backend *mem_bken list_for_each_entry(m_page, &cow->pages, list) { if ((count >= offset) && (count < offset + num)) { - ret = vm_insert_pfn(vma, vaddr, _mali_page_node_get_pfn(m_page)); + ret = vmf_insert_pfn(vma, vaddr, _mali_page_node_get_pfn(m_page)); if (unlikely(0 != ret)) { if (count == offset) { diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory_os_alloc.c b/drivers/gpu/arm/mali400/mali/linux/mali_memory_os_alloc.c index 5cbcc75990f8..1e1f5eb4a0f7 100755 --- a/drivers/gpu/arm/mali400/mali/linux/mali_memory_os_alloc.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_memory_os_alloc.c @@ -361,11 +361,11 @@ int mali_mem_os_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma) list_for_each_entry(m_page, &os_mem->pages, list) { /* We should use vm_insert_page, but it does a dcache - * flush which makes it way slower than remap_pfn_range or vm_insert_pfn. + * flush which makes it way slower than remap_pfn_range or vmf_insert_pfn. ret = vm_insert_page(vma, addr, page); */ page = m_page->page; - ret = vm_insert_pfn(vma, addr, page_to_pfn(page)); + ret = vmf_insert_pfn(vma, addr, page_to_pfn(page)); if (unlikely(0 != ret)) { return -EFAULT; @@ -403,7 +403,7 @@ _mali_osk_errcode_t mali_mem_os_resize_cpu_map_locked(mali_mem_backend *mem_bken vm_end -= _MALI_OSK_MALI_PAGE_SIZE; if (mapping_page_num > 0) { - ret = vm_insert_pfn(vma, vm_end, page_to_pfn(m_page->page)); + ret = vmf_insert_pfn(vma, vm_end, page_to_pfn(m_page->page)); if (unlikely(0 != ret)) { /*will return -EBUSY If the page has already been mapped into table, but it's OK*/ @@ -426,7 +426,7 @@ _mali_osk_errcode_t mali_mem_os_resize_cpu_map_locked(mali_mem_backend *mem_bken list_for_each_entry(m_page, &os_mem->pages, list) { if (count >= offset) { - ret = vm_insert_pfn(vma, vstart, page_to_pfn(m_page->page)); + ret = vmf_insert_pfn(vma, vstart, page_to_pfn(m_page->page)); if (unlikely(0 != ret)) { /*will return -EBUSY If the page has already been mapped into table, but it's OK*/ diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c b/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c index c2308b8a0eb5..0b4f828680d0 100644 --- a/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c @@ -129,7 +129,7 @@ int mali_mem_secure_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct * MALI_DEBUG_ASSERT(0 == size % _MALI_OSK_MALI_PAGE_SIZE); for (j = 0; j < size / _MALI_OSK_MALI_PAGE_SIZE; j++) { - ret = vm_insert_pfn(vma, addr, PFN_DOWN(phys)); + ret = vmf_insert_pfn(vma, addr, PFN_DOWN(phys)); if (unlikely(0 != ret)) { return -EFAULT; diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_osk_time.c b/drivers/gpu/arm/mali400/mali/linux/mali_osk_time.c index 34481e3bad20..d295e712ac7a 100755 --- a/drivers/gpu/arm/mali400/mali/linux/mali_osk_time.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_osk_time.c @@ -46,14 +46,14 @@ void _mali_osk_time_ubusydelay(u32 usecs) u64 _mali_osk_time_get_ns(void) { - struct timespec tsval; - getnstimeofday(&tsval); - return (u64)timespec_to_ns(&tsval); + struct timespec64 tsval; + ktime_get_real_ts64(&tsval); + return (u64)timespec64_to_ns(&tsval); } u64 _mali_osk_boot_time_get_ns(void) { - struct timespec tsval; - get_monotonic_boottime(&tsval); - return (u64)timespec_to_ns(&tsval); + struct timespec64 tsval; + ktime_get_boottime_ts64(&tsval); + return (u64)timespec64_to_ns(&tsval); } diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_ukk_mem.c b/drivers/gpu/arm/mali400/mali/linux/mali_ukk_mem.c index 8e6d5b0da0ef..baea4c688db9 100755 --- a/drivers/gpu/arm/mali400/mali/linux/mali_ukk_mem.c +++ b/drivers/gpu/arm/mali400/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, (const void *)(uintptr_t)kargs.dest, kargs.size) || - !access_ok(VERIFY_READ, (const void *)(uintptr_t)kargs.src, kargs.size)) { + if (!access_ok((const void *)(uintptr_t)kargs.dest, kargs.size) || + !access_ok((const void *)(uintptr_t)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(user_buffer, kargs.size)) goto err_exit; /* allocate temporary buffer (kernel side) to store mmu page table info */ diff --git a/drivers/gpu/arm/mali400/ump/linux/ump_osk_low_level_mem.c b/drivers/gpu/arm/mali400/ump/linux/ump_osk_low_level_mem.c index 004bcfd3b0db..e08bf25257b0 100755 --- a/drivers/gpu/arm/mali400/ump/linux/ump_osk_low_level_mem.c +++ b/drivers/gpu/arm/mali400/ump/linux/ump_osk_low_level_mem.c @@ -223,7 +223,7 @@ void _ump_osk_msync(ump_dd_mem *mem, void *virt, u32 offset, u32 size, ump_uk_ms /* Flush L1 using virtual address, the entire range in one go. * Only flush if user space process has a valid write mapping on given address. */ - if ((mem) && (virt != NULL) && (access_ok(VERIFY_WRITE, virt, size))) { + if ((mem) && (virt != NULL) && (access_ok(virt, size))) { __cpuc_flush_dcache_area(virt, size); DBG_MSG(3, ("UMP[%02u] Flushing CPU L1 Cache. CPU address: %x, size: %x\n", mem->secure_id, virt, size)); } else {