Skip to contentSkip to conversation

drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices

PATCH In review Mario Limonciello 2 participants 2 messages Nov 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices

This command corresponding to this attribute was deprecated in the PMFW for YC so don't show a non-functional attribute.

Verify that the function has been implemented by the subsystem.

---
Changes from v1->v2:
* Change smu_get_power_profile_mode to return -EOPNOTSUPP if not supported by underlying implementation
* Check amdgpu_dpm_get_power_profile_mode to determine unsupported

 drivers/gpu/drm/amd/pm/amdgpu_pm.c        |  4 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -0
index 49fe4155c374..41472ed99253 100644
@@ -2094,6 +2094,10 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
 	} else if (DEVICE_ATTR_IS(pp_dpm_dclk)) {
 		if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))
 			*states = ATTR_STATE_UNSUPPORTED;
+	} else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
+		if (!adev->powerplay.pp_funcs->get_power_profile_mode ||
+		    amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
+			*states = ATTR_STATE_UNSUPPORTED;
 	}
 
 	switch (asic_type) {
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7 -4
index b06c59dcc1b4..821ae6e78703 100644
@@ -2534,13 +2534,15 @@ static int smu_get_power_profile_mode(void *handle, char *buf)
 	struct smu_context *smu = handle;
 	int ret = 0;
 
-	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+	    !smu->ppt_funcs->get_power_profile_mode)
 		return -EOPNOTSUPP;
+	if (!buf)
+		return -EINVAL;
 
 	mutex_lock(&smu->mutex);
 
-	if (smu->ppt_funcs->get_power_profile_mode)
-		ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
+	ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
 
 	mutex_unlock(&smu->mutex);
 
@@ -2554,7 +2556,8 @@ static int smu_set_power_profile_mode(void *handle,
 	struct smu_context *smu = handle;
 	int ret = 0;
 
-	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+	    !smu->ppt_funcs->set_power_profile_mode)
 		return -EOPNOTSUPP;
 
 	mutex_lock(&smu->mutex);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 56 lines · Mario Limonciello

This command corresponding to this attribute was deprecated in the PMFW for YC so don't show a non-functional attribute.

Verify that the function has been implemented by the subsystem.

---
Changes from v1->v2:
* Change smu_get_power_profile_mode to return -EOPNOTSUPP if not supported by underlying implementation
* Check amdgpu_dpm_get_power_profile_mode to determine unsupported

 drivers/gpu/drm/amd/pm/amdgpu_pm.c        |  4 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -0
index 49fe4155c374..41472ed99253 100644
@@ -2094,6 +2094,10 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
        } else if (DEVICE_ATTR_IS(pp_dpm_dclk)) {
                if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))
                        *states = ATTR_STATE_UNSUPPORTED;
+       } else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
+               if (!adev->powerplay.pp_funcs->get_power_profile_mode ||
+                   amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
+                       *states = ATTR_STATE_UNSUPPORTED;
        }
 
        switch (asic_type) {
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5 -3
index b06c59dcc1b4..821ae6e78703 100644
@@ -2534,13 +2534,15 @@ static int smu_get_power_profile_mode(void *handle, char *buf)
        struct smu_context *smu = handle;
        int ret = 0;
 
-       if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+       if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+           !smu->ppt_funcs->get_power_profile_mode)
                return -EOPNOTSUPP;
+       if (!buf)
+               return -EINVAL;
 
        mutex_lock(&smu->mutex);
 
-       if (smu->ppt_funcs->get_power_profile_mode)
-               ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
+       ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
 
        mutex_unlock(&smu->mutex);
 

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle, · line 2563

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
@@ -2554,7 +2556,8 @@ static int smu_set_power_profile_mode(void *handle,
        struct smu_context *smu = handle;
        int ret = 0;
 
-       if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+       if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+           !smu->ppt_funcs->set_power_profile_mode)
                return -EOPNOTSUPP;
 
        mutex_lock(&smu->mutex);

You'll need to add similar functionality in pp_get_power_profile_mode() in amd_powerplay.c to cover the older asics.

Alex

Quoted 3 lines

--
2.25.1