Commit 428da2bd authored by Nicholas Kazlauskas's avatar Nicholas Kazlauskas Committed by Alex Deucher

drm/amd/display: Enable vblank interrupt during CRC capture

[Why]
In order to read CRC events when CRC capture is enabled the vblank
interrput handler needs to be running for the CRTC. The handler is
enabled while there is an active vblank reference.

When running IGT tests there will often be no active vblank reference
but the test expects to read a CRC value. This is valid usage (and
works on i915 since they have a CRC interrupt handler) so the reference
to the vblank should be grabbed while capture is active.

This issue was found running:

igt@kms_plane_multiple@atomic-pipe-b-tiling-none

The pipe-b is the only one in the initial commit and was not previously
active so no vblank reference is grabbed. The vblank interrupt is
not enabled and the test times out.

[How]
Keep a reference to the vblank as long as CRC capture is enabled.
If userspace never explicitly disables it then the reference is
also dropped when removing the CRTC from the context (stream = NULL).
Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Reviewed-by: default avatarSun peng Li <Sunpeng.Li@amd.com>
Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 22051b63
...@@ -4917,10 +4917,22 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev, ...@@ -4917,10 +4917,22 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
*/ */
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
struct dm_crtc_state *dm_old_crtc_state = to_dm_crtc_state(old_crtc_state); struct dm_crtc_state *dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc); struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
if (drm_atomic_crtc_needs_modeset(new_crtc_state) && dm_old_crtc_state->stream) if (drm_atomic_crtc_needs_modeset(new_crtc_state)
&& dm_old_crtc_state->stream) {
/*
* CRC capture was enabled but not disabled.
* Release the vblank reference.
*/
if (dm_new_crtc_state->crc_enabled) {
drm_crtc_vblank_put(crtc);
dm_new_crtc_state->crc_enabled = false;
}
manage_dm_interrupts(adev, acrtc, false); manage_dm_interrupts(adev, acrtc, false);
}
} }
/* /*
* Add check here for SoC's that support hardware cursor plane, to * Add check here for SoC's that support hardware cursor plane, to
......
...@@ -66,6 +66,7 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) ...@@ -66,6 +66,7 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
{ {
struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state); struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state);
struct dc_stream_state *stream_state = crtc_state->stream; struct dc_stream_state *stream_state = crtc_state->stream;
bool enable;
enum amdgpu_dm_pipe_crc_source source = dm_parse_crc_source(src_name); enum amdgpu_dm_pipe_crc_source source = dm_parse_crc_source(src_name);
...@@ -80,28 +81,27 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) ...@@ -80,28 +81,27 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
return -EINVAL; return -EINVAL;
} }
enable = (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO);
if (!dc_stream_configure_crc(stream_state->ctx->dc, stream_state,
enable, enable))
return -EINVAL;
/* When enabling CRC, we should also disable dithering. */ /* When enabling CRC, we should also disable dithering. */
if (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO) { dc_stream_set_dither_option(stream_state,
if (dc_stream_configure_crc(stream_state->ctx->dc, enable ? DITHER_OPTION_TRUN8
stream_state, : DITHER_OPTION_DEFAULT);
true, true)) {
crtc_state->crc_enabled = true; /*
dc_stream_set_dither_option(stream_state, * Reading the CRC requires the vblank interrupt handler to be
DITHER_OPTION_TRUN8); * enabled. Keep a reference until CRC capture stops.
} */
else if (!crtc_state->crc_enabled && enable)
return -EINVAL; drm_crtc_vblank_get(crtc);
} else { else if (crtc_state->crc_enabled && !enable)
if (dc_stream_configure_crc(stream_state->ctx->dc, drm_crtc_vblank_put(crtc);
stream_state,
false, false)) { crtc_state->crc_enabled = enable;
crtc_state->crc_enabled = false;
dc_stream_set_dither_option(stream_state,
DITHER_OPTION_DEFAULT);
}
else
return -EINVAL;
}
/* Reset crc_skipped on dm state */ /* Reset crc_skipped on dm state */
crtc_state->crc_skip_count = 0; crtc_state->crc_skip_count = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment