From 705dd2ad774e3a38f09dee3ade85dfd0cc342c13 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Mon, 13 Apr 2020 13:38:10 +0530 Subject: [PATCH] gpu: nvgpu: use timespec64 Due to y2038 problem, where timestamps will overflow if logged in 32bit values, upstream linux kernel has removed timespec and friends. Correpsonding jiffies conversion functions are also obsolete. Update the notifier timestamp setup code to comply with this. Bug 2925664 Change-Id: I5266e3d748e536175af8eff5111fcc54556332a8 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2326514 Tested-by: mobile promotions Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Jonathan Hunter Reviewed-by: Vaibhav Kachore Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/include/nvgpu/nvhost.h | 1 - drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 4 ++-- drivers/gpu/nvgpu/os/linux/linux-channel.c | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h index 6466318a0..12a507ed3 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h @@ -32,7 +32,6 @@ struct gk20a; struct nvgpu_nvhost_dev; struct sync_pt; struct sync_fence; -struct timespec; /** * @file Functions that initialize the sync points diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index 0fba35576..d15e6bac1 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -685,7 +685,7 @@ static int gk20a_channel_wait(struct nvgpu_channel *ch, struct dma_buf *dmabuf; struct gk20a *g = ch->g; struct notification *notif; - struct timespec tv; + struct timespec64 tv; u64 jiffies; ulong id; u32 offset; @@ -745,7 +745,7 @@ static int gk20a_channel_wait(struct nvgpu_channel *ch, /* TBD: fill in correct information */ jiffies = get_jiffies_64(); - jiffies_to_timespec(jiffies, &tv); + jiffies_to_timespec64(jiffies, &tv); notif->timestamp.nanoseconds[0] = tv.tv_nsec; notif->timestamp.nanoseconds[1] = tv.tv_sec; notif->info32 = 0xDEADBEEF; /* should be object name */ diff --git a/drivers/gpu/nvgpu/os/linux/linux-channel.c b/drivers/gpu/nvgpu/os/linux/linux-channel.c index f8e4a2703..fd2e47d36 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-channel.c +++ b/drivers/gpu/nvgpu/os/linux/linux-channel.c @@ -121,12 +121,11 @@ void nvgpu_set_err_notifier_locked(struct nvgpu_channel *ch, u32 error) if (priv->error_notifier.dmabuf) { struct nvgpu_notification *notification = priv->error_notifier.notification; - struct timespec time_data; + struct timespec64 time_data; u64 nsec; - getnstimeofday(&time_data); - nsec = ((u64)time_data.tv_sec) * 1000000000u + - (u64)time_data.tv_nsec; + ktime_get_real_ts64(&time_data); + nsec = time_data.tv_sec * 1000000000u + time_data.tv_nsec; notification->time_stamp.nanoseconds[0] = (u32)nsec; notification->time_stamp.nanoseconds[1] =