Skip to content

Commit a8d42cd

Browse files
Tzung-Bi Shihalexdeucher
authored andcommitted
drm/amd/display: mark static functions noinline_for_stack
When compiling allmodconfig (CONFIG_WERROR=y) with clang-19, see the following errors: .../display/dc/dml2/display_mode_core.c:6268:13: warning: stack frame size (3128) exceeds limit (3072) in 'dml_prefetch_check' [-Wframe-larger-than] .../display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c:7236:13: warning: stack frame size (3256) exceeds limit (3072) in 'dml_core_mode_support' [-Wframe-larger-than] Mark static functions called by dml_prefetch_check() and dml_core_mode_support() noinline_for_stack to avoid them become huge functions and thus exceed the frame size limit. A way to reproduce: $ git checkout next-20250107 $ mkdir build_dir $ export PATH=/tmp/llvm-19.1.6-x86_64/bin:$PATH $ make LLVM=1 O=build_dir allmodconfig $ make LLVM=1 O=build_dir drivers/gpu/drm/ -j The way how it chose static functions to mark: [0] Unset CONFIG_WERROR in build_dir/.config. To get display_mode_core.o without errors. [1] Get a function list called by dml_prefetch_check(). $ sed -n '6268,6711p' drivers/gpu/drm/amd/display/dc/dml2/display_mode_core.c \ | sed -n -r 's/.*\W(\w+)\(.*/\1/p' | sort -u >/tmp/syms [2] Get the non-inline function list. Objdump won't show the symbols if they are inline functions. $ make LLVM=1 O=build_dir drivers/gpu/drm/ -j $ objdump -d build_dir/.../display_mode_core.o | \ ./scripts/checkstack.pl x86_64 0 | \ grep -f /tmp/syms | cut -d' ' -f2- >/tmp/orig [3] Get the full function list. Append "-fno-inline" to `CFLAGS_.../display_mode_core.o` in drivers/gpu/drm/amd/display/dc/dml2/Makefile. $ make LLVM=1 O=build_dir drivers/gpu/drm/ -j $ objdump -d build_dir/.../display_mode_core.o | \ ./scripts/checkstack.pl x86_64 0 | \ grep -f /tmp/syms | cut -d' ' -f2- >/tmp/noinline [4] Get the inline function list. If a symbol only in /tmp/noinline but not in /tmp/orig, it is a good candidate to mark noinline. $ diff /tmp/orig /tmp/noinline Chosen functions and their stack sizes: CalculateBandwidthAvailableForImmediateFlip [display_mode_core.o]:144 CalculateExtraLatency [display_mode_core.o]:176 CalculateTWait [display_mode_core.o]:64 CalculateVActiveBandwithSupport [display_mode_core.o]:112 set_calculate_prefetch_schedule_params [display_mode_core.o]:48 CheckGlobalPrefetchAdmissibility [dml2_core_dcn4_calcs.o]:544 calculate_bandwidth_available [dml2_core_dcn4_calcs.o]:320 calculate_vactive_det_fill_latency [dml2_core_dcn4_calcs.o]:272 CalculateDCFCLKDeepSleep [dml2_core_dcn4_calcs.o]:208 CalculateODMMode [dml2_core_dcn4_calcs.o]:208 CalculateOutputLink [dml2_core_dcn4_calcs.o]:176 Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 1241b64 commit a8d42cd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

drivers/gpu/drm/amd/display/dc/dml2/display_mode_core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@ static void CalculateBytePerPixelAndBlockSizes(
17361736
#endif
17371737
} // CalculateBytePerPixelAndBlockSizes
17381738

1739-
static dml_float_t CalculateTWait(
1739+
static noinline_for_stack dml_float_t CalculateTWait(
17401740
dml_uint_t PrefetchMode,
17411741
enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,
17421742
dml_bool_t SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
@@ -4458,7 +4458,7 @@ static void CalculateSwathWidth(
44584458
}
44594459
} // CalculateSwathWidth
44604460

4461-
static dml_float_t CalculateExtraLatency(
4461+
static noinline_for_stack dml_float_t CalculateExtraLatency(
44624462
dml_uint_t RoundTripPingLatencyCycles,
44634463
dml_uint_t ReorderingBytes,
44644464
dml_float_t DCFCLK,
@@ -5915,7 +5915,7 @@ static dml_uint_t DSCDelayRequirement(
59155915
return DSCDelayRequirement_val;
59165916
}
59175917

5918-
static dml_bool_t CalculateVActiveBandwithSupport(dml_uint_t NumberOfActiveSurfaces,
5918+
static noinline_for_stack dml_bool_t CalculateVActiveBandwithSupport(dml_uint_t NumberOfActiveSurfaces,
59195919
dml_float_t ReturnBW,
59205920
dml_bool_t NotUrgentLatencyHiding[],
59215921
dml_float_t ReadBandwidthLuma[],
@@ -6019,7 +6019,7 @@ static void CalculatePrefetchBandwithSupport(
60196019
#endif
60206020
}
60216021

6022-
static dml_float_t CalculateBandwidthAvailableForImmediateFlip(
6022+
static noinline_for_stack dml_float_t CalculateBandwidthAvailableForImmediateFlip(
60236023
dml_uint_t NumberOfActiveSurfaces,
60246024
dml_float_t ReturnBW,
60256025
dml_float_t ReadBandwidthLuma[],
@@ -6213,7 +6213,7 @@ static dml_uint_t CalculateMaxVStartup(
62136213
return max_vstartup_lines;
62146214
}
62156215

6216-
static void set_calculate_prefetch_schedule_params(struct display_mode_lib_st *mode_lib,
6216+
static noinline_for_stack void set_calculate_prefetch_schedule_params(struct display_mode_lib_st *mode_lib,
62176217
struct CalculatePrefetchSchedule_params_st *CalculatePrefetchSchedule_params,
62186218
dml_uint_t j,
62196219
dml_uint_t k)
@@ -6265,7 +6265,7 @@ static void set_calculate_prefetch_schedule_params(struct display_mode_lib_st *m
62656265
CalculatePrefetchSchedule_params->Tno_bw = &mode_lib->ms.Tno_bw[k];
62666266
}
62676267

6268-
static void dml_prefetch_check(struct display_mode_lib_st *mode_lib)
6268+
static noinline_for_stack void dml_prefetch_check(struct display_mode_lib_st *mode_lib)
62696269
{
62706270
struct dml_core_mode_support_locals_st *s = &mode_lib->scratch.dml_core_mode_support_locals;
62716271
struct CalculatePrefetchSchedule_params_st *CalculatePrefetchSchedule_params = &mode_lib->scratch.CalculatePrefetchSchedule_params;

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,7 @@ static double dml_get_return_bandwidth_available(
27782778
return return_bw_mbps;
27792779
}
27802780

2781-
static void calculate_bandwidth_available(
2781+
static noinline_for_stack void calculate_bandwidth_available(
27822782
double avg_bandwidth_available_min[dml2_core_internal_soc_state_max],
27832783
double avg_bandwidth_available[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max],
27842784
double urg_bandwidth_available_min[dml2_core_internal_soc_state_max], // min between SDP and DRAM
@@ -3625,7 +3625,7 @@ static void CalculateDCFCLKDeepSleepTdlut(
36253625
dml2_printf("DML::%s: DCFClkDeepSleep = %f (final)\n", __func__, *DCFClkDeepSleep);
36263626
}
36273627

3628-
static void CalculateDCFCLKDeepSleep(
3628+
static noinline_for_stack void CalculateDCFCLKDeepSleep(
36293629
const struct dml2_display_cfg *display_cfg,
36303630
unsigned int NumberOfActiveSurfaces,
36313631
unsigned int BytePerPixelY[],
@@ -4142,7 +4142,7 @@ static bool ValidateODMMode(enum dml2_odm_mode ODMMode,
41424142
return true;
41434143
}
41444144

4145-
static void CalculateODMMode(
4145+
static noinline_for_stack void CalculateODMMode(
41464146
unsigned int MaximumPixelsPerLinePerDSCUnit,
41474147
unsigned int HActive,
41484148
enum dml2_output_format_class OutFormat,
@@ -4239,7 +4239,7 @@ static void CalculateODMMode(
42394239
#endif
42404240
}
42414241

4242-
static void CalculateOutputLink(
4242+
static noinline_for_stack void CalculateOutputLink(
42434243
struct dml2_core_internal_scratch *s,
42444244
double PHYCLK,
42454245
double PHYCLKD18,
@@ -5999,7 +5999,7 @@ static double calculate_impacted_Tsw(unsigned int exclude_plane_idx, unsigned in
59995999
}
60006000

60016001
// a global check against the aggregate effect of the per plane prefetch schedule
6002-
static bool CheckGlobalPrefetchAdmissibility(struct dml2_core_internal_scratch *scratch,
6002+
static noinline_for_stack bool CheckGlobalPrefetchAdmissibility(struct dml2_core_internal_scratch *scratch,
60036003
struct dml2_core_calcs_CheckGlobalPrefetchAdmissibility_params *p)
60046004
{
60056005
struct dml2_core_calcs_CheckGlobalPrefetchAdmissibility_locals *s = &scratch->CheckGlobalPrefetchAdmissibility_locals;
@@ -7012,7 +7012,7 @@ static void calculate_bytes_to_fetch_required_to_hide_latency(
70127012
}
70137013
}
70147014

7015-
static void calculate_vactive_det_fill_latency(
7015+
static noinline_for_stack void calculate_vactive_det_fill_latency(
70167016
const struct dml2_display_cfg *display_cfg,
70177017
unsigned int num_active_planes,
70187018
unsigned int bytes_required_l[],

0 commit comments

Comments
 (0)