drm/radeon: Fix deadlock on runtime suspend
radeon's ->runtime_suspend hook calls drm_kms_helper_poll_disable(),
which waits for the output poll worker to finish if it's running.
The output poll worker meanwhile calls pm_runtime_get_sync() in
radeon's ->detect hooks, which waits for the ongoing suspend to finish,
causing a deadlock.
Fix by not acquiring a runtime PM ref if the ->detect hooks are called
in the output poll worker's context. This is safe because the poll
worker is only enabled while runtime active and we know that
->runtime_suspend waits for it to finish.
Stack trace for posterity:
INFO: task kworker/0:3:31847 blocked for more than 120 seconds
Workqueue: events output_poll_execute [drm_kms_helper]
Call Trace:
schedule+0x3c/0x90
rpm_resume+0x1e2/0x690
__pm_runtime_resume+0x3f/0x60
radeon_lvds_detect+0x39/0xf0 [radeon]
output_poll_execute+0xda/0x1e0 [drm_kms_helper]
process_one_work+0x14b/0x440
worker_thread+0x48/0x4a0
INFO: task kworker/2:0:10493 blocked for more than 120 seconds.
Workqueue: pm pm_runtime_work
Call Trace:
schedule+0x3c/0x90
schedule_timeout+0x1b3/0x240
wait_for_common+0xc2/0x180
wait_for_completion+0x1d/0x20
flush_work+0xfc/0x1a0
__cancel_work_timer+0xa5/0x1d0
cancel_delayed_work_sync+0x13/0x20
drm_kms_helper_poll_disable+0x1f/0x30 [drm_kms_helper]
radeon_pmops_runtime_suspend+0x3d/0xa0 [radeon]
pci_pm_runtime_suspend+0x61/0x1a0
vga_switcheroo_runtime_suspend+0x21/0x70
__rpm_callback+0x32/0x70
rpm_callback+0x24/0x80
rpm_suspend+0x12b/0x640
pm_runtime_work+0x6f/0xb0
process_one_work+0x14b/0x440
worker_thread+0x48/0x4a0
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94147
Fixes: 10ebc0bc09
("drm/radeon: add runtime PM support (v2)")
Cc: stable@vger.kernel.org # v3.13+: 27d4ee03078a: workqueue: Allow retrieval of current task's work struct
Cc: stable@vger.kernel.org # v3.13+: 25c058ccaf2e: drm: Allow determining if current task is output poll worker
Cc: Ismo Toijala <ismo.toijala@gmail.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Link: https://patchwork.freedesktop.org/patch/msgid/64ea02c44f91dda19bc563902b97bbc699040392.1518338789.git.lukas@wunner.de
This commit is contained in:
parent
d61a5c1063
commit
15734feff2
|
@ -900,9 +900,11 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
|
||||||
enum drm_connector_status ret = connector_status_disconnected;
|
enum drm_connector_status ret = connector_status_disconnected;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = pm_runtime_get_sync(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
if (r < 0)
|
r = pm_runtime_get_sync(connector->dev->dev);
|
||||||
return connector_status_disconnected;
|
if (r < 0)
|
||||||
|
return connector_status_disconnected;
|
||||||
|
}
|
||||||
|
|
||||||
if (encoder) {
|
if (encoder) {
|
||||||
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
|
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
|
||||||
|
@ -925,8 +927,12 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
|
||||||
/* check acpi lid status ??? */
|
/* check acpi lid status ??? */
|
||||||
|
|
||||||
radeon_connector_update_scratch_regs(connector, ret);
|
radeon_connector_update_scratch_regs(connector, ret);
|
||||||
pm_runtime_mark_last_busy(connector->dev->dev);
|
|
||||||
pm_runtime_put_autosuspend(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
|
pm_runtime_mark_last_busy(connector->dev->dev);
|
||||||
|
pm_runtime_put_autosuspend(connector->dev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,9 +1046,11 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
|
||||||
enum drm_connector_status ret = connector_status_disconnected;
|
enum drm_connector_status ret = connector_status_disconnected;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = pm_runtime_get_sync(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
if (r < 0)
|
r = pm_runtime_get_sync(connector->dev->dev);
|
||||||
return connector_status_disconnected;
|
if (r < 0)
|
||||||
|
return connector_status_disconnected;
|
||||||
|
}
|
||||||
|
|
||||||
encoder = radeon_best_single_encoder(connector);
|
encoder = radeon_best_single_encoder(connector);
|
||||||
if (!encoder)
|
if (!encoder)
|
||||||
|
@ -1109,8 +1117,10 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
|
||||||
radeon_connector_update_scratch_regs(connector, ret);
|
radeon_connector_update_scratch_regs(connector, ret);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
pm_runtime_mark_last_busy(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
pm_runtime_put_autosuspend(connector->dev->dev);
|
pm_runtime_mark_last_busy(connector->dev->dev);
|
||||||
|
pm_runtime_put_autosuspend(connector->dev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1174,9 +1184,11 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
|
||||||
if (!radeon_connector->dac_load_detect)
|
if (!radeon_connector->dac_load_detect)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
r = pm_runtime_get_sync(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
if (r < 0)
|
r = pm_runtime_get_sync(connector->dev->dev);
|
||||||
return connector_status_disconnected;
|
if (r < 0)
|
||||||
|
return connector_status_disconnected;
|
||||||
|
}
|
||||||
|
|
||||||
encoder = radeon_best_single_encoder(connector);
|
encoder = radeon_best_single_encoder(connector);
|
||||||
if (!encoder)
|
if (!encoder)
|
||||||
|
@ -1188,8 +1200,12 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
|
||||||
if (ret == connector_status_connected)
|
if (ret == connector_status_connected)
|
||||||
ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false);
|
ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false);
|
||||||
radeon_connector_update_scratch_regs(connector, ret);
|
radeon_connector_update_scratch_regs(connector, ret);
|
||||||
pm_runtime_mark_last_busy(connector->dev->dev);
|
|
||||||
pm_runtime_put_autosuspend(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
|
pm_runtime_mark_last_busy(connector->dev->dev);
|
||||||
|
pm_runtime_put_autosuspend(connector->dev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1252,9 +1268,11 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
|
||||||
enum drm_connector_status ret = connector_status_disconnected;
|
enum drm_connector_status ret = connector_status_disconnected;
|
||||||
bool dret = false, broken_edid = false;
|
bool dret = false, broken_edid = false;
|
||||||
|
|
||||||
r = pm_runtime_get_sync(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
if (r < 0)
|
r = pm_runtime_get_sync(connector->dev->dev);
|
||||||
return connector_status_disconnected;
|
if (r < 0)
|
||||||
|
return connector_status_disconnected;
|
||||||
|
}
|
||||||
|
|
||||||
if (radeon_connector->detected_hpd_without_ddc) {
|
if (radeon_connector->detected_hpd_without_ddc) {
|
||||||
force = true;
|
force = true;
|
||||||
|
@ -1437,8 +1455,10 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
pm_runtime_mark_last_busy(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
pm_runtime_put_autosuspend(connector->dev->dev);
|
pm_runtime_mark_last_busy(connector->dev->dev);
|
||||||
|
pm_runtime_put_autosuspend(connector->dev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1689,9 +1709,11 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
|
||||||
if (radeon_dig_connector->is_mst)
|
if (radeon_dig_connector->is_mst)
|
||||||
return connector_status_disconnected;
|
return connector_status_disconnected;
|
||||||
|
|
||||||
r = pm_runtime_get_sync(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
if (r < 0)
|
r = pm_runtime_get_sync(connector->dev->dev);
|
||||||
return connector_status_disconnected;
|
if (r < 0)
|
||||||
|
return connector_status_disconnected;
|
||||||
|
}
|
||||||
|
|
||||||
if (!force && radeon_check_hpd_status_unchanged(connector)) {
|
if (!force && radeon_check_hpd_status_unchanged(connector)) {
|
||||||
ret = connector->status;
|
ret = connector->status;
|
||||||
|
@ -1778,8 +1800,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
pm_runtime_mark_last_busy(connector->dev->dev);
|
if (!drm_kms_helper_is_poll_worker()) {
|
||||||
pm_runtime_put_autosuspend(connector->dev->dev);
|
pm_runtime_mark_last_busy(connector->dev->dev);
|
||||||
|
pm_runtime_put_autosuspend(connector->dev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue