aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/0100-drm-amd-display-Add-refcount-debug-assert.patch
blob: d0350e730c80ed5f2629f53a35f84a07ca7f3144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
From ac7de98034671e90c9ceb36303484a9f14aa8ccc Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Date: Tue, 20 Dec 2016 18:01:30 -0500
Subject: [PATCH 0100/4131] drm/amd/display: Add refcount debug assert

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Signed-off-by: Jordan Lazare <Jordan.Lazare@amd.com>
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Reviewed-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Jordan Lazare <Jordan.Lazare@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_sink.c    |  5 +++--
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c  |  5 ++++-
 drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 14 +++++++++++---
 drivers/gpu/drm/amd/display/dc/core/dc_target.c  |  4 +++-
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
index 67ae799..9dff0bf 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
@@ -71,6 +71,7 @@ void dc_sink_retain(const struct dc_sink *dc_sink)
 {
 	struct sink *sink = DC_SINK_TO_SINK(dc_sink);
 
+	ASSERT(sink->ref_count > 0);
 	++sink->ref_count;
 }
 
@@ -78,6 +79,7 @@ void dc_sink_release(const struct dc_sink *dc_sink)
 {
 	struct sink *sink = DC_SINK_TO_SINK(dc_sink);
 
+	ASSERT(sink->ref_count > 0);
 	--sink->ref_count;
 
 	if (sink->ref_count == 0) {
@@ -96,8 +98,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
 	if (false == construct(sink, init_params))
 		goto construct_fail;
 
-	/* TODO should we move this outside to where the assignment actually happens? */
-	dc_sink_retain(&sink->protected.public);
+	++sink->ref_count;
 
 	return &sink->protected.public;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 84e3fbb..39a6124 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -99,6 +99,8 @@ static void destruct(struct core_stream *stream)
 void dc_stream_retain(const struct dc_stream *dc_stream)
 {
 	struct stream *stream = DC_STREAM_TO_STREAM(dc_stream);
+
+	ASSERT(stream->ref_count > 0);
 	stream->ref_count++;
 }
 
@@ -108,6 +110,7 @@ void dc_stream_release(const struct dc_stream *public)
 	struct core_stream *protected = DC_STREAM_TO_CORE(public);
 
 	if (public != NULL) {
+		ASSERT(stream->ref_count > 0);
 		stream->ref_count--;
 
 		if (stream->ref_count == 0) {
@@ -134,7 +137,7 @@ struct dc_stream *dc_create_stream_for_sink(
 	if (false == construct(&stream->protected, dc_sink))
 			goto construct_fail;
 
-	dc_stream_retain(&stream->protected.public);
+	stream->ref_count++;
 
 	return &stream->protected.public;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
index cf8fb9a..6b4c75a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
@@ -105,7 +105,7 @@ struct dc_surface *dc_create_surface(const struct dc *dc)
 	if (false == construct(core_dc->ctx, surface))
 		goto construct_fail;
 
-	dc_surface_retain(&surface->protected.public);
+	++surface->ref_count;
 
 	return &surface->protected.public;
 
@@ -162,6 +162,7 @@ void dc_surface_retain(const struct dc_surface *dc_surface)
 {
 	struct surface *surface = DC_SURFACE_TO_SURFACE(dc_surface);
 
+	ASSERT(surface->ref_count > 0);
 	++surface->ref_count;
 }
 
@@ -169,6 +170,7 @@ void dc_surface_release(const struct dc_surface *dc_surface)
 {
 	struct surface *surface = DC_SURFACE_TO_SURFACE(dc_surface);
 
+	ASSERT(surface->ref_count > 0);
 	--surface->ref_count;
 
 	if (surface->ref_count == 0) {
@@ -181,12 +183,15 @@ void dc_gamma_retain(const struct dc_gamma *dc_gamma)
 {
 	struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma);
 
+	ASSERT(gamma->ref_count > 0);
 	++gamma->ref_count;
 }
 
 void dc_gamma_release(const struct dc_gamma *dc_gamma)
 {
 	struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma);
+
+	ASSERT(gamma->ref_count > 0);
 	--gamma->ref_count;
 
 	if (gamma->ref_count == 0)
@@ -200,7 +205,7 @@ struct dc_gamma *dc_create_gamma()
 	if (gamma == NULL)
 		goto alloc_fail;
 
-	dc_gamma_retain(&gamma->protected.public);
+	++gamma->ref_count;
 
 	return &gamma->protected.public;
 
@@ -212,12 +217,15 @@ void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf)
 {
 	struct transfer_func *tf = DC_TRANSFER_FUNC_TO_TRANSFER_FUNC(dc_tf);
 
+	ASSERT(tf->ref_count > 0);
 	++tf->ref_count;
 }
 
 void dc_transfer_func_release(const struct dc_transfer_func *dc_tf)
 {
 	struct transfer_func *tf = DC_TRANSFER_FUNC_TO_TRANSFER_FUNC(dc_tf);
+
+	ASSERT(tf->ref_count > 0);
 	--tf->ref_count;
 
 	if (tf->ref_count == 0)
@@ -231,7 +239,7 @@ struct dc_transfer_func *dc_create_transfer_func()
 	if (tf == NULL)
 		goto alloc_fail;
 
-	dc_transfer_func_retain(&tf->protected.public);
+	++tf->ref_count;
 
 	return &tf->protected.public;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_target.c b/drivers/gpu/drm/amd/display/dc/core/dc_target.c
index 2531df7..d4ecf2d 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_target.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_target.c
@@ -71,6 +71,7 @@ void dc_target_retain(const struct dc_target *dc_target)
 {
 	struct target *target = DC_TARGET_TO_TARGET(dc_target);
 
+	ASSERT(target->ref_count > 0);
 	target->ref_count++;
 }
 
@@ -81,6 +82,7 @@ void dc_target_release(const struct dc_target *dc_target)
 
 	ASSERT(target->ref_count > 0);
 	target->ref_count--;
+
 	if (target->ref_count == 0) {
 		destruct(protected);
 		dm_free(target);
@@ -120,7 +122,7 @@ struct dc_target *dc_create_target_for_streams(
 
 	construct(&target->protected, stream->ctx, dc_streams, stream_count);
 
-	dc_target_retain(&target->protected.public);
+	target->ref_count++;
 
 	return &target->protected.public;
 
-- 
2.7.4