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

drm/amd/pm: adjust the visibility of pp_table sysfs node

v1:
- make pp_table invisible on VF mode (only valid on BM)
- make pp_table invisible on Mi* chips (Not supported)
- make pp_table invisible if scpm feature is enabled.

v2:
move pp_table invisible code logic into amdgpu_dpm_get_pp_table() function.

v3:
add table buffer pointer check both on powerplay & swsmu.

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Yang Wang and committed by
Alex Deucher
5de8ce0f 66a50fa4

+24 -6
+9 -3
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 1187 1187 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; 1188 1188 int ret = 0; 1189 1189 1190 - if (!pp_funcs->get_pp_table) 1191 - return 0; 1190 + if (!table) 1191 + return -EINVAL; 1192 + 1193 + if (amdgpu_sriov_vf(adev) || !pp_funcs->get_pp_table || adev->scpm_enabled) 1194 + return -EOPNOTSUPP; 1192 1195 1193 1196 mutex_lock(&adev->pm.mutex); 1194 1197 ret = pp_funcs->get_pp_table(adev->powerplay.pp_handle, ··· 1718 1715 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; 1719 1716 int ret = 0; 1720 1717 1721 - if (!pp_funcs->set_pp_table) 1718 + if (!buf || !size) 1719 + return -EINVAL; 1720 + 1721 + if (amdgpu_sriov_vf(adev) || !pp_funcs->set_pp_table || adev->scpm_enabled) 1722 1722 return -EOPNOTSUPP; 1723 1723 1724 1724 mutex_lock(&adev->pm.mutex);
+10 -1
drivers/gpu/drm/amd/pm/amdgpu_pm.c
··· 2506 2506 AMDGPU_DEVICE_ATTR_RO(pp_num_states, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2507 2507 AMDGPU_DEVICE_ATTR_RO(pp_cur_state, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2508 2508 AMDGPU_DEVICE_ATTR_RW(pp_force_state, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2509 - AMDGPU_DEVICE_ATTR_RW(pp_table, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF), 2509 + AMDGPU_DEVICE_ATTR_RW(pp_table, ATTR_FLAG_BASIC), 2510 2510 AMDGPU_DEVICE_ATTR_RW(pp_dpm_sclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF, 2511 2511 .attr_update = pp_dpm_clk_default_attr_update), 2512 2512 AMDGPU_DEVICE_ATTR_RW(pp_dpm_mclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF, ··· 2638 2638 if (amdgpu_dpm_get_apu_thermal_limit(adev, &limit) == 2639 2639 -EOPNOTSUPP) 2640 2640 *states = ATTR_STATE_UNSUPPORTED; 2641 + } else if (DEVICE_ATTR_IS(pp_table)) { 2642 + int ret; 2643 + char *tmp = NULL; 2644 + 2645 + ret = amdgpu_dpm_get_pp_table(adev, &tmp); 2646 + if (ret == -EOPNOTSUPP || !tmp) 2647 + *states = ATTR_STATE_UNSUPPORTED; 2648 + else 2649 + *states = ATTR_STATE_SUPPORTED; 2641 2650 } 2642 2651 2643 2652 switch (gc_ver) {
+4 -1
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
··· 631 631 { 632 632 struct pp_hwmgr *hwmgr = handle; 633 633 634 - if (!hwmgr || !hwmgr->pm_en || !hwmgr->soft_pp_table) 634 + if (!hwmgr || !hwmgr->pm_en || !table) 635 635 return -EINVAL; 636 + 637 + if (!hwmgr->soft_pp_table) 638 + return -EOPNOTSUPP; 636 639 637 640 *table = (char *)hwmgr->soft_pp_table; 638 641 return hwmgr->soft_pp_table_size;
+1 -1
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 634 634 return -EOPNOTSUPP; 635 635 636 636 if (!smu_table->power_play_table && !smu_table->hardcode_pptable) 637 - return -EINVAL; 637 + return -EOPNOTSUPP; 638 638 639 639 if (smu_table->hardcode_pptable) 640 640 *table = smu_table->hardcode_pptable;