Skip to content

Commit

Permalink
drm/amdkcl: test jiffies64_to_msecs()
Browse files Browse the repository at this point in the history
fake a kcl copy for legacy kernel support.

Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
  • Loading branch information
Flora Cui authored and Kent Russell committed Oct 27, 2020
1 parent f6e990e commit 8d11082
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdkcl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ amdkcl-y += kcl_device_cgroup.o kcl_drm_cache.o kcl_drm.o \
kcl_fence_array.o kcl_fence.o kcl_io.o kcl_kthread.o kcl_mm.o kcl_pci.o \
kcl_perf_event.o kcl_reservation.o kcl_suspend.o kcl_workqueue.o \
kcl_seq_file.o kcl_connector.o kcl_backlight.o kcl_drm_atomic_helper.o \
kcl_drm_crtc.o kcl_drm_fb.o kcl_drm_modeset_lock.o kcl_drm_modes.o
kcl_drm_crtc.o kcl_drm_fb.o kcl_drm_modeset_lock.o kcl_drm_modes.o kcl_time.o
amdkcl-$(CONFIG_MMU_NOTIFIER) += kcl_mn.o
amdkcl-y += dma-buf/dma-resv.o

Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/amd/amdkcl/kcl_time.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: MIT */
#include <linux/ktime.h>
#include <kcl/kcl_timekeeping.h>

#ifndef HAVE_JIFFIES64_TO_MSECS
u64 jiffies64_to_msecs(const u64 j)
{
#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
return (MSEC_PER_SEC / HZ) * j;
#else
return div_u64(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
#endif
}
EXPORT_SYMBOL(jiffies64_to_msecs);
#endif
3 changes: 3 additions & 0 deletions drivers/gpu/drm/amd/dkms/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@
/* IRQ translation domains exist */
#define HAVE_IRQ_DOMAIN 1

/* jiffies64_to_msecs() is available */
#define HAVE_JIFFIES64_TO_MSECS 1

/* kallsyms_lookup_name is available */
#define HAVE_KALLSYMS_LOOKUP_NAME 1

Expand Down
11 changes: 11 additions & 0 deletions drivers/gpu/drm/amd/dkms/m4/jiffies64_to_msecs.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dnl #
dnl # v5.1-rc3-699-g3b15d09f7e6d
dnl # time: Introduce jiffies64_to_msecs()
dnl #
AC_DEFUN([AC_AMDGPU_JIFFIES64_TO_MSECS], [
AC_KERNEL_DO_BACKGROUND([
AC_KERNEL_CHECK_SYMBOL_EXPORT([jiffies64_to_msecs], [kernel/time/time.c], [
AC_DEFINE(HAVE_JIFFIES64_TO_MSECS, 1, [jiffies64_to_msecs() is available])
])
])
])
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/dkms/m4/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ AC_DEFUN([AC_CONFIG_KERNEL], [
AC_AMDGPU_DOWN_READ_KILLABLE
AC_AMDGPU_DRM_DRIVER_RELEASE
AC_AMDGPU_KTHREAD_USE_MM
AC_AMDGPU_JIFFIES64_TO_MSECS
AC_KERNEL_WAIT
AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
Expand Down
4 changes: 4 additions & 0 deletions include/kcl/kcl_timekeeping.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ static inline u64 ktime_get_mono_fast_ns(void)
}
#endif

#ifndef HAVE_JIFFIES64_TO_MSECS
extern u64 jiffies64_to_msecs(u64 j);
#endif

#endif

0 comments on commit 8d11082

Please sign in to comment.