Blob Blame History Raw
From: "Leo (Sunpeng) Li" <sunpeng.li@amd.com>
Date: Thu, 21 Sep 2017 16:13:00 -0400
Subject: drm/amd/display: Move copy_construct from state_alloc to atomic_check.
Git-commit: d4d4a64574ab546811d29a21366afe6bb6cdb264
Patch-mainline: v4.15-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

Previously atomic_check assumed that dc_state is allocated and filled
in. This is not the case when we hit EDEADLK and have to backup and
retry.

We could change atomic_state_clear but that revealed some other
problems. For now let's create and construct dc_state in atomic_check.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -691,9 +691,6 @@ struct drm_atomic_state *
 dm_atomic_state_alloc(struct drm_device *dev)
 {
 	struct dm_atomic_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
-	struct validate_context *new_ctx;
-	struct amdgpu_device *adev = dev->dev_private;
-	struct dc *dc = adev->dm.dc;
 
 	if (!state)
 		return NULL;
@@ -701,16 +698,6 @@ dm_atomic_state_alloc(struct drm_device
 	if (drm_atomic_state_init(dev, &state->base) < 0)
 		goto fail;
 
-	/* copy existing configuration */
-	new_ctx = dc_create_state();
-
-	if (!new_ctx)
-		goto fail;
-
-	dc_resource_validate_ctx_copy_construct_current(dc, new_ctx);
-
-	state->context = new_ctx;
-
 	return &state->base;
 
 fail:
@@ -4465,6 +4452,10 @@ int amdgpu_dm_atomic_check(struct drm_de
 		return ret;
 	}
 
+	dm_state->context = dc_create_state();
+	ASSERT(dm_state->context);
+	dc_resource_validate_ctx_copy_construct_current(dc, dm_state->context);
+
 	/* copy existing configuration */
 	set_count = 0;
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {