Commit fa022a9b authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu: add pm sysfs files late

They were added relatively early in the driver init process
which meant that in some cases the driver was not finished
initializing before external tools tried to use them which
could result in a crash depending on the timing.
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
parent 51a4726b
...@@ -6185,6 +6185,11 @@ static int ci_dpm_late_init(void *handle) ...@@ -6185,6 +6185,11 @@ static int ci_dpm_late_init(void *handle)
if (!amdgpu_dpm) if (!amdgpu_dpm)
return 0; return 0;
/* init the sysfs and debugfs files late */
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
return ret;
ret = ci_set_temperature_range(adev); ret = ci_set_temperature_range(adev);
if (ret) if (ret)
return ret; return ret;
...@@ -6232,9 +6237,6 @@ static int ci_dpm_sw_init(void *handle) ...@@ -6232,9 +6237,6 @@ static int ci_dpm_sw_init(void *handle)
adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps; adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps;
if (amdgpu_dpm == 1) if (amdgpu_dpm == 1)
amdgpu_pm_print_power_states(adev); amdgpu_pm_print_power_states(adev);
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
goto dpm_failed;
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
DRM_INFO("amdgpu: dpm initialized\n"); DRM_INFO("amdgpu: dpm initialized\n");
......
...@@ -596,6 +596,12 @@ static int cz_dpm_late_init(void *handle) ...@@ -596,6 +596,12 @@ static int cz_dpm_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
if (amdgpu_dpm) { if (amdgpu_dpm) {
int ret;
/* init the sysfs and debugfs files late */
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
return ret;
/* powerdown unused blocks for now */ /* powerdown unused blocks for now */
cz_dpm_powergate_uvd(adev, true); cz_dpm_powergate_uvd(adev, true);
cz_dpm_powergate_vce(adev, true); cz_dpm_powergate_vce(adev, true);
...@@ -632,10 +638,6 @@ static int cz_dpm_sw_init(void *handle) ...@@ -632,10 +638,6 @@ static int cz_dpm_sw_init(void *handle)
if (amdgpu_dpm == 1) if (amdgpu_dpm == 1)
amdgpu_pm_print_power_states(adev); amdgpu_pm_print_power_states(adev);
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
goto dpm_init_failed;
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
DRM_INFO("amdgpu: dpm initialized\n"); DRM_INFO("amdgpu: dpm initialized\n");
......
...@@ -2995,6 +2995,12 @@ static int kv_dpm_late_init(void *handle) ...@@ -2995,6 +2995,12 @@ static int kv_dpm_late_init(void *handle)
{ {
/* powerdown unused blocks for now */ /* powerdown unused blocks for now */
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int ret;
/* init the sysfs and debugfs files late */
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
return ret;
kv_dpm_powergate_acp(adev, true); kv_dpm_powergate_acp(adev, true);
kv_dpm_powergate_samu(adev, true); kv_dpm_powergate_samu(adev, true);
...@@ -3038,9 +3044,6 @@ static int kv_dpm_sw_init(void *handle) ...@@ -3038,9 +3044,6 @@ static int kv_dpm_sw_init(void *handle)
adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps; adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps;
if (amdgpu_dpm == 1) if (amdgpu_dpm == 1)
amdgpu_pm_print_power_states(adev); amdgpu_pm_print_power_states(adev);
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
goto dpm_failed;
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
DRM_INFO("amdgpu: dpm initialized\n"); DRM_INFO("amdgpu: dpm initialized\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment