Commit 3ed9a335 authored by Alex Deucher's avatar Alex Deucher Committed by Christian König

drm/radeon/pm: don't walk the crtc list before it has been initialized (v2)

Avoids a crash in certain cases when thermal irqs are generated
before the display structures have been initialized.

v2: fix the vblank and vrefresh helpers as well

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=73931Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
parent cb3e4e7c
...@@ -158,6 +158,7 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev) ...@@ -158,6 +158,7 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev)
u32 line_time_us, vblank_lines; u32 line_time_us, vblank_lines;
u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */
if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
radeon_crtc = to_radeon_crtc(crtc); radeon_crtc = to_radeon_crtc(crtc);
if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
...@@ -170,6 +171,7 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev) ...@@ -170,6 +171,7 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev)
break; break;
} }
} }
}
return vblank_time_us; return vblank_time_us;
} }
...@@ -181,6 +183,7 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev) ...@@ -181,6 +183,7 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev)
struct radeon_crtc *radeon_crtc; struct radeon_crtc *radeon_crtc;
u32 vrefresh = 0; u32 vrefresh = 0;
if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
radeon_crtc = to_radeon_crtc(crtc); radeon_crtc = to_radeon_crtc(crtc);
if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
...@@ -188,7 +191,7 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev) ...@@ -188,7 +191,7 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev)
break; break;
} }
} }
}
return vrefresh; return vrefresh;
} }
......
...@@ -1406,6 +1406,7 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev) ...@@ -1406,6 +1406,7 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev)
rdev->pm.active_crtcs = 0; rdev->pm.active_crtcs = 0;
rdev->pm.active_crtc_count = 0; rdev->pm.active_crtc_count = 0;
if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
list_for_each_entry(crtc, list_for_each_entry(crtc,
&ddev->mode_config.crtc_list, head) { &ddev->mode_config.crtc_list, head) {
radeon_crtc = to_radeon_crtc(crtc); radeon_crtc = to_radeon_crtc(crtc);
...@@ -1414,6 +1415,7 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev) ...@@ -1414,6 +1415,7 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev)
rdev->pm.active_crtc_count++; rdev->pm.active_crtc_count++;
} }
} }
}
if (rdev->pm.pm_method == PM_METHOD_PROFILE) { if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
radeon_pm_update_profile(rdev); radeon_pm_update_profile(rdev);
...@@ -1478,6 +1480,7 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev) ...@@ -1478,6 +1480,7 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev)
/* update active crtc counts */ /* update active crtc counts */
rdev->pm.dpm.new_active_crtcs = 0; rdev->pm.dpm.new_active_crtcs = 0;
rdev->pm.dpm.new_active_crtc_count = 0; rdev->pm.dpm.new_active_crtc_count = 0;
if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
list_for_each_entry(crtc, list_for_each_entry(crtc,
&ddev->mode_config.crtc_list, head) { &ddev->mode_config.crtc_list, head) {
radeon_crtc = to_radeon_crtc(crtc); radeon_crtc = to_radeon_crtc(crtc);
...@@ -1486,6 +1489,7 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev) ...@@ -1486,6 +1489,7 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev)
rdev->pm.dpm.new_active_crtc_count++; rdev->pm.dpm.new_active_crtc_count++;
} }
} }
}
/* update battery/ac status */ /* update battery/ac status */
if (power_supply_is_system_supplied() > 0) if (power_supply_is_system_supplied() > 0)
......
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