[PATCH 29/81] drm/amd/display: Add correct retain/release

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Harry Wentland <harry.wentland@xxxxxxx>

Needed by objs in dm_atomic_state

Change-Id: I78ccd1fba5022dd686b5df290534b86fa089e30a
Signed-off-by: Harry Wentland <harry.wentland 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       | 10 ++++++++++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c |  6 ++++++
 2 files changed, 16 insertions(+)

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 1b69848..c2a6f2e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -658,9 +658,19 @@ void dm_atomic_state_clear(struct drm_atomic_state *s)
 static void dm_atomic_state_free(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]);
+		}
+	}
+
+	for (i = 0; i < dm_state->set_count; i++)
+		dc_stream_release(dm_state->set[i].stream);
+
 	kfree(dm_state);
 }
 
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 52d1922..13fc497 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
@@ -3038,11 +3038,15 @@ static uint32_t update_in_val_sets_stream(
 	}
 
 	val_sets[i].stream = new_stream;
+	dc_stream_retain(new_stream);
 	crtcs[i] = crtc;
 
 	if (i == set_count) {
 		/* nothing found. add new one to the end */
 		return set_count + 1;
+	} else {
+		/* update. relase old stream */
+		dc_stream_release(old_stream);
 	}
 
 	return set_count;
@@ -3064,6 +3068,7 @@ static uint32_t remove_from_val_sets(
 		return set_count;
 	}
 
+	dc_stream_release(stream);
 	set_count--;
 
 	for (; i < set_count; i++) {
@@ -3168,6 +3173,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
 		if (acrtc->stream) {
+			dc_stream_retain(acrtc->stream);
 			dm_state->set[dm_state->set_count].stream = acrtc->stream;
 			crtc_set[dm_state->set_count] = crtc;
 			++dm_state->set_count;
-- 
2.7.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux