Skip to contentSkip to conversation

drm/amdgpu: Report the Frame number at beginning of CRC calculation

PATCH New Mark Yacoub 1 participant 1 message Apr 8, 2021

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

PATCH 1/1 drm/amdgpu: Report the Frame number at beginning of CRC calculation

From: Mark Yacoub <[email protected]>

On reporting back the frame number of the CRCs through drm_crtc_add_crc_entry(), send back the vblank count at the time the frame CRC starts calculating rather than when the CRCs are ready to be reported.

Tested by running IGT module: kms_plane::capture_crc()

Cc Harry Wentland <[email protected]>
Cc Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h   |  1 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c   | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +1 -0
index 8bfe901cf2374..b1e7af435b440 100644
@@ -461,6 +461,7 @@ struct dm_crtc_state {
 	int update_type;
 	int active_planes;
 
+	u64 vblank_at_crc_init;
 	int crc_skip_count;
 	enum amdgpu_dm_pipe_crc_source crc_src;
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +12 -1
index 66cb8730586b1..abf9dcefadbe6 100644
@@ -305,6 +305,17 @@ void amdgpu_dm_crtc_handle_crc_irq(struct drm_crtc *crtc)
 	 * first two CRC values.
 	 */
 	if (crtc_state->crc_skip_count < 2) {
+		/*
+		 * Save the vblank count at the time when the CRC calculation starts and comes here
+		 * for the first time (crc_skip_count=0).
+		 * drm_crtc_add_crc_entry() reports the number of the frame these CRCs are about,
+		 * which should be the vblank_count of the frame rather than when the CRCs are
+		 * ready.
+		 */
+		if (crtc_state->crc_skip_count == 0) {
+			crtc_state->vblank_at_crc_init =
+				drm_crtc_accurate_vblank_count(crtc);
+		}
 		crtc_state->crc_skip_count += 1;
 		return;
 	}
@@ -315,6 +326,6 @@ void amdgpu_dm_crtc_handle_crc_irq(struct drm_crtc *crtc)
 			return;
 
 		drm_crtc_add_crc_entry(crtc, true,
-				       drm_crtc_accurate_vblank_count(crtc), crcs);
+				       crtc_state->vblank_at_crc_init, crcs);
 	}
 }
Signature · 6 lines
2.31.0.208.g409f899ff0-goog

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel