All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harry Wentland <harry.wentland-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Yongqiang Sun <yongqiang.sun-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 07/10] drm/amd/display: Set gamma to NULL at release
Date: Thu, 29 Dec 2016 13:29:40 -0500	[thread overview]
Message-ID: <20161229182943.16087-8-harry.wentland@amd.com> (raw)
In-Reply-To: <20161229182943.16087-1-harry.wentland-5C7GfCeVMHo@public.gmane.org>

From: Yongqiang Sun <yongqiang.sun@amd.com>

Change-Id: Iff63270cf76bcd0cb8f76342df3d333425c89b85
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>
---
 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 aca13d1cd4bb..12620df7056d 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 d962baa477f5..d607972b830b 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 23f41b690c02..599f8b0894c2 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 599d9f9aa7ca..3611de90e1e9 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.9.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2016-12-29 18:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29 18:29 [PATCH 00/10] DC Patches Dec 29, 2016 Harry Wentland
     [not found] ` <20161229182943.16087-1-harry.wentland-5C7GfCeVMHo@public.gmane.org>
2016-12-29 18:29   ` [PATCH 01/10] drm/amd/display: Allow multiple instance of DTO regs Harry Wentland
2016-12-29 18:29   ` [PATCH 02/10] drm/amd/display: DAL3: HDR10 Infoframe encoding Harry Wentland
     [not found]     ` <20161229182943.16087-3-harry.wentland-5C7GfCeVMHo@public.gmane.org>
2017-01-07 23:23       ` Is there any public git repo with DAL? Yurii Kolesnykov
     [not found]         ` <7704ce2f-1666-dfe9-afdf-5b2845f5d460-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-07 23:30           ` Andres Rodriguez
     [not found]             ` <260e1efe-69e0-680a-ae78-c6d14a1f7df9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-09 13:43               ` Deucher, Alexander
2016-12-29 18:29   ` [PATCH 03/10] drm/amd/display: debug opt disable hdmi deep color Harry Wentland
2016-12-29 18:29   ` [PATCH 04/10] drm/amd/display: debug option to disable color module fucntionality Harry Wentland
2016-12-29 18:29   ` [PATCH 05/10] drm/amd/display: Don't use target before null check Harry Wentland
2016-12-29 18:29   ` [PATCH 06/10] drm/amd/display: Add missing function to fix crush for DP Test pattern 4 Harry Wentland
2016-12-29 18:29   ` Harry Wentland [this message]
2016-12-29 18:29   ` [PATCH 08/10] drm/amd/display: set HBR3 and TPS4 capable flags Harry Wentland
2016-12-29 18:29   ` [PATCH 09/10] drm/amd/display: Fix color module crash when hotplug monitors Harry Wentland
2016-12-29 18:29   ` [PATCH 10/10] drm/amd/display: enable option to disable HDR related updates Harry Wentland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161229182943.16087-8-harry.wentland@amd.com \
    --to=harry.wentland-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=yongqiang.sun-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.