drm/amd/display: Add IPS residency info to debugfs

[Why]
For debugging and testing purpose

[How]
Usage:
- echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_ips_residency_cntl
- echo 0 > /sys/kernel/debug/dri/0/amdgpu_dm_ips_residency_cntl
- cat /sys/kernel/debug/dri/0/amdgpu_dm_ips_residency

Reviewed-by: ChiaHsuan (Tom) Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: Matthew Stewart <matthew.stewart2@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Ray Wu 2026-01-06 17:58:48 +08:00 committed by Alex Deucher
parent a625dc4989
commit d5db4f88e0

View File

@ -2709,6 +2709,65 @@ static int ips_status_show(struct seq_file *m, void *unused)
return 0;
}
/*
* IPS residency information from DMUB service. Read only.
*
* For time-window (segment) measurement:
* 1) echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_ips_residency_cntl
* 2) sleep <seconds>
* 3) echo 0 > /sys/kernel/debug/dri/0/amdgpu_dm_ips_residency_cntl
* 4) cat /sys/kernel/debug/dri/0/amdgpu_dm_ips_residency
*/
static int ips_residency_show(struct seq_file *m, void *unused)
{
struct amdgpu_device *adev = m->private;
struct dc *dc = adev->dm.dc;
uint8_t panel_inst = 0;
enum ips_residency_mode mode;
struct dmub_ips_residency_info info;
mutex_lock(&adev->dm.dc_lock);
mode = IPS_RESIDENCY__IPS1_RCG;
if (!dc_dmub_srv_ips_query_residency_info(dc->ctx, panel_inst, &info, mode)) {
seq_printf(m, "ISP query failed\n");
} else {
unsigned int pct, frac;
pct = info.residency_millipercent / 1000;
frac = info.residency_millipercent % 1000;
seq_printf(m, "IPS residency: %u.%03u%% \n", pct, frac);
seq_printf(m, " entry_counter: %u\n", info.entry_counter);
seq_printf(m, " total_time_us: %llu\n",
(unsigned long long)info.total_time_us);
seq_printf(m, " total_inactive_time_us: %llu\n",
(unsigned long long)info.total_inactive_time_us);
}
mutex_unlock(&adev->dm.dc_lock);
return 0;
}
static int ips_residency_cntl_get(void *data, u64 *val)
{
*val = 0;
return 0;
}
static int ips_residency_cntl_set(void *data, u64 val)
{
struct amdgpu_device *adev = data;
struct dc *dc = adev->dm.dc;
uint8_t panel_inst = 0;
int ret = 0;
mutex_lock(&adev->dm.dc_lock);
if (!dc_dmub_srv_ips_residency_cntl(dc->ctx, panel_inst, !!val))
ret = -EIO;
mutex_unlock(&adev->dm.dc_lock);
return ret;
}
/*
* Backlight at this moment. Read only.
* As written to display, taking ABM and backlight lut into account.
@ -3370,9 +3429,12 @@ DEFINE_DEBUGFS_ATTRIBUTE(disallow_edp_enter_psr_fops,
disallow_edp_enter_psr_get,
disallow_edp_enter_psr_set, "%llu\n");
DEFINE_DEBUGFS_ATTRIBUTE(ips_residency_cntl_fops, ips_residency_cntl_get,
ips_residency_cntl_set, "%llu\n");
DEFINE_SHOW_ATTRIBUTE(current_backlight);
DEFINE_SHOW_ATTRIBUTE(target_backlight);
DEFINE_SHOW_ATTRIBUTE(ips_status);
DEFINE_SHOW_ATTRIBUTE(ips_residency);
static const struct {
char *name;
@ -4271,7 +4333,14 @@ void dtn_debugfs_init(struct amdgpu_device *adev)
debugfs_create_file_unsafe("amdgpu_dm_disable_hpd", 0644, root, adev,
&disable_hpd_ops);
if (adev->dm.dc->caps.ips_support)
if (adev->dm.dc->caps.ips_support) {
debugfs_create_file_unsafe("amdgpu_dm_ips_status", 0644, root, adev,
&ips_status_fops);
debugfs_create_file_unsafe("amdgpu_dm_ips_residency_cntl", 0644, root, adev,
&ips_residency_cntl_fops);
debugfs_create_file_unsafe("amdgpu_dm_ips_residency", 0644, root, adev,
&ips_residency_fops);
}
}