newer kernels have modified the time API

https://www.merging.com/products/alsa_r ... s67_driver
Forum rules
The Merging Technologies team cannot be held responsible for support queries logged on the public forums. If a support query is logged here and only here, it may not be found and dealt with by the appropriate team.
If you need assistance please contact tech support.
ccaudle
Posts: 4
Joined: Thu Feb 14, 2019 05:58

newer kernels have modified the time API

Postby ccaudle » Thu Feb 14, 2019 06:27

Newer kernels have changed the API to request system time in order to handle the roll-over of the 32 bit time structure in 2038.
This change is needed for the driver to compile on 4.18 and newer kernels:

Code: Select all

diff --git a/driver/MTAL_LKernelAPI.c b/driver/MTAL_LKernelAPI.c
index 6f8cc20..be0a44e 100644
--- a/driver/MTAL_LKernelAPI.c
+++ b/driver/MTAL_LKernelAPI.c
@@ -185,7 +185,10 @@ void MTAL_LK_write_unlock_irqrestore(MTAL_LK_rwlock_ptr rwlock, unsigned long fl
 uint64_t MTAL_LK_GetCounterTime(void) // 100 ns precision
 {
     uint64_t timeVal = 0ull;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0) // getrawmonotonic64 deprecated in mid-2018
+    struct timespec64 ts64;
+    ktime_get_raw_ts64(&ts64);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
     struct timespec64 ts64;
     getrawmonotonic64(&ts64);
 #else
 

florian
Posts: 79
Joined: Wed May 29, 2002 10:02
Location: Lausanne Switzerland
Contact:

Re: newer kernels have modified the time API

Postby florian » Wed Mar 13, 2019 09:28

Thanks for your contribution. The fix is validated and has been pushed in the repository.
https://bitbucket.org/MergingTechnologies/ravenna-alsa-lkm/commits/1754a73ddc935c4c3ba1a3c622af0468a2b9552c

A pull request would be the good solution for such cases. We will keep you updated once available.

hifi25nl
Posts: 7
Joined: Wed Feb 27, 2019 10:52

Re: newer kernels have modified the time API

Postby hifi25nl » Mon Mar 25, 2019 00:34

Still does not compile in kernel 5.0.3


Code: Select all

In file included from ./include/linux/bitmap.h:9,
                 from ./include/linux/cpumask.h:12,
                 from ./arch/x86/include/asm/paravirt.h:17,
                 from ./arch/x86/include/asm/irqflags.h:68,
                 from ./include/linux/irqflags.h:16,
                 from ./include/asm-generic/percpu.h:8,
                 from ./arch/x86/include/asm/percpu.h:544,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from ./include/linux/preempt.h:82,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:10,
                 from /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/module_netlink.c:32:
In function ‘memcpy’,
    inlined from ‘recv_reply_from_user_land’ at /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/module_netlink.c:163:6:
./include/linux/string.h:352:9: warning: argument 1 null where non-null expected [-Wnonnull]
  return __builtin_memcpy(p, q, size);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/module_netlink.c: In function ‘recv_reply_from_user_land’:
./include/linux/string.h:352:9: note: in a call to built-in function ‘__builtin_memcpy’
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/module_timer.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/EtherTubeNetfilter.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/RTP_streams_manager.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/RTP_audio_stream.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/RTP_stream.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/RTP_stream_info.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/MTAL_EthUtils.o
  CC [M]  /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/MTAL_LKernelAPI.o
/media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/MTAL_LKernelAPI.c: In function ‘MTAL_LK_GetSystemTime’:
/media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/MTAL_LKernelAPI.c:215:5: error: implicit declaration of function ‘getnstimeofday64’; did you mean ‘getnstimeofday’? [-Werror=implicit-function-declaration]
     getnstimeofday64(&ts64);
     ^~~~~~~~~~~~~~~~
     getnstimeofday
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:277: /media/linux/Downloads/Temp/ravenna-alsa-lkm/driver/MTAL_LKernelAPI.o] Error 1
make[1]: *** [Makefile:1553: _module_/media/linux/Downloads/Temp/ravenna-alsa-lkm/driver] Error 2
make[1]: Leaving directory '/usr/lib/modules/5.0.3-rt1-1-rt/build'
make: *** [Makefile:14: modules] Error 2

L0gi
Posts: 1
Joined: Mon Apr 15, 2019 09:57

Re: newer kernels have modified the time API

Postby L0gi » Mon Apr 15, 2019 10:33

It is still missing this fix:

Code: Select all

diff --git a/driver/MTAL_LKernelAPI.c b/driver/MTAL_LKernelAPI.c
index 084b632..faee32d 100644
--- a/driver/MTAL_LKernelAPI.c
+++ b/driver/MTAL_LKernelAPI.c
@@ -210,7 +210,10 @@ uint64_t MTAL_LK_GetCounterFreq(void)
 uint64_t MTAL_LK_GetSystemTime(void)
 {
     uint64_t timeVal = 0ull;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
+    struct timespec64 ts64;
+    ktime_get_real_ts64(&ts64);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
     struct timespec64 ts64;
     getnstimeofday64(&ts64);
 #else



"getnstimeofday64" has been completely replaced/renamed (c.f. https://www.kernel.org/doc/html/latest/ ... imeofday64)

"
Deprecated interfaces:

struct timeval do_gettimeofday(void)
struct timespec getnstimeofday(void)
struct timespec64 getnstimeofday64(void)
void ktime_get_real_ts(struct timespec *)

ktime_get_real_ts64() is a direct replacement, but consider using monotonic time (ktime_get_ts64()) and/or a ktime_t based interface (ktime_get()/ktime_get_real()).
"

florian
Posts: 79
Joined: Wed May 29, 2002 10:02
Location: Lausanne Switzerland
Contact:

Re: newer kernels have modified the time API

Postby florian » Tue Jul 02, 2019 14:18

Fixed in the latest commit. Thanks

wcom939
Posts: 2
Joined: Sat Sep 21, 2019 13:19

Re: newer kernels have modified the time API

Postby wcom939 » Sat Sep 21, 2019 13:21

Hi,

Still receiving this error when attempting to compile on Ubuntu 18 from latest master.

Thanks,
Dan