Scott mentioned that ktime should be using a runtime clock which stops during suspend. The exception to this is ktime_get_bootime() which does not stop when suspended.
This is described in https://www.kernel.org/doc/html/latest/core-api/timekeeping.html There was perhaps some confusion as CLOCK_MONOTONIC does not count time suspended on linux but does for us. Index: include/linux/ktime.h =================================================================== RCS file: /cvs/src/sys/dev/pci/drm/include/linux/ktime.h,v retrieving revision 1.5 diff -u -p -r1.5 ktime.h --- include/linux/ktime.h 29 Jul 2020 09:52:21 -0000 1.5 +++ include/linux/ktime.h 3 Aug 2020 08:26:55 -0000 @@ -28,7 +28,7 @@ static inline ktime_t ktime_get(void) { struct timespec ts; - nanouptime(&ts); + nanoruntime(&ts); return TIMESPEC_TO_NSEC(&ts); } @@ -36,7 +36,7 @@ static inline ktime_t ktime_get_raw(void) { struct timespec ts; - nanouptime(&ts); + nanoruntime(&ts); return TIMESPEC_TO_NSEC(&ts); } Index: include/linux/timekeeping.h =================================================================== RCS file: /cvs/src/sys/dev/pci/drm/include/linux/timekeeping.h,v retrieving revision 1.8 diff -u -p -r1.8 timekeeping.h --- include/linux/timekeeping.h 29 Jul 2020 09:52:21 -0000 1.8 +++ include/linux/timekeeping.h 3 Aug 2020 08:28:30 -0000 @@ -3,7 +3,6 @@ #ifndef _LINUX_TIMEKEEPING_H #define _LINUX_TIMEKEEPING_H -#define ktime_get_boottime() ktime_get() #define get_seconds() gettime() static inline time_t @@ -24,6 +23,14 @@ static inline uint64_t ktime_get_ns(void) { return ktime_get(); +} + +static inline ktime_t +ktime_get_boottime(void) +{ + struct timespec ts; + nanouptime(&ts); + return TIMESPEC_TO_NSEC(&ts); } #endif