Patch "drm/amdgpu: Fix deadlock on runtime suspend" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
drm/amdgpu: Fix deadlock on runtime suspend
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
drm-amdgpu-fix-deadlock-on-runtime-suspend.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
aa0aad57909eb321746325951d66af88a83bc956Mon Sep 17 00:00:00 2001
From: Lukas Wunner <[email protected]>
Date: Sun, 11 Feb 2018 10:38:28 +0100
Subject: drm/amdgpu: Fix deadlock on runtime suspend
From: Lukas Wunner <[email protected]>
commit aa0aad57909eb321746325951d66af88a83bc956 upstream.
amdgpu'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 amdgpu'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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 58 ++++++++++++++++--------- 1 file changed, 38 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +38 -20
@@ -739,9 +739,11 @@ amdgpu_connector_lvds_detect(struct drm_enum drm_connector_status ret = connector_status_disconnected;int r; - r =pm_runtime_get_sync (connector->dev->dev); -if (r <0 ) -return connector_status_disconnected; +if (!drm_kms_helper_is_poll_worker ()) { + r =pm_runtime_get_sync (connector->dev->dev); +if (r <0 ) +return connector_status_disconnected; + }if (encoder) {struct amdgpu_encoder *amdgpu_encoder =to_amdgpu_encoder (encoder);
@@ -760,8 +762,12 @@ amdgpu_connector_lvds_detect(struct drm_/* check acpi lid status ??? */ amdgpu_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; }
@@ -871,9 +877,11 @@ amdgpu_connector_vga_detect(struct drm_cenum drm_connector_status ret = connector_status_disconnected;int r; - r =pm_runtime_get_sync (connector->dev->dev); -if (r <0 ) -return connector_status_disconnected; +if (!drm_kms_helper_is_poll_worker ()) { + r =pm_runtime_get_sync (connector->dev->dev); +if (r <0 ) +return connector_status_disconnected; + } encoder =amdgpu_connector_best_single_encoder (connector);if (!encoder)
@@ -927,8 +935,10 @@ amdgpu_connector_vga_detect(struct drm_camdgpu_connector_update_scratch_regs (connector, ret); out: -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; }
@@ -991,9 +1001,11 @@ amdgpu_connector_dvi_detect(struct drm_cenum drm_connector_status ret = connector_status_disconnected;bool dret = false, broken_edid = false; - r =pm_runtime_get_sync (connector->dev->dev); -if (r <0 ) -return connector_status_disconnected; +if (!drm_kms_helper_is_poll_worker ()) { + r =pm_runtime_get_sync (connector->dev->dev); +if (r <0 ) +return connector_status_disconnected; + }if (!force &&amdgpu_connector_check_hpd_status_unchanged (connector)) { ret = connector->status;
@@ -1118,8 +1130,10 @@ out:amdgpu_connector_update_scratch_regs (connector, ret); exit: -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; }
@@ -1362,9 +1376,11 @@ amdgpu_connector_dp_detect(struct drm_costruct drm_encoder *encoder =amdgpu_connector_best_single_encoder (connector);int r; - r =pm_runtime_get_sync (connector->dev->dev); -if (r <0 ) -return connector_status_disconnected; +if (!drm_kms_helper_is_poll_worker ()) { + r =pm_runtime_get_sync (connector->dev->dev); +if (r <0 ) +return connector_status_disconnected; + }if (!force &&amdgpu_connector_check_hpd_status_unchanged (connector)) { ret = connector->status;
@@ -1432,8 +1448,10 @@ amdgpu_connector_dp_detect(struct drm_coamdgpu_connector_update_scratch_regs (connector, ret); out: -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; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/workqueue-allow-retrieval-of-current-task-s-work-struct.patch queue-4.9/drm-radeon-fix-deadlock-on-runtime-suspend.patch queue-4.9/drm-amdgpu-fix-deadlock-on-runtime-suspend.patch queue-4.9/drm-allow-determining-if-current-task-is-output-poll-worker.patch queue-4.9/drm-nouveau-fix-deadlock-on-runtime-suspend.patch