[PATCH 11/12] drm/amd/display: Fix refcount over dc_sink.

Harry Wentland harry.wentland at amd.com
Thu Dec 8 01:26:23 UTC 2016


From: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com>

Retain a dc_sink pointer until a new physical pointer
arrives in case of new display connected.

Change-Id: If0a7ebab865f3486f82a5e54c8b77b9a0a10e739
Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com>
Reviewed-by: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 70d6e4168b31..164beac7d521 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -745,9 +745,17 @@ void amdgpu_dm_update_connector_after_detect(
 		mutex_lock(&dev->mode_config.mutex);
 
 		if (sink) {
-			if (aconnector->dc_sink)
+			if (aconnector->dc_sink) {
 				amdgpu_dm_remove_sink_from_freesync_module(
 								connector);
+				/* retain and release bellow are used for
+				 * bump up refcount for sink because the link don't point
+				 * to it anymore after disconnect so on next crtc to connector
+				 * reshuffle by UMD we will get into unwanted dc_sink release
+				 */
+				if (aconnector->dc_sink != aconnector->dc_em_sink)
+					dc_sink_release(aconnector->dc_sink);
+			}
 			aconnector->dc_sink = sink;
 			amdgpu_dm_add_sink_to_freesync_module(
 						connector, aconnector->edid);
@@ -755,6 +763,8 @@ void amdgpu_dm_update_connector_after_detect(
 			amdgpu_dm_remove_sink_from_freesync_module(connector);
 			if (!aconnector->dc_sink)
 				aconnector->dc_sink = aconnector->dc_em_sink;
+			else if (aconnector->dc_sink != aconnector->dc_em_sink)
+				dc_sink_retain(aconnector->dc_sink);
 		}
 
 		mutex_unlock(&dev->mode_config.mutex);
-- 
2.9.3



More information about the amd-gfx mailing list