Browse Source

drm/amd/display: Add correct retain/release

Needed by objs in dm_atomic_state

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Harry Wentland 8 years ago
parent
commit
b29fc8661d

+ 10 - 0
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)
 static void dm_atomic_state_free(struct drm_atomic_state *state)
 {
 {
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
+	int i, j;
 
 
 	drm_atomic_state_default_release(state);
 	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);
 	kfree(dm_state);
 }
 }
 
 

+ 6 - 0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c

@@ -2874,11 +2874,15 @@ static uint32_t update_in_val_sets_stream(
 	}
 	}
 
 
 	val_sets[i].stream = new_stream;
 	val_sets[i].stream = new_stream;
+	dc_stream_retain(new_stream);
 	crtcs[i] = crtc;
 	crtcs[i] = crtc;
 
 
 	if (i == set_count) {
 	if (i == set_count) {
 		/* nothing found. add new one to the end */
 		/* nothing found. add new one to the end */
 		return set_count + 1;
 		return set_count + 1;
+	} else {
+		/* update. relase old stream */
+		dc_stream_release(old_stream);
 	}
 	}
 
 
 	return set_count;
 	return set_count;
@@ -2900,6 +2904,7 @@ static uint32_t remove_from_val_sets(
 		return set_count;
 		return set_count;
 	}
 	}
 
 
+	dc_stream_release(stream);
 	set_count--;
 	set_count--;
 
 
 	for (; i < set_count; i++) {
 	for (; i < set_count; i++) {
@@ -3004,6 +3009,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
 
 		if (acrtc->stream) {
 		if (acrtc->stream) {
+			dc_stream_retain(acrtc->stream);
 			dm_state->set[dm_state->set_count].stream = acrtc->stream;
 			dm_state->set[dm_state->set_count].stream = acrtc->stream;
 			crtc_set[dm_state->set_count] = crtc;
 			crtc_set[dm_state->set_count] = crtc;
 			++dm_state->set_count;
 			++dm_state->set_count;