diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 589b36e8c5cf..0e13d80d2a95 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -270,30 +270,28 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, | |||
270 | struct drm_device *ddev = dev_get_drvdata(dev); | 270 | struct drm_device *ddev = dev_get_drvdata(dev); |
271 | struct amdgpu_device *adev = ddev->dev_private; | 271 | struct amdgpu_device *adev = ddev->dev_private; |
272 | enum amd_pm_state_type state = 0; | 272 | enum amd_pm_state_type state = 0; |
273 | long idx; | 273 | unsigned long idx; |
274 | int ret; | 274 | int ret; |
275 | 275 | ||
276 | if (strlen(buf) == 1) | 276 | if (strlen(buf) == 1) |
277 | adev->pp_force_state_enabled = false; | 277 | adev->pp_force_state_enabled = false; |
278 | else { | 278 | else if (adev->pp_enabled) { |
279 | ret = kstrtol(buf, 0, &idx); | 279 | struct pp_states_info data; |
280 | 280 | ||
281 | if (ret) { | 281 | ret = kstrtoul(buf, 0, &idx); |
282 | if (ret || idx >= ARRAY_SIZE(data.states)) { | ||
282 | count = -EINVAL; | 283 | count = -EINVAL; |
283 | goto fail; | 284 | goto fail; |
284 | } | 285 | } |
285 | 286 | ||
286 | if (adev->pp_enabled) { | 287 | amdgpu_dpm_get_pp_num_states(adev, &data); |
287 | struct pp_states_info data; | 288 | state = data.states[idx]; |
288 | amdgpu_dpm_get_pp_num_states(adev, &data); | 289 | /* only set user selected power states */ |
289 | state = data.states[idx]; | 290 | if (state != POWER_STATE_TYPE_INTERNAL_BOOT && |
290 | /* only set user selected power states */ | 291 | state != POWER_STATE_TYPE_DEFAULT) { |
291 | if (state != POWER_STATE_TYPE_INTERNAL_BOOT && | 292 | amdgpu_dpm_dispatch_task(adev, |
292 | state != POWER_STATE_TYPE_DEFAULT) { | 293 | AMD_PP_EVENT_ENABLE_USER_STATE, &state, NULL); |
293 | amdgpu_dpm_dispatch_task(adev, | 294 | adev->pp_force_state_enabled = true; |
294 | AMD_PP_EVENT_ENABLE_USER_STATE, &state, NULL); | ||
295 | adev->pp_force_state_enabled = true; | ||
296 | } | ||
297 | } | 295 | } |
298 | } | 296 | } |
299 | fail: | 297 | fail: |