aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
authorKevin Wang <Kevin1.Wang@amd.com>2019-01-17 00:29:06 -0500
committerAlex Deucher <alexander.deucher@amd.com>2019-03-19 16:03:58 -0400
commitea2d0bf8c7f07ca6d0de11628a5d3af6c247e51c (patch)
tree73e55e9a1d8f3757362ff51ecf2d9d03ceabbc81 /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
parent0989532330e1e7d25693c14b3d57288aa4915f81 (diff)
drm/amd/powerplay: implement sysfs of pp_cur_state function
add function of smu_get_currente_state for sw-smu. v2: fix code typo error if (ret); Signed-off-by: Kevin Wang <Kevin1.Wang@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 5eda007ea632..569f7be61b53 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -377,23 +377,29 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
377 struct drm_device *ddev = dev_get_drvdata(dev); 377 struct drm_device *ddev = dev_get_drvdata(dev);
378 struct amdgpu_device *adev = ddev->dev_private; 378 struct amdgpu_device *adev = ddev->dev_private;
379 struct pp_states_info data; 379 struct pp_states_info data;
380 struct smu_context *smu = &adev->smu;
380 enum amd_pm_state_type pm = 0; 381 enum amd_pm_state_type pm = 0;
381 int i = 0; 382 int i = 0, ret = 0;
382 383
383 if (adev->powerplay.pp_funcs->get_current_power_state 384 if (is_support_sw_smu(adev)) {
385 pm = smu_get_current_power_state(smu);
386 ret = smu_get_power_num_states(smu, &data);
387 if (ret)
388 return ret;
389 } else if (adev->powerplay.pp_funcs->get_current_power_state
384 && adev->powerplay.pp_funcs->get_pp_num_states) { 390 && adev->powerplay.pp_funcs->get_pp_num_states) {
385 pm = amdgpu_dpm_get_current_power_state(adev); 391 pm = amdgpu_dpm_get_current_power_state(adev);
386 amdgpu_dpm_get_pp_num_states(adev, &data); 392 amdgpu_dpm_get_pp_num_states(adev, &data);
393 }
387 394
388 for (i = 0; i < data.nums; i++) { 395 for (i = 0; i < data.nums; i++) {
389 if (pm == data.states[i]) 396 if (pm == data.states[i])
390 break; 397 break;
391 }
392
393 if (i == data.nums)
394 i = -EINVAL;
395 } 398 }
396 399
400 if (i == data.nums)
401 i = -EINVAL;
402
397 return snprintf(buf, PAGE_SIZE, "%d\n", i); 403 return snprintf(buf, PAGE_SIZE, "%d\n", i);
398} 404}
399 405