31df30b52ad178ef58f1a179caabad5082f57257
[packages/xorg-driver-video-nvidia-legacy-390xx.git] / kernel-5.9.patch
1 diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
2 index ab06dbc..dd335b5 100644
3 --- a/kernel/common/inc/nv-linux.h
4 +++ b/kernel/common/inc/nv-linux.h
5 @@ -159,7 +159,7 @@ static inline uid_t __kuid_val(kuid_t uid)
6  }
7  #endif
8  
9 -#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
10 +#if defined(NVCPU_X86_64) && !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL)
11  #include <linux/syscalls.h>         /* sys_ioctl()                      */
12  #include <linux/ioctl32.h>          /* register_ioctl32_conversion()    */
13  #endif
14 diff --git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h
15 index d2d7657..a5325fe 100644
16 --- a/kernel/common/inc/nv-mm.h
17 +++ b/kernel/common/inc/nv-mm.h
18 @@ -144,9 +144,13 @@ typedef int vm_fault_t;
19                  flags |= FOLL_FORCE;
20  
21          #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
22 -
23 +            #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG)
24                 return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
25                                              pages, vmas, NULL);
26 +            #else
27 +               return get_user_pages_remote(mm, start, nr_pages, flags,
28 +                                            pages, vmas, NULL);
29 +            #endif
30  
31          #else
32  
33 @@ -159,7 +163,7 @@ typedef int vm_fault_t;
34      #endif
35  #else
36      #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
37 -        #define NV_GET_USER_PAGES_REMOTE    NV_GET_USER_PAGES
38 +        #define NV_GET_USER_PAGES_REMOTE    get_user_pages
39      #else
40          #include <linux/mm.h>
41          #include <linux/sched.h>
42 diff --git a/kernel/conftest.sh b/kernel/conftest.sh
43 index e900963..ef82dee 100755
44 --- a/kernel/conftest.sh
45 +++ b/kernel/conftest.sh
46 @@ -3043,6 +3043,7 @@ compile_test() {
47  
48              if [ -f conftest$$.o ]; then
49                  echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
50 +                echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
51                  echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
52                  echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
53                  rm -f conftest$$.o
54 @@ -3070,14 +3071,20 @@ compile_test() {
55              rm -f conftest$$.c
56  
57              if [ -f conftest$$.o ]; then
58 +                echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
59                  echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
60                  echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
61                  rm -f conftest$$.o
62                  return
63              fi
64  
65 +            echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
66 +
67 +            #
68              # conftest #3: check if get_user_pages_remote() has locked argument
69 -            
70 +            # Return if these arguments are present. Fall through to conftest #4
71 +            # if these args are absent.
72 +            #
73              echo "$CONFTEST_PREAMBLE
74              #include <linux/mm.h>
75              long get_user_pages_remote(struct task_struct *tsk,
76 @@ -3095,13 +3102,40 @@ compile_test() {
77              rm -f conftest$$.c
78  
79              if [ -f conftest$$.o ]; then
80 +                echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
81 +                echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
82 +                rm -f conftest$$.o
83 +                return
84 +            fi
85 +
86 +            #
87 +            # conftest #4: check if get_user_pages_remote() does not take
88 +            # tsk argument.
89 +            #
90 +            echo "$CONFTEST_PREAMBLE
91 +            #include <linux/mm.h>
92 +            long get_user_pages_remote(struct mm_struct *mm,
93 +                                       unsigned long start,
94 +                                       unsigned long nr_pages,
95 +                                       unsigned int gup_flags,
96 +                                       struct page **pages,
97 +                                       struct vm_area_struct **vmas,
98 +                                       int *locked) {
99 +                return 0;
100 +            }" > conftest$$.c
101 +
102 +            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
103 +            rm -f conftest$$.c
104 +
105 +            if [ -f conftest$$.o ]; then
106 +                echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
107                  echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
108                  rm -f conftest$$.o
109              else
110 +
111 +                echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
112                  echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
113              fi
114 -            echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
115 -
116          ;;
117  
118          usleep_range)
119 @@ -4131,6 +4165,115 @@ compile_test() {
120              compile_check_conftest "$CODE" "NV_PCI_DEV_HAS_SKIP_BUS_PM" "" "types"
121          ;;
122  
123 +        drm_gem_object_put_unlocked)
124 +            #
125 +            # Determine if the function drm_gem_object_put_unlocked() is present.
126 +            #
127 +            # In v5.9-rc1, commit 2f4dd13d4bb8 ("drm/gem: add
128 +            # drm_gem_object_put helper") removes drm_gem_object_put_unlocked()
129 +            # function and replace its definition by transient macro. Commit
130 +            # ab15d56e27be ("drm: remove transient
131 +            # drm_gem_object_put_unlocked()") finally removes
132 +            # drm_gem_object_put_unlocked() macro.
133 +            #
134 +            CODE="
135 +            #if defined(NV_DRM_DRMP_H_PRESENT)
136 +            #include <drm/drmP.h>
137 +            #endif
138 +
139 +            #if defined(NV_DRM_DRM_GEM_H_PRESENT)
140 +            #include <drm/drm_gem.h>
141 +            #endif
142 +            void conftest_drm_gem_object_put_unlocked(void) {
143 +                drm_gem_object_put_unlocked();
144 +            }"
145 +
146 +            compile_check_conftest "$CODE" "NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT" "" "functions"
147 +        ;;
148 +
149 +        drm_display_mode_has_vrefresh)
150 +            #
151 +            # Determine if the 'drm_display_mode' structure has a 'vrefresh'
152 +            # field.
153 +            #
154 +            # Removed by commit 0425662fdf05 ("drm: Nuke mode->vrefresh") in
155 +            # v5.9-rc1.
156 +            #
157 +            CODE="
158 +            #include <drm/drm_modes.h>
159 +
160 +            int conftest_drm_display_mode_has_vrefresh(void) {
161 +                return offsetof(struct drm_display_mode, vrefresh);
162 +            }"
163 +
164 +            compile_check_conftest "$CODE" "NV_DRM_DISPLAY_MODE_HAS_VREFRESH" "types"
165 +
166 +        ;;
167 +
168 +        drm_driver_master_set_has_int_return_type)
169 +            #
170 +            # Determine if drm_driver::master_set() returns integer value
171 +            #
172 +            # Changed to void by commit 907f53200f98 ("drm: vmwgfx: remove
173 +            # drm_driver::master_set() return type") in v5.9-rc1.
174 +            #
175 +            CODE="
176 +            #if defined(NV_DRM_DRMP_H_PRESENT)
177 +            #include <drm/drmP.h>
178 +            #endif
179 +
180 +            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
181 +            #include <drm/drm_drv.h>
182 +            #endif
183 +
184 +            int conftest_drm_driver_master_set_has_int_return_type(struct drm_driver *drv,
185 +                struct drm_device *dev, struct drm_file *file_priv, bool from_open) {
186 +
187 +                return drv->master_set(dev, file_priv, from_open);
188 +            }"
189 +
190 +            compile_check_conftest "$CODE" "NV_DRM_DRIVER_SET_MASTER_HAS_INT_RETURN_TYPE" "" "types"
191 +        ;;
192 +
193 +        drm_driver_has_gem_free_object)
194 +            #
195 +            # Determine if the 'drm_driver' structure has a 'gem_free_object'
196 +            # function pointer.
197 +            #
198 +            # drm_driver::gem_free_object is removed by commit 1a9458aeb8eb
199 +            # ("drm: remove drm_driver::gem_free_object") in v5.9-rc1.
200 +            #
201 +            CODE="
202 +            #if defined(NV_DRM_DRMP_H_PRESENT)
203 +            #include <drm/drmP.h>
204 +            #endif
205 +
206 +            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
207 +            #include <drm/drm_drv.h>
208 +            #endif
209 +
210 +            int conftest_drm_driver_has_gem_free_object(void) {
211 +                return offsetof(struct drm_driver, gem_free_object);
212 +            }"
213 +
214 +            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT" "" "types"
215 +        ;;
216 +
217 +        vga_tryget)
218 +            #
219 +            # Determine if vga_tryget() is present
220 +            #
221 +            # vga_tryget() was removed by commit f369bc3f9096 ("vgaarb: mark
222 +            # vga_tryget static") in v5.9-rc1 (2020-08-01).
223 +            #
224 +            CODE="
225 +            #include <linux/vgaarb.h>
226 +            void conftest_vga_tryget(void) {
227 +                vga_tryget();
228 +            }"
229 +
230 +            compile_check_conftest "$CODE" "NV_VGA_TRYGET_PRESENT" "" "functions"
231 +        ;;
232      esac
233  }
234  
235 diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
236 index 17e377d..1b4cc6d 100644
237 --- a/kernel/nvidia-drm/nvidia-drm-drv.c
238 +++ b/kernel/nvidia-drm/nvidia-drm-drv.c
239 @@ -466,8 +466,8 @@ static void nv_drm_unload(struct drm_device *dev)
240  
241  #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
242  
243 -static int nv_drm_master_set(struct drm_device *dev,
244 -                             struct drm_file *file_priv, bool from_open)
245 +static int __nv_drm_master_set(struct drm_device *dev,
246 +                               struct drm_file *file_priv, bool from_open)
247  {
248      struct nv_drm_device *nv_dev = to_nv_device(dev);
249  
250 @@ -478,6 +478,21 @@ static int nv_drm_master_set(struct drm_device *dev,
251      return 0;
252  }
253  
254 +#if defined(NV_DRM_DRIVER_SET_MASTER_HAS_INT_RETURN_TYPE)
255 +static int nv_drm_master_set(struct drm_device *dev,
256 +                             struct drm_file *file_priv, bool from_open)
257 +{
258 +    return __nv_drm_master_set(dev, file_priv, from_open);
259 +}
260 +#else
261 +static void nv_drm_master_set(struct drm_device *dev,
262 +                              struct drm_file *file_priv, bool from_open)
263 +{
264 +     WARN_ON(__nv_drm_master_set(dev, file_priv, from_open) != 0);
265 +}
266 +#endif
267 +
268 +
269  #if defined(NV_DRM_MASTER_DROP_HAS_FROM_RELEASE_ARG)
270  static
271  void nv_drm_master_drop(struct drm_device *dev,
272 @@ -677,7 +692,9 @@ static struct drm_driver nv_drm_driver = {
273  #endif
274                                 DRIVER_GEM  | DRIVER_RENDER,
275  
276 +#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT)
277      .gem_free_object        = nv_drm_gem_free,
278 +#endif
279  
280      .ioctls                 = nv_drm_ioctls,
281      .num_ioctls             = ARRAY_SIZE(nv_drm_ioctls),
282 diff --git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
283 index 5691a7a..18c50ca 100644
284 --- a/kernel/nvidia-drm/nvidia-drm-gem.h
285 +++ b/kernel/nvidia-drm/nvidia-drm-gem.h
286 @@ -87,7 +87,13 @@ static inline void
287  nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem)
288  {
289  #if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
290 +
291 +#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT)
292      drm_gem_object_put_unlocked(&nv_gem->base);
293 +#else
294 +    drm_gem_object_put(&nv_gem->base);
295 +#endif
296 +
297  #else
298      drm_gem_object_unreference_unlocked(&nv_gem->base);
299  #endif
300 diff --git a/kernel/nvidia-drm/nvidia-drm-utils.c b/kernel/nvidia-drm/nvidia-drm-utils.c
301 index 8cb2d5e..e30b2b6 100644
302 --- a/kernel/nvidia-drm/nvidia-drm-utils.c
303 +++ b/kernel/nvidia-drm/nvidia-drm-utils.c
304 @@ -103,7 +103,9 @@ void
305  nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode,
306                                 struct drm_display_mode *mode)
307  {
308 +#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
309      mode->vrefresh    = (displayMode->timings.refreshRate + 500) / 1000; /* In Hz */
310 +#endif
311  
312      mode->clock       = (displayMode->timings.pixelClockHz + 500) / 1000; /* In Hz */
313  
314 @@ -189,7 +191,11 @@ bool drm_format_to_nvkms_format(u32 format,
315  void drm_mode_to_nvkms_display_mode(const struct drm_display_mode *src,
316                                      struct NvKmsKapiDisplayMode *dst)
317  {
318 +#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
319      dst->timings.refreshRate  = src->vrefresh * 1000;
320 +#else
321 +    dst->timings.refreshRate  = drm_mode_vrefresh(src) * 1000;
322 +#endif
323  
324      dst->timings.pixelClockHz = src->clock * 1000; /* In Hz */
325  
326 diff --git a/kernel/nvidia-uvm/uvm8_tools.c b/kernel/nvidia-uvm/uvm8_tools.c
327 index 86dbb77..63d0b64 100644
328 --- a/kernel/nvidia-uvm/uvm8_tools.c
329 +++ b/kernel/nvidia-uvm/uvm8_tools.c
330 @@ -190,7 +190,6 @@ static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp)
331  {
332      long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data);
333  
334 -    smp_read_barrier_depends();
335      return (uvm_tools_event_tracker_t *)event_tracker;
336  }
337  
338 diff --git a/kernel/nvidia-uvm/uvm8_va_range.h b/kernel/nvidia-uvm/uvm8_va_range.h
339 index 8cae357..6166cc8 100644
340 --- a/kernel/nvidia-uvm/uvm8_va_range.h
341 +++ b/kernel/nvidia-uvm/uvm8_va_range.h
342 @@ -717,7 +717,6 @@ static uvm_va_block_t *uvm_va_range_block(uvm_va_range_t *va_range, size_t index
343      // make sure that any initialization of this block by the creating thread is
344      // visible to later accesses in this thread, which requires a data
345      // dependency barrier.
346 -    smp_read_barrier_depends();
347      return block;
348  }
349  
350 diff --git a/kernel/nvidia/nv.c b/kernel/nvidia/nv.c
351 index 15983f6..cfb2375 100644
352 --- a/kernel/nvidia/nv.c
353 +++ b/kernel/nvidia/nv.c
354 @@ -3872,7 +3872,9 @@ nvidia_probe
355  
356  #if defined(CONFIG_VGA_ARB) && !defined(NVCPU_PPC64LE)
357  #if defined(VGA_DEFAULT_DEVICE)
358 +#if defined(NV_VGA_TRYGET_PRESENT)
359      vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
360 +#endif
361  #endif
362      vga_set_legacy_decoding(dev, VGA_RSRC_NONE);
363  #endif
364
365
This page took 0.588948 seconds and 2 git commands to generate.