Skip to contentSkip to conversation

drm/amdkcl: Resolve build issue with kcl_amdgpu_get_vblank_time_ns

PATCH New Danijel Slivka 1 participant 1 message Jan 19, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkcl: Resolve build issue with kcl_amdgpu_get_vblank_time_ns

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.

---
 .../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
drivers/gpu/drm/amd/backport/include/kcl/kcl_amdgpu.h +10 -6
index fc2eecd49d62..21dd7f1dd2e9 100644
@@ -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 */
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -3
index c8ba92e9ff1b..443dbf152734 100755
@@ -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);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +1 -1
index 5e83030ce88b..7b6634617fca 100644
@@ -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),
drivers/gpu/drm/amd/dkms/config/config.h +6 -0
index 39ca152effa3..98f38a604d28 100644
@@ -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
 
drivers/gpu/drm/amd/dkms/m4/drm_vblank_crtc_struct.m4 new file +43 -0

43 lines not on this page · raw message

drivers/gpu/drm/amd/dkms/m4/kernel.m4 +2 -0
index cf4f9e7011d7..7b77926c172c 100644
@@ -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"], [
Signature · 1 line
2.25.1