Skip to contentSkip to conversation

drm/amd: add some extra checks that is_dig_enabled is defined

PATCH In review Mario Limonciello 3 participants 7 messages Dec 10, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amd: add some extra checks that is_dig_enabled is defined

There are a few places that this isn't checked that could potentially be a NULL pointer access.

---
 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c |  3 ++-
 .../display/dc/dce110/dce110_hw_sequencer.c   | 21 +++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c +2 -1
index ac2d4c4f04e4..8653b4b8bcfc 100644
@@ -77,7 +77,8 @@ int rn_get_active_display_cnt_wa(
 		const struct dc_link *link = dc->links[i];
 
 		/* abusing the fact that the dig and phy are coupled to see if the phy is enabled */
-		if (link->link_enc->funcs->is_dig_enabled(link->link_enc))
+		if (link->link_enc->funcs->is_dig_enabled &&
+		    link->link_enc->funcs->is_dig_enabled(link->link_enc))
 			display_count++;
 	}
 
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +10 -11
index abef132fa016..0d6dc329dddb 100644
@@ -1827,17 +1827,16 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
 			if (edp_link != edp_streams[0]->link)
 				continue;
 			// enable fastboot if backend is enabled on eDP
-			if (edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc)) {
-				/* Set optimization flag on eDP stream*/
-				if (edp_link->link_status.link_active) {
-					edp_stream = edp_streams[0];
-					can_apply_edp_fast_boot = !is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);
-					edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
-					if (can_apply_edp_fast_boot)
-						DC_LOG_EVENT_LINK_TRAINING("eDP fast boot disabled to optimize link rate\n");
-
-					break;
-				}
+			if (edp_link->link_enc->funcs->is_dig_enabled &&
+			    edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc) &&
+			    edp_link->link_status.link_active) {
+				edp_stream = edp_streams[0];
+				can_apply_edp_fast_boot = !is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);
+				edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
+				if (can_apply_edp_fast_boot)
+					DC_LOG_EVENT_LINK_TRAINING("eDP fast boot disabled to optimize link rate\n");
+
+				break;
 			}
 		}
 		// We are trying to enable eDP, don't power down VDD
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 drm/amd: move variable to local scope

edp_stream is only used when backend is enabled on eDP, don't declare the variable outside that scope.

---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +1 -2
index 0d6dc329dddb..fb578b311b98 100644
@@ -1798,7 +1798,6 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
 	struct dc_stream_state *edp_streams[MAX_NUM_EDP];
 	struct dc_link *edp_link_with_sink = NULL;
 	struct dc_link *edp_link = NULL;
-	struct dc_stream_state *edp_stream = NULL;
 	struct dce_hwseq *hws = dc->hwseq;
 	int edp_with_sink_num;
 	int edp_num;
@@ -1830,7 +1829,7 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
 			if (edp_link->link_enc->funcs->is_dig_enabled &&
 			    edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc) &&
 			    edp_link->link_status.link_active) {
-				edp_stream = edp_streams[0];
+				struct dc_stream_state *edp_stream = edp_streams[0];
 				can_apply_edp_fast_boot = !is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);
 				edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
 				if (can_apply_edp_fast_boot)
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 2/2] drm/amd: move variable to local scope

Am 10.12.21 um 16:54 schrieb Mario Limonciello:

Quoted 21 lines

edp_stream is only used when backend is enabled on eDP, don't declare the variable outside that scope.

---
  drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -1
index 0d6dc329dddb..fb578b311b98 100644
@@ -1798,7 +1798,6 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
  	struct dc_stream_state *edp_streams[MAX_NUM_EDP];
  	struct dc_link *edp_link_with_sink = NULL;
  	struct dc_link *edp_link = NULL;
-	struct dc_stream_state *edp_stream = NULL;
  	struct dce_hwseq *hws = dc->hwseq;
  	int edp_with_sink_num;
  	int edp_num;

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context) · line 1833

Quoted 6 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +1 -1
@@ -1830,7 +1829,7 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
  			if (edp_link->link_enc->funcs->is_dig_enabled &&
  			    edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc) &&
  			    edp_link->link_status.link_active) {
-				edp_stream = edp_streams[0];
+				struct dc_stream_state *edp_stream = edp_streams[0];
  				can_apply_edp_fast_boot = !is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);

While you are at it, there should always be an empty line between declaration and code.

Running your patches through checkpatch.pl helps spotting such stuff.

Christian.

Quoted 2 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
  				edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
  				if (can_apply_edp_fast_boot)
#3 lore raw

RE: [PATCH 2/2] drm/amd: move variable to local scope

[AMD Official Use Only]

Quoted 41 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, December 10, 2021 10:07
To: Limonciello, Mario <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 2/2] drm/amd: move variable to local scope

Am 10.12.21 um 16:54 schrieb Mario Limonciello:

Review

Quoted 9 lines

edp_stream is only used when backend is enabled on eDP, don't declare the variable outside that scope.

---
  drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc

Quoted 4 lines

index 0d6dc329dddb..fb578b311b98 100644

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
@@ -1798,7 +1798,6 @@ void dce110_enable_accelerated_mode(struct dc

*dc, struct dc_state *context)

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -1
  	struct dc_stream_state *edp_streams[MAX_NUM_EDP];
  	struct dc_link *edp_link_with_sink = NULL;
  	struct dc_link *edp_link = NULL;
-	struct dc_stream_state *edp_stream = NULL;
  	struct dce_hwseq *hws = dc->hwseq;
  	int edp_with_sink_num;
  	int edp_num;
@@ -1830,7 +1829,7 @@ void dce110_enable_accelerated_mode(struct dc

*dc, struct dc_state *context)

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

Quoted 6 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
  			if (edp_link->link_enc->funcs->is_dig_enabled &&
  			    edp_link->link_enc->funcs->is_dig_enabled(edp_link-

link_enc) &&
edp_link->link_status.link_active) {

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +1 -1
-				edp_stream = edp_streams[0];
+				struct dc_stream_state *edp_stream =

edp_streams[0];

Quoted 5 lines
Quoted 1 line

can_apply_edp_fast_boot =

!is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);

While you are at it, there should always be an empty line between declaration and code.

Very well, will fix it. Can I have a tag with assumption that fix in place, or should I re-send?

Quoted 3 lines

Running your patches through checkpatch.pl helps spotting such stuff.

Actually checkpatch didn't catch that.

$ ./scripts/checkpatch.pl 0002-drm-amd-move-variable-to-local-scope.patch
total: 0 errors, 0 warnings, 15 lines checked

0002-drm-amd-move-variable-to-local-scope.patch has no obvious style problems and is ready for submission.

Quoted 5 lines

Christian.

Quoted 3 lines

edp_stream-
apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
if (can_apply_edp_fast_boot)

maintainer
#4 lore raw

Re: [PATCH 2/2] drm/amd: move variable to local scope

Am 10.12.21 um 17:12 schrieb Limonciello, Mario:

Quoted 43 lines

[AMD Official Use Only]

Quoted 41 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, December 10, 2021 10:07
To: Limonciello, Mario <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 2/2] drm/amd: move variable to local scope

Am 10.12.21 um 16:54 schrieb Mario Limonciello:

Review

Quoted 9 lines

edp_stream is only used when backend is enabled on eDP, don't declare the variable outside that scope.

---
   drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc

Quoted 4 lines

index 0d6dc329dddb..fb578b311b98 100644

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
@@ -1798,7 +1798,6 @@ void dce110_enable_accelerated_mode(struct dc

*dc, struct dc_state *context)

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -1
   	struct dc_stream_state *edp_streams[MAX_NUM_EDP];
   	struct dc_link *edp_link_with_sink = NULL;
   	struct dc_link *edp_link = NULL;
-	struct dc_stream_state *edp_stream = NULL;
   	struct dce_hwseq *hws = dc->hwseq;
   	int edp_with_sink_num;
   	int edp_num;
@@ -1830,7 +1829,7 @@ void dce110_enable_accelerated_mode(struct dc

*dc, struct dc_state *context)

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

Quoted 6 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
   			if (edp_link->link_enc->funcs->is_dig_enabled &&
   			    edp_link->link_enc->funcs->is_dig_enabled(edp_link-

link_enc) &&
edp_link->link_status.link_active) {

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +1 -1
-				edp_stream = edp_streams[0];
+				struct dc_stream_state *edp_stream =

edp_streams[0];

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

can_apply_edp_fast_boot =

!is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);

While you are at it, there should always be an empty line between declaration and code.

Very well, will fix it. Can I have a tag with assumption that fix in place, or should I re-send?

Just fix inline, it's not a major issue anyway.

Quoted 9 lines
Quoted 3 lines

Running your patches through checkpatch.pl helps spotting such stuff.

Actually checkpatch didn't catch that.

$ ./scripts/checkpatch.pl 0002-drm-amd-move-variable-to-local-scope.patch
total: 0 errors, 0 warnings, 15 lines checked

0002-drm-amd-move-variable-to-local-scope.patch has no obvious style problems and is ready for submission.

Mhm, something is going wrong here. checkpatch.pl is complaining quite badly for that patch:

ERROR: DOS line endings
#169: FILE: drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c:1832:
+^I^I^I^Istruct dc_stream_state *edp_stream = edp_streams[0];^M$

Especially the DOS line ending is not something we can push like this, but could be that the AMD mail servers are messing up things once more.

Christian.

Quoted 6 lines
Quoted 6 lines

Christian.

Quoted 3 lines

edp_stream-
apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
if (can_apply_edp_fast_boot)

#5 lore raw

RE: [PATCH 2/2] drm/amd: move variable to local scope

[AMD Official Use Only]

Quoted 53 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, December 10, 2021 10:19
To: Limonciello, Mario <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amd: move variable to local scope

Am 10.12.21 um 17:12 schrieb Limonciello, Mario:

Quoted 21 lines

[AMD Official Use Only]

Quoted 19 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, December 10, 2021 10:07
To: Limonciello, Mario <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 2/2] drm/amd: move variable to local scope

Am 10.12.21 um 16:54 schrieb Mario Limonciello:

Quoted 9 lines

edp_stream is only used when backend is enabled on eDP, don't declare the variable outside that scope.

---
   drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)

diff --git

a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

Quoted 23 lines
Quoted 23 lines

b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc

Quoted 4 lines

index 0d6dc329dddb..fb578b311b98 100644

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
@@ -1798,7 +1798,6 @@ void dce110_enable_accelerated_mode(struct dc

*dc, struct dc_state *context)

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c void dce110_enable_accelerated_mode(struct dc

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -1
   	struct dc_stream_state *edp_streams[MAX_NUM_EDP];
   	struct dc_link *edp_link_with_sink = NULL;
   	struct dc_link *edp_link = NULL;
-	struct dc_stream_state *edp_stream = NULL;
   	struct dce_hwseq *hws = dc->hwseq;
   	int edp_with_sink_num;
   	int edp_num;
@@ -1830,7 +1829,7 @@ void dce110_enable_accelerated_mode(struct dc

*dc, struct dc_state *context)

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c

Quoted 6 lines
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
   			if (edp_link->link_enc->funcs->is_dig_enabled &&
   			    edp_link->link_enc->funcs->is_dig_enabled(edp_link-

link_enc) &&
edp_link->link_status.link_active) {

drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +1 -1
-				edp_stream = edp_streams[0];
+				struct dc_stream_state *edp_stream =

edp_streams[0];

Quoted 1 line

can_apply_edp_fast_boot =

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

!is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);

While you are at it, there should always be an empty line between declaration and code.

Very well, will fix it. Can I have a tag with assumption that fix in place, or should I re-send?

Just fix inline, it's not a major issue anyway.

OK once I have a tag for the series will do so.

Quoted 15 lines
Quoted 10 lines
Quoted 4 lines

Running your patches through checkpatch.pl helps spotting such stuff.

Actually checkpatch didn't catch that.

$ ./scripts/checkpatch.pl 0002-drm-amd-move-variable-to-local-scope.patch
total: 0 errors, 0 warnings, 15 lines checked

0002-drm-amd-move-variable-to-local-scope.patch has no obvious style

problems and is ready for submission.

Mhm, something is going wrong here. checkpatch.pl is complaining quite badly for that patch:

Quoted 7 lines

ERROR: DOS line endings
#169: FILE:
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c:1832:
+^I^I^I^Istruct dc_stream_state *edp_stream = edp_streams[0];^M$

Especially the DOS line ending is not something we can push like this, but could be that the AMD mail servers are messing up things once more.

That's gotta be Exchange or outlook doing it or something.

$ wget https://patchwork.freedesktop.org/patch/466268/mbox/ -O patch
--2021-12-10 10:21:23--  https://patchwork.freedesktop.org/patch/466268/mbox/
Resolving patchwork.freedesktop.org (patchwork.freedesktop.org)... 131.252.210.167, 2610:10:20:722:a800:ff:feee:56cf
Connecting to patchwork.freedesktop.org (patchwork.freedesktop.org)|131.252.210.167|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1975 (1.9K) [text/plain]
Saving to: ‘patch’

patch 100%[====================================================================================================================>] 1.93K --.-KB/s in 0s

2021-12-10 10:21:26 (60.2 MB/s) - ‘patch’ saved [1975/1975]
$ ~/src/linux/scripts/checkpatch.pl patch
total: 0 errors, 0 warnings, 15 lines checked

patch has no obvious style problems and is ready for submission.

Quoted 9 lines

Christian.

Quoted 6 lines
Quoted 6 lines

Christian.

Quoted 3 lines

edp_stream-
apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
if (can_apply_edp_fast_boot)

maintainer Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] drm/amd: move variable to local scope

In reply to Mario Limonciello

With Christian's comments addressed both patches are

Harry

Quoted 30 lines · Mario Limonciello

edp_stream is only used when backend is enabled on eDP, don't declare the variable outside that scope.

---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +1 -2
index 0d6dc329dddb..fb578b311b98 100644
@@ -1798,7 +1798,6 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
 	struct dc_stream_state *edp_streams[MAX_NUM_EDP];
 	struct dc_link *edp_link_with_sink = NULL;
 	struct dc_link *edp_link = NULL;
-	struct dc_stream_state *edp_stream = NULL;
 	struct dce_hwseq *hws = dc->hwseq;
 	int edp_with_sink_num;
 	int edp_num;
@@ -1830,7 +1829,7 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
 			if (edp_link->link_enc->funcs->is_dig_enabled &&
 			    edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc) &&
 			    edp_link->link_status.link_active) {
-				edp_stream = edp_streams[0];
+				struct dc_stream_state *edp_stream = edp_streams[0];
 				can_apply_edp_fast_boot = !is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);
 				edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
 				if (can_apply_edp_fast_boot)