Skip to content

Commit 526f452

Browse files
nathanchancemchehab
authored andcommitted
media: mxl5xx: Move xpt structures off stack
When building for LoongArch with clang 18.0.0, the stack usage of probe() is larger than the allowed 2048 bytes: drivers/media/dvb-frontends/mxl5xx.c:1698:12: warning: stack frame size (2368) exceeds limit (2048) in 'probe' [-Wframe-larger-than] 1698 | static int probe(struct mxl *state, struct mxl5xx_cfg *cfg) | ^ 1 warning generated. This is the result of the linked LLVM commit, which changes how the arrays of structures in config_ts() get handled with CONFIG_INIT_STACK_ZERO and CONFIG_INIT_STACK_PATTERN, which causes the above warning in combination with inlining, as config_ts() gets inlined into probe(). This warning can be easily fixed by moving the array of structures off of the stackvia 'static const', which is a better location for these variables anyways because they are static data that is only ever read from, never modified, so allocating the stack space is wasteful. This drops the stack usage from 2368 bytes to 256 bytes with the same compiler and configuration. Link: https://lore.kernel.org/linux-media/20240111-dvb-mxl5xx-move-structs-off-stack-v1-1-ca4230e67c11@kernel.org Cc: stable@vger.kernel.org Closes: ClangBuiltLinux#1977 Link: llvm/llvm-project@afe8b93 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent cbe4999 commit 526f452

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

drivers/media/dvb-frontends/mxl5xx.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,57 +1381,57 @@ static int config_ts(struct mxl *state, enum MXL_HYDRA_DEMOD_ID_E demod_id,
13811381
u32 nco_count_min = 0;
13821382
u32 clk_type = 0;
13831383

1384-
struct MXL_REG_FIELD_T xpt_sync_polarity[MXL_HYDRA_DEMOD_MAX] = {
1384+
static const struct MXL_REG_FIELD_T xpt_sync_polarity[MXL_HYDRA_DEMOD_MAX] = {
13851385
{0x90700010, 8, 1}, {0x90700010, 9, 1},
13861386
{0x90700010, 10, 1}, {0x90700010, 11, 1},
13871387
{0x90700010, 12, 1}, {0x90700010, 13, 1},
13881388
{0x90700010, 14, 1}, {0x90700010, 15, 1} };
1389-
struct MXL_REG_FIELD_T xpt_clock_polarity[MXL_HYDRA_DEMOD_MAX] = {
1389+
static const struct MXL_REG_FIELD_T xpt_clock_polarity[MXL_HYDRA_DEMOD_MAX] = {
13901390
{0x90700010, 16, 1}, {0x90700010, 17, 1},
13911391
{0x90700010, 18, 1}, {0x90700010, 19, 1},
13921392
{0x90700010, 20, 1}, {0x90700010, 21, 1},
13931393
{0x90700010, 22, 1}, {0x90700010, 23, 1} };
1394-
struct MXL_REG_FIELD_T xpt_valid_polarity[MXL_HYDRA_DEMOD_MAX] = {
1394+
static const struct MXL_REG_FIELD_T xpt_valid_polarity[MXL_HYDRA_DEMOD_MAX] = {
13951395
{0x90700014, 0, 1}, {0x90700014, 1, 1},
13961396
{0x90700014, 2, 1}, {0x90700014, 3, 1},
13971397
{0x90700014, 4, 1}, {0x90700014, 5, 1},
13981398
{0x90700014, 6, 1}, {0x90700014, 7, 1} };
1399-
struct MXL_REG_FIELD_T xpt_ts_clock_phase[MXL_HYDRA_DEMOD_MAX] = {
1399+
static const struct MXL_REG_FIELD_T xpt_ts_clock_phase[MXL_HYDRA_DEMOD_MAX] = {
14001400
{0x90700018, 0, 3}, {0x90700018, 4, 3},
14011401
{0x90700018, 8, 3}, {0x90700018, 12, 3},
14021402
{0x90700018, 16, 3}, {0x90700018, 20, 3},
14031403
{0x90700018, 24, 3}, {0x90700018, 28, 3} };
1404-
struct MXL_REG_FIELD_T xpt_lsb_first[MXL_HYDRA_DEMOD_MAX] = {
1404+
static const struct MXL_REG_FIELD_T xpt_lsb_first[MXL_HYDRA_DEMOD_MAX] = {
14051405
{0x9070000C, 16, 1}, {0x9070000C, 17, 1},
14061406
{0x9070000C, 18, 1}, {0x9070000C, 19, 1},
14071407
{0x9070000C, 20, 1}, {0x9070000C, 21, 1},
14081408
{0x9070000C, 22, 1}, {0x9070000C, 23, 1} };
1409-
struct MXL_REG_FIELD_T xpt_sync_byte[MXL_HYDRA_DEMOD_MAX] = {
1409+
static const struct MXL_REG_FIELD_T xpt_sync_byte[MXL_HYDRA_DEMOD_MAX] = {
14101410
{0x90700010, 0, 1}, {0x90700010, 1, 1},
14111411
{0x90700010, 2, 1}, {0x90700010, 3, 1},
14121412
{0x90700010, 4, 1}, {0x90700010, 5, 1},
14131413
{0x90700010, 6, 1}, {0x90700010, 7, 1} };
1414-
struct MXL_REG_FIELD_T xpt_enable_output[MXL_HYDRA_DEMOD_MAX] = {
1414+
static const struct MXL_REG_FIELD_T xpt_enable_output[MXL_HYDRA_DEMOD_MAX] = {
14151415
{0x9070000C, 0, 1}, {0x9070000C, 1, 1},
14161416
{0x9070000C, 2, 1}, {0x9070000C, 3, 1},
14171417
{0x9070000C, 4, 1}, {0x9070000C, 5, 1},
14181418
{0x9070000C, 6, 1}, {0x9070000C, 7, 1} };
1419-
struct MXL_REG_FIELD_T xpt_err_replace_sync[MXL_HYDRA_DEMOD_MAX] = {
1419+
static const struct MXL_REG_FIELD_T xpt_err_replace_sync[MXL_HYDRA_DEMOD_MAX] = {
14201420
{0x9070000C, 24, 1}, {0x9070000C, 25, 1},
14211421
{0x9070000C, 26, 1}, {0x9070000C, 27, 1},
14221422
{0x9070000C, 28, 1}, {0x9070000C, 29, 1},
14231423
{0x9070000C, 30, 1}, {0x9070000C, 31, 1} };
1424-
struct MXL_REG_FIELD_T xpt_err_replace_valid[MXL_HYDRA_DEMOD_MAX] = {
1424+
static const struct MXL_REG_FIELD_T xpt_err_replace_valid[MXL_HYDRA_DEMOD_MAX] = {
14251425
{0x90700014, 8, 1}, {0x90700014, 9, 1},
14261426
{0x90700014, 10, 1}, {0x90700014, 11, 1},
14271427
{0x90700014, 12, 1}, {0x90700014, 13, 1},
14281428
{0x90700014, 14, 1}, {0x90700014, 15, 1} };
1429-
struct MXL_REG_FIELD_T xpt_continuous_clock[MXL_HYDRA_DEMOD_MAX] = {
1429+
static const struct MXL_REG_FIELD_T xpt_continuous_clock[MXL_HYDRA_DEMOD_MAX] = {
14301430
{0x907001D4, 0, 1}, {0x907001D4, 1, 1},
14311431
{0x907001D4, 2, 1}, {0x907001D4, 3, 1},
14321432
{0x907001D4, 4, 1}, {0x907001D4, 5, 1},
14331433
{0x907001D4, 6, 1}, {0x907001D4, 7, 1} };
1434-
struct MXL_REG_FIELD_T xpt_nco_clock_rate[MXL_HYDRA_DEMOD_MAX] = {
1434+
static const struct MXL_REG_FIELD_T xpt_nco_clock_rate[MXL_HYDRA_DEMOD_MAX] = {
14351435
{0x90700044, 16, 80}, {0x90700044, 16, 81},
14361436
{0x90700044, 16, 82}, {0x90700044, 16, 83},
14371437
{0x90700044, 16, 84}, {0x90700044, 16, 85},

0 commit comments

Comments
 (0)