Skip to content

Commit b0e4e20

Browse files
arndbbroonie
authored andcommitted
firmware: cs_dsp: avoid large local variables
Having 1280 bytes of local variables on the stack exceeds the limit on 32-bit architectures: drivers/firmware/cirrus/test/cs_dsp_test_bin.c: In function 'bin_patch_mixed_packed_unpacked_random': drivers/firmware/cirrus/test/cs_dsp_test_bin.c:2097:1: error: the frame size of 1784 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Use dynamic allocation for the largest two here. Fixes: dd0b6b1 ("firmware: cs_dsp: Add KUnit testing of bin file download") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241216121541.3455880-1-arnd@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 37c42bd commit b0e4e20

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

drivers/firmware/cirrus/test/cs_dsp_test_bin.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,8 +1978,10 @@ static void bin_patch_mixed_packed_unpacked_random(struct kunit *test)
19781978
4, 51, 76, 72, 16, 6, 39, 62, 15, 41, 28, 73, 53, 40, 45, 54,
19791979
14, 55, 46, 66, 64, 59, 23, 9, 67, 47, 19, 71, 35, 18, 42, 1,
19801980
};
1981-
u32 packed_payload[80][3];
1982-
u32 unpacked_payload[80];
1981+
struct {
1982+
u32 packed[80][3];
1983+
u32 unpacked[80];
1984+
} *payload;
19831985
u32 readback[3];
19841986
unsigned int alg_base_words, patch_pos_words;
19851987
unsigned int alg_base_in_packed_regs, patch_pos_in_packed_regs;
@@ -1988,8 +1990,11 @@ static void bin_patch_mixed_packed_unpacked_random(struct kunit *test)
19881990
struct firmware *fw;
19891991
int i;
19901992

1991-
get_random_bytes(packed_payload, sizeof(packed_payload));
1992-
get_random_bytes(unpacked_payload, sizeof(unpacked_payload));
1993+
payload = kunit_kmalloc(test, sizeof(*payload), GFP_KERNEL);
1994+
KUNIT_ASSERT_NOT_NULL(test, payload);
1995+
1996+
get_random_bytes(payload->packed, sizeof(payload->packed));
1997+
get_random_bytes(payload->unpacked, sizeof(payload->unpacked));
19931998

19941999
/* Create a patch entry for every offset in offset_words[] */
19952000
for (i = 0; i < ARRAY_SIZE(offset_words); ++i) {
@@ -2010,17 +2015,17 @@ static void bin_patch_mixed_packed_unpacked_random(struct kunit *test)
20102015
bin_test_mock_algs[0].ver,
20112016
param->mem_type,
20122017
payload_offset,
2013-
packed_payload[i],
2014-
sizeof(packed_payload[i]));
2018+
payload->packed[i],
2019+
sizeof(payload->packed[i]));
20152020
} else {
20162021
payload_offset = offset_words[i] * 4;
20172022
cs_dsp_mock_bin_add_patch(priv->local->bin_builder,
20182023
bin_test_mock_algs[0].id,
20192024
bin_test_mock_algs[0].ver,
20202025
unpacked_mem_type,
20212026
payload_offset,
2022-
&unpacked_payload[i],
2023-
sizeof(unpacked_payload[i]));
2027+
&payload->unpacked[i],
2028+
sizeof(payload->unpacked[i]));
20242029
}
20252030
}
20262031

@@ -2033,7 +2038,7 @@ static void bin_patch_mixed_packed_unpacked_random(struct kunit *test)
20332038
/*
20342039
* Readback the packed registers that should have been written.
20352040
* Place the values into the expected location in readback[] so
2036-
* that the content of readback[] should match packed_payload[]
2041+
* that the content of readback[] should match payload->packed[]
20372042
*/
20382043
for (i = 0; i < ARRAY_SIZE(offset_words); ++i) {
20392044
alg_base_words = cs_dsp_mock_xm_header_get_alg_base_in_words(priv,
@@ -2055,16 +2060,16 @@ static void bin_patch_mixed_packed_unpacked_random(struct kunit *test)
20552060
regmap_raw_read(priv->dsp->regmap, reg_addr, readback,
20562061
sizeof(readback)),
20572062
0);
2058-
KUNIT_EXPECT_MEMEQ(test, readback, packed_payload[i], sizeof(packed_payload[i]));
2063+
KUNIT_EXPECT_MEMEQ(test, readback, payload->packed[i], sizeof(payload->packed[i]));
20592064

20602065
/* Drop expected writes from the cache */
2061-
cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(packed_payload[i]));
2066+
cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(payload->packed[i]));
20622067
}
20632068

20642069
/*
20652070
* Readback the unpacked registers that should have been written.
20662071
* Place the values into the expected location in readback[] so
2067-
* that the content of readback[] should match unpacked_payload[]
2072+
* that the content of readback[] should match payload->unpacked[]
20682073
*/
20692074
for (i = 0; i < ARRAY_SIZE(offset_words); ++i) {
20702075
alg_base_words = cs_dsp_mock_xm_header_get_alg_base_in_words(priv,
@@ -2085,10 +2090,10 @@ static void bin_patch_mixed_packed_unpacked_random(struct kunit *test)
20852090
regmap_raw_read(priv->dsp->regmap, reg_addr,
20862091
&readback[0], sizeof(readback[0])),
20872092
0);
2088-
KUNIT_EXPECT_EQ(test, readback[0], unpacked_payload[i]);
2093+
KUNIT_EXPECT_EQ(test, readback[0], payload->unpacked[i]);
20892094

20902095
/* Drop expected writes from the cache */
2091-
cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(unpacked_payload[i]));
2096+
cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(payload->unpacked[i]));
20922097
}
20932098

20942099
/* Drop expected writes and the cache should then be clean */

0 commit comments

Comments
 (0)