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: Anthony Koo <anthony.koo-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 03/25] drm/amd/display: Disable Modules at Runtime
Date: Mon, 23 Jan 2017 09:35:51 -0500	[thread overview]
Message-ID: <20170123143613.15441-4-harry.wentland@amd.com> (raw)
In-Reply-To: <20170123143613.15441-1-harry.wentland-5C7GfCeVMHo@public.gmane.org>

From: Anthony Koo <Anthony.Koo@amd.com>

Add NULL check in modules

Change-Id: I3e668c93b16795c539ac790638694c2b4c4dab28
Signed-off-by: Anthony Koo <anthony.koo@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
---
 .../drm/amd/display/modules/freesync/freesync.c    | 94 +++++++++++++++-------
 .../gpu/drm/amd/display/modules/inc/mod_freesync.h |  7 --
 2 files changed, 65 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 6f4d169f4e4e..e0703c588e47 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -205,11 +205,16 @@ static unsigned int map_index_from_stream(struct core_freesync *core_freesync,
 bool mod_freesync_add_stream(struct mod_freesync *mod_freesync,
 		const struct dc_stream *stream, struct mod_freesync_caps *caps)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
-	struct core_stream *core_stream =
-			DC_STREAM_TO_CORE(stream);
-	struct core_dc *core_dc = DC_TO_CORE(core_freesync->dc);
+	struct core_stream *core_stream = NULL;
+	struct core_dc *core_dc = NULL;
+	struct core_freesync *core_freesync = NULL;
+
+	if (mod_freesync == NULL)
+		return false;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
+	core_stream = DC_STREAM_TO_CORE(stream);
+	core_dc = DC_TO_CORE(core_freesync->dc);
 
 	int persistent_freesync_enable = 0;
 	struct persistent_data_flag flag;
@@ -270,11 +275,16 @@ bool mod_freesync_add_stream(struct mod_freesync *mod_freesync,
 bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync,
 		const struct dc_stream *stream)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
-
 	int i = 0;
-	unsigned int index = map_index_from_stream(core_freesync, stream);
+	struct core_freesync *core_freesync = NULL;
+	unsigned int index = 0;
+
+	if (mod_freesync == NULL)
+		return false;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
+	index = map_index_from_stream(core_freesync, stream);
+
 	dc_stream_release(core_freesync->map[index].stream);
 	core_freesync->map[index].stream = NULL;
 	/* To remove this entity, shift everything after down */
@@ -621,11 +631,14 @@ static void set_static_ramp_variables(struct core_freesync *core_freesync,
 void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
 		const struct dc_stream **streams, int num_streams)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
-
 	unsigned int index, v_total = 0;
 	struct freesync_state *state;
+	struct core_freesync *core_freesync = NULL;
+
+	if (mod_freesync == NULL)
+		return;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
 
 	if (core_freesync->num_entities == 0)
 		return;
@@ -691,11 +704,15 @@ void mod_freesync_update_state(struct mod_freesync *mod_freesync,
 		const struct dc_stream **streams, int num_streams,
 		struct mod_freesync_params *freesync_params)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
 	bool freesync_program_required = false;
 	unsigned int stream_index;
 	struct freesync_state *state;
+	struct core_freesync *core_freesync = NULL;
+
+	if (mod_freesync == NULL)
+		return;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
 
 	if (core_freesync->num_entities == 0)
 		return;
@@ -762,10 +779,14 @@ bool mod_freesync_get_state(struct mod_freesync *mod_freesync,
 		const struct dc_stream *stream,
 		struct mod_freesync_params *freesync_params)
 {
-	struct core_freesync *core_freesync =
-				MOD_FREESYNC_TO_CORE(mod_freesync);
+	unsigned int index = NULL;
+	struct core_freesync *core_freesync = NULL;
 
-	unsigned int index = map_index_from_stream(core_freesync, stream);
+	if (mod_freesync == NULL)
+		return false;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
+	index = map_index_from_stream(core_freesync, stream);
 
 	if (core_freesync->map[index].state.fullscreen) {
 		freesync_params->state = FREESYNC_STATE_FULLSCREEN;
@@ -794,13 +815,17 @@ bool mod_freesync_set_user_enable(struct mod_freesync *mod_freesync,
 		const struct dc_stream **streams, int num_streams,
 		struct mod_freesync_user_enable *user_enable)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
-	struct core_dc *core_dc = DC_TO_CORE(core_freesync->dc);
-
 	unsigned int stream_index, map_index;
 	int persistent_data = 0;
 	struct persistent_data_flag flag;
+	struct core_dc *core_dc = NULL;
+	struct core_freesync *core_freesync = NULL;
+
+	if (mod_freesync == NULL)
+		return false;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
+	core_dc = DC_TO_CORE(core_freesync->dc);
 
 	flag.save_per_edid = true;
 	flag.save_per_link = false;
@@ -842,10 +867,14 @@ bool mod_freesync_get_user_enable(struct mod_freesync *mod_freesync,
 		const struct dc_stream *stream,
 		struct mod_freesync_user_enable *user_enable)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
+	unsigned int index = 0;
+	struct core_freesync *core_freesync = NULL;
 
-	unsigned int index = map_index_from_stream(core_freesync, stream);
+	if (mod_freesync == NULL)
+		return false;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
+	index = map_index_from_stream(core_freesync, stream);
 
 	*user_enable = core_freesync->map[index].user_enable;
 
@@ -855,12 +884,15 @@ bool mod_freesync_get_user_enable(struct mod_freesync *mod_freesync,
 void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync,
 		const struct dc_stream **streams, int num_streams)
 {
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
-
 	unsigned int stream_index, map_index;
 	unsigned min_frame_duration_in_ns, max_frame_duration_in_ns;
 	struct freesync_state *state;
+	struct core_freesync *core_freesync = NULL;
+
+	if (mod_freesync == NULL)
+		return;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
 
 	for (stream_index = 0; stream_index < num_streams; stream_index++) {
 
@@ -1121,8 +1153,12 @@ void mod_freesync_pre_update_plane_addresses(struct mod_freesync *mod_freesync,
 		unsigned int curr_time_stamp_in_us)
 {
 	unsigned int stream_index, map_index, last_render_time_in_us = 0;
-	struct core_freesync *core_freesync =
-			MOD_FREESYNC_TO_CORE(mod_freesync);
+	struct core_freesync *core_freesync = NULL;
+
+	if (mod_freesync == NULL)
+		return;
+
+	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
 
 	for (stream_index = 0; stream_index < num_streams; stream_index++) {
 
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
index 7abfe34dc2d9..783ff2ef3bee 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
@@ -110,13 +110,6 @@ bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync,
 		const struct dc_stream *stream);
 
 /*
- * Build additional parameters for dc_stream when creating stream for
- * sink to support freesync
- */
-void mod_freesync_update_stream(struct mod_freesync *mod_freesync,
-		struct dc_stream *stream);
-
-/*
  * Update the freesync state flags for each display and program
  * freesync accordingly
  */
-- 
2.9.3

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

  parent reply	other threads:[~2017-01-23 14:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23 14:35 [PATCH 00/25] DC Patches Jan 23, 2017 Harry Wentland
     [not found] ` <20170123143613.15441-1-harry.wentland-5C7GfCeVMHo@public.gmane.org>
2017-01-23 14:35   ` [PATCH 01/25] drm/amd/display: Null check clock source Harry Wentland
2017-01-23 14:35   ` [PATCH 02/25] drm/amd/display: Output Transfer Function Regamma Refactor Harry Wentland
2017-01-23 14:35   ` Harry Wentland [this message]
2017-01-23 14:35   ` [PATCH 04/25] drm/amd/display: Fixing some fallout from dc_target removal Harry Wentland
2017-01-23 14:35   ` [PATCH 05/25] drm/amd/display: No audio output heard from DP panel Harry Wentland
2017-01-23 14:35   ` [PATCH 06/25] drm/amd/display: Use pflip prepare and submit parts (v2) Harry Wentland
2017-01-23 14:35   ` [PATCH 07/25] drm/amd/display: mode change without breaking unaffected streams Harry Wentland
2017-01-23 14:35   ` [PATCH 08/25] drm/amd/display: assert if mask is 0 in set_reg_field_value_ex Harry Wentland
2017-01-23 14:35   ` [PATCH 09/25] drm/amd/display: remove un-used defines and dead code Harry Wentland
2017-01-23 14:35   ` [PATCH 10/25] drm/amd/display: remove hw_crtc_timing Harry Wentland
2017-01-23 14:35   ` [PATCH 11/25] drm/amd/display: remove hw_info_frame Harry Wentland
2017-01-23 14:36   ` [PATCH 12/25] drm/amd/display: remove SIGNAL_TYPE_WIRELESS Harry Wentland
2017-01-23 14:36   ` [PATCH 13/25] drm/amd/display: remove dead code Harry Wentland
2017-01-23 14:36   ` [PATCH 14/25] drm/amd/display: remove calculate_adjustments in conversion.h Harry Wentland
2017-01-23 14:36   ` [PATCH 15/25] drm/amd/display: Set default degamma to sRGB instead of bypass Harry Wentland
2017-01-23 14:36   ` [PATCH 16/25] drm/amd/display: HDR Enablement For Applications Harry Wentland
2017-01-23 14:36   ` [PATCH 17/25] drm/amd/display: refactor clk_resync to avoid assertion Harry Wentland
2017-01-23 14:36   ` [PATCH 18/25] drm/amd/display: Remove meta_pitch Harry Wentland
2017-01-23 14:36   ` [PATCH 19/25] drm/amd/display: rename BGRA8888 to ABGR8888 Harry Wentland
2017-01-23 14:36   ` [PATCH 20/25] drm/amd/display: Fix missing conditions in hw sequencer Harry Wentland
2017-01-23 14:36   ` [PATCH 21/25] drm/amd/display: Add missing MI masks Harry Wentland
2017-01-23 14:36   ` [PATCH 22/25] drm/amd/display: Add interrupt entries for VBLANK isr Harry Wentland
     [not found]     ` <20170123143613.15441-23-harry.wentland-5C7GfCeVMHo@public.gmane.org>
2017-01-23 17:43       ` Alex Deucher
2017-01-23 14:36   ` [PATCH 23/25] drm/amd/display: Register on VLBLANK ISR Harry Wentland
2017-01-23 14:36   ` [PATCH 24/25] drm/amd/display: Clean index in irq init loop Harry Wentland
2017-01-23 14:36   ` [PATCH 25/25] drm/amd/display: add missing dcc update on flip call 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=20170123143613.15441-4-harry.wentland@amd.com \
    --to=harry.wentland-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=anthony.koo-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.