Mageia Bugzilla – Attachment 11638 Details for
Bug 26612
dkms-nvidia-current fails to build on old kernels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Completion of 5.6 patch for fixing building in older kernels
NVIDIA-Linux-x86_64-430.64-fixes-for-kernels-where-do_gettimeofday-still-exists.patch (text/plain), 8.71 KB, created by
Giuseppe Ghibò
on 2020-05-12 15:10:39 CEST
(
hide
)
Description:
Completion of 5.6 patch for fixing building in older kernels
Filename:
MIME Type:
Creator:
Giuseppe Ghibò
Created:
2020-05-12 15:10:39 CEST
Size:
8.71 KB
patch
obsolete
>From 2e94283d60ebfc43b69e2e987e6ea94d2ffbefde Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Giuseppe=20Ghib=C3=B2?= <ghibo@mageia.org> >Date: Tue, 12 May 2020 14:24:46 +0200 >Subject: [PATCH] fixes for kernels where do_gettimeofday() still exists > >With the patch for the 5.6.x kernels, the nvidia 430.64 kernel modules fails to build on >older kernels, where the do_gettimeofday() function is still existing (such >as in kernel 4.19.x). This patch, borrowed from the nvidia 440 series, fixes this problem. > >--- > kernel/common/inc/nv-time.h | 13 +++++++------ > kernel/conftest.sh | 17 +++++++++++++++++ > kernel/nvidia-modeset/nvidia-modeset-linux.c | 2 +- > kernel/nvidia-modeset/nvidia-modeset.Kbuild | 1 + > kernel/nvidia-uvm/nvidia-uvm.Kbuild | 1 + > kernel/nvidia-uvm/uvm_linux.h | 2 +- > kernel/nvidia/nvidia.Kbuild | 1 + > kernel/nvidia/nvlink_linux.c | 18 +++++++++--------- > kernel/nvidia/os-interface.c | 10 +++++----- > 9 files changed, 43 insertions(+), 22 deletions(-) > >diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h >index f03c7b0..b4fe2b7 100644 >--- a/kernel/common/inc/nv-time.h >+++ b/kernel/common/inc/nv-time.h >@@ -26,23 +26,24 @@ > #include "conftest.h" > > #include <linux/ktime.h> > >-struct nv_timeval { >- __kernel_long_t tv_sec; >- __kernel_suseconds_t tv_usec; >-}; >+#if defined (NV_TIMEVAL_PRESENT) >+typedef struct timeval nv_timeval; >+#else >+typedef struct __kernel_old_timeval nv_timeval; >+#endif > >-static inline void nv_gettimeofday(struct nv_timeval *tv) >+static inline void nv_gettimeofday(nv_timeval *tv) > { > #ifdef NV_DO_GETTIMEOFDAY_PRESENT > do_gettimeofday(tv); > #else > struct timespec64 now; > > ktime_get_real_ts64(&now); > >- *tv = (struct nv_timeval) { >+ *tv = (nv_timeval) { > .tv_sec = now.tv_sec, > .tv_usec = now.tv_nsec/1000, > }; > #endif // NV_DO_GETTIMEOFDAY_PRESENT >diff --git a/kernel/conftest.sh b/kernel/conftest.sh >index b76d127..cd968d6 100755 >--- a/kernel/conftest.sh >+++ b/kernel/conftest.sh >@@ -3387,8 +3387,25 @@ compile_test() { > > compile_check_conftest "$CODE" "NV_DRM_DRIVER_PRIME_FLAG_PRESENT" "" "types" > ;; > >+ timeval) >+ # >+ # Determine if the 'struct timeval' type is present. >+ # >+ # Removed by commit c766d1472c70 ("y2038: hide >+ # timeval/timespec/itimerval/itimerspec types") in 5.6-rc3 >+ # (2020-02-20). >+ # >+ CODE=" >+ #include <linux/time.h> >+ >+ struct timeval tm; >+ " >+ >+ compile_check_conftest "$CODE" "NV_TIMEVAL_PRESENT" "" "types" >+ ;; >+ > *) > # Unknown test name given > echo "Error: unknown conftest '$1' requested" >&2 > exit 1 >diff --git a/kernel/nvidia-modeset/nvidia-modeset-linux.c b/kernel/nvidia-modeset/nvidia-modeset-linux.c >index ceab5de..fcb7880 100644 >--- a/kernel/nvidia-modeset/nvidia-modeset-linux.c >+++ b/kernel/nvidia-modeset/nvidia-modeset-linux.c >@@ -278,9 +278,9 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec) > } > > NvU64 NVKMS_API_CALL nvkms_get_usec(void) > { >- struct nv_timeval tv; >+ nv_timeval tv; > > nv_gettimeofday(&tv); > > return (((NvU64)tv.tv_sec) * 1000000) + tv.tv_usec; >diff --git a/kernel/nvidia-modeset/nvidia-modeset.Kbuild b/kernel/nvidia-modeset/nvidia-modeset.Kbuild >index 6c4f1a2..fb66216 100644 >--- a/kernel/nvidia-modeset/nvidia-modeset.Kbuild >+++ b/kernel/nvidia-modeset/nvidia-modeset.Kbuild >@@ -82,8 +82,9 @@ NV_OBJECTS_DEPEND_ON_CONFTEST += $(NVIDIA_MODESET_OBJECTS) > > NV_CONFTEST_MACRO_COMPILE_TESTS += INIT_WORK > NV_CONFTEST_TYPE_COMPILE_TESTS += file_inode > NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations >+NV_CONFTEST_TYPE_COMPILE_TESTS += timeval > NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data > NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_remove > NV_CONFTEST_FUNCTION_COMPILE_TESTS += timer_setup > NV_CONFTEST_FUNCTION_COMPILE_TESTS += do_gettimeofday >diff --git a/kernel/nvidia-uvm/nvidia-uvm.Kbuild b/kernel/nvidia-uvm/nvidia-uvm.Kbuild >index e5fcab5..288278f 100644 >--- a/kernel/nvidia-uvm/nvidia-uvm.Kbuild >+++ b/kernel/nvidia-uvm/nvidia-uvm.Kbuild >@@ -113,4 +113,5 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += get_user_pages > NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_has_address > NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_present > NV_CONFTEST_TYPE_COMPILE_TESTS += vm_ops_fault_removed_vma_arg > NV_CONFTEST_TYPE_COMPILE_TESTS += node_states_n_memory >+NV_CONFTEST_TYPE_COMPILE_TESTS += timeval >diff --git a/kernel/nvidia-uvm/uvm_linux.h b/kernel/nvidia-uvm/uvm_linux.h >index 4e1c198..c7bd07e 100644 >--- a/kernel/nvidia-uvm/uvm_linux.h >+++ b/kernel/nvidia-uvm/uvm_linux.h >@@ -322,9 +322,9 @@ static inline NvU64 NV_GETTIME(void) > /* We can only return a microsecond-precise value with the > * available non-GPL symbols. */ > static inline NvU64 NV_GETTIME(void) > { >- struct nv_timeval tv = {0}; >+ nv_timeval tv = {0}; > > nv_gettimeofday(&tv); > > return (tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000ULL); >diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild >index 57a78b9..0903987 100644 >--- a/kernel/nvidia/nvidia.Kbuild >+++ b/kernel/nvidia/nvidia.Kbuild >@@ -168,8 +168,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_insert_pfn_prot > NV_CONFTEST_TYPE_COMPILE_TESTS += vmf_insert_pfn_prot > NV_CONFTEST_TYPE_COMPILE_TESTS += address_space_init_once > NV_CONFTEST_TYPE_COMPILE_TESTS += vm_ops_fault_removed_vma_arg > NV_CONFTEST_TYPE_COMPILE_TESTS += vmbus_channel_has_ringbuffer_page >+NV_CONFTEST_TYPE_COMPILE_TESTS += timeval > NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present > NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_hyperv_available > NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_kvm_build > NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_grid_build >diff --git a/kernel/nvidia/nvlink_linux.c b/kernel/nvidia/nvlink_linux.c >index 2bd25ce..0af3d1a 100644 >--- a/kernel/nvidia/nvlink_linux.c >+++ b/kernel/nvidia/nvlink_linux.c >@@ -509,21 +509,21 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size) > } > > static NvBool nv_timer_less_than > ( >- const struct nv_timeval *a, >- const struct nv_timeval *b >+ const nv_timeval *a, >+ const nv_timeval *b > ) > { > return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec) > : (a->tv_sec < b->tv_sec); > } > > static void nv_timeradd > ( >- const struct nv_timeval *a, >- const struct nv_timeval *b, >- struct nv_timeval *result >+ const nv_timeval *a, >+ const nv_timeval *b, >+ nv_timeval *result > ) > { > result->tv_sec = a->tv_sec + b->tv_sec; > result->tv_usec = a->tv_usec + b->tv_usec; >@@ -535,11 +535,11 @@ static void nv_timeradd > } > > static void nv_timersub > ( >- const struct nv_timeval *a, >- const struct nv_timeval *b, >- struct nv_timeval *result >+ const nv_timeval *a, >+ const nv_timeval *b, >+ nv_timeval *result > ) > { > result->tv_sec = a->tv_sec - b->tv_sec; > result->tv_usec = a->tv_usec - b->tv_usec; >@@ -557,9 +557,9 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms) > { > unsigned long us; > unsigned long jiffies; > unsigned long mdelay_safe_msec; >- struct nv_timeval tm_end, tm_aux; >+ nv_timeval tm_end, tm_aux; > > nv_gettimeofday(&tm_aux); > > if (in_irq() && (ms > NV_MAX_ISR_DELAY_MS)) >diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c >index 27f5ada..a3797d5 100644 >--- a/kernel/nvidia/os-interface.c >+++ b/kernel/nvidia/os-interface.c >@@ -451,9 +451,9 @@ NV_STATUS NV_API_CALL os_get_current_time( > NvU32 *seconds, > NvU32 *useconds > ) > { >- struct nv_timeval tm; >+ nv_timeval tm; > > nv_gettimeofday(&tm); > > *seconds = tm.tv_sec; >@@ -543,9 +543,9 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds) > unsigned long mdelay_safe_msec; > unsigned long usec; > > #ifdef NV_CHECK_DELAY_ACCURACY >- struct nv_timeval tm1, tm2; >+ nv_timeval tm1, tm2; > > nv_gettimeofday(&tm1); > #endif > >@@ -583,11 +583,11 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds) > { > unsigned long MicroSeconds; > unsigned long jiffies; > unsigned long mdelay_safe_msec; >- struct nv_timeval tm_end, tm_aux; >+ nv_timeval tm_end, tm_aux; > #ifdef NV_CHECK_DELAY_ACCURACY >- struct nv_timeval tm_start; >+ nv_timeval tm_start; > #endif > > nv_gettimeofday(&tm_aux); > #ifdef NV_CHECK_DELAY_ACCURACY >@@ -1930,9 +1930,9 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp > ) > { > struct ipmi_recv_msg *rx_msg; > int err_no; >- struct nv_timeval tv; >+ nv_timeval tv; > NvU64 start_time; > > nv_gettimeofday(&tv); > start_time = NV_TIMEVAL_TO_US(tv); >-- >2.21.3 >
From 2e94283d60ebfc43b69e2e987e6ea94d2ffbefde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giuseppe=20Ghib=C3=B2?= <ghibo@mageia.org> Date: Tue, 12 May 2020 14:24:46 +0200 Subject: [PATCH] fixes for kernels where do_gettimeofday() still exists With the patch for the 5.6.x kernels, the nvidia 430.64 kernel modules fails to build on older kernels, where the do_gettimeofday() function is still existing (such as in kernel 4.19.x). This patch, borrowed from the nvidia 440 series, fixes this problem. --- kernel/common/inc/nv-time.h | 13 +++++++------ kernel/conftest.sh | 17 +++++++++++++++++ kernel/nvidia-modeset/nvidia-modeset-linux.c | 2 +- kernel/nvidia-modeset/nvidia-modeset.Kbuild | 1 + kernel/nvidia-uvm/nvidia-uvm.Kbuild | 1 + kernel/nvidia-uvm/uvm_linux.h | 2 +- kernel/nvidia/nvidia.Kbuild | 1 + kernel/nvidia/nvlink_linux.c | 18 +++++++++--------- kernel/nvidia/os-interface.c | 10 +++++----- 9 files changed, 43 insertions(+), 22 deletions(-) diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h index f03c7b0..b4fe2b7 100644 --- a/kernel/common/inc/nv-time.h +++ b/kernel/common/inc/nv-time.h @@ -26,23 +26,24 @@ #include "conftest.h" #include <linux/ktime.h> -struct nv_timeval { - __kernel_long_t tv_sec; - __kernel_suseconds_t tv_usec; -}; +#if defined (NV_TIMEVAL_PRESENT) +typedef struct timeval nv_timeval; +#else +typedef struct __kernel_old_timeval nv_timeval; +#endif -static inline void nv_gettimeofday(struct nv_timeval *tv) +static inline void nv_gettimeofday(nv_timeval *tv) { #ifdef NV_DO_GETTIMEOFDAY_PRESENT do_gettimeofday(tv); #else struct timespec64 now; ktime_get_real_ts64(&now); - *tv = (struct nv_timeval) { + *tv = (nv_timeval) { .tv_sec = now.tv_sec, .tv_usec = now.tv_nsec/1000, }; #endif // NV_DO_GETTIMEOFDAY_PRESENT diff --git a/kernel/conftest.sh b/kernel/conftest.sh index b76d127..cd968d6 100755 --- a/kernel/conftest.sh +++ b/kernel/conftest.sh @@ -3387,8 +3387,25 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_DRIVER_PRIME_FLAG_PRESENT" "" "types" ;; + timeval) + # + # Determine if the 'struct timeval' type is present. + # + # Removed by commit c766d1472c70 ("y2038: hide + # timeval/timespec/itimerval/itimerspec types") in 5.6-rc3 + # (2020-02-20). + # + CODE=" + #include <linux/time.h> + + struct timeval tm; + " + + compile_check_conftest "$CODE" "NV_TIMEVAL_PRESENT" "" "types" + ;; + *) # Unknown test name given echo "Error: unknown conftest '$1' requested" >&2 exit 1 diff --git a/kernel/nvidia-modeset/nvidia-modeset-linux.c b/kernel/nvidia-modeset/nvidia-modeset-linux.c index ceab5de..fcb7880 100644 --- a/kernel/nvidia-modeset/nvidia-modeset-linux.c +++ b/kernel/nvidia-modeset/nvidia-modeset-linux.c @@ -278,9 +278,9 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec) } NvU64 NVKMS_API_CALL nvkms_get_usec(void) { - struct nv_timeval tv; + nv_timeval tv; nv_gettimeofday(&tv); return (((NvU64)tv.tv_sec) * 1000000) + tv.tv_usec; diff --git a/kernel/nvidia-modeset/nvidia-modeset.Kbuild b/kernel/nvidia-modeset/nvidia-modeset.Kbuild index 6c4f1a2..fb66216 100644 --- a/kernel/nvidia-modeset/nvidia-modeset.Kbuild +++ b/kernel/nvidia-modeset/nvidia-modeset.Kbuild @@ -82,8 +82,9 @@ NV_OBJECTS_DEPEND_ON_CONFTEST += $(NVIDIA_MODESET_OBJECTS) NV_CONFTEST_MACRO_COMPILE_TESTS += INIT_WORK NV_CONFTEST_TYPE_COMPILE_TESTS += file_inode NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations +NV_CONFTEST_TYPE_COMPILE_TESTS += timeval NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_remove NV_CONFTEST_FUNCTION_COMPILE_TESTS += timer_setup NV_CONFTEST_FUNCTION_COMPILE_TESTS += do_gettimeofday diff --git a/kernel/nvidia-uvm/nvidia-uvm.Kbuild b/kernel/nvidia-uvm/nvidia-uvm.Kbuild index e5fcab5..288278f 100644 --- a/kernel/nvidia-uvm/nvidia-uvm.Kbuild +++ b/kernel/nvidia-uvm/nvidia-uvm.Kbuild @@ -113,4 +113,5 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += get_user_pages NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_has_address NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_present NV_CONFTEST_TYPE_COMPILE_TESTS += vm_ops_fault_removed_vma_arg NV_CONFTEST_TYPE_COMPILE_TESTS += node_states_n_memory +NV_CONFTEST_TYPE_COMPILE_TESTS += timeval diff --git a/kernel/nvidia-uvm/uvm_linux.h b/kernel/nvidia-uvm/uvm_linux.h index 4e1c198..c7bd07e 100644 --- a/kernel/nvidia-uvm/uvm_linux.h +++ b/kernel/nvidia-uvm/uvm_linux.h @@ -322,9 +322,9 @@ static inline NvU64 NV_GETTIME(void) /* We can only return a microsecond-precise value with the * available non-GPL symbols. */ static inline NvU64 NV_GETTIME(void) { - struct nv_timeval tv = {0}; + nv_timeval tv = {0}; nv_gettimeofday(&tv); return (tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000ULL); diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild index 57a78b9..0903987 100644 --- a/kernel/nvidia/nvidia.Kbuild +++ b/kernel/nvidia/nvidia.Kbuild @@ -168,8 +168,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_insert_pfn_prot NV_CONFTEST_TYPE_COMPILE_TESTS += vmf_insert_pfn_prot NV_CONFTEST_TYPE_COMPILE_TESTS += address_space_init_once NV_CONFTEST_TYPE_COMPILE_TESTS += vm_ops_fault_removed_vma_arg NV_CONFTEST_TYPE_COMPILE_TESTS += vmbus_channel_has_ringbuffer_page +NV_CONFTEST_TYPE_COMPILE_TESTS += timeval NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_hyperv_available NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_kvm_build NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_grid_build diff --git a/kernel/nvidia/nvlink_linux.c b/kernel/nvidia/nvlink_linux.c index 2bd25ce..0af3d1a 100644 --- a/kernel/nvidia/nvlink_linux.c +++ b/kernel/nvidia/nvlink_linux.c @@ -509,21 +509,21 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size) } static NvBool nv_timer_less_than ( - const struct nv_timeval *a, - const struct nv_timeval *b + const nv_timeval *a, + const nv_timeval *b ) { return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec) : (a->tv_sec < b->tv_sec); } static void nv_timeradd ( - const struct nv_timeval *a, - const struct nv_timeval *b, - struct nv_timeval *result + const nv_timeval *a, + const nv_timeval *b, + nv_timeval *result ) { result->tv_sec = a->tv_sec + b->tv_sec; result->tv_usec = a->tv_usec + b->tv_usec; @@ -535,11 +535,11 @@ static void nv_timeradd } static void nv_timersub ( - const struct nv_timeval *a, - const struct nv_timeval *b, - struct nv_timeval *result + const nv_timeval *a, + const nv_timeval *b, + nv_timeval *result ) { result->tv_sec = a->tv_sec - b->tv_sec; result->tv_usec = a->tv_usec - b->tv_usec; @@ -557,9 +557,9 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms) { unsigned long us; unsigned long jiffies; unsigned long mdelay_safe_msec; - struct nv_timeval tm_end, tm_aux; + nv_timeval tm_end, tm_aux; nv_gettimeofday(&tm_aux); if (in_irq() && (ms > NV_MAX_ISR_DELAY_MS)) diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c index 27f5ada..a3797d5 100644 --- a/kernel/nvidia/os-interface.c +++ b/kernel/nvidia/os-interface.c @@ -451,9 +451,9 @@ NV_STATUS NV_API_CALL os_get_current_time( NvU32 *seconds, NvU32 *useconds ) { - struct nv_timeval tm; + nv_timeval tm; nv_gettimeofday(&tm); *seconds = tm.tv_sec; @@ -543,9 +543,9 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds) unsigned long mdelay_safe_msec; unsigned long usec; #ifdef NV_CHECK_DELAY_ACCURACY - struct nv_timeval tm1, tm2; + nv_timeval tm1, tm2; nv_gettimeofday(&tm1); #endif @@ -583,11 +583,11 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds) { unsigned long MicroSeconds; unsigned long jiffies; unsigned long mdelay_safe_msec; - struct nv_timeval tm_end, tm_aux; + nv_timeval tm_end, tm_aux; #ifdef NV_CHECK_DELAY_ACCURACY - struct nv_timeval tm_start; + nv_timeval tm_start; #endif nv_gettimeofday(&tm_aux); #ifdef NV_CHECK_DELAY_ACCURACY @@ -1930,9 +1930,9 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp ) { struct ipmi_recv_msg *rx_msg; int err_no; - struct nv_timeval tv; + nv_timeval tv; NvU64 start_time; nv_gettimeofday(&tv); start_time = NV_TIMEVAL_TO_US(tv); -- 2.21.3
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 26612
:
11637
| 11638 |
11639