drm/amdgpu: fix avg vs input power reporting on smu7
Alex Deucher
maintainerPATCH 1/4 drm/amdgpu: fix avg vs input power reporting on smu7
Hawaii, Bonaire, Fiji, and Tonga support average power, the others support current power.
--- .../gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +16 -1
@@ -3995,6 +3995,7 @@ static int smu7_read_sensor(struct pp_hwmgr *hwmgr, int idx,uint32_t sclk, mclk, activity_percent;uint32_t offset, val_vid;struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); +struct amdgpu_device *adev = hwmgr->adev;/* size must be at least 4 bytes for all sensors */ if (*size <4 )
@@ -4038,7 +4039,21 @@ static int smu7_read_sensor(struct pp_hwmgr *hwmgr, int idx, *size =4 ;return 0 ;case AMDGPU_PP_SENSOR_GPU_INPUT_POWER : -return smu7_get_gpu_power (hwmgr, (uint32_t *)value); +if ((adev->asic_type !=CHIP_HAWAII ) && + (adev->asic_type !=CHIP_BONAIRE ) && + (adev->asic_type !=CHIP_FIJI ) && + (adev->asic_type !=CHIP_TONGA )) +return smu7_get_gpu_power (hwmgr, (uint32_t *)value); +else +return -EOPNOTSUPP ; +case AMDGPU_PP_SENSOR_GPU_AVG_POWER : +if ((adev->asic_type !=CHIP_HAWAII ) && + (adev->asic_type !=CHIP_BONAIRE ) && + (adev->asic_type !=CHIP_FIJI ) && + (adev->asic_type !=CHIP_TONGA )) +return -EOPNOTSUPP ; +else +return smu7_get_gpu_power (hwmgr, (uint32_t *)value);case AMDGPU_PP_SENSOR_VDDGFX :if ((data->vr_config &VRCONF_VDDGFX_MASK ) == (VR_SVI2_PLANE_2 <<VRCONF_VDDGFX_SHIFT ))
Signature · 1 line
2.42.0
Alex Deucher
maintainerPATCH 2/4 drm/amdgpu: fall back to INPUT power for AVG power via INFO IOCTL
For backwards compatibility with userspace.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6 -1
@@ -1105,7 +1105,12 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)if (amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_AVG_POWER , (void *)&ui32, &ui32_size)) { -return -EINVAL ; +/* fall back to input power for backwards compat */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GPU_INPUT_POWER , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } } ui32 >>=8 ;break ;
Signature · 1 line
2.42.0
Alex Deucher
maintainerPATCH 3/4 drm/amdgpu: add new INFO IOCTL query for input power
In reply to Alex DeucherSome chips provide both average and input power. Previously we just exposed average power, add a new query for input power.
Example userspace:
https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs/tree/input_power
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++++++ include/uapi/drm/amdgpu_drm.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9 -0
@@ -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,
include/uapi/drm/amdgpu_drm.h +2 -0
@@ -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
Signature · 1 line
2.42.0
Alex Deucher
maintainerPATCH 4/4 drm/amdgpu/pm: clarify debugfs pm output
In reply to Alex DeucherOn APUs power is SoC power, not just GPU. Clarify that for UVD/VCE/VCN the IP is powered down, not disabled which can confusing and lead to concerns that the IP is actually not available.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +18 -10
@@ -4353,11 +4353,19 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *aif (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_VDDNB , (void *)&value, &size))seq_printf (m,"\t%u mV (VDDNB)\n" , value); size =sizeof (uint32_t ); -if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_AVG_POWER , (void *)&query, &size)) -seq_printf (m,"\t%u.%02u W (average GPU)\n" , query >>8 , query &0xff ); +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_AVG_POWER , (void *)&query, &size)) { +if (adev->flags &AMD_IS_APU ) +seq_printf (m,"\t%u.%02u W (average SoC including CPU)\n" , query >>8 , query &0xff ); +else +seq_printf (m,"\t%u.%02u W (average SoC)\n" , query >>8 , query &0xff ); + } size =sizeof (uint32_t ); -if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_INPUT_POWER , (void *)&query, &size)) -seq_printf (m,"\t%u.%02u W (current GPU)\n" , query >>8 , query &0xff ); +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_INPUT_POWER , (void *)&query, &size)) { +if (adev->flags &AMD_IS_APU ) +seq_printf (m,"\t%u.%02u W (current SoC including CPU)\n" , query >>8 , query &0xff ); +else +seq_printf (m,"\t%u.%02u W (current SoC)\n" , query >>8 , query &0xff ); + } size =sizeof (value);seq_printf (m,"\n" );
@@ -4383,9 +4391,9 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a/* VCN clocks */ if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_VCN_POWER_STATE , (void *)&value, &size)) {if (!value) { -seq_printf (m,"VCN: Disabled\n" ); +seq_printf (m,"VCN: Powered down\n" ); }else { -seq_printf (m,"VCN: Enabled\n" ); +seq_printf (m,"VCN: Powered up\n" );if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_UVD_DCLK , (void *)&value, &size))seq_printf (m,"\t%u MHz (DCLK)\n" , value/100 );if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_UVD_VCLK , (void *)&value, &size))
@@ -4397,9 +4405,9 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a/* UVD clocks */ if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_UVD_POWER , (void *)&value, &size)) {if (!value) { -seq_printf (m,"UVD: Disabled\n" ); +seq_printf (m,"UVD: Powered down\n" ); }else { -seq_printf (m,"UVD: Enabled\n" ); +seq_printf (m,"UVD: Powered up\n" );if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_UVD_DCLK , (void *)&value, &size))seq_printf (m,"\t%u MHz (DCLK)\n" , value/100 );if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_UVD_VCLK , (void *)&value, &size))
@@ -4411,9 +4419,9 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a/* VCE clocks */ if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_VCE_POWER , (void *)&value, &size)) {if (!value) { -seq_printf (m,"VCE: Disabled\n" ); +seq_printf (m,"VCE: Powered down\n" ); }else { -seq_printf (m,"VCE: Enabled\n" ); +seq_printf (m,"VCE: Powered up\n" );if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_VCE_ECCLK , (void *)&value, &size))seq_printf (m,"\t%u MHz (ECCLK)\n" , value/100 ); }
Signature · 1 line
2.42.0