From 2517ba8ab52016fcf2c24d2b0f4cda52a485ae5a Mon Sep 17 00:00:00 2001 From: "Leo (Sunpeng) Li" Date: Thu, 21 Sep 2017 16:13:00 -0400 Subject: [PATCH 2396/4131] drm/amd/display: Move copy_construct from state_alloc to atomic_check 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 Reviewed-by: Harry Wentland --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) 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 46cbafc..ade9998 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -730,9 +730,6 @@ static struct drm_atomic_state * dm_atomic_state_alloc(struct drm_device *dev) { struct dm_atomic_state *state = kzalloc(sizeof(*state), GFP_KERNEL); - struct dc_state *new_ctx; - struct amdgpu_device *adev = dev->dev_private; - struct dc *dc = adev->dm.dc; if (!state) return NULL; @@ -740,16 +737,6 @@ dm_atomic_state_alloc(struct drm_device *dev) 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_state_copy_construct_current(dc, new_ctx); - - state->context = new_ctx; - return &state->base; fail: @@ -4898,6 +4885,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, } } + dm_state->context = dc_create_state(); + ASSERT(dm_state->context); + dc_resource_state_copy_construct_current(dc, dm_state->context); + /* Remove exiting planes if they are modified */ ret = dm_update_planes_state(dc, state, false, &lock_and_validation_needed); if (ret) { -- 2.7.4