]> git.pld-linux.org Git - packages/xorg-driver-video-nvidia-legacy-390xx.git/blob - kernel-5.6.patch
- fix build checks
[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-uvm/uvm_linux.h b/kernel/nvidia-uvm/uvm_linux.h
185 index 8784a82..c256cdb 100644
186 --- a/kernel/nvidia-uvm/uvm_linux.h
187 +++ b/kernel/nvidia-uvm/uvm_linux.h
188 @@ -329,7 +329,16 @@ static inline uint64_t NV_DIV64(uint64_t dividend, uint64_t divisor, uint64_t *r
189  }
190  #endif
191  
192 -#if defined(CLOCK_MONOTONIC_RAW)
193 +#if defined(NV_KTIME_GET_RAW_TS64_PRESENT)
194 +static inline NvU64 NV_GETTIME(void)
195 +{
196 +    struct timespec64 ts64 = {0};
197 +
198 +    ktime_get_raw_ts64(&ts64);
199 +
200 +    return (ts64.tv_sec * 1000000000ULL + ts64.tv_nsec);
201 +}
202 +#elif defined(CLOCK_MONOTONIC_RAW)
203  /* Return a nanosecond-precise value */
204  static inline NvU64 NV_GETTIME(void)
205  {
206 @@ -345,7 +354,7 @@ static inline NvU64 NV_GETTIME(void)
207   * available non-GPL symbols. */
208  static inline NvU64 NV_GETTIME(void)
209  {
210 -    struct timeval tv = {0};
211 +    struct nv_timeval tv = {0};
212  
213      nv_gettimeofday(&tv);
214  
215 diff --git a/kernel/nvidia/nv-procfs.c b/kernel/nvidia/nv-procfs.c
216 index 5808a88..bc60a08 100644
217 --- a/kernel/nvidia/nv-procfs.c
218 +++ b/kernel/nvidia/nv-procfs.c
219 @@ -414,6 +414,15 @@ done:
220      return ((status < 0) ? status : (int)count);
221  }
222  
223 +#if defined(NV_HAVE_PROC_OPS)
224 +static struct proc_ops nv_procfs_registry_fops = {
225 +    .proc_open    = nv_procfs_open_registry,
226 +    .proc_read    = seq_read,
227 +    .proc_write   = nv_procfs_write_file,
228 +    .proc_lseek   = seq_lseek,
229 +    .proc_release = nv_procfs_close_registry,
230 +};
231 +#else
232  static struct file_operations nv_procfs_registry_fops = {
233      .owner   = THIS_MODULE,
234      .open    = nv_procfs_open_registry,
235 @@ -422,6 +431,7 @@ static struct file_operations nv_procfs_registry_fops = {
236      .llseek  = seq_lseek,
237      .release = nv_procfs_close_registry,
238  };
239 +#endif
240  
241  /*
242   * Forwards error to nv_log_error which exposes data to vendor callback
243 @@ -517,12 +527,20 @@ done:
244      return status;
245  }
246  
247 +#if defined(NV_HAVE_PROC_OPS)
248 +static struct proc_ops nv_procfs_exercise_error_forwarding_fops = {
249 +    .proc_open    = nv_procfs_open_exercise_error_forwarding,
250 +    .proc_write   = nv_procfs_write_file,
251 +    .proc_release = nv_procfs_close_exercise_error_forwarding,
252 +};
253 +#else
254  static struct file_operations nv_procfs_exercise_error_forwarding_fops = {
255      .owner   = THIS_MODULE,
256      .open    = nv_procfs_open_exercise_error_forwarding,
257      .write   = nv_procfs_write_file,
258      .release = nv_procfs_close_exercise_error_forwarding,
259  };
260 +#endif
261  
262  static int
263  nv_procfs_read_unbind_lock(
264 @@ -650,6 +668,15 @@ done:
265      return rc;
266  }
267  
268 +#if defined(NV_HAVE_PROC_OPS)
269 +static struct proc_ops nv_procfs_unbind_lock_fops = {
270 +    .proc_open    = nv_procfs_open_unbind_lock,
271 +    .proc_read    = seq_read,
272 +    .proc_write   = nv_procfs_write_file,
273 +    .proc_lseek   = seq_lseek,
274 +    .proc_release = nv_procfs_close_unbind_lock,
275 +};
276 +#else
277  static struct file_operations nv_procfs_unbind_lock_fops = {
278      .owner   = THIS_MODULE,
279      .open    = nv_procfs_open_unbind_lock,
280 @@ -658,6 +685,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
281      .llseek  = seq_lseek,
282      .release = nv_procfs_close_unbind_lock,
283  };
284 +#endif
285  
286  static int
287  nv_procfs_read_text_file(
288 diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
289 index 8ae1016..da7f135 100644
290 --- a/kernel/nvidia/nvidia.Kbuild
291 +++ b/kernel/nvidia/nvidia.Kbuild
292 @@ -117,6 +117,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += on_each_cpu
293  NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_call_function
294  NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_evaluate_integer
295  NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache
296 +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
297  NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc
298  NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
299  NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_domain_nr
300 @@ -169,7 +170,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
301  NV_CONFTEST_TYPE_COMPILE_TESTS += proc_dir_entry
302  NV_CONFTEST_TYPE_COMPILE_TESTS += scatterlist
303  NV_CONFTEST_TYPE_COMPILE_TESTS += sg_table
304 +NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
305  NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
306 +NV_CONFTEST_TYPE_COMPILE_TESTS += ktime_get_raw_ts64
307  NV_CONFTEST_TYPE_COMPILE_TESTS += vm_operations_struct
308  NV_CONFTEST_TYPE_COMPILE_TESTS += atomic_long_type
309  NV_CONFTEST_TYPE_COMPILE_TESTS += pci_save_state
310 diff --git a/kernel/nvidia/nvlink_linux.c b/kernel/nvidia/nvlink_linux.c
311 index 0014280..537b257 100644
312 --- a/kernel/nvidia/nvlink_linux.c
313 +++ b/kernel/nvidia/nvlink_linux.c
314 @@ -518,8 +518,8 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size)
315  
316  static NvBool nv_timer_less_than
317  (
318 -    const struct timeval *a,
319 -    const struct timeval *b
320 +    const struct nv_timeval *a,
321 +    const struct nv_timeval *b
322  )
323  {
324      return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec) 
325 @@ -528,9 +528,9 @@ static NvBool nv_timer_less_than
326  
327  static void nv_timeradd
328  (
329 -    const struct timeval    *a,
330 -    const struct timeval    *b,
331 -    struct timeval          *result
332 +    const struct nv_timeval    *a,
333 +    const struct nv_timeval    *b,
334 +    struct nv_timeval          *result
335  )
336  {
337      result->tv_sec = a->tv_sec + b->tv_sec;
338 @@ -544,9 +544,9 @@ static void nv_timeradd
339  
340  static void nv_timersub
341  (
342 -    const struct timeval    *a,
343 -    const struct timeval    *b,
344 -    struct timeval          *result
345 +    const struct nv_timeval    *a,
346 +    const struct nv_timeval    *b,
347 +    struct nv_timeval          *result
348  )
349  {
350      result->tv_sec = a->tv_sec - b->tv_sec;
351 @@ -566,7 +566,7 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
352      unsigned long us;
353      unsigned long jiffies;
354      unsigned long mdelay_safe_msec;
355 -    struct timeval tm_end, tm_aux;
356 +    struct nv_timeval tm_end, tm_aux;
357  
358      nv_gettimeofday(&tm_aux);
359  
360 diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c
361 index 344daa8..39d0a19 100644
362 --- a/kernel/nvidia/os-interface.c
363 +++ b/kernel/nvidia/os-interface.c
364 @@ -430,7 +430,7 @@ NV_STATUS NV_API_CALL os_get_current_time(
365      NvU32 *useconds
366  )
367  {
368 -    struct timeval tm;
369 +    struct nv_timeval tm;
370  
371      nv_gettimeofday(&tm);
372  
373 @@ -444,9 +444,15 @@ NV_STATUS NV_API_CALL os_get_current_time(
374  
375  void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
376  {
377 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0)
378 +    struct timespec64 ts;
379 +
380 +    jiffies_to_timespec64(jiffies, &ts);
381 +#else
382      struct timespec ts;
383  
384      jiffies_to_timespec(jiffies, &ts);
385 +#endif
386  
387      *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec);
388  }
389 @@ -502,7 +508,7 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
390      unsigned long usec;
391  
392  #ifdef NV_CHECK_DELAY_ACCURACY
393 -    struct timeval tm1, tm2;
394 +    struct nv_timeval tm1, tm2;
395  
396      nv_gettimeofday(&tm1);
397  #endif
398 @@ -542,9 +548,9 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
399      unsigned long MicroSeconds;
400      unsigned long jiffies;
401      unsigned long mdelay_safe_msec;
402 -    struct timeval tm_end, tm_aux;
403 +    struct nv_timeval tm_end, tm_aux;
404  #ifdef NV_CHECK_DELAY_ACCURACY
405 -    struct timeval tm_start;
406 +    struct nv_timeval tm_start;
407  #endif
408  
409      nv_gettimeofday(&tm_aux);
410 @@ -1926,7 +1932,7 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp
411  {
412      struct ipmi_recv_msg    *rx_msg;
413      int                     err_no;
414 -    struct timeval          tv;
415 +    struct nv_timeval          tv;
416      NvU64                   start_time;
417  
418      nv_gettimeofday(&tv);
This page took 0.068772 seconds and 3 git commands to generate.