[PATCH 33/81] drm/amd/display: Update atomic state hooks.

sunpeng.li at amd.com sunpeng.li at amd.com
Tue Jul 25 13:53:53 UTC 2017


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

Reimplement atomic_state_alloc and atomic_state_clear to
release validate_ctx.

Change-Id: I57be6be9d570a90ab355731eed4defe53f3f3fcb
Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 25 +++++++++-------------
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    |  2 +-
 2 files changed, 11 insertions(+), 16 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 c2a6f2e..d0651b6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -648,33 +648,29 @@ dm_atomic_state_alloc(struct drm_device *dev)
 	return &state->base;
 }
 
-void dm_atomic_state_clear(struct drm_atomic_state *s)
-{
-	struct dm_atomic_state *state = to_dm_atomic_state(s);
-	drm_atomic_state_default_clear(&state->base);
-}
-
 
-static void dm_atomic_state_free(struct drm_atomic_state *state)
+void dm_atomic_state_clear(struct drm_atomic_state *state)
 {
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
 	int i, j;
 
-	drm_atomic_state_default_release(state);
-
 	for (i = 0; i < dm_state->set_count; i++) {
 		for (j = 0; j < dm_state->set[i].surface_count; j++) {
 			dc_surface_release(dm_state->set[i].surfaces[j]);
+			dm_state->set[i].surfaces[j] = NULL;
 		}
-	}
 
-	for (i = 0; i < dm_state->set_count; i++)
 		dc_stream_release(dm_state->set[i].stream);
+		dm_state->set[i].stream = NULL;
+	}
+	dm_state->set_count = 0;
 
-	kfree(dm_state);
-}
-
+	dc_resource_validate_ctx_destruct(dm_state->context);
+	dm_free(dm_state->context);
+	dm_state->context = NULL;
 
+	drm_atomic_state_default_clear(state);
+}
 
 static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
 	.fb_create = amdgpu_user_framebuffer_create,
@@ -683,7 +679,6 @@ static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 	.atomic_state_alloc = dm_atomic_state_alloc,
 	.atomic_state_clear = dm_atomic_state_clear,
-	.atomic_state_free = dm_atomic_state_free,
 };
 
 static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index 8445337..2a5c7b1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -2859,6 +2859,7 @@ void amdgpu_dm_atomic_commit_tail(
 	/* DC is optimized not to do anything if 'streams' didn't change. */
 	WARN_ON(!dc_commit_context(dm->dc, dm_state->context));
 
+
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
@@ -3233,7 +3234,6 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 						__func__, acrtc->base.base.id);
 				break;
 			}
-			new_stream->priv = acrtc;
 
 			new_streams[new_stream_count] = new_stream;
 			dm_state->set_count = update_in_val_sets_stream(
-- 
2.7.4



More information about the amd-gfx mailing list