summaryrefslogtreecommitdiff
path: root/meta-xilinx/meta-xilinx-bsp/recipes-graphics/mali/kernel-module-mali/0017-Support-for-vm_insert_pfn-deprecated-from-kernel-4.2.patch
blob: 9c4bbee9f7c72f824b28a022b102c1a8776cd415 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From 953cab73b8bc487da330aa454abd7f8c7466737e Mon Sep 17 00:00:00 2001
From: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com>
Date: Mon, 24 Feb 2020 18:32:16 -0800
Subject: [LINUX][rel-v2020.1][PATCH v1 2/3] Support for vm_insert_pfn
 deprecated from kernel 4.20

From kernel 4.20 onwards, support for vm_insert_pfn is deprecated.
Hence, replace the same with vmf_insert_pfn.

Signed-off-by: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com>
---
 .../devicedrv/mali/linux/mali_memory_block_alloc.c   |  6 +++++-
 driver/src/devicedrv/mali/linux/mali_memory_cow.c    | 14 ++++++++++++--
 .../src/devicedrv/mali/linux/mali_memory_os_alloc.c  | 20 +++++++++++++++++---
 driver/src/devicedrv/mali/linux/mali_memory_secure.c |  7 ++++++-
 4 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/driver/src/devicedrv/mali/linux/mali_memory_block_alloc.c b/driver/src/devicedrv/mali/linux/mali_memory_block_alloc.c
index 0c5b6c3..e528699 100644
--- linux/mali_memory_block_alloc.c
+++ b/linux/mali_memory_block_alloc.c
@@ -309,9 +309,13 @@ 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);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+		ret = vmf_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page));
+		if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 		ret = vm_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page));
-
 		if (unlikely(0 != ret)) {
+#endif
 			return -EFAULT;
 		}
 		addr += _MALI_OSK_MALI_PAGE_SIZE;
diff --git a/driver/src/devicedrv/mali/linux/mali_memory_cow.c b/driver/src/devicedrv/mali/linux/mali_memory_cow.c
index f1d44fe..1dae1d6 100644
--- linux/mali_memory_cow.c
+++ b/linux/mali_memory_cow.c
@@ -532,9 +532,14 @@ 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);
 		*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+		ret = vmf_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page));
+		if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 		ret = vm_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page));
-
 		if (unlikely(0 != ret)) {
+#endif
+
 			return ret;
 		}
 		addr += _MALI_OSK_MALI_PAGE_SIZE;
@@ -569,9 +574,14 @@ _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)) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+			ret = vmf_insert_pfn(vma, vaddr, _mali_page_node_get_pfn(m_page));
+			if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 			ret = vm_insert_pfn(vma, vaddr, _mali_page_node_get_pfn(m_page));
-
 			if (unlikely(0 != ret)) {
+#endif
+
 				if (count == offset) {
 					return _MALI_OSK_ERR_FAULT;
 				} else {
diff --git a/driver/src/devicedrv/mali/linux/mali_memory_os_alloc.c b/driver/src/devicedrv/mali/linux/mali_memory_os_alloc.c
index 3fb6f05..7de3920 100644
--- linux/mali_memory_os_alloc.c
+++ b/linux/mali_memory_os_alloc.c
@@ -378,9 +378,14 @@ 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;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+		ret = vmf_insert_pfn(vma, addr, page_to_pfn(page));
+		if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 		ret = vm_insert_pfn(vma, addr, page_to_pfn(page));
-
 		if (unlikely(0 != ret)) {
+#endif
+
 			return -EFAULT;
 		}
 		addr += _MALI_OSK_MALI_PAGE_SIZE;
@@ -416,9 +421,13 @@ _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) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+				ret = vmf_insert_pfn(vma, vm_end, page_to_pfn(m_page->page));
+				if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 				ret = vm_insert_pfn(vma, vm_end, page_to_pfn(m_page->page));
-
 				if (unlikely(0 != ret)) {
+#endif
 					/*will return -EBUSY If the page has already been mapped into table, but it's OK*/
 					if (-EBUSY == ret) {
 						break;
@@ -439,9 +448,14 @@ _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) {
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+				ret = vmf_insert_pfn(vma, vstart, page_to_pfn(m_page->page));
+				if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 				ret = vm_insert_pfn(vma, vstart, page_to_pfn(m_page->page));
-
 				if (unlikely(0 != ret)) {
+#endif
+
 					/*will return -EBUSY If the page has already been mapped into table, but it's OK*/
 					if (-EBUSY == ret) {
 						break;
diff --git a/driver/src/devicedrv/mali/linux/mali_memory_secure.c b/driver/src/devicedrv/mali/linux/mali_memory_secure.c
index 5546304..cebd1c8 100644
--- linux/mali_memory_secure.c
+++ b/linux/mali_memory_secure.c
@@ -132,9 +132,14 @@ 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++) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+			ret = vmf_insert_pfn(vma, addr, PFN_DOWN(phys));
+			if (unlikely(VM_FAULT_ERROR & ret)) {
+#else
 			ret = vm_insert_pfn(vma, addr, PFN_DOWN(phys));
-
 			if (unlikely(0 != ret)) {
+#endif
+
 				return -EFAULT;
 			}
 			addr += _MALI_OSK_MALI_PAGE_SIZE;
-- 
2.7.4