Guest User

Untitled

a guest
Feb 29th, 2020
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
  2. index 123fdd2..778df2c 100644
  3. --- a/common/inc/nv-linux.h
  4. +++ b/common/inc/nv-linux.h
  5. @@ -564,7 +564,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/common/inc/nv-procfs.h b/common/inc/nv-procfs.h
  18. index 3c812ea..9e9bc2c 100644
  19. --- a/common/inc/nv-procfs.h
  20. +++ b/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/common/inc/nv-time.h b/common/inc/nv-time.h
  83. index 2c799c9..0206062 100644
  84. --- a/common/inc/nv-time.h
  85. +++ b/common/inc/nv-time.h
  86. @@ -30,7 +30,12 @@
  87. #include <linux/ktime.h>
  88. #endif
  89.  
  90. -static inline void nv_gettimeofday(struct timeval *tv)
  91. +struct nv_timeval {
  92. + __kernel_long_t tv_sec;
  93. + __kernel_suseconds_t tv_usec;
  94. +};
  95. +
  96. +static inline void nv_gettimeofday(struct nv_timeval *tv)
  97. {
  98. #ifdef NV_DO_GETTIMEOFDAY_PRESENT
  99. do_gettimeofday(tv);
  100. @@ -39,7 +44,7 @@ static inline void nv_gettimeofday(struct timeval *tv)
  101.  
  102. ktime_get_real_ts64(&now);
  103.  
  104. - *tv = (struct timeval) {
  105. + *tv = (struct nv_timeval) {
  106. .tv_sec = now.tv_sec,
  107. .tv_usec = now.tv_nsec/1000,
  108. };
  109. diff --git a/conftest.sh b/conftest.sh
  110. index 26f53d4..8c1bec8 100644
  111. --- a/conftest.sh
  112. +++ b/conftest.sh
  113. @@ -1136,6 +1136,22 @@ compile_test() {
  114. compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions"
  115. ;;
  116.  
  117. + ioremap_nocache)
  118. + #
  119. + # Determine if the ioremap_nocache() function is present.
  120. + #
  121. + # Removed by commit 4bdc0d676a64 ("remove ioremap_nocache and
  122. + # devm_ioremap_nocache") in v5.6 (2020-01-06)
  123. + #
  124. + CODE="
  125. + #include <asm/io.h>
  126. + void conftest_ioremap_nocache(void) {
  127. + ioremap_nocache();
  128. + }"
  129. +
  130. + compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
  131. + ;;
  132. +
  133. ioremap_wc)
  134. #
  135. # Determine if the ioremap_wc() function is present.
  136. @@ -1331,6 +1347,46 @@ compile_test() {
  137. compile_check_conftest "$CODE" "NV_SG_TABLE_PRESENT" "" "types"
  138. ;;
  139.  
  140. + proc_ops)
  141. + CODE="
  142. + #include <linux/proc_fs.h>
  143. + int conftest_proc_ops(void) {
  144. + return offsetof(struct proc_ops, proc_open);
  145. + }"
  146. +
  147. + compile_check_conftest "$CODE" "NV_HAVE_PROC_OPS" "" "types"
  148. + ;;
  149. +
  150. + ktime_get_raw_ts64)
  151. + #
  152. + # Determine if the ktime_get_raw_ts64() function is present.
  153. + #
  154. + CODE="
  155. + #include <linux/ktime.h>
  156. + int conftest_ktime_get_raw_ts64(void) {
  157. + struct timespec64 ts = {0};
  158. +
  159. + ktime_get_raw_ts64(&ts64);
  160. + }"
  161. +
  162. + compile_check_conftest "$CODE" "NV_KTIME_GET_RAW_TS64_PRESENT" "" "functions"
  163. + ;;
  164. +
  165. + ktime_get_real_ts64)
  166. + #
  167. + # Determine if the ktime_get_real_ts64() function is present.
  168. + #
  169. + CODE="
  170. + #include <linux/ktime.h>
  171. + int conftest_ktime_get_raw_ts64(void) {
  172. + struct timespec64 ts = {0};
  173. +
  174. + ktime_get_real_ts64(&ts64);
  175. + }"
  176. +
  177. + compile_check_conftest "$CODE" "NV_KTIME_GET_REAL_TS64_PRESENT" "" "functions"
  178. + ;;
  179. +
  180. sg_alloc_table)
  181. #
  182. # Determine if include/linux/scatterlist.h exists and which table
  183. diff --git a/nvidia-modeset/nvidia-modeset-linux.c b/nvidia-modeset/nvidia-modeset-linux.c
  184. index a479f20..f7afb8a 100644
  185. --- a/nvidia-modeset/nvidia-modeset-linux.c
  186. +++ b/nvidia-modeset/nvidia-modeset-linux.c
  187. @@ -212,7 +212,7 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec)
  188.  
  189. NvU64 NVKMS_API_CALL nvkms_get_usec(void)
  190. {
  191. - struct timeval tv;
  192. + struct nv_timeval tv;
  193.  
  194. nv_gettimeofday(&tv);
  195.  
  196. diff --git a/nvidia-uvm/uvm8_tools.c b/nvidia-uvm/uvm8_tools.c
  197. index 9351b93..ac0ec50 100644
  198. --- a/nvidia-uvm/uvm8_tools.c
  199. +++ b/nvidia-uvm/uvm8_tools.c
  200. @@ -213,6 +213,10 @@ static void put_user_pages(struct page **pages, NvU64 page_count)
  201. }
  202. */
  203.  
  204. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
  205. +#define put_user_pages unpin_user_pages
  206. +#endif
  207. +
  208. static void unmap_user_pages(struct page **pages, void *addr, NvU64 size)
  209. {
  210. size = DIV_ROUND_UP(size, PAGE_SIZE);
  211. diff --git a/nvidia-uvm/uvm_linux.h b/nvidia-uvm/uvm_linux.h
  212. index 8784a82..c0e1666 100644
  213. --- a/nvidia-uvm/uvm_linux.h
  214. +++ b/nvidia-uvm/uvm_linux.h
  215. @@ -329,7 +329,16 @@ static inline uint64_t NV_DIV64(uint64_t dividend, uint64_t divisor, uint64_t *r
  216. }
  217. #endif
  218.  
  219. -#if defined(CLOCK_MONOTONIC_RAW)
  220. +#if defined(NV_KTIME_GET_RAW_TS64_PRESENT)
  221. +static inline NvU64 NV_GETTIME(void)
  222. +{
  223. + struct timespec64 ts;
  224. +
  225. + ktime_get_raw_ts64(&ts);
  226. +
  227. + return (ts.tv_sec * 1000000000ULL + ts.tv_nsec);
  228. +}
  229. +#elif defined(CLOCK_MONOTONIC_RAW)
  230. /* Return a nanosecond-precise value */
  231. static inline NvU64 NV_GETTIME(void)
  232. {
  233. @@ -345,7 +354,7 @@ static inline NvU64 NV_GETTIME(void)
  234. * available non-GPL symbols. */
  235. static inline NvU64 NV_GETTIME(void)
  236. {
  237. - struct timeval tv = {0};
  238. + struct nv_timeval tv = {0};
  239.  
  240. nv_gettimeofday(&tv);
  241.  
  242. diff --git a/nvidia/nv-procfs.c b/nvidia/nv-procfs.c
  243. index 5808a88..a87e83c 100644
  244. --- a/nvidia/nv-procfs.c
  245. +++ b/nvidia/nv-procfs.c
  246. @@ -414,6 +414,15 @@ done:
  247. return ((status < 0) ? status : (int)count);
  248. }
  249.  
  250. +#if defined(NV_HAVE_PROC_OPS)
  251. +static struct proc_ops nv_procfs_registry_fops = {
  252. + .proc_open = nv_procfs_open_registry,
  253. + .proc_read = seq_read,
  254. + .proc_write = nv_procfs_write_file,
  255. + .proc_lseek = seq_lseek,
  256. + .proc_release = nv_procfs_close_registry,
  257. +};
  258. +#else
  259. static struct file_operations nv_procfs_registry_fops = {
  260. .owner = THIS_MODULE,
  261. .open = nv_procfs_open_registry,
  262. @@ -422,6 +431,7 @@ static struct file_operations nv_procfs_registry_fops = {
  263. .llseek = seq_lseek,
  264. .release = nv_procfs_close_registry,
  265. };
  266. +#endif
  267.  
  268. /*
  269. * Forwards error to nv_log_error which exposes data to vendor callback
  270. @@ -517,12 +527,20 @@ done:
  271. return status;
  272. }
  273.  
  274. +#if defined(NV_HAVE_PROC_OPS)
  275. +static struct proc_ops nv_procfs_exercise_error_forwarding_fops = {
  276. + .proc_open = nv_procfs_open_exercise_error_forwarding,
  277. + .proc_write = nv_procfs_write_file,
  278. + .proc_release = nv_procfs_close_exercise_error_forwarding,
  279. +};
  280. +#else
  281. static struct file_operations nv_procfs_exercise_error_forwarding_fops = {
  282. .owner = THIS_MODULE,
  283. .open = nv_procfs_open_exercise_error_forwarding,
  284. .write = nv_procfs_write_file,
  285. .release = nv_procfs_close_exercise_error_forwarding,
  286. };
  287. +#endif
  288.  
  289. static int
  290. nv_procfs_read_unbind_lock(
  291. @@ -650,6 +668,15 @@ done:
  292. return rc;
  293. }
  294.  
  295. +#if defined(NV_HAVE_PROC_OPS)
  296. +static struct proc_ops nv_procfs_unbind_lock_fops = {
  297. + .proc_open = nv_procfs_open_unbind_lock,
  298. + .proc_read = seq_read,
  299. + .proc_write = nv_procfs_write_file,
  300. + .proc_lseek = seq_lseek,
  301. + .proc_release = nv_procfs_close_unbind_lock,
  302. +};
  303. +#else
  304. static struct file_operations nv_procfs_unbind_lock_fops = {
  305. .owner = THIS_MODULE,
  306. .open = nv_procfs_open_unbind_lock,
  307. @@ -658,6 +685,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
  308. .llseek = seq_lseek,
  309. .release = nv_procfs_close_unbind_lock,
  310. };
  311. +#endif
  312.  
  313. static int
  314. nv_procfs_read_text_file(
  315. diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
  316. index e1474f0..f6741e6 100644
  317. --- a/nvidia/nvidia.Kbuild
  318. +++ b/nvidia/nvidia.Kbuild
  319. @@ -120,6 +120,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += on_each_cpu
  320. NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_call_function
  321. NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_evaluate_integer
  322. NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache
  323. +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
  324. NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc
  325. NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
  326. NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_domain_nr
  327. @@ -171,6 +172,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += proc_dir_entry
  328. NV_CONFTEST_TYPE_COMPILE_TESTS += scatterlist
  329. NV_CONFTEST_TYPE_COMPILE_TESTS += sg_table
  330. NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
  331. +NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
  332. +NV_CONFTEST_TYPE_COMPILE_TESTS += ktime_get_raw_ts64
  333. +NV_CONFTEST_TYPE_COMPILE_TESTS += ktime_get_real_ts64
  334. NV_CONFTEST_TYPE_COMPILE_TESTS += vm_operations_struct
  335. NV_CONFTEST_TYPE_COMPILE_TESTS += atomic_long_type
  336. NV_CONFTEST_TYPE_COMPILE_TESTS += pci_save_state
  337. diff --git a/nvidia/nvlink_linux.c b/nvidia/nvlink_linux.c
  338. index 0014280..537b257 100644
  339. --- a/nvidia/nvlink_linux.c
  340. +++ b/nvidia/nvlink_linux.c
  341. @@ -518,8 +518,8 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size)
  342.  
  343. static NvBool nv_timer_less_than
  344. (
  345. - const struct timeval *a,
  346. - const struct timeval *b
  347. + const struct nv_timeval *a,
  348. + const struct nv_timeval *b
  349. )
  350. {
  351. return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec)
  352. @@ -528,9 +528,9 @@ static NvBool nv_timer_less_than
  353.  
  354. static void nv_timeradd
  355. (
  356. - const struct timeval *a,
  357. - const struct timeval *b,
  358. - struct timeval *result
  359. + const struct nv_timeval *a,
  360. + const struct nv_timeval *b,
  361. + struct nv_timeval *result
  362. )
  363. {
  364. result->tv_sec = a->tv_sec + b->tv_sec;
  365. @@ -544,9 +544,9 @@ static void nv_timeradd
  366.  
  367. static void nv_timersub
  368. (
  369. - const struct timeval *a,
  370. - const struct timeval *b,
  371. - struct timeval *result
  372. + const struct nv_timeval *a,
  373. + const struct nv_timeval *b,
  374. + struct nv_timeval *result
  375. )
  376. {
  377. result->tv_sec = a->tv_sec - b->tv_sec;
  378. @@ -566,7 +566,7 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
  379. unsigned long us;
  380. unsigned long jiffies;
  381. unsigned long mdelay_safe_msec;
  382. - struct timeval tm_end, tm_aux;
  383. + struct nv_timeval tm_end, tm_aux;
  384.  
  385. nv_gettimeofday(&tm_aux);
  386.  
  387. diff --git a/nvidia/os-interface.c b/nvidia/os-interface.c
  388. index 344daa8..39d0a19 100644
  389. --- a/nvidia/os-interface.c
  390. +++ b/nvidia/os-interface.c
  391. @@ -430,7 +430,7 @@ NV_STATUS NV_API_CALL os_get_current_time(
  392. NvU32 *useconds
  393. )
  394. {
  395. - struct timeval tm;
  396. + struct nv_timeval tm;
  397.  
  398. nv_gettimeofday(&tm);
  399.  
  400. @@ -444,9 +444,15 @@ NV_STATUS NV_API_CALL os_get_current_time(
  401.  
  402. void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
  403. {
  404. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0)
  405. + struct timespec64 ts;
  406. +
  407. + jiffies_to_timespec64(jiffies, &ts);
  408. +#else
  409. struct timespec ts;
  410.  
  411. jiffies_to_timespec(jiffies, &ts);
  412. +#endif
  413.  
  414. *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec);
  415. }
  416. @@ -502,7 +508,7 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
  417. unsigned long usec;
  418.  
  419. #ifdef NV_CHECK_DELAY_ACCURACY
  420. - struct timeval tm1, tm2;
  421. + struct nv_timeval tm1, tm2;
  422.  
  423. nv_gettimeofday(&tm1);
  424. #endif
  425. @@ -542,9 +548,9 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
  426. unsigned long MicroSeconds;
  427. unsigned long jiffies;
  428. unsigned long mdelay_safe_msec;
  429. - struct timeval tm_end, tm_aux;
  430. + struct nv_timeval tm_end, tm_aux;
  431. #ifdef NV_CHECK_DELAY_ACCURACY
  432. - struct timeval tm_start;
  433. + struct nv_timeval tm_start;
  434. #endif
  435.  
  436. nv_gettimeofday(&tm_aux);
  437. @@ -1926,7 +1932,7 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp
  438. {
  439. struct ipmi_recv_msg *rx_msg;
  440. int err_no;
  441. - struct timeval tv;
  442. + struct nv_timeval tv;
  443. NvU64 start_time;
  444.  
  445. nv_gettimeofday(&tv);
RAW Paste Data