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
|
From f794108c995e6213ddc1839fc80605b022f1c36c Mon Sep 17 00:00:00 2001
From: Yongqiang Sun <yongqiang.sun@amd.com>
Date: Fri, 23 Dec 2016 10:18:08 -0500
Subject: [PATCH 0108/4131] drm/amd/display: Set gamma to NULL at release
Signed-off-by: Yongqiang Sun <yongqiang.sun@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>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 2 +-
drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 9 +++++----
drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
drivers/gpu/drm/amd/display/modules/color/color.c | 8 +++-----
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index aca13d1..12620df 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1458,7 +1458,7 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda
if (updates[i].gamma &&
updates[i].gamma != surface->public.gamma_correction) {
if (surface->public.gamma_correction != NULL)
- dc_gamma_release(surface->public.
+ dc_gamma_release(&surface->public.
gamma_correction);
dc_gamma_retain(updates[i].gamma);
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 d962baa..d607972 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
@@ -74,8 +74,7 @@ static bool construct(struct dc_context *ctx, struct surface *surface)
static void destruct(struct surface *surface)
{
if (surface->protected.public.gamma_correction != NULL) {
- dc_gamma_release(surface->protected.public.gamma_correction);
- surface->protected.public.gamma_correction = NULL;
+ dc_gamma_release(&surface->protected.public.gamma_correction);
}
if (surface->protected.public.in_transfer_func != NULL) {
dc_transfer_func_release(
@@ -189,15 +188,17 @@ void dc_gamma_retain(const struct dc_gamma *dc_gamma)
++gamma->ref_count;
}
-void dc_gamma_release(const struct dc_gamma *dc_gamma)
+void dc_gamma_release(const struct dc_gamma **dc_gamma)
{
- struct gamma *gamma = DC_GAMMA_TO_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)
dm_free(gamma);
+
+ *dc_gamma = NULL;
}
struct dc_gamma *dc_create_gamma()
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 23f41b6..599f8b0 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -318,7 +318,7 @@ void dc_surface_retain(const struct dc_surface *dc_surface);
void dc_surface_release(const struct dc_surface *dc_surface);
void dc_gamma_retain(const struct dc_gamma *dc_gamma);
-void dc_gamma_release(const struct dc_gamma *dc_gamma);
+void dc_gamma_release(const struct dc_gamma **dc_gamma);
struct dc_gamma *dc_create_gamma(void);
void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf);
diff --git a/drivers/gpu/drm/amd/display/modules/color/color.c b/drivers/gpu/drm/amd/display/modules/color/color.c
index 599d9f9..3611de9 100644
--- a/drivers/gpu/drm/amd/display/modules/color/color.c
+++ b/drivers/gpu/drm/amd/display/modules/color/color.c
@@ -1557,7 +1557,7 @@ void mod_color_destroy(struct mod_color *mod_color)
for (i = 0; i < core_color->num_sinks; i++)
if (core_color->state[i].gamma)
- dc_gamma_release(core_color->state[i].gamma);
+ dc_gamma_release(&core_color->state[i].gamma);
dm_free(core_color->state);
@@ -1749,8 +1749,7 @@ bool mod_color_remove_sink(struct mod_color *mod_color,
for (i = 0; i < core_color->num_sinks; i++) {
if (core_color->caps[i].sink == sink) {
if (core_color->state[i].gamma) {
- dc_gamma_release(core_color->state[i].gamma);
- core_color->state[i].gamma = NULL;
+ dc_gamma_release(&core_color->state[i].gamma);
}
/* To remove this sink, shift everything after down */
@@ -2444,8 +2443,7 @@ bool mod_color_set_input_gamma_correction(struct mod_color *mod_color,
if (core_color->state[sink_index].gamma != gamma) {
if (core_color->state[sink_index].gamma)
dc_gamma_release(
- core_color->state[sink_index].
- gamma);
+ &core_color->state[sink_index].gamma);
dc_gamma_retain(gamma);
core_color->state[sink_index].gamma = gamma;
--
2.7.4
|