Skip to content

Commit 8cfd6a0

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amd/pm: Hide irrelevant pm device attributes
Change return code to EOPNOTSUPP for unsupported functions. Use the error code information to hide sysfs nodes not valid for the SOC. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Yang Wang <kevinyang.wang@amd.com> Reviewed-by: Asad Kamal <asad.kamal@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 0553eb9 commit 8cfd6a0

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
491491
int amdgpu_dpm_get_apu_thermal_limit(struct amdgpu_device *adev, uint32_t *limit)
492492
{
493493
const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
494-
int ret = -EINVAL;
494+
int ret = -EOPNOTSUPP;
495495

496496
if (pp_funcs && pp_funcs->get_apu_thermal_limit) {
497497
mutex_lock(&adev->pm.mutex);
@@ -505,7 +505,7 @@ int amdgpu_dpm_get_apu_thermal_limit(struct amdgpu_device *adev, uint32_t *limit
505505
int amdgpu_dpm_set_apu_thermal_limit(struct amdgpu_device *adev, uint32_t limit)
506506
{
507507
const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
508-
int ret = -EINVAL;
508+
int ret = -EOPNOTSUPP;
509509

510510
if (pp_funcs && pp_funcs->set_apu_thermal_limit) {
511511
mutex_lock(&adev->pm.mutex);
@@ -1182,7 +1182,7 @@ int amdgpu_dpm_get_sclk_od(struct amdgpu_device *adev)
11821182
int ret = 0;
11831183

11841184
if (!pp_funcs->get_sclk_od)
1185-
return 0;
1185+
return -EOPNOTSUPP;
11861186

11871187
mutex_lock(&adev->pm.mutex);
11881188
ret = pp_funcs->get_sclk_od(adev->powerplay.pp_handle);
@@ -1196,7 +1196,7 @@ int amdgpu_dpm_set_sclk_od(struct amdgpu_device *adev, uint32_t value)
11961196
const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
11971197

11981198
if (is_support_sw_smu(adev))
1199-
return 0;
1199+
return -EOPNOTSUPP;
12001200

12011201
mutex_lock(&adev->pm.mutex);
12021202
if (pp_funcs->set_sclk_od)
@@ -1219,7 +1219,7 @@ int amdgpu_dpm_get_mclk_od(struct amdgpu_device *adev)
12191219
int ret = 0;
12201220

12211221
if (!pp_funcs->get_mclk_od)
1222-
return 0;
1222+
return -EOPNOTSUPP;
12231223

12241224
mutex_lock(&adev->pm.mutex);
12251225
ret = pp_funcs->get_mclk_od(adev->powerplay.pp_handle);
@@ -1233,7 +1233,7 @@ int amdgpu_dpm_set_mclk_od(struct amdgpu_device *adev, uint32_t value)
12331233
const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
12341234

12351235
if (is_support_sw_smu(adev))
1236-
return 0;
1236+
return -EOPNOTSUPP;
12371237

12381238
mutex_lock(&adev->pm.mutex);
12391239
if (pp_funcs->set_mclk_od)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,18 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
21972197
} else if (DEVICE_ATTR_IS(xgmi_plpd_policy)) {
21982198
if (amdgpu_dpm_get_xgmi_plpd_mode(adev, NULL) == XGMI_PLPD_NONE)
21992199
*states = ATTR_STATE_UNSUPPORTED;
2200+
} else if (DEVICE_ATTR_IS(pp_dpm_mclk_od)) {
2201+
if (amdgpu_dpm_get_mclk_od(adev) == -EOPNOTSUPP)
2202+
*states = ATTR_STATE_UNSUPPORTED;
2203+
} else if (DEVICE_ATTR_IS(pp_dpm_sclk_od)) {
2204+
if (amdgpu_dpm_get_sclk_od(adev) == -EOPNOTSUPP)
2205+
*states = ATTR_STATE_UNSUPPORTED;
2206+
} else if (DEVICE_ATTR_IS(apu_thermal_cap)) {
2207+
u32 limit;
2208+
2209+
if (amdgpu_dpm_get_apu_thermal_limit(adev, &limit) ==
2210+
-EOPNOTSUPP)
2211+
*states = ATTR_STATE_UNSUPPORTED;
22002212
}
22012213

22022214
switch (gc_ver) {

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,7 @@ static int smu_read_sensor(void *handle,
27472747

27482748
static int smu_get_apu_thermal_limit(void *handle, uint32_t *limit)
27492749
{
2750-
int ret = -EINVAL;
2750+
int ret = -EOPNOTSUPP;
27512751
struct smu_context *smu = handle;
27522752

27532753
if (smu->ppt_funcs && smu->ppt_funcs->get_apu_thermal_limit)
@@ -2758,7 +2758,7 @@ static int smu_get_apu_thermal_limit(void *handle, uint32_t *limit)
27582758

27592759
static int smu_set_apu_thermal_limit(void *handle, uint32_t limit)
27602760
{
2761-
int ret = -EINVAL;
2761+
int ret = -EOPNOTSUPP;
27622762
struct smu_context *smu = handle;
27632763

27642764
if (smu->ppt_funcs && smu->ppt_funcs->set_apu_thermal_limit)

0 commit comments

Comments
 (0)