8cb672195b86a3cebacf24708a0f0b99392b6937
[packages/xorg-driver-video-nvidia-legacy-390xx.git] / kernel-5.11.patch
1 diff --color -ur NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/common/inc/nv-linux.h NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/common/inc/nv-linux.h
2 --- NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/common/inc/nv-linux.h   2020-12-28 17:25:19.000000000 +0100
3 +++ NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/common/inc/nv-linux.h        2021-02-25 18:20:36.357193386 +0100
4 @@ -115,7 +115,9 @@
5  
6  #include <linux/moduleparam.h>      /* module_param()                   */
7  #include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
8 +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
9  #include <asm/kmap_types.h>         /* page table entry lookup          */
10 +#endif
11  
12  #include <linux/pci.h>              /* pci_find_class, etc              */
13  #include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
14 diff --color -ur NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/conftest.sh NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/conftest.sh
15 --- NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/conftest.sh     2020-12-18 06:56:44.000000000 +0100
16 +++ NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/conftest.sh  2021-02-25 18:20:36.357193386 +0100
17 @@ -1748,14 +1748,6 @@
18              void conftest_drm_available(void) {
19                  struct drm_driver drv;
20  
21 -                /* 2013-01-15 89177644a7b6306e6084a89eab7e290f4bfef397 */
22 -                drv.gem_prime_pin = 0;
23 -                drv.gem_prime_get_sg_table = 0;
24 -                drv.gem_prime_vmap = 0;
25 -                drv.gem_prime_vunmap = 0;
26 -                (void)drm_gem_prime_import;
27 -                (void)drm_gem_prime_export;
28 -
29                  /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
30                  (void)drm_dev_alloc;
31  
32 @@ -4354,6 +4346,74 @@
33              compile_check_conftest "$CODE" "NV_DRM_PRIME_PAGES_TO_SG_HAS_DRM_DEVICE_ARG" "" "types"
34          ;;
35  
36 +        drm_driver_has_gem_prime_callbacks)
37 +            #
38 +            # Determine if drm_driver structure has the GEM and PRIME callback
39 +            # function pointers.
40 +            #
41 +            # The GEM and PRIME callback are removed from drm_driver
42 +            # structure, by commit d693def4fd1c ("drm: Remove obsolete GEM and
43 +            # PRIME callbacks from struct drm_driver").
44 +            #
45 +            CODE="
46 +            #if defined(NV_DRM_DRMP_H_PRESENT)
47 +            #include <drm/drmP.h>
48 +            #endif
49 +
50 +            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
51 +            #include <drm/drm_drv.h>
52 +            #endif
53 +
54 +            void conftest_drm_driver_has_gem_and_prime_callbacks(void) {
55 +                struct drm_driver drv;
56 +
57 +                drv.gem_prime_pin = 0;
58 +                drv.gem_prime_get_sg_table = 0;
59 +                drv.gem_prime_vmap = 0;
60 +                drv.gem_prime_vunmap = 0;
61 +                drv.gem_vm_ops = 0;
62 +            }"
63 +
64 +            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS" "" "types"
65 +        ;;
66 +
67 +        drm_crtc_atomic_check_has_atomic_state_arg)
68 +            #
69 +            # Determine if drm_crtc_helper_funcs::atomic_check takes 'state'
70 +            # argument of 'struct drm_atomic_state' type.
71 +            #
72 +            # The commit 29b77ad7b9ca ("drm/atomic: Pass the full state to CRTC
73 +            # atomic_check") passed the full atomic state to
74 +            # drm_crtc_helper_funcs::atomic_check()
75 +            #
76 +            # Turning incompatible-pointer-types check into error is necessary
77 +            # to make test fail if drm_crtc_helper_funcs::atomic_check is taking
78 +            # 'crtc_state' instead of 'state', otherwise test simply pass
79 +            # because compilation succeeds throwing incompatible-pointer-types
80 +            # warning. This test is expected to fail on Linux kernels <= v5.10,
81 +            # the commit ea8daa7b9784 ("kbuild: Add option to turn incompatible
82 +            # pointer check into error") has turned incompatible-pointer-types
83 +            # check into error from v4.6.
84 +            #
85 +            echo "$CONFTEST_PREAMBLE
86 +            #include <drm/drm_modeset_helper_vtables.h>
87 +            int conftest_drm_crtc_atomic_check_has_atomic_state_arg(
88 +                    struct drm_crtc *crtc, struct drm_atomic_state *state) {
89 +                const struct drm_crtc_helper_funcs *funcs = crtc->helper_private;
90 +                return funcs->atomic_check(crtc, state);
91 +            }" > conftest$$.c
92 +
93 +            $CC $CFLAGS -Werror=incompatible-pointer-types -c conftest$$.c > /dev/null 2>&1
94 +            rm -f conftest$$.c
95 +
96 +            if [ -f conftest$$.o ]; then
97 +                rm -f conftest$$.o
98 +                echo "#define NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" | append_conftest "types"
99 +            else
100 +                echo "#undef NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" | append_conftest "types"
101 +            fi
102 +        ;;
103 +
104      esac
105  }
106  
107 diff --color -ur NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-crtc.c NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/nvidia-drm/nvidia-drm-crtc.c
108 --- NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-crtc.c    2020-12-28 17:25:22.000000000 +0100
109 +++ NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/nvidia-drm/nvidia-drm-crtc.c 2021-02-25 18:20:36.360526434 +0100
110 @@ -336,9 +336,18 @@
111   * the 'nv_drm_crtc_state::req_config', that is fine becase 'nv_drm_crtc_state'
112   * will be discarded if ->atomic_check() fails.
113   */
114 +#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
115 +static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
116 +                                    struct drm_atomic_state *state)
117 +#else
118  static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
119                                      struct drm_crtc_state *crtc_state)
120 +#endif
121  {
122 +#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
123 +    struct drm_crtc_state *crtc_state =
124 +        drm_atomic_get_new_crtc_state(state, crtc);
125 +#endif
126      struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
127      struct NvKmsKapiHeadRequestedConfig *req_config =
128          &nv_crtc_state->req_config;
129 @@ -408,8 +417,13 @@
130  }
131  
132  #ifdef NV_DRM_CRTC_HELPER_FUNCS_HAS_ATOMIC_ENABLE
133 +#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
134 +static void nv_drm_crtc_atomic_enable(struct drm_crtc *crtc,
135 +                                      struct drm_atomic_state *state)
136 +#else
137  static void nv_drm_crtc_atomic_enable(struct drm_crtc *crtc,
138                                        struct drm_crtc_state *old_crtc_state)
139 +#endif
140  {
141  
142  }
143 diff --color -ur NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-drv.c NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/nvidia-drm/nvidia-drm-drv.c
144 --- NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-drv.c     2020-12-28 17:25:22.000000000 +0100
145 +++ NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/nvidia-drm/nvidia-drm-drv.c  2021-02-25 18:20:51.539230188 +0100
146 @@ -700,10 +700,12 @@
147      .num_ioctls             = ARRAY_SIZE(nv_drm_ioctls),
148  
149      .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
150 +#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS)
151      .gem_prime_export       = nv_drm_gem_prime_export,
152      .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
153      .gem_prime_vmap         = nv_drm_gem_prime_vmap,
154      .gem_prime_vunmap       = nv_drm_gem_prime_vunmap,
155 +#endif
156  
157  #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
158      .gem_prime_res_obj      = nv_drm_gem_prime_res_obj,
159 @@ -759,7 +761,9 @@
160      nv_drm_driver.dumb_map_offset  = nv_drm_dumb_map_offset;
161      nv_drm_driver.dumb_destroy     = drm_gem_dumb_destroy;
162  
163 +#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS)
164      nv_drm_driver.gem_vm_ops       = &nv_drm_gem_vma_ops;
165 +#endif
166  #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
167  }
168  
169 diff --color -ur NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/nvidia-drm/nvidia-drm.Kbuild NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/nvidia-drm/nvidia-drm.Kbuild
170 --- NVIDIA-Linux-x86_64-390.141-no-compat32.orig/kernel/nvidia-drm/nvidia-drm.Kbuild    2020-12-18 06:56:50.000000000 +0100
171 +++ NVIDIA-Linux-x86_64-390.141-no-compat32/kernel/nvidia-drm/nvidia-drm.Kbuild 2021-02-25 18:20:36.360526434 +0100
172 @@ -98,3 +98,5 @@
173  NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_master_set_has_int_return_type
174  NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
175  NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
176 +NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_callbacks
177 +NV_CONFTEST_TYPE_COMPILE_TESTS += drm_crtc_atomic_check_has_atomic_state_arg
This page took 0.260728 seconds and 2 git commands to generate.