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

Mark Yacoub markyacoub at chromium.org
Thu Apr 8 19:55:12 UTC 2021


From: Mark Yacoub <markyacoub at google.com>

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 <harry.wentland at amd.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 8bfe901cf2374..b1e7af435b440 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -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;
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
index 66cb8730586b1..abf9dcefadbe6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
@@ -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);
 	}
 }
-- 
2.31.0.208.g409f899ff0-goog



More information about the dri-devel mailing list