Skip to content

Commit bb9f7b6

Browse files
superm1alexdeucher
authored andcommitted
drm/amd: Add a new hwmon attribute for instantaneous power
Some GPUs provide support for current power, some average power, and some both. To be able to support all these combinations, introduce a new attribute. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent d117fd2 commit bb9f7b6

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/gpu/drm/amd/pm/amdgpu_pm.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,19 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,
28032803
return sysfs_emit(buf, "%u\n", val);
28042804
}
28052805

2806+
static ssize_t amdgpu_hwmon_show_power_input(struct device *dev,
2807+
struct device_attribute *attr,
2808+
char *buf)
2809+
{
2810+
unsigned int val;
2811+
2812+
val = amdgpu_hwmon_get_power(dev, AMDGPU_PP_SENSOR_GPU_POWER);
2813+
if (val < 0)
2814+
return val;
2815+
2816+
return sysfs_emit(buf, "%u\n", val);
2817+
}
2818+
28062819
static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev,
28072820
struct device_attribute *attr,
28082821
char *buf)
@@ -3023,6 +3036,8 @@ static ssize_t amdgpu_hwmon_show_mclk_label(struct device *dev,
30233036
*
30243037
* - power1_average: average power used by the SoC in microWatts. On APUs this includes the CPU.
30253038
*
3039+
* - power1_input: instantaneous power used by the SoC in microWatts. On APUs this includes the CPU.
3040+
*
30263041
* - power1_cap_min: minimum cap supported in microWatts
30273042
*
30283043
* - power1_cap_max: maximum cap supported in microWatts
@@ -3091,6 +3106,7 @@ static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NU
30913106
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0);
30923107
static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, amdgpu_hwmon_show_vddnb_label, NULL, 0);
30933108
static SENSOR_DEVICE_ATTR(power1_average, S_IRUGO, amdgpu_hwmon_show_power_avg, NULL, 0);
3109+
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, amdgpu_hwmon_show_power_input, NULL, 0);
30943110
static SENSOR_DEVICE_ATTR(power1_cap_max, S_IRUGO, amdgpu_hwmon_show_power_cap_max, NULL, 0);
30953111
static SENSOR_DEVICE_ATTR(power1_cap_min, S_IRUGO, amdgpu_hwmon_show_power_cap_min, NULL, 0);
30963112
static SENSOR_DEVICE_ATTR(power1_cap, S_IRUGO | S_IWUSR, amdgpu_hwmon_show_power_cap, amdgpu_hwmon_set_power_cap, 0);
@@ -3137,6 +3153,7 @@ static struct attribute *hwmon_attributes[] = {
31373153
&sensor_dev_attr_in1_input.dev_attr.attr,
31383154
&sensor_dev_attr_in1_label.dev_attr.attr,
31393155
&sensor_dev_attr_power1_average.dev_attr.attr,
3156+
&sensor_dev_attr_power1_input.dev_attr.attr,
31403157
&sensor_dev_attr_power1_cap_max.dev_attr.attr,
31413158
&sensor_dev_attr_power1_cap_min.dev_attr.attr,
31423159
&sensor_dev_attr_power1_cap.dev_attr.attr,

0 commit comments

Comments
 (0)