Skip to content

Commit

Permalink
v4.20-rc build fix
Browse files Browse the repository at this point in the history
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
  • Loading branch information
wens authored and superna9999 committed Nov 6, 2018
1 parent e2532fa commit 2c9bd8a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
4 changes: 2 additions & 2 deletions driver/src/devicedrv/mali/linux/mali_memory_block_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,15 @@ void mali_mem_block_mali_unmap(mali_mem_allocation *alloc)

int mali_mem_block_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma)
{
int ret;
vm_fault_t ret;
mali_mem_block_mem *block_mem = &mem_bkend->block_mem;
unsigned long addr = vma->vm_start;
struct mali_page_node *m_page;
MALI_DEBUG_ASSERT(mem_bkend->type == MALI_MEM_BLOCK);

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;
Expand Down
8 changes: 4 additions & 4 deletions driver/src/devicedrv/mali/linux/mali_memory_cow.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ int mali_mem_cow_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma
{
mali_mem_cow *cow = &mem_bkend->cow_mem;
struct mali_page_node *m_page;
int ret;
vm_fault_t ret;
unsigned long addr = vma->vm_start;
MALI_DEBUG_ASSERT(mem_bkend->type == MALI_MEM_COW);

Expand All @@ -532,7 +532,7 @@ int mali_mem_cow_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma
* flush which makes it way slower than remap_pfn_range or vm_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;
Expand All @@ -557,7 +557,7 @@ _mali_osk_errcode_t mali_mem_cow_cpu_map_pages_locked(mali_mem_backend *mem_bken
{
mali_mem_cow *cow = &mem_bkend->cow_mem;
struct mali_page_node *m_page;
int ret;
vm_fault_t ret;
int offset;
int count ;
unsigned long vstart = vma->vm_start;
Expand All @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions driver/src/devicedrv/mali/linux/mali_memory_os_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ int mali_mem_os_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma)
mali_mem_os_mem *os_mem = &mem_bkend->os_mem;
struct mali_page_node *m_page;
struct page *page;
int ret;
vm_fault_t ret;
unsigned long addr = vma->vm_start;
MALI_DEBUG_ASSERT(MALI_MEM_OS == mem_bkend->type);

Expand All @@ -378,7 +378,7 @@ int mali_mem_os_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma)
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;
Expand All @@ -393,7 +393,7 @@ _mali_osk_errcode_t mali_mem_os_resize_cpu_map_locked(mali_mem_backend *mem_bken
{
mali_mem_os_mem *os_mem = &mem_bkend->os_mem;
struct mali_page_node *m_page;
int ret;
vm_fault_t ret;
int offset;
int mapping_page_num;
int count ;
Expand All @@ -416,7 +416,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*/
Expand All @@ -439,7 +439,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*/
Expand Down
4 changes: 2 additions & 2 deletions driver/src/devicedrv/mali/linux/mali_memory_secure.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void mali_mem_secure_mali_unmap(mali_mem_allocation *alloc)
int mali_mem_secure_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma)
{

int ret = 0;
vm_fault_t ret = 0;
struct scatterlist *sg;
mali_mem_secure *secure_mem = &mem_bkend->secure_mem;
unsigned long addr = vma->vm_start;
Expand All @@ -132,7 +132,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;
Expand Down
13 changes: 13 additions & 0 deletions driver/src/devicedrv/mali/linux/mali_memory_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@

#include <linux/mm.h>

/* vm_fault_t was introduced in 4.17, and is typedef int as of 4.20 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,17,0))
typedef int vm_fault_t;
#endif

/*
* vm_insert_pfn() was removed in 4.20. The new vmf_insert_pfn returns
* vm_fault_t, which is non-zero on error.
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0))
#define vmf_insert_pfn vm_insert_pfn
#endif

#if defined(CONFIG_MALI400_UMP)
#include "ump_kernel_interface.h"
#endif
Expand Down
9 changes: 9 additions & 0 deletions driver/src/devicedrv/mali/linux/mali_osk_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "mali_osk.h"
#include <linux/jiffies.h>
#include <linux/ktime.h>
#include <linux/time.h>
#include <asm/delay.h>

Expand Down Expand Up @@ -46,14 +47,22 @@ void _mali_osk_time_ubusydelay(u32 usecs)

u64 _mali_osk_time_get_ns(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
return ktime_get_real_ns();
#else
struct timespec tsval;
getnstimeofday(&tsval);
return (u64)timespec_to_ns(&tsval);
#endif
}

u64 _mali_osk_boot_time_get_ns(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
return ktime_get_boot_ns();
#else
struct timespec tsval;
get_monotonic_boottime(&tsval);
return (u64)timespec_to_ns(&tsval);
#endif
}

0 comments on commit 2c9bd8a

Please sign in to comment.