drm/amd/display: Set gamma to NULL at release
authorYongqiang Sun <yongqiang.sun@amd.com>
Fri, 23 Dec 2016 15:18:08 +0000 (10:18 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 21:07:48 +0000 (17:07 -0400)
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
drivers/gpu/drm/amd/display/dc/core/dc_surface.c
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/modules/color/color.c

index aca13d1cd4bb07a5cd3ce2e658cde5e94bba8d6a..12620df7056dfd74f9ca6781344251b4faabf815 100644 (file)
@@ -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);
index d962baa477f55e9519a69d2070132820b035dc72..d607972b830bc5c8bb41f89aed0f61adb5c3bcf5 100644 (file)
@@ -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()
index 23f41b690c025565bb398ce5570d093ee7447f68..599f8b0894c26f791ffaf1782ed5005ac47513e7 100644 (file)
@@ -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);
index 599d9f9aa7caa8c46c910f5e673f543a65d9674f..3611de90e1e9a556d694fab2d926310056d45c77 100644 (file)
@@ -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;