Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: dd0b6b1f29b9 ("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>

authored by

Arnd Bergmann and committed by
Mark Brown
b0e4e203 37c42bde

+19 -14
+19 -14
drivers/firmware/cirrus/test/cs_dsp_test_bin.c
··· 1978 1978 4, 51, 76, 72, 16, 6, 39, 62, 15, 41, 28, 73, 53, 40, 45, 54, 1979 1979 14, 55, 46, 66, 64, 59, 23, 9, 67, 47, 19, 71, 35, 18, 42, 1, 1980 1980 }; 1981 - u32 packed_payload[80][3]; 1982 - u32 unpacked_payload[80]; 1981 + struct { 1982 + u32 packed[80][3]; 1983 + u32 unpacked[80]; 1984 + } *payload; 1983 1985 u32 readback[3]; 1984 1986 unsigned int alg_base_words, patch_pos_words; 1985 1987 unsigned int alg_base_in_packed_regs, patch_pos_in_packed_regs; ··· 1990 1988 struct firmware *fw; 1991 1989 int i; 1992 1990 1993 - get_random_bytes(packed_payload, sizeof(packed_payload)); 1994 - get_random_bytes(unpacked_payload, sizeof(unpacked_payload)); 1991 + payload = kunit_kmalloc(test, sizeof(*payload), GFP_KERNEL); 1992 + KUNIT_ASSERT_NOT_NULL(test, payload); 1993 + 1994 + get_random_bytes(payload->packed, sizeof(payload->packed)); 1995 + get_random_bytes(payload->unpacked, sizeof(payload->unpacked)); 1995 1996 1996 1997 /* Create a patch entry for every offset in offset_words[] */ 1997 1998 for (i = 0; i < ARRAY_SIZE(offset_words); ++i) { ··· 2015 2010 bin_test_mock_algs[0].ver, 2016 2011 param->mem_type, 2017 2012 payload_offset, 2018 - packed_payload[i], 2019 - sizeof(packed_payload[i])); 2013 + payload->packed[i], 2014 + sizeof(payload->packed[i])); 2020 2015 } else { 2021 2016 payload_offset = offset_words[i] * 4; 2022 2017 cs_dsp_mock_bin_add_patch(priv->local->bin_builder, ··· 2024 2019 bin_test_mock_algs[0].ver, 2025 2020 unpacked_mem_type, 2026 2021 payload_offset, 2027 - &unpacked_payload[i], 2028 - sizeof(unpacked_payload[i])); 2022 + &payload->unpacked[i], 2023 + sizeof(payload->unpacked[i])); 2029 2024 } 2030 2025 } 2031 2026 ··· 2038 2033 /* 2039 2034 * Readback the packed registers that should have been written. 2040 2035 * Place the values into the expected location in readback[] so 2041 - * that the content of readback[] should match packed_payload[] 2036 + * that the content of readback[] should match payload->packed[] 2042 2037 */ 2043 2038 for (i = 0; i < ARRAY_SIZE(offset_words); ++i) { 2044 2039 alg_base_words = cs_dsp_mock_xm_header_get_alg_base_in_words(priv, ··· 2060 2055 regmap_raw_read(priv->dsp->regmap, reg_addr, readback, 2061 2056 sizeof(readback)), 2062 2057 0); 2063 - KUNIT_EXPECT_MEMEQ(test, readback, packed_payload[i], sizeof(packed_payload[i])); 2058 + KUNIT_EXPECT_MEMEQ(test, readback, payload->packed[i], sizeof(payload->packed[i])); 2064 2059 2065 2060 /* Drop expected writes from the cache */ 2066 - cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(packed_payload[i])); 2061 + cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(payload->packed[i])); 2067 2062 } 2068 2063 2069 2064 /* 2070 2065 * Readback the unpacked registers that should have been written. 2071 2066 * Place the values into the expected location in readback[] so 2072 - * that the content of readback[] should match unpacked_payload[] 2067 + * that the content of readback[] should match payload->unpacked[] 2073 2068 */ 2074 2069 for (i = 0; i < ARRAY_SIZE(offset_words); ++i) { 2075 2070 alg_base_words = cs_dsp_mock_xm_header_get_alg_base_in_words(priv, ··· 2090 2085 regmap_raw_read(priv->dsp->regmap, reg_addr, 2091 2086 &readback[0], sizeof(readback[0])), 2092 2087 0); 2093 - KUNIT_EXPECT_EQ(test, readback[0], unpacked_payload[i]); 2088 + KUNIT_EXPECT_EQ(test, readback[0], payload->unpacked[i]); 2094 2089 2095 2090 /* Drop expected writes from the cache */ 2096 - cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(unpacked_payload[i])); 2091 + cs_dsp_mock_regmap_drop_bytes(priv, reg_addr, sizeof(payload->unpacked[i])); 2097 2092 } 2098 2093 2099 2094 /* Drop expected writes and the cache should then be clean */