mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
0989532330
commit
ea2d0bf8c7
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,12 @@
|
|||
#include "smu_v11_0.h"
|
||||
#include "atom.h"
|
||||
|
||||
enum amd_pm_state_type smu_get_current_power_state(struct smu_context *smu)
|
||||
{
|
||||
/* not support power state */
|
||||
return POWER_STATE_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
int smu_get_power_num_states(struct smu_context *smu,
|
||||
struct pp_states_info *state_info)
|
||||
{
|
||||
|
|
|
@ -382,5 +382,6 @@ int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
|
|||
int smu_sys_get_pp_table(struct smu_context *smu, void **table);
|
||||
int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size);
|
||||
int smu_get_power_num_states(struct smu_context *smu, struct pp_states_info *state_info);
|
||||
enum amd_pm_state_type smu_get_current_power_state(struct smu_context *smu);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue