Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add the sensor value of VCN activity

This will add the sensor value of VCN activity for some ASICs.

Signed-off-by: Xiaojian Du <Xiaojian.Du@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Xiaojian Du and committed by
Alex Deucher
d1b2703c 88867807

+38
+1
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 150 150 AMDGPU_PP_SENSOR_VCN_POWER_STATE, 151 151 AMDGPU_PP_SENSOR_PEAK_PSTATE_SCLK, 152 152 AMDGPU_PP_SENSOR_PEAK_PSTATE_MCLK, 153 + AMDGPU_PP_SENSOR_VCN_LOAD, 153 154 }; 154 155 155 156 enum amd_pp_task {
+37
drivers/gpu/drm/amd/pm/amdgpu_pm.c
··· 1582 1582 } 1583 1583 1584 1584 /** 1585 + * DOC: vcn_busy_percent 1586 + * 1587 + * The amdgpu driver provides a sysfs API for reading how busy the VCN 1588 + * is as a percentage. The file vcn_busy_percent is used for this. 1589 + * The SMU firmware computes a percentage of load based on the 1590 + * aggregate activity level in the IP cores. 1591 + */ 1592 + static ssize_t amdgpu_get_vcn_busy_percent(struct device *dev, 1593 + struct device_attribute *attr, 1594 + char *buf) 1595 + { 1596 + struct drm_device *ddev = dev_get_drvdata(dev); 1597 + struct amdgpu_device *adev = drm_to_adev(ddev); 1598 + unsigned int value; 1599 + int r; 1600 + 1601 + r = amdgpu_hwmon_get_sensor_generic(adev, AMDGPU_PP_SENSOR_VCN_LOAD, &value); 1602 + if (r) 1603 + return r; 1604 + 1605 + return sysfs_emit(buf, "%d\n", value); 1606 + } 1607 + 1608 + /** 1585 1609 * DOC: pcie_bw 1586 1610 * 1587 1611 * The amdgpu driver provides a sysfs API for estimating how much data ··· 2204 2180 .attr_update = pp_od_clk_voltage_attr_update), 2205 2181 AMDGPU_DEVICE_ATTR_RO(gpu_busy_percent, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2206 2182 AMDGPU_DEVICE_ATTR_RO(mem_busy_percent, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2183 + AMDGPU_DEVICE_ATTR_RO(vcn_busy_percent, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2207 2184 AMDGPU_DEVICE_ATTR_RO(pcie_bw, ATTR_FLAG_BASIC), 2208 2185 AMDGPU_DEVICE_ATTR_RW(pp_features, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2209 2186 AMDGPU_DEVICE_ATTR_RO(unique_id, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), ··· 2247 2222 if ((adev->flags & AMD_IS_APU && 2248 2223 gc_ver != IP_VERSION(9, 4, 3)) || 2249 2224 gc_ver == IP_VERSION(9, 0, 1)) 2225 + *states = ATTR_STATE_UNSUPPORTED; 2226 + } else if (DEVICE_ATTR_IS(vcn_busy_percent)) { 2227 + if (!(gc_ver == IP_VERSION(10, 3, 1) || 2228 + gc_ver == IP_VERSION(10, 3, 3) || 2229 + gc_ver == IP_VERSION(10, 3, 6) || 2230 + gc_ver == IP_VERSION(10, 3, 7) || 2231 + gc_ver == IP_VERSION(11, 0, 1) || 2232 + gc_ver == IP_VERSION(11, 0, 4) || 2233 + gc_ver == IP_VERSION(11, 5, 0))) 2250 2234 *states = ATTR_STATE_UNSUPPORTED; 2251 2235 } else if (DEVICE_ATTR_IS(pcie_bw)) { 2252 2236 /* PCIe Perf counters won't work on APU nodes */ ··· 4463 4429 /* MEM Load */ 4464 4430 if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MEM_LOAD, (void *)&value, &size)) 4465 4431 seq_printf(m, "MEM Load: %u %%\n", value); 4432 + /* VCN Load */ 4433 + if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_VCN_LOAD, (void *)&value, &size)) 4434 + seq_printf(m, "VCN Load: %u %%\n", value); 4466 4435 4467 4436 seq_printf(m, "\n"); 4468 4437