[PATCH] drm/amdkcl: Resolve build issue with kcl_amdgpu_get_vblank_time_ns
Danijel Slivka
danijel.slivka at amd.com
Thu Jan 20 04:00:52 UTC 2022
Fix incompatible pointer type passed as argument 1
of 'drm_crtc_vblank_count_and_time'. Wrapp the code that uses
drm_vblank_crtc->time under HAVE_DRM_VBLANK_CRTC_STRUCT and
access time field of drm_vblank_crtc structure depending on
the field type, defined by HAVE_DRM_VBLANK_USE_KTIME_T or
HAVE_DRM_VBLANK_CRTC_HAS_ARRAY_TIME_FIELD.
Signed-off-by: Danijel Slivka <danijel.slivka at amd.com>
---
.../drm/amd/backport/include/kcl/kcl_amdgpu.h | 16 ++++---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +--
.../amd/display/amdgpu_dm/amdgpu_dm_trace.h | 2 +-
drivers/gpu/drm/amd/dkms/config/config.h | 6 +++
.../drm/amd/dkms/m4/drm_vblank_crtc_struct.m4 | 43 +++++++++++++++++++
drivers/gpu/drm/amd/dkms/m4/kernel.m4 | 2 +
6 files changed, 65 insertions(+), 10 deletions(-)
create mode 100644 drivers/gpu/drm/amd/dkms/m4/drm_vblank_crtc_struct.m4
diff --git a/drivers/gpu/drm/amd/backport/include/kcl/kcl_amdgpu.h b/drivers/gpu/drm/amd/backport/include/kcl/kcl_amdgpu.h
index fc2eecd49d62..21dd7f1dd2e9 100644
--- a/drivers/gpu/drm/amd/backport/include/kcl/kcl_amdgpu.h
+++ b/drivers/gpu/drm/amd/backport/include/kcl/kcl_amdgpu.h
@@ -90,16 +90,20 @@ static inline int kcl_amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, un
#endif /* HAVE_STRUCT_DRM_CRTC_FUNCS_GET_VBLANK_TIMESTAMP */
#if defined(HAVE_DRM_VBLANK_USE_KTIME_T)
-static inline ktime_t kcl_amdgpu_get_vblank_time_ns(struct drm_vblank_crtc *vblank) {
+static inline ktime_t kcl_amdgpu_get_vblank_time_ns(struct drm_vblank_crtc *vblank)
+{
return vblank->time;
}
+#elif defined(HAVE_DRM_VBLANK_CRTC_HAS_ARRAY_TIME_FIELD)
+static inline ktime_t kcl_amdgpu_get_vblank_time_ns(struct drm_vblank_crtc *vblank)
+{
+ return timeval_to_ktime(vblank->time[(vblank->count) % DRM_VBLANKTIME_RBSIZE]);
+}
#else
-static inline ktime_t kcl_amdgpu_get_vblank_time_ns(struct drm_vblank_crtc *vblank) {
- struct timeval tv;
- drm_crtc_vblank_count_and_time(vblank, &tv);
- return timeval_to_ktime(tv);
+static inline ktime_t kcl_amdgpu_get_vblank_time_ns(struct drm_vblank_crtc *vblank)
+{
+ return timeval_to_ktime(vblank->time);
}
#endif /* HAVE_DRM_VBLANK_USE_KTIME_T */
-
#endif /* AMDGPU_BACKPORT_KCL_AMDGPU_H */
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index c8ba92e9ff1b..443dbf152734 100755
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -495,7 +495,7 @@ static void dm_pflip_high_irq(void *interrupt_params)
vrr_active, (int) !e);
}
-#ifndef HAVE_KTIME_IS_UNION
+#if defined(HAVE_DRM_VBLANK_CRTC_STRUCT) && !defined(HAVE_KTIME_IS_UNION)
static inline ktime_t get_drm_vblank_crtc_time(struct drm_vblank_crtc *vblank)
{
return kcl_amdgpu_get_vblank_time_ns(vblank);
@@ -507,7 +507,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
struct common_irq_params *irq_params = interrupt_params;
struct amdgpu_device *adev = irq_params->adev;
struct amdgpu_crtc *acrtc;
-#ifndef HAVE_KTIME_IS_UNION
+#if defined(HAVE_DRM_VBLANK_CRTC_STRUCT) && !defined(HAVE_KTIME_IS_UNION)
struct drm_device *drm_dev;
struct drm_vblank_crtc *vblank;
ktime_t frame_duration_ns, previous_timestamp;
@@ -519,7 +519,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
if (acrtc) {
vrr_active = amdgpu_dm_vrr_active_irq(acrtc);
-#ifndef HAVE_KTIME_IS_UNION
+#if defined(HAVE_DRM_VBLANK_CRTC_STRUCT) && !defined(HAVE_KTIME_IS_UNION)
drm_dev = acrtc->base.dev;
vblank = &drm_dev->vblank[acrtc->base.index];
previous_timestamp = atomic64_read(&irq_params->previous_timestamp);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
index 5e83030ce88b..7b6634617fca 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
@@ -684,7 +684,7 @@ TRACE_EVENT(amdgpu_dmub_trace_high_irq,
__entry->param0, __entry->param1)
);
-#ifndef HAVE_KTIME_IS_UNION
+#if defined(HAVE_DRM_VBLANK_CRTC_STRUCT) && !defined(HAVE_KTIME_IS_UNION)
TRACE_EVENT(amdgpu_refresh_rate_track,
TP_PROTO(int crtc_index, ktime_t refresh_rate_ns, uint32_t refresh_rate_hz),
TP_ARGS(crtc_index, refresh_rate_ns, refresh_rate_hz),
diff --git a/drivers/gpu/drm/amd/dkms/config/config.h b/drivers/gpu/drm/amd/dkms/config/config.h
index 39ca152effa3..98f38a604d28 100644
--- a/drivers/gpu/drm/amd/dkms/config/config.h
+++ b/drivers/gpu/drm/amd/dkms/config/config.h
@@ -386,6 +386,12 @@
/* drm_vblank struct use ktime_t for time field */
#define HAVE_DRM_VBLANK_USE_KTIME_T 1
+/* drm_vblank->time is array */
+#define HAVE_DRM_VBLANK_CRTC_HAS_ARRAY_TIME_FIELD 1
+
+/* drm_vblank_crtc struct exists */
+#define HAVE_DRM_VBLANK_CRTC_STRUCT 1
+
/* drm_driver->release() is available */
#define HAVE_DRM_DRIVER_RELEASE 1
diff --git a/drivers/gpu/drm/amd/dkms/m4/drm_vblank_crtc_struct.m4 b/drivers/gpu/drm/amd/dkms/m4/drm_vblank_crtc_struct.m4
new file mode 100644
index 000000000000..380424bf0401
--- /dev/null
+++ b/drivers/gpu/drm/amd/dkms/m4/drm_vblank_crtc_struct.m4
@@ -0,0 +1,43 @@
+dnl #
+dnl # commit v3.12-rc3-146-g5380e9293b86
+dnl # drm: Collect per-crtc vblank stuff to a struct
+dnl #
+AC_DEFUN([AC_AMDGPU_DRM_VBLANK_CRTC_STRUCT], [
+ AC_KERNEL_DO_BACKGROUND([
+ AC_KERNEL_TRY_COMPILE([
+ #ifdef HAVE_DRM_DRMP_H
+ #include <drm/drmP.h>
+ #else
+ #include <drm/drm_vblank.h>
+ #endif
+ ], [
+ struct drm_vblank_crtc *vblank = NULL;
+ ], [ AC_DEFINE(HAVE_DRM_VBLANK_CRTC_STRUCT, 1,
+ [drm_vblank_crtc struct exists])
+ ])
+ ])
+])
+
+dnl #
+dnl # commit v4.6-rc7-1094-gd4055a9b2079
+dnl # drm: use seqlock for vblank time/count
+dnl #
+AC_DEFUN([AC_AMDGPU_DRM_VBLANK_CRTC_HAS_ARRAY_TIME_FIELD], [
+ AC_KERNEL_DO_BACKGROUND([
+ AC_KERNEL_TRY_COMPILE([
+ #ifdef HAVE_DRM_DRMP_H
+ #include <drm/drmP.h>
+ #else
+ #include <drm/drm_vblank.h>
+ #endif
+ #include <linux/ktime.h>
+ ], [
+ struct drm_vblank_crtc *vblank = NULL;
+ sizeof(vblank->time[DRM_VBLANKTIME_RBSIZE - 1]);
+ ], [
+ AC_DEFINE(HAVE_DRM_VBLANK_CRTC_HAS_ARRAY_TIME_FIELD, 1,
+ [drm_vblank->time is array])
+ ])
+ ])
+])
+
diff --git a/drivers/gpu/drm/amd/dkms/m4/kernel.m4 b/drivers/gpu/drm/amd/dkms/m4/kernel.m4
index cf4f9e7011d7..7b77926c172c 100644
--- a/drivers/gpu/drm/amd/dkms/m4/kernel.m4
+++ b/drivers/gpu/drm/amd/dkms/m4/kernel.m4
@@ -249,6 +249,8 @@ AC_DEFUN([AC_CONFIG_KERNEL], [
AC_AMDGPU_DRM_EDID_GET_MONITOR_NAME
AC_AMDGPU_STRUCT_KOBJ_TYPE
AC_AMDGPU_CLOSE_FD
+ AC_AMDGPU_DRM_VBLANK_CRTC_STRUCT
+ AC_AMDGPU_DRM_VBLANK_CRTC_HAS_ARRAY_TIME_FIELD
AC_KERNEL_WAIT
AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
--
2.25.1
More information about the amd-gfx
mailing list