On Fri, Nov 10, 2023 at 3:22 AM Lazar, Lijo <lijo.lazar@xxxxxxx> wrote: > > > > On 11/10/2023 3:44 AM, Alex Deucher wrote: > > Some chips provide both average and input power. Previously > > we just exposed average power, add a new query for input > > power. > > > > Input looks like a misnomer (not the supply side, but the power > consumed). Better to rename to instantaneous or current power. I guess > that will require rename of AMDGPU_PP_SENSOR_GPU_INPUT_POWER too. It aligns with the sysfs naming. E.g., https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface power[1-*]_input Instantaneous power use Unit: microWatt RO Alex > > Thanks, > Lijo > > > Example userspace: > > https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs/tree/input_power > > > > Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++++++ > > include/uapi/drm/amdgpu_drm.h | 2 ++ > > 2 files changed, 11 insertions(+) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > index bf4f48fe438d..48496bb585c7 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > @@ -1114,6 +1114,15 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) > > } > > ui32 >>= 8; > > break; > > + case AMDGPU_INFO_SENSOR_GPU_INPUT_POWER: > > + /* get input GPU power */ > > + if (amdgpu_dpm_read_sensor(adev, > > + AMDGPU_PP_SENSOR_GPU_INPUT_POWER, > > + (void *)&ui32, &ui32_size)) { > > + return -EINVAL; > > + } > > + ui32 >>= 8; > > + break; > > case AMDGPU_INFO_SENSOR_VDDNB: > > /* get VDDNB in millivolts */ > > if (amdgpu_dpm_read_sensor(adev, > > diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h > > index ad21c613fec8..96e32dafd4f0 100644 > > --- a/include/uapi/drm/amdgpu_drm.h > > +++ b/include/uapi/drm/amdgpu_drm.h > > @@ -865,6 +865,8 @@ struct drm_amdgpu_cs_chunk_cp_gfx_shadow { > > #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa > > /* Subquery id: Query GPU peak pstate memory clock */ > > #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb > > + /* Subquery id: Query input GPU power */ > > + #define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER 0xc > > /* Number of VRAM page faults on CPU access. */ > > #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E > > #define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F