aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2395-drm-amd-display-Refactor-dc_state-creation-into-a-fu.patch
blob: 01c5e1b102c5f514072413c7b682e7a9de4545c6 (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
From d25df3438ebc745ecc3d6ec23958f416e7d96e1c Mon Sep 17 00:00:00 2001
From: "Leo (Sunpeng) Li" <sunpeng.li@amd.com>
Date: Thu, 7 Sep 2017 16:46:34 -0400
Subject: [PATCH 2395/4131] drm/amd/display: Refactor dc_state creation into a
 function.

For less repetition and easy debugging.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 +---
 drivers/gpu/drm/amd/display/dc/core/dc.c          | 23 ++++++++++++++---------
 drivers/gpu/drm/amd/display/dc/dc.h               |  1 +
 3 files changed, 16 insertions(+), 12 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 779c83d..46cbafc 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -741,13 +741,11 @@ dm_atomic_state_alloc(struct drm_device *dev)
 		goto fail;
 
 	/* copy existing configuration */
-	new_ctx = dm_alloc(sizeof(*new_ctx));
+	new_ctx = dc_create_state();
 
 	if (!new_ctx)
 		goto fail;
 
-	atomic_inc(&new_ctx->ref_count);
-
 	dc_resource_state_copy_construct_current(dc, new_ctx);
 
 	state->context = new_ctx;
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 4dbf749..f2f8953 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -480,15 +480,13 @@ static bool construct(struct dc *dc,
 		goto fail;
 	}
 
-	dc->current_state = dm_alloc(sizeof(*dc->current_state));
+	dc->current_state = dc_create_state();
 
 	if (!dc->current_state) {
 		dm_error("%s: failed to create validate ctx\n", __func__);
 		goto fail;
 	}
 
-	atomic_inc(&dc->current_state->ref_count);
-
 	dc_ctx->cgs_device = init_params->cgs_device;
 	dc_ctx->driver_context = init_params->driver;
 	dc_ctx->dc = dc;
@@ -663,14 +661,12 @@ bool dc_validate_guaranteed(
 	if (!dc_validate_stream(dc, stream))
 		return false;
 
-	context = dm_alloc(sizeof(struct dc_state));
+	context = dc_create_state();
 	if (context == NULL)
 		goto context_alloc_fail;
 
 	dc_resource_state_construct(dc, dc->current_state);
 
-	atomic_inc(&context->ref_count);
-
 	result = dc->res_pool->funcs->validate_guaranteed(
 					dc, stream, context);
 
@@ -991,6 +987,17 @@ bool dc_commit_planes_to_stream(
 	return true;
 }
 
+struct dc_state *dc_create_state(void)
+{
+	struct dc_state *context = dm_alloc(sizeof(struct dc_state));
+
+	if (!context)
+		return NULL;
+
+	atomic_inc(&context->ref_count);
+	return context;
+}
+
 void dc_retain_state(struct dc_state *context)
 {
 	ASSERT(atomic_read(&context->ref_count) > 0);
@@ -1269,14 +1276,12 @@ void dc_update_planes_and_stream(struct dc *dc,
 			new_planes[i] = srf_updates[i].surface;
 
 		/* initialize scratch memory for building context */
-		context = dm_alloc(sizeof(*context));
+		context = dc_create_state();
 		if (context == NULL) {
 			DC_ERROR("Failed to allocate new validate context!\n");
 			return;
 		}
 
-		atomic_inc(&context->ref_count);
-
 		dc_resource_state_copy_construct(
 				dc->current_state, context);
 
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 99c7a78..bf14fab 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -754,6 +754,7 @@ enum surface_update_type dc_check_update_surfaces_for_stream(
 		const struct dc_stream_status *stream_status);
 
 
+struct dc_state *dc_create_state(void);
 void dc_retain_state(struct dc_state *context);
 void dc_release_state(struct dc_state *context);
 
-- 
2.7.4