All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix a bunch of allmodconfig errors
@ 2022-11-25  9:25 ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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(-)


-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 0/3] Fix a bunch of allmodconfig errors
@ 2022-11-25  9:25 ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

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(-)


-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 0/3] Fix a bunch of allmodconfig errors
@ 2022-11-25  9:25 ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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(-)


-- 
2.38.1.584.g0f3c55d4c2-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code
  2022-11-25  9:25 ` Lee Jones
  (?)
@ 2022-11-25  9:25   ` Lee Jones
  -1 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 .../drm/amd/display/dc/dml/calcs/dce_calcs.c  | 483 +++++++++---------
 1 file changed, 245 insertions(+), 238 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
index 0100a6053ab6b..ce5918830c030 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
@@ -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;
-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code
@ 2022-11-25  9:25   ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

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.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 .../drm/amd/display/dc/dml/calcs/dce_calcs.c  | 483 +++++++++---------
 1 file changed, 245 insertions(+), 238 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
index 0100a6053ab6b..ce5918830c030 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
@@ -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;
-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code
@ 2022-11-25  9:25   ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 .../drm/amd/display/dc/dml/calcs/dce_calcs.c  | 483 +++++++++---------
 1 file changed, 245 insertions(+), 238 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
index 0100a6053ab6b..ce5918830c030 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
@@ -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;
-- 
2.38.1.584.g0f3c55d4c2-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame
  2022-11-25  9:25 ` Lee Jones
  (?)
@ 2022-11-25  9:25   ` Lee Jones
  -1 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/gpu/drm/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 34f5a092c99e7..1fa7b9760adb8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -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"
-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame
@ 2022-11-25  9:25   ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

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.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/gpu/drm/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 34f5a092c99e7..1fa7b9760adb8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -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"
-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame
@ 2022-11-25  9:25   ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/gpu/drm/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 34f5a092c99e7..1fa7b9760adb8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -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"
-- 
2.38.1.584.g0f3c55d4c2-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled
  2022-11-25  9:25 ` Lee Jones
  (?)
@ 2022-11-25  9:25   ` Lee Jones
  -1 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c3c0b077ade33..82d475168db95 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled
@ 2022-11-25  9:25   ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

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.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c3c0b077ade33..82d475168db95 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
-- 
2.38.1.584.g0f3c55d4c2-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled
@ 2022-11-25  9:25   ` Lee Jones
  0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2022-11-25  9:25 UTC (permalink / raw)
  To: lee, arnd, akpm, nathan, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, ndesaulniers, trix, harry.wentland, sunpeng.li,
	Rodrigo.Siqueira, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

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.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c3c0b077ade33..82d475168db95 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
-- 
2.38.1.584.g0f3c55d4c2-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled
  2022-11-25  9:25   ` Lee Jones
  (?)
@ 2022-11-25 10:05     ` Arnd Bergmann
  -1 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:05 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Signed-off-by: Lee Jones <lee@kernel.org>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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 | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index c3c0b077ade33..82d475168db95 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled
@ 2022-11-25 10:05     ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:05 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Signed-off-by: Lee Jones <lee@kernel.org>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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 | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index c3c0b077ade33..82d475168db95 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled
@ 2022-11-25 10:05     ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:05 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Signed-off-by: Lee Jones <lee@kernel.org>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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 | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index c3c0b077ade33..82d475168db95 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame
  2022-11-25  9:25   ` Lee Jones
  (?)
@ 2022-11-25 10:06     ` Arnd Bergmann
  -1 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:06 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>  drivers/gpu/drm/Kconfig | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 34f5a092c99e7..1fa7b9760adb8 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame
@ 2022-11-25 10:06     ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:06 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>  drivers/gpu/drm/Kconfig | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 34f5a092c99e7..1fa7b9760adb8 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame
@ 2022-11-25 10:06     ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:06 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>  drivers/gpu/drm/Kconfig | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 34f5a092c99e7..1fa7b9760adb8 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code
  2022-11-25  9:25   ` Lee Jones
  (?)
@ 2022-11-25 10:09     ` Arnd Bergmann
  -1 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:09 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Signed-off-by: Lee Jones <lee@kernel.org>

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code
@ 2022-11-25 10:09     ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:09 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: amd-gfx, dri-devel, llvm, linux-kernel, linux-arm-kernel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Signed-off-by: Lee Jones <lee@kernel.org>

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code
@ 2022-11-25 10:09     ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2022-11-25 10:09 UTC (permalink / raw)
  To: Lee Jones, Andrew Morton, Nathan Chancellor, Maarten Lankhorst,
	mripard, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Nick Desaulniers, Tom Rix, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui.Pan
  Cc: linux-arm-kernel, linux-kernel, llvm, amd-gfx, dri-devel

On Fri, Nov 25, 2022, at 10:25, Lee Jones wrote:
> 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.
>
> Signed-off-by: Lee Jones <lee@kernel.org>

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-11-25 10:32 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25  9:25 [PATCH 0/3] Fix a bunch of allmodconfig errors Lee Jones
2022-11-25  9:25 ` Lee Jones
2022-11-25  9:25 ` Lee Jones
2022-11-25  9:25 ` [PATCH 1/3] drm/amd/display/dc/calcs/dce_calcs: Break-out a stack-heavy chunk of code Lee Jones
2022-11-25  9:25   ` Lee Jones
2022-11-25  9:25   ` Lee Jones
2022-11-25 10:09   ` Arnd Bergmann
2022-11-25 10:09     ` Arnd Bergmann
2022-11-25 10:09     ` Arnd Bergmann
2022-11-25  9:25 ` [PATCH 2/3] drm/amdgpu: Temporarily disable broken Clang builds due to blown stack-frame Lee Jones
2022-11-25  9:25   ` Lee Jones
2022-11-25  9:25   ` Lee Jones
2022-11-25 10:06   ` Arnd Bergmann
2022-11-25 10:06     ` Arnd Bergmann
2022-11-25 10:06     ` Arnd Bergmann
2022-11-25  9:25 ` [PATCH 3/3] Kconfig.debug: Provide a little extra FRAME_WARN leeway when KASAN is enabled Lee Jones
2022-11-25  9:25   ` Lee Jones
2022-11-25  9:25   ` Lee Jones
2022-11-25 10:05   ` Arnd Bergmann
2022-11-25 10:05     ` Arnd Bergmann
2022-11-25 10:05     ` Arnd Bergmann

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.