diff options
author | Kevin Wang <Kevin1.Wang@amd.com> | 2019-01-17 13:29:06 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-03-19 15:03:58 -0500 |
commit | ea2d0bf8c7f07ca6d0de11628a5d3af6c247e51c (patch) | |
tree | 73e55e9a1d8f3757362ff51ecf2d9d03ceabbc81 /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |
parent | 0989532330e1e7d25693c14b3d57288aa4915f81 (diff) | |
download | linux-stable-ea2d0bf8c7f07ca6d0de11628a5d3af6c247e51c.tar.gz linux-stable-ea2d0bf8c7f07ca6d0de11628a5d3af6c247e51c.tar.bz2 linux-stable-ea2d0bf8c7f07ca6d0de11628a5d3af6c247e51c.zip |
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.c | 24 |
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, struct drm_device *ddev = dev_get_drvdata(dev); struct amdgpu_device *adev = ddev->dev_private; struct pp_states_info data; + struct smu_context *smu = &adev->smu; enum amd_pm_state_type pm = 0; - int i = 0; + int i = 0, ret = 0; - if (adev->powerplay.pp_funcs->get_current_power_state + if (is_support_sw_smu(adev)) { + pm = smu_get_current_power_state(smu); + ret = smu_get_power_num_states(smu, &data); + if (ret) + return ret; + } else if (adev->powerplay.pp_funcs->get_current_power_state && adev->powerplay.pp_funcs->get_pp_num_states) { pm = amdgpu_dpm_get_current_power_state(adev); amdgpu_dpm_get_pp_num_states(adev, &data); + } - for (i = 0; i < data.nums; i++) { - if (pm == data.states[i]) - break; - } - - if (i == data.nums) - i = -EINVAL; + for (i = 0; i < data.nums; i++) { + if (pm == data.states[i]) + break; } + if (i == data.nums) + i = -EINVAL; + return snprintf(buf, PAGE_SIZE, "%d\n", i); } |