ee37bc7e | 19-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Delete redundant assignments in cs_dsp_test_bin.c
Delete two redundant assignments in cs_dsp_test_bin.c.
Unfortunately none of W=1 or the static analysis tools I ran flagged these
firmware: cs_dsp: Delete redundant assignments in cs_dsp_test_bin.c
Delete two redundant assignments in cs_dsp_test_bin.c.
Unfortunately none of W=1 or the static analysis tools I ran flagged these.
Fixes: dd0b6b1f29b9 ("firmware: cs_dsp: Add KUnit testing of bin file download") Reported-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com> Closes: https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602511 Closes: https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602490 Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241219155719.84276-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
644115e8 | 17-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Fix endianness conversion in cs_dsp_mock_wmfw.c
In cs_dsp_mock_wmfw_add_coeff_desc() the value stored in longstring->len needs a cpu_to_le16() conversion.
Fixes: 5cf1b7b47180 ("fi
firmware: cs_dsp: Fix endianness conversion in cs_dsp_mock_wmfw.c
In cs_dsp_mock_wmfw_add_coeff_desc() the value stored in longstring->len needs a cpu_to_le16() conversion.
Fixes: 5cf1b7b47180 ("firmware: cs_dsp: Add mock wmfw file generator for KUnit testing") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202412170233.8DnsdtY6-lkp@intel.com/ Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241217105624.139479-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
b0e4e203 | 16-Dec-2024 |
Arnd Bergmann <arnd@arndb.de> |
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 functio
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>
show more ...
|
75a4a6ef | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of client callbacks
Test that the cs_dsp_client_ops callbacks are called when expected.
pre_run, post_run - when cs_dsp_run() is called. pre_stop, post_stop - wh
firmware: cs_dsp: Add KUnit testing of client callbacks
Test that the cs_dsp_client_ops callbacks are called when expected.
pre_run, post_run - when cs_dsp_run() is called. pre_stop, post_stop - when cs_dsp_stop() is called control_add - when a WMFW is loaded control_remove - when cs_dsp_remove() is called
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-13-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
feb5fb06 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of wmfw error cases
Add tests for various types of errors and illegal values in wmfw files. This covers buffer overflows as well as general unsupported field valu
firmware: cs_dsp: Add KUnit testing of wmfw error cases
Add tests for various types of errors and illegal values in wmfw files. This covers buffer overflows as well as general unsupported field values.
There are several sets of test cases to cover various different versions of the wmfw file format.
V0 format was only used on the earlier ADSP2 devices. It does not have algorithm blocks.
V1 format is used on all ADSP2 versions. It added algorithm blocks and firmware coefficient descriptor blocks. Strings are stored in fixed-length arrays.
V2 format is used on all ADSP2 versions. It is similar to V1 but space for strings is variable-length with either an 8-bit or 16-bit length field.
V3 format is used on Halo Core DSPs and is mostly identical to the V3 format.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-12-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
cd8c0584 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of bin error cases
Add tests for various types of errors and illegal values in bin files. This covers buffer overflows as well as general unsupported field values
firmware: cs_dsp: Add KUnit testing of bin error cases
Add tests for various types of errors and illegal values in bin files. This covers buffer overflows as well as general unsupported field values.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-11-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
fe54fd54 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of control read/write
Add KUnit test cases for control read/write.
Tests cases cover general reading and writing of controls: 1) Read/write at offset position in
firmware: cs_dsp: Add KUnit testing of control read/write
Add KUnit test cases for control read/write.
Tests cases cover general reading and writing of controls: 1) Read/write at offset position in control. 2) Read/write of various lengths less than length of the control. 3) Rejecting illegal arguments.
The test cases are run for ADSP2 with 16-bit registers, ADSP2 with 32-bit registers and Halo Core with 32-bit registers. The ADSP2 cases are further divided into runs for V1 and V2 format WMFW files, because there are differences in how V1 and V2 defines controls.
The obsolete V0 format does not have controls, so no testing of that format is needed.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-10-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
9b33a4fc | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of control cache
Add KUnit test cases for the caching of control content.
The test cases can be divided into four groups: 1) The cache is correctly initialized w
firmware: cs_dsp: Add KUnit testing of control cache
Add KUnit test cases for the caching of control content.
The test cases can be divided into four groups: 1) The cache is correctly initialized when the firmware is first downloaded. 2) Reads return the correct data. 3) Writes update the registers and cache. 4) If a value has been written to the control it is retained in the cache and written out to the registers when the firmware is started.
There are multiple test suites to cover: - V1 and V2 format files on 16-bit and 32-bit ADSP2. - V3 format files on Halo Core DSPs.
V1 format files, and some V2 format files, didn't provide access flags for the controls. There are a couple of test cases for unspecified flags to ensure backwards compatibility with the original implementation of these older firmware versions.
The obsolete V0 format does not have controls, so no testing of that format is needed.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-9-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
83baecd9 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of control parsing
Add KUnit test cases for parsing of firmware controls out of the wmfw. These test cases are only testing that the data in the wmfw is correctly
firmware: cs_dsp: Add KUnit testing of control parsing
Add KUnit test cases for parsing of firmware controls out of the wmfw. These test cases are only testing that the data in the wmfw is correctly interpreted and entered into the list of controls.
The test cases can be roughly divided into three types: 1) The correct values are extracted from the wmfw. 2) Variable-length strings are handled correctly. 3) Controls are correctly identified as unique or identical.
There are multiple test suites to cover: - V1 and V2 format files on 16-bit and 32-bit ADSP2. - V3 format files on Halo Core DSPs.
V1 format does not have named controls, and the strings in the coefficient descriptor are fixed-length fields. On V2 and V3 format the controls are named and all strings are variable-length.
The obsolete V0 format does not have controls, so no testing of that format is needed.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-8-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
a2b2f2c1 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of wmfw download
This adds a KUnit test suite to test downloading wmfw files.
The general technique is 1. Create mock wmfw file content 2. Tell cs_dsp to downloa
firmware: cs_dsp: Add KUnit testing of wmfw download
This adds a KUnit test suite to test downloading wmfw files.
The general technique is 1. Create mock wmfw file content 2. Tell cs_dsp to download the wmfw file 3. Check in the emulated regmap registers that the correct values have been written to DSP memory 4. Drop the regmap cache for the expected written registers and then do a regcache_sync() to check for unexpected writes to other registers.
The test covers ADSP2 v1 and v2, and HALO Core DSPs. (ADSP1 is very obsolete so isn't tested).
There is a large number of test cases and parameterized variants of tests because of the many different addressing schemes supported by the Cirrus devices. The DSP has 2 or 3 memory spaces: XM, YM and ZM. The DSP sees these using its native addressing, which is word-addressed (not byte-addressed). The host sees these through one of several register mappings (depending on the DSP type and parent codec family). The registers have three different addressing schemes: 16-bit registers addressed by register number, 32-bit registers addressed by register number, or 32-bit registers addressed by byte (with a stride of 4). In addition to these multiple addressing schemes, the Halo Core DSPs have a "packed" register mapping that maps 4 DSP words into 3 registers. In addition to this there are 4 versions of the wmfw file format to be tested.
The test cases intentionally have relatively little factoring-out of similar code. This makes it much easier to visually verify that a test case is testing correctly, and what exactly it is testing. Factoring out large amounts of code into helper functions tends to obscure what the actual test procedure is, so increasing the chance of hidden errors where test cases don't actually test as intended.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-7-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
dd0b6b1f | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of bin file download
This adds a KUnit test suite to test downloading bin files.
The general technique is 1. Create mock bin file content 2. Tell cs_dsp to downl
firmware: cs_dsp: Add KUnit testing of bin file download
This adds a KUnit test suite to test downloading bin files.
The general technique is 1. Create mock bin file content 2. Tell cs_dsp to download the bin file 3. Check in the emulated regmap registers that the correct values have been written to DSP memory 4. Drop the regmap cache for the expected written registers and then do a regcache_sync() to check for unexpected writes to other registers.
The test covers ADSP2 v1 and v2, and HALO Core DSPs. (ADSP1 is very obsolete so isn't tested).
There is a large number of test cases and parameterized variants of tests because of the many different addressing schemes supported by the Cirrus devices. The DSP has 2 or 3 memory spaces: XM, YM and ZM. The DSP sees these using its native addressing, which is word-addressed (not byte-addressed). The host sees these through one of several register mappings (depending on the DSP type and parent codec family). The registers have three different addressing schemes: 16-bit registers addressed by register number, 32-bit registers addressed by register number, or 32-bit registers addressed by byte (with a stride of 4). In addition to these multiple addressing schemes, the Halo Core DSPs have a "packed" register mapping that maps 4 DSP words into 3 registers. The bin file addresses the data blob relative to the base address of an algorithm, which has to be calculated in both DSP words (for the DSP to access) and register addresses (for the host).
This results in many different addressing schemes used in parallel, hence the complexity of the address and size manipulation in the test cases: word addresses in DSP memory, byte offsets, word offsets, register addresses (either byte-addressed 32-bit or index-addressed 16-bit), and packed register addresses.
The test cases intentionally have relatively little factoring-out of similar code. This makes it much easier to visually verify that a test case is testing correctly, and what exactly it is testing. Factoring out large amounts of code into helper functions tends to obscure what the actual test procedure is, so increasing the chance of hidden errors where test cases don't actually test as intended.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-6-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
7c052c66 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add mock bin file generator for KUnit testing
Add a mock firmware file that emulates what the firmware build tools would normally create. This will be used by KUnit tests to genera
firmware: cs_dsp: Add mock bin file generator for KUnit testing
Add a mock firmware file that emulates what the firmware build tools would normally create. This will be used by KUnit tests to generate a test bin file.
The data payload in a bin is an opaque blob, so the mock bin only needs to generate the appropriate file header and description block for each payload blob.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-5-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
5cf1b7b4 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add mock wmfw file generator for KUnit testing
Add a mock firmware file that emulates what the firmware build tools would normally create. This will be used by KUnit tests to gener
firmware: cs_dsp: Add mock wmfw file generator for KUnit testing
Add a mock firmware file that emulates what the firmware build tools would normally create. This will be used by KUnit tests to generate a test wmfw file.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-4-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
41e78c0f | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add mock DSP memory map for KUnit testing
Add helper functions to implement an emulation of the DSP memory map.
There are three main groups of functionality:
1. Define a mock cs_
firmware: cs_dsp: Add mock DSP memory map for KUnit testing
Add helper functions to implement an emulation of the DSP memory map.
There are three main groups of functionality:
1. Define a mock cs_dsp_region table. 2. Calculate the addresses of memory and algorithms from the firmware header in XM. 3. Build a mock XM header in emulated XM.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
dc0e5ca8 | 10-Jul-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Rename fw_ver to wmfw_ver
Rename the confusingly named struct member fw_ver to wmfw_ver. It contains the wmfw format version of the loaded wmfw file.
This commit also contains an
firmware: cs_dsp: Rename fw_ver to wmfw_ver
Rename the confusingly named struct member fw_ver to wmfw_ver. It contains the wmfw format version of the loaded wmfw file.
This commit also contains an update to wm_adsp for the new name.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240710103640.78197-5-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
a4939119 | 10-Jul-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Clarify wmfw format version log message
Change the log message of the wmfw format version to include the file name, and change the message to say "format" instead of "Firmware vers
firmware: cs_dsp: Clarify wmfw format version log message
Change the log message of the wmfw format version to include the file name, and change the message to say "format" instead of "Firmware version". Merge this with the message that logs the timestamp.
The wmfw format version is information that is useful to have logged because the behaviour of firmware controls depends on the wmfw format. So "unexpected" behaviour could be caused by having expectations based on one format of wmfw when a different format has been loaded.
But the original message was confusing. It reported the file format version but didn't actually log the name of the file it referred to. It also called it "Firmware version", which is confusing when a later message also logs a firmware version that is the version of the actual firmware within the wmfw.
The logging of the firmware timestamp has been merged into this. That was originally a dbg-only message, but as we are already logging a line of info, we might as well add a few extra characters to log the timestamp. The timestamp is now logged in hexadecimal - it's not particularly useful as a decimal value.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240710103640.78197-4-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|