]> git.pld-linux.org Git - packages/xorg-driver-video-nvidia-legacy-390xx.git/blob - kernel-5.6.patch
fix build with kernel 5.7
[packages/xorg-driver-video-nvidia-legacy-390xx.git] / kernel-5.6.patch
1 diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
2 index 85041c2..ac5bb95 100644
3 --- a/kernel/common/inc/nv-linux.h
4 +++ b/kernel/common/inc/nv-linux.h
5 @@ -553,7 +553,11 @@ static inline void *nv_ioremap(NvU64 phys, NvU64 size)
6  
7  static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size)
8  {
9 +#if defined(NV_IOREMAP_NOCACHE_PRESENT)
10      void *ptr = ioremap_nocache(phys, size);
11 +#else
12 +    void *ptr = ioremap(phys, size);
13 +#endif
14      if (ptr)
15          NV_MEMDBG_ADD(ptr, size);
16      return ptr;
17 diff --git a/kernel/common/inc/nv-procfs.h b/kernel/common/inc/nv-procfs.h
18 index 3c812ea..e57c4f9 100644
19 --- a/kernel/common/inc/nv-procfs.h
20 +++ b/kernel/common/inc/nv-procfs.h
21 @@ -52,6 +52,19 @@
22      })
23  #endif
24  
25 +#if defined(NV_HAVE_PROC_OPS)
26 +#define NV_CREATE_PROC_FILE(filename,parent,__name,__data)               \
27 +   ({                                                                    \
28 +        struct proc_dir_entry *__entry;                                  \
29 +        int mode = (S_IFREG | S_IRUGO);                                  \
30 +        const struct proc_ops *fops = &nv_procfs_##__name##_fops;        \
31 +        if (fops->proc_write != 0)                                       \
32 +            mode |= S_IWUSR;                                             \
33 +        __entry = NV_CREATE_PROC_ENTRY(filename, mode, parent, fops,     \
34 +            __data);                                                     \
35 +        __entry;                                                         \
36 +    })
37 +#else
38  #define NV_CREATE_PROC_FILE(filename,parent,__name,__data)               \
39     ({                                                                    \
40          struct proc_dir_entry *__entry;                                  \
41 @@ -63,6 +76,7 @@
42              __data);                                                     \
43          __entry;                                                         \
44      })
45 +#endif
46  
47  /*
48   * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
49 @@ -104,6 +118,24 @@
50      remove_proc_entry(entry->name, entry->parent);
51  #endif
52  
53 +#if defined(NV_HAVE_PROC_OPS)
54 +#define NV_DEFINE_PROCFS_SINGLE_FILE(__name)                                  \
55 +    static int nv_procfs_open_##__name(                                       \
56 +        struct inode *inode,                                                  \
57 +        struct file *filep                                                    \
58 +    )                                                                         \
59 +    {                                                                         \
60 +        return single_open(filep, nv_procfs_read_##__name,                    \
61 +            NV_PDE_DATA(inode));                                              \
62 +    }                                                                         \
63 +                                                                              \
64 +    static const struct proc_ops nv_procfs_##__name##_fops = {                \
65 +        .proc_open       = nv_procfs_open_##__name,                           \
66 +        .proc_read       = seq_read,                                          \
67 +        .proc_lseek      = seq_lseek,                                         \
68 +        .proc_release    = single_release,                                    \
69 +    };
70 +#else
71  #define NV_DEFINE_PROCFS_SINGLE_FILE(__name)                                  \
72      static int nv_procfs_open_##__name(                                       \
73          struct inode *inode,                                                  \
74 @@ -121,6 +153,7 @@
75          .llseek     = seq_lseek,                                              \
76          .release    = single_release,                                         \
77      };
78 +#endif
79  
80  #endif  /* CONFIG_PROC_FS */
81  
82 diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h
83 index 2c799c9..0206062 100644
84 --- a/kernel/common/inc/nv-time.h
85 +++ b/kernel/common/inc/nv-time.h
86 @@ -30,7 +30,17 @@
87  #include <linux/ktime.h>
88  #endif
89  
90 -static inline void nv_gettimeofday(struct timeval *tv)
91 +#include <linux/version.h>
92 +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
93 +#define nv_timeval timeval
94 +#else
95 +struct nv_timeval {
96 +    __kernel_long_t      tv_sec;
97 +    __kernel_suseconds_t tv_usec;
98 +};
99 +#endif
100 +
101 +static inline void nv_gettimeofday(struct nv_timeval *tv)
102  {
103  #ifdef NV_DO_GETTIMEOFDAY_PRESENT
104      do_gettimeofday(tv);
105 @@ -39,7 +44,7 @@ static inline void nv_gettimeofday(struct timeval *tv)
106  
107      ktime_get_real_ts64(&now);
108  
109 -    *tv = (struct timeval) {
110 +    *tv = (struct nv_timeval) {
111          .tv_sec = now.tv_sec,
112          .tv_usec = now.tv_nsec/1000,
113      };
114 diff --git a/kernel/conftest.sh b/kernel/conftest.sh
115 index ec9e093..463a464 100755
116 --- a/kernel/conftest.sh
117 +++ b/kernel/conftest.sh
118 @@ -1197,6 +1197,22 @@ compile_test() {
119              compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions"
120          ;;
121  
122 +        ioremap_nocache)
123 +            #
124 +            # Determine if the ioremap_nocache() function is present.
125 +            #
126 +            # Removed by commit 4bdc0d676a64 ("remove ioremap_nocache and
127 +            # devm_ioremap_nocache") in v5.6 (2020-01-06)
128 +            #
129 +            CODE="
130 +            #include <asm/io.h>
131 +            void conftest_ioremap_nocache(void) {
132 +                ioremap_nocache();
133 +            }"
134 +
135 +            compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
136 +        ;;
137 +
138          ioremap_wc)
139              #
140              # Determine if the ioremap_wc() function is present.
141 @@ -1430,6 +1446,29 @@ compile_test() {
142              compile_check_conftest "$CODE" "NV_SG_ALLOC_TABLE_FROM_PAGES_PRESENT" "" "functions"
143          ;;
144  
145 +        proc_ops)
146 +            CODE="
147 +            #include <linux/proc_fs.h>
148 +            int conftest_proc_ops(void) {
149 +                return offsetof(struct proc_ops, proc_open);
150 +            }"
151 +
152 +            compile_check_conftest "$CODE" "NV_HAVE_PROC_OPS" "" "types"
153 +        ;;
154 +
155 +        ktime_get_raw_ts64)
156 +            #
157 +            # Determine if the ktime_get_raw_ts64() function is present.
158 +            #
159 +            CODE="
160 +            #include <linux/ktime.h>
161 +            int conftest_ktime_get_raw_ts64(void) {
162 +                ktime_get_raw_ts64();
163 +            }"
164 +
165 +            compile_check_conftest "$CODE" "NV_KTIME_GET_RAW_TS64_PRESENT" "" "functions"
166 +        ;;
167 +
168          efi_enabled)
169              #
170              # Determine if the efi_enabled symbol is present, or if
171 diff --git a/kernel/nvidia-modeset/nvidia-modeset-linux.c b/kernel/nvidia-modeset/nvidia-modeset-linux.c
172 index d42aabb..f0404fb 100644
173 --- a/kernel/nvidia-modeset/nvidia-modeset-linux.c
174 +++ b/kernel/nvidia-modeset/nvidia-modeset-linux.c
175 @@ -216,7 +216,7 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec)
176  
177  NvU64 NVKMS_API_CALL nvkms_get_usec(void)
178  {
179 -    struct timeval tv;
180 +    struct nv_timeval tv;
181  
182      nv_gettimeofday(&tv);
183  
184 diff --git a/kernel/nvidia/nv-procfs.c b/kernel/nvidia/nv-procfs.c
185 index 5808a88..bc60a08 100644
186 --- a/kernel/nvidia/nv-procfs.c
187 +++ b/kernel/nvidia/nv-procfs.c
188 @@ -414,6 +414,15 @@ done:
189      return ((status < 0) ? status : (int)count);
190  }
191  
192 +#if defined(NV_HAVE_PROC_OPS)
193 +static struct proc_ops nv_procfs_registry_fops = {
194 +    .proc_open    = nv_procfs_open_registry,
195 +    .proc_read    = seq_read,
196 +    .proc_write   = nv_procfs_write_file,
197 +    .proc_lseek   = seq_lseek,
198 +    .proc_release = nv_procfs_close_registry,
199 +};
200 +#else
201  static struct file_operations nv_procfs_registry_fops = {
202      .owner   = THIS_MODULE,
203      .open    = nv_procfs_open_registry,
204 @@ -422,6 +431,7 @@ static struct file_operations nv_procfs_registry_fops = {
205      .llseek  = seq_lseek,
206      .release = nv_procfs_close_registry,
207  };
208 +#endif
209  
210  /*
211   * Forwards error to nv_log_error which exposes data to vendor callback
212 @@ -517,12 +527,20 @@ done:
213      return status;
214  }
215  
216 +#if defined(NV_HAVE_PROC_OPS)
217 +static struct proc_ops nv_procfs_exercise_error_forwarding_fops = {
218 +    .proc_open    = nv_procfs_open_exercise_error_forwarding,
219 +    .proc_write   = nv_procfs_write_file,
220 +    .proc_release = nv_procfs_close_exercise_error_forwarding,
221 +};
222 +#else
223  static struct file_operations nv_procfs_exercise_error_forwarding_fops = {
224      .owner   = THIS_MODULE,
225      .open    = nv_procfs_open_exercise_error_forwarding,
226      .write   = nv_procfs_write_file,
227      .release = nv_procfs_close_exercise_error_forwarding,
228  };
229 +#endif
230  
231  static int
232  nv_procfs_read_unbind_lock(
233 @@ -650,6 +668,15 @@ done:
234      return rc;
235  }
236  
237 +#if defined(NV_HAVE_PROC_OPS)
238 +static struct proc_ops nv_procfs_unbind_lock_fops = {
239 +    .proc_open    = nv_procfs_open_unbind_lock,
240 +    .proc_read    = seq_read,
241 +    .proc_write   = nv_procfs_write_file,
242 +    .proc_lseek   = seq_lseek,
243 +    .proc_release = nv_procfs_close_unbind_lock,
244 +};
245 +#else
246  static struct file_operations nv_procfs_unbind_lock_fops = {
247      .owner   = THIS_MODULE,
248      .open    = nv_procfs_open_unbind_lock,
249 @@ -658,6 +685,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
250      .llseek  = seq_lseek,
251      .release = nv_procfs_close_unbind_lock,
252  };
253 +#endif
254  
255  static int
256  nv_procfs_read_text_file(
257 diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
258 index 8ae1016..da7f135 100644
259 --- a/kernel/nvidia/nvidia.Kbuild
260 +++ b/kernel/nvidia/nvidia.Kbuild
261 @@ -117,6 +117,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += on_each_cpu
262  NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_call_function
263  NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_evaluate_integer
264  NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache
265 +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
266  NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc
267  NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
268  NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_domain_nr
269 @@ -169,7 +170,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
270  NV_CONFTEST_TYPE_COMPILE_TESTS += proc_dir_entry
271  NV_CONFTEST_TYPE_COMPILE_TESTS += scatterlist
272  NV_CONFTEST_TYPE_COMPILE_TESTS += sg_table
273 +NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
274  NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
275 +NV_CONFTEST_TYPE_COMPILE_TESTS += ktime_get_raw_ts64
276  NV_CONFTEST_TYPE_COMPILE_TESTS += vm_operations_struct
277  NV_CONFTEST_TYPE_COMPILE_TESTS += atomic_long_type
278  NV_CONFTEST_TYPE_COMPILE_TESTS += pci_save_state
279 diff --git a/kernel/nvidia/nvlink_linux.c b/kernel/nvidia/nvlink_linux.c
280 index 0014280..537b257 100644
281 --- a/kernel/nvidia/nvlink_linux.c
282 +++ b/kernel/nvidia/nvlink_linux.c
283 @@ -518,8 +518,8 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size)
284  
285  static NvBool nv_timer_less_than
286  (
287 -    const struct timeval *a,
288 -    const struct timeval *b
289 +    const struct nv_timeval *a,
290 +    const struct nv_timeval *b
291  )
292  {
293      return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec) 
294 @@ -528,9 +528,9 @@ static NvBool nv_timer_less_than
295  
296  static void nv_timeradd
297  (
298 -    const struct timeval    *a,
299 -    const struct timeval    *b,
300 -    struct timeval          *result
301 +    const struct nv_timeval    *a,
302 +    const struct nv_timeval    *b,
303 +    struct nv_timeval          *result
304  )
305  {
306      result->tv_sec = a->tv_sec + b->tv_sec;
307 @@ -544,9 +544,9 @@ static void nv_timeradd
308  
309  static void nv_timersub
310  (
311 -    const struct timeval    *a,
312 -    const struct timeval    *b,
313 -    struct timeval          *result
314 +    const struct nv_timeval    *a,
315 +    const struct nv_timeval    *b,
316 +    struct nv_timeval          *result
317  )
318  {
319      result->tv_sec = a->tv_sec - b->tv_sec;
320 @@ -566,7 +566,7 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
321      unsigned long us;
322      unsigned long jiffies;
323      unsigned long mdelay_safe_msec;
324 -    struct timeval tm_end, tm_aux;
325 +    struct nv_timeval tm_end, tm_aux;
326  
327      nv_gettimeofday(&tm_aux);
328  
329 diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c
330 index 344daa8..39d0a19 100644
331 --- a/kernel/nvidia/os-interface.c
332 +++ b/kernel/nvidia/os-interface.c
333 @@ -430,7 +430,7 @@ NV_STATUS NV_API_CALL os_get_current_time(
334      NvU32 *useconds
335  )
336  {
337 -    struct timeval tm;
338 +    struct nv_timeval tm;
339  
340      nv_gettimeofday(&tm);
341  
342 @@ -444,9 +444,15 @@ NV_STATUS NV_API_CALL os_get_current_time(
343  
344  void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
345  {
346 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0)
347 +    struct timespec64 ts;
348 +
349 +    jiffies_to_timespec64(jiffies, &ts);
350 +#else
351      struct timespec ts;
352  
353      jiffies_to_timespec(jiffies, &ts);
354 +#endif
355  
356      *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec);
357  }
358 @@ -502,7 +508,7 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
359      unsigned long usec;
360  
361  #ifdef NV_CHECK_DELAY_ACCURACY
362 -    struct timeval tm1, tm2;
363 +    struct nv_timeval tm1, tm2;
364  
365      nv_gettimeofday(&tm1);
366  #endif
367 @@ -542,9 +548,9 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
368      unsigned long MicroSeconds;
369      unsigned long jiffies;
370      unsigned long mdelay_safe_msec;
371 -    struct timeval tm_end, tm_aux;
372 +    struct nv_timeval tm_end, tm_aux;
373  #ifdef NV_CHECK_DELAY_ACCURACY
374 -    struct timeval tm_start;
375 +    struct nv_timeval tm_start;
376  #endif
377  
378      nv_gettimeofday(&tm_aux);
379 @@ -1926,7 +1932,7 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp
380  {
381      struct ipmi_recv_msg    *rx_msg;
382      int                     err_no;
383 -    struct timeval          tv;
384 +    struct nv_timeval          tv;
385      NvU64                   start_time;
386  
387      nv_gettimeofday(&tv);
This page took 0.068635 seconds and 3 git commands to generate.