Skip to contentSkip to conversation

Fix a bunch of allmodconfig errors

PATCH Superseded Lee Jones 2 participants 7 messages Nov 25, 2022

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lee Jones

author
#0 lore raw

cover Fix a bunch of allmodconfig errors

Since b339ec9c229aa ("kbuild: Only default to -Werror if COMPILE_TEST") WERROR now defaults to COMPILE_TEST meaning that it's enabled for allmodconfig builds. This leads to some interesting failures, each resolved in this set.

With this set applied, I am able to obtain a successful allmodconfig Arm build.

Lee Jones (3):
drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of
code
drm/amdgpu: Temporarily disable broken Clang builds due to blown
stack-frame
Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is
enabled

 drivers/gpu/drm/Kconfig                       |   7 +
 .../drm/amd/display/dc/dml/calcs/dce_calcs.c  | 483 +++++++++---------
 lib/Kconfig.debug                             |   1 +
 3 files changed, 253 insertions(+), 238 deletions(-)
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
author
#1 lore raw

PATCH 1/3 drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code

bw_calcs() presently blows the stack-frame limit by calling functions inside a argument list which return quite a bit of data to be passed onto sub-functions. Simply breaking out this hunk reduces the stack-frame use by 500 Bytes, preventing the following compiler warning:

drivers/gpu/drm/amd/amdgpu/../display/dc/dml/calcs/dce_calcs.c:3285:6:
warning: stack frame size (1384) exceeds limit (1024)
in 'bw_calcs' [-Wframe-larger-than]
bool bw_calcs(struct dc_context *ctx,
^
1 warning generated.

This resolves the issue and takes us one step closer towards a successful allmodconfig WERROR build.

---
 .../drm/amd/display/dc/dml/calcs/dce_calcs.c  | 483 +++++++++---------
 1 file changed, 245 insertions(+), 238 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c +245 -238
index 0100a6053ab6b..ce5918830c030 100644
@@ -3034,6 +3034,248 @@ static bool all_displays_in_sync(const struct pipe_ctx pipe[],
 	return true;
 }
 
+void bw_calcs_mid_phase(struct dc_context *ctx, const struct bw_calcs_dceip *dceip,
+			const struct bw_calcs_vbios *vbios, struct dce_bw_output *calcs_output,
+			struct bw_fixed low_sclk, struct bw_fixed mid1_sclk,
+			struct bw_fixed mid2_sclk, struct bw_fixed mid3_sclk,
+			struct bw_fixed mid_yclk, struct bw_calcs_data *data)
+{
+	((struct bw_calcs_vbios *)vbios)->low_sclk = mid3_sclk;
+	((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid3_sclk;
+	((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid3_sclk;
+	calculate_bandwidth(dceip, vbios, data);
+
+	calcs_output->nbp_state_change_wm_ns[0].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[4],bw_int_to_fixed(1000)));
+	calcs_output->nbp_state_change_wm_ns[1].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->nbp_state_change_wm_ns[2].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
+
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->nbp_state_change_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->nbp_state_change_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->nbp_state_change_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->nbp_state_change_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->nbp_state_change_wm_ns[5].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
+
+	calcs_output->stutter_exit_wm_ns[0].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->stutter_exit_wm_ns[1].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->stutter_exit_wm_ns[2].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->stutter_exit_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->stutter_exit_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->stutter_exit_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->stutter_exit_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->stutter_exit_wm_ns[5].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[9], bw_int_to_fixed(1000)));
+
+	calcs_output->stutter_entry_wm_ns[0].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->stutter_entry_wm_ns[1].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->stutter_entry_wm_ns[2].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->stutter_entry_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->stutter_entry_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->stutter_entry_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->stutter_entry_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->stutter_entry_wm_ns[5].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[9], bw_int_to_fixed(1000)));
+
+	calcs_output->urgent_wm_ns[0].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->urgent_wm_ns[1].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->urgent_wm_ns[2].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->urgent_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->urgent_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->urgent_wm_ns[3].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->urgent_wm_ns[4].b_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->urgent_wm_ns[5].b_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[9], bw_int_to_fixed(1000)));
+
+	((struct bw_calcs_vbios *)vbios)->low_sclk = low_sclk;
+	((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid1_sclk;
+	((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid2_sclk;
+	((struct bw_calcs_vbios *)vbios)->low_yclk = mid_yclk;
+	calculate_bandwidth(dceip, vbios, data);
+
+	calcs_output->nbp_state_change_wm_ns[0].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->nbp_state_change_wm_ns[1].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->nbp_state_change_wm_ns[2].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->nbp_state_change_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->nbp_state_change_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->nbp_state_change_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->nbp_state_change_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->nbp_state_change_wm_ns[5].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
+
+
+	calcs_output->stutter_exit_wm_ns[0].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->stutter_exit_wm_ns[1].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->stutter_exit_wm_ns[2].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->stutter_exit_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->stutter_exit_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->stutter_exit_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->stutter_exit_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       stutter_exit_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->stutter_exit_wm_ns[5].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_exit_watermark[9], bw_int_to_fixed(1000)));
+	calcs_output->stutter_entry_wm_ns[0].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->stutter_entry_wm_ns[1].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->stutter_entry_wm_ns[2].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->stutter_entry_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[0],
+					       bw_int_to_fixed(1000)));
+		calcs_output->stutter_entry_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[1],
+					       bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->stutter_entry_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[7],
+					       bw_int_to_fixed(1000)));
+		calcs_output->stutter_entry_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[8],
+					       bw_int_to_fixed(1000)));
+	}
+	calcs_output->stutter_entry_wm_ns[5].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       stutter_entry_watermark[9], bw_int_to_fixed(1000)));
+	calcs_output->urgent_wm_ns[0].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[4], bw_int_to_fixed(1000)));
+	calcs_output->urgent_wm_ns[1].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[5], bw_int_to_fixed(1000)));
+	calcs_output->urgent_wm_ns[2].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[6], bw_int_to_fixed(1000)));
+	if (ctx->dc->caps.max_slave_planes) {
+		calcs_output->urgent_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[0], bw_int_to_fixed(1000)));
+		calcs_output->urgent_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[1], bw_int_to_fixed(1000)));
+	} else {
+		calcs_output->urgent_wm_ns[3].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[7], bw_int_to_fixed(1000)));
+		calcs_output->urgent_wm_ns[4].c_mark =
+			bw_fixed_to_int(bw_mul(data->
+					       urgent_watermark[8], bw_int_to_fixed(1000)));
+	}
+	calcs_output->urgent_wm_ns[5].c_mark =
+		bw_fixed_to_int(bw_mul(data->
+				       urgent_watermark[9], bw_int_to_fixed(1000)));
+}
+
 /*
  * Return:
  *	true -	Display(s) configuration supported.
@@ -3228,244 +3470,9 @@ bool bw_calcs(struct dc_context *ctx,
 			bw_fixed_to_int(bw_mul(data->
 				urgent_watermark[9], bw_int_to_fixed(1000)));
 
-		if (dceip->version != BW_CALCS_VERSION_CARRIZO) {
-			((struct bw_calcs_vbios *)vbios)->low_sclk = mid3_sclk;
-			((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid3_sclk;
-			((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid3_sclk;
-			calculate_bandwidth(dceip, vbios, data);
-
-			calcs_output->nbp_state_change_wm_ns[0].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[4],bw_int_to_fixed(1000)));
-			calcs_output->nbp_state_change_wm_ns[1].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->nbp_state_change_wm_ns[2].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
-
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->nbp_state_change_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->nbp_state_change_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->nbp_state_change_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->nbp_state_change_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->nbp_state_change_wm_ns[5].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
-
-
-
-			calcs_output->stutter_exit_wm_ns[0].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->stutter_exit_wm_ns[1].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->stutter_exit_wm_ns[2].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->stutter_exit_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->stutter_exit_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->stutter_exit_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->stutter_exit_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->stutter_exit_wm_ns[5].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[9], bw_int_to_fixed(1000)));
-
-			calcs_output->stutter_entry_wm_ns[0].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->stutter_entry_wm_ns[1].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->stutter_entry_wm_ns[2].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->stutter_entry_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_entry_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->stutter_entry_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_entry_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->stutter_entry_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_entry_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->stutter_entry_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_entry_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->stutter_entry_wm_ns[5].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[9], bw_int_to_fixed(1000)));
-
-			calcs_output->urgent_wm_ns[0].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->urgent_wm_ns[1].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->urgent_wm_ns[2].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->urgent_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->urgent_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->urgent_wm_ns[3].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->urgent_wm_ns[4].b_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->urgent_wm_ns[5].b_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[9], bw_int_to_fixed(1000)));
-
-			((struct bw_calcs_vbios *)vbios)->low_sclk = low_sclk;
-			((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid1_sclk;
-			((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid2_sclk;
-			((struct bw_calcs_vbios *)vbios)->low_yclk = mid_yclk;
-			calculate_bandwidth(dceip, vbios, data);
-
-			calcs_output->nbp_state_change_wm_ns[0].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->nbp_state_change_wm_ns[1].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->nbp_state_change_wm_ns[2].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->nbp_state_change_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->nbp_state_change_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->nbp_state_change_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->nbp_state_change_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->nbp_state_change_wm_ns[5].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
-
-
-			calcs_output->stutter_exit_wm_ns[0].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->stutter_exit_wm_ns[1].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->stutter_exit_wm_ns[2].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->stutter_exit_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->stutter_exit_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->stutter_exit_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->stutter_exit_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						stutter_exit_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->stutter_exit_wm_ns[5].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_exit_watermark[9], bw_int_to_fixed(1000)));
-			calcs_output->stutter_entry_wm_ns[0].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->stutter_entry_wm_ns[1].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->stutter_entry_wm_ns[2].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->stutter_entry_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[0],
-						bw_int_to_fixed(1000)));
-				calcs_output->stutter_entry_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[1],
-						bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->stutter_entry_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[7],
-						bw_int_to_fixed(1000)));
-				calcs_output->stutter_entry_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->stutter_entry_watermark[8],
-						bw_int_to_fixed(1000)));
-			}
-			calcs_output->stutter_entry_wm_ns[5].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					stutter_entry_watermark[9], bw_int_to_fixed(1000)));
-			calcs_output->urgent_wm_ns[0].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[4], bw_int_to_fixed(1000)));
-			calcs_output->urgent_wm_ns[1].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[5], bw_int_to_fixed(1000)));
-			calcs_output->urgent_wm_ns[2].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[6], bw_int_to_fixed(1000)));
-			if (ctx->dc->caps.max_slave_planes) {
-				calcs_output->urgent_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[0], bw_int_to_fixed(1000)));
-				calcs_output->urgent_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[1], bw_int_to_fixed(1000)));
-			} else {
-				calcs_output->urgent_wm_ns[3].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[7], bw_int_to_fixed(1000)));
-				calcs_output->urgent_wm_ns[4].c_mark =
-					bw_fixed_to_int(bw_mul(data->
-						urgent_watermark[8], bw_int_to_fixed(1000)));
-			}
-			calcs_output->urgent_wm_ns[5].c_mark =
-				bw_fixed_to_int(bw_mul(data->
-					urgent_watermark[9], bw_int_to_fixed(1000)));
-		}
+		if (dceip->version != BW_CALCS_VERSION_CARRIZO)
+			bw_calcs_mid_phase(ctx, dceip, vbios, calcs_output, low_sclk,
+					   mid1_sclk, mid2_sclk, mid3_sclk, mid_yclk, data);
 
 		if (dceip->version == BW_CALCS_VERSION_CARRIZO) {
 			((struct bw_calcs_vbios *)vbios)->low_yclk = high_yclk;
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
#2 lore raw

Re: [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code

Quoted 13 lines · Lee Jones

bw_calcs() presently blows the stack-frame limit by calling functions inside a argument list which return quite a bit of data to be passed onto sub-functions. Simply breaking out this hunk reduces the stack-frame use by 500 Bytes, preventing the following compiler warning:

drivers/gpu/drm/amd/amdgpu/../display/dc/dml/calcs/dce_calcs.c:3285:6:
warning: stack frame size (1384) exceeds limit (1024)
in 'bw_calcs' [-Wframe-larger-than]
bool bw_calcs(struct dc_context *ctx,
^
1 warning generated.

Quoted 4 lines

This resolves the issue and takes us one step closer towards a successful allmodconfig WERROR build.

Is this still needed with the patch to turn off the display engine on most architectures? On which architecture and with which compiler do you still observe the problem?

Note that this probably doesn't actually solve the potential stack overflow by itself, since the function that is now split out is still called with the parent stack active. Splitting out multiple smaller bits however would solve it since then the stack frames could overlap.

Arnd

author
#3 lore raw

PATCH 2/3 drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame

In reply to Lee Jones

calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 || ARM64) architectures built with Clang (all released versions), whereby the stack frame gets blown up to well over 5k. This would cause an immediate kernel panic on most architectures. We'll revert this when the following bug report has been resolved: https://github.com/llvm/llvm-project/issues/41896.

---
 drivers/gpu/drm/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/Kconfig +7 -0
index 34f5a092c99e7..1fa7b9760adb8 100644
@@ -265,6 +265,7 @@ source "drivers/gpu/drm/radeon/Kconfig"
 
 config DRM_AMDGPU
 	tristate "AMD GPU"
+	depends on BROKEN || !CC_IS_CLANG || !(X86_64 || SPARC64 || ARM64)
 	depends on DRM && PCI && MMU
 	select FW_LOADER
 	select DRM_DISPLAY_DP_HELPER
@@ -289,6 +290,12 @@ config DRM_AMDGPU
 	help
 	  Choose this option if you have a recent AMD Radeon graphics card.
 
+	  calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 || ARM64)
+	  architectures built with Clang (all released versions), whereby the stack
+	  frame gets blown up to well over 5k.  This would cause an immediate kernel
+	  panic on most architectures.  We'll revert this when the following bug report
+	  has been resolved: https://github.com/llvm/llvm-project/issues/41896.
+
 	  If M is selected, the module will be called amdgpu.
 
 source "drivers/gpu/drm/amd/amdgpu/Kconfig"
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
#4 lore raw

Re: [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame

Quoted 17 lines · Lee Jones

calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 || ARM64) architectures built with Clang (all released versions), whereby the stack frame gets blown up to well over 5k. This would cause an immediate kernel panic on most architectures. We'll revert this when the following bug report has been resolved: https://github.com/llvm/llvm-project/issues/41896.

---
 drivers/gpu/drm/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/Kconfig +0 -0
index 34f5a092c99e7..1fa7b9760adb8 100644

drivers/gpu/drm/Kconfig source "drivers/gpu/drm/radeon/Kconfig" · line 268

Quoted 4 lines
drivers/gpu/drm/Kconfig +1 -0
@@ -265,6 +265,7 @@ source "drivers/gpu/drm/radeon/Kconfig"
 
 config DRM_AMDGPU
 	tristate "AMD GPU"
+	depends on BROKEN || !CC_IS_CLANG || !(X86_64 || SPARC64 || ARM64)

The logic looks fine, this has been broken for so long without anyone paying attention that limiting the broken code to the working architectures is probably the best way to avoid trouble.

However, as far as I can tell, the problem doesn't affect the entire driver, only the "new" display engine, so I would probably try to limit this to turning off CONFIG_DRM_AMD_DC for architectures that don't have a fixed clang.

Arnd

author
#5 lore raw

PATCH 3/3 Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled

In reply to Lee Jones

When enabled, KASAN enlarges function's stack-frames. Pushing quite a few over the current threshold. This can mainly be seen on 32-bit architectures where the present limit (when !GCC) is a lowly 1024-Bytes.

---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)
lib/Kconfig.debug +1 -0
index c3c0b077ade33..82d475168db95 100644
@@ -399,6 +399,7 @@ config FRAME_WARN
 	default 2048 if GCC_PLUGIN_LATENT_ENTROPY
 	default 2048 if PARISC
 	default 1536 if (!64BIT && XTENSA)
+	default 1280 if KASAN && !64BIT
 	default 1024 if !64BIT
 	default 2048 if 64BIT
 	help
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
Acked-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled

Quoted 6 lines · Lee Jones

When enabled, KASAN enlarges function's stack-frames. Pushing quite a few over the current threshold. This can mainly be seen on 32-bit architectures where the present limit (when !GCC) is a lowly 1024-Bytes.

If this affects only clang but not gcc, I wonder if we could limit the scope and keep the 1024 byte limit on gcc builds.

lib/Kconfig.debug config FRAME_WARN · line 399

Quoted 10 lines
---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)
lib/Kconfig.debug +0 -0
index c3c0b077ade33..82d475168db95 100644
@@ -399,6 +399,7 @@ config FRAME_WARN
 	default 2048 if GCC_PLUGIN_LATENT_ENTROPY

This is actually a related bug that we should fix: allmodconfig with gcc turns on GCC_PLUGIN_LATENT_ENTROPY, so the limit ends up being way too high. I think we need to either ensure that allmodconfig turns off the latent entropy plugin, or that the limit gets lowered again to something that is not any higher than the KASAN limit.

Arnd