From: Ivan Lipski <[email protected]> [Why&How] Other than visualconfirm, which is not always accurate, there is no reliable way to get the currently used pstate switch method in runtime.
Expand debugfs to output the current pstate switch method per connector. Resolve the connector's current CRTC stream and report the matching pipe's p_state_type, or P_STATE_UNKNOWN if inactive. Cc: George Zhang <[email protected]> Signed-off-by: Ivan Lipski <[email protected]> Signed-off-by: Chenyu Chen <[email protected]> --- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c index 68356cb8e4de..dc7d5c19eb6c 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -3739,6 +3739,37 @@ DEFINE_SHOW_ATTRIBUTE(cacp_ace_curve_area); DEFINE_SHOW_ATTRIBUTE(ips_status); DEFINE_SHOW_ATTRIBUTE(ips_residency); +/* Reports the pstate method of this connector's active CRTC. */ +static int pstate_switch_method_show(struct seq_file *m, void *unused) +{ + struct amdgpu_dm_connector *connector = to_amdgpu_dm_connector(m->private); + struct amdgpu_device *adev = drm_to_adev(connector->base.dev); + struct dm_crtc_state *crtc_state; + struct dc_state *context; + unsigned int i; + int method = P_STATE_UNKNOWN; + + if (connector->base.state && connector->base.state->crtc) { + crtc_state = to_dm_crtc_state(connector->base.state->crtc->state); + mutex_lock(&adev->dm.dc_lock); + context = adev->dm.dc->current_state; + for (i = 0; i < adev->dm.dc->res_pool->pipe_count; i++) { + struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; + + if (pipe->stream == crtc_state->stream && pipe->plane_state) { + method = pipe->p_state_type; + break; + } + } + mutex_unlock(&adev->dm.dc_lock); + } + + seq_printf(m, "%d\n", method); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(pstate_switch_method); + static const struct { char *name; const struct file_operations *fops; @@ -3907,6 +3938,9 @@ void connector_debugfs_init(struct amdgpu_dm_connector *connector) int i; struct dentry *dir = connector->base.debugfs_entry; + debugfs_create_file("pstate_switch_method", 0444, dir, connector, + &pstate_switch_method_fops); + if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort || connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) { for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) { -- 2.43.0
