summarylogtreecommitdiffstats
path: root/kernel-5.7.patch
blob: 27104c3d853958475d40ac4e58532d9bbc1bb25b (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
147
148
149
150
151
152
153
154
155
156
diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
index 85041c2..8d30833 100644
--- a/kernel/common/inc/nv-linux.h
+++ b/kernel/common/inc/nv-linux.h
@@ -231,6 +231,7 @@ NV_STATUS nvos_forward_error_to_cray(struct pci_dev *, NvU32,
 #endif
 
 #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+#include <asm/pgtable_types.h>
 #include <asm/set_memory.h>
 #endif
 
diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index cc25806..7d040ab 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -130,6 +130,7 @@ test_headers() {
 
     # Arch specific headers which need testing
     FILES_ARCH="asm/book3s/64/hash-64k.h"
+    FILES_ARCH="$FILES_ARCH asm/pgtable_types.h"
     FILES_ARCH="$FILES_ARCH asm/set_memory.h"
     FILES_ARCH="$FILES_ARCH asm/powernv.h"
     FILES_ARCH="$FILES_ARCH asm/tlbflush.h"
@@ -398,6 +399,7 @@ compile_test() {
             #
             CODE="
             #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+            #include <asm/pgtable_types.h>
             #include <asm/set_memory.h>
             #else
             #include <asm/cacheflush.h>
@@ -415,6 +417,7 @@ compile_test() {
             #
             CODE="
             #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+            #include <asm/pgtable_types.h>
             #include <asm/set_memory.h>
             #else
             #include <asm/cacheflush.h>
@@ -426,6 +429,22 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_SET_MEMORY_ARRAY_UC_PRESENT" "" "functions"
         ;;
 
+	set_pages_array_uc)
+            #
+            # Determine if the set_pages_array_uc() function is present.
+            #
+            CODE="
+            #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+            #include <asm/pgtable_types.h>
+            #include <asm/set_memory.h>
+            #endif
+            void conftest_set_pages_array_uc(void) {
+                set_pages_array_uc();
+            }"
+
+            compile_check_conftest "$CODE" "NV_SET_PAGES_ARRAY_UC_PRESENT" "" "functions"
+	;;
+
         sysfs_slab_unlink)
             #
             # Determine if the sysfs_slab_unlink() function is present.
@@ -467,6 +486,7 @@ compile_test() {
             #
             CODE="
             #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+            #include <asm/pgtable_types.h>
             #include <asm/set_memory.h>
             #else
             #include <asm/cacheflush.h>
diff --git a/kernel/nvidia/nv-vm.c b/kernel/nvidia/nv-vm.c
index e407714..e1f3095 100644
--- a/kernel/nvidia/nv-vm.c
+++ b/kernel/nvidia/nv-vm.c
@@ -62,7 +62,7 @@ static inline int nv_set_memory_array_type_present(NvU32 type)
 {
     switch (type)
     {
-#if defined(NV_SET_MEMORY_ARRAY_UC_PRESENT)
+#if defined(NV_SET_PAGES_ARRAY_UC_PRESENT) || defined(NV_SET_MEMORY_ARRAY_UC_PRESENT)
         case NV_MEMORY_UNCACHED:
             return 1;
         case NV_MEMORY_WRITEBACK:
@@ -74,14 +74,25 @@ static inline int nv_set_memory_array_type_present(NvU32 type)
 }
 
 static inline void nv_set_memory_array_type(
+#if defined(NV_SET_PAGES_ARRAY_UC_PRESENT)
+    struct page** pages,
+#else
     unsigned long *pages,
+#endif
     NvU32 num_pages,
     NvU32 type
 )
 {
     switch (type)
     {
-#if defined(NV_SET_MEMORY_ARRAY_UC_PRESENT)
+#if defined(NV_SET_PAGES_ARRAY_UC_PRESENT)
+        case NV_MEMORY_UNCACHED:
+            set_pages_array_uc(pages, num_pages);
+            break;
+        case NV_MEMORY_WRITEBACK:
+            set_pages_array_wb(pages, num_pages);
+            break;
+#elif defined(NV_SET_MEMORY_ARRAY_UC_PRESENT)
         case NV_MEMORY_UNCACHED:
             set_memory_array_uc(pages, num_pages);
             break;
@@ -125,7 +136,11 @@ static inline void nv_set_memory_type(nv_alloc_t *at, NvU32 type)
 {
     NvU32 i;
     NV_STATUS status;
+#if defined(NV_SET_PAGES_ARRAY_UC_PRESENT)
+    struct page** pages;
+#else
     unsigned long *pages;
+#endif
     nvidia_pte_t *page_ptr;
     struct page *page;
 
@@ -136,7 +151,7 @@ static inline void nv_set_memory_type(nv_alloc_t *at, NvU32 type)
         if (nv_set_memory_array_type_present(type))
         {
             status = os_alloc_mem((void **)&pages,
-                        at->num_pages * sizeof(unsigned long));
+                        at->num_pages * sizeof(*pages));
             if (status != NV_OK)
                 pages = NULL;
         }
@@ -147,7 +162,11 @@ static inline void nv_set_memory_type(nv_alloc_t *at, NvU32 type)
             {
                 page_ptr = at->page_table[i];
                 page = NV_GET_PAGE_STRUCT(page_ptr->phys_addr);
+#if defined(NV_SET_PAGES_ARRAY_UC_PRESENT)
+                pages[i] = page;
+#else
                 pages[i] = (unsigned long)page_address(page);
+#endif
             }
             nv_set_memory_array_type(pages, at->num_pages, type);
             os_free_mem(pages);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 8ae1016..104d4fd 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -105,6 +105,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += list_is_first
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_uc
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_array_uc
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_array_uc
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += change_page_attr
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_get_class
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_choose_state