firmware: cirrus: Add KUnit tests for cs_dsp
Subsystems (2)
Richard Fitzgerald
maintainercover firmware: cirrus: Add KUnit tests for cs_dsp
This series adds KUnit tests for the cs_dsp module.
Most of the functionality in cs_dsp is for downloading firmware to DSP memory and interacting with "control" words defined in that memory. This doesn't require any emulation of running firmware, because it is only reading and writing registers. So the testing can be done using a dummy regmap. The way this is used to perform testing is described in more detail in the commit message for each test.
ADSP1 is not tested because this was only used by the WM2200 codec, a long-obsolete part that was discontinued in 2015.
Richard Fitzgerald (12):
firmware: cs_dsp: Add mock regmap for KUnit testing
firmware: cs_dsp: Add mock DSP memory map for KUnit testing
firmware: cs_dsp: Add mock wmfw file generator for KUnit testing
firmware: cs_dsp: Add mock bin file generator for KUnit testing
firmware: cs_dsp: Add KUnit testing of bin file download
firmware: cs_dsp: Add KUnit testing of wmfw download
firmware: cs_dsp: Add KUnit testing of control parsing
firmware: cs_dsp: Add KUnit testing of control cache
firmware: cs_dsp: Add KUnit testing of control read/write
firmware: cs_dsp: Add KUnit testing of bin error cases
firmware: cs_dsp: Add KUnit testing of wmfw error cases
firmware: cs_dsp: Add KUnit testing of client callbacks
MAINTAINERS | 4 +- drivers/firmware/cirrus/Kconfig | 20 + drivers/firmware/cirrus/Makefile | 2 + drivers/firmware/cirrus/test/Makefile | 23 + .../firmware/cirrus/test/cs_dsp_mock_bin.c | 199 + .../cirrus/test/cs_dsp_mock_mem_maps.c | 751 ++++ .../firmware/cirrus/test/cs_dsp_mock_regmap.c | 367 ++ .../firmware/cirrus/test/cs_dsp_mock_utils.c | 13 + .../firmware/cirrus/test/cs_dsp_mock_wmfw.c | 473 +++ .../firmware/cirrus/test/cs_dsp_test_bin.c | 2557 +++++++++++++ .../cirrus/test/cs_dsp_test_bin_error.c | 600 +++ .../cirrus/test/cs_dsp_test_callbacks.c | 688 ++++ .../cirrus/test/cs_dsp_test_control_cache.c | 3282 +++++++++++++++++ .../cirrus/test/cs_dsp_test_control_parse.c | 1851 ++++++++++ .../cirrus/test/cs_dsp_test_control_rw.c | 2669 ++++++++++++++ .../firmware/cirrus/test/cs_dsp_test_wmfw.c | 2211 +++++++++++ .../cirrus/test/cs_dsp_test_wmfw_error.c | 1347 +++++++ drivers/firmware/cirrus/test/cs_dsp_tests.c | 14 + .../linux/firmware/cirrus/cs_dsp_test_utils.h | 160 + 19 files changed, 17229 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/cirrus/test/Makefile create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_bin.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_mem_maps.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_regmap.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_utils.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_wmfw.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_bin.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_bin_error.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_control_cache.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_control_rw.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_wmfw.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_wmfw_error.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_tests.c create mode 100644 include/linux/firmware/cirrus/cs_dsp_test_utils.h
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 1/12 firmware: cs_dsp: Add mock regmap for KUnit testing
Add a mock regmap implementation to act as a simulated DSP for KUnit testing. This is built as a utility module so that it could be used by clients of cs_dsp to create a mock "DSP" for their own testing.
cs_dsp interacts with the DSP only through registers. Most of the register space of the DSP is RAM. ADSP cores have a small set of control registers. HALO Core DSPs have a much larger set of control registers but only a small subset are used.
Most writes are "blind" in the sense that cs_dsp does not expect to receive any sort of response from the DSP. So there isn't any need to emulate a "DSP", only a set of registers that can be written and read back.
The idea of the mock regmap is to use the cache to accumulate writes which can then be tested against the values that are expected to be in the registers.
Stray writes can be detected by dropping the cache entries for all addresses that should have been written and then issuing a regcache_sync(). If this causes bus writes it means there were writes to unexpected registers.
--- MAINTAINERS | 4 +- drivers/firmware/cirrus/Kconfig | 6 + drivers/firmware/cirrus/Makefile | 2 + drivers/firmware/cirrus/test/Makefile | 8 + .../firmware/cirrus/test/cs_dsp_mock_regmap.c | 367 ++++++++++++++++++ .../firmware/cirrus/test/cs_dsp_mock_utils.c | 13 + .../linux/firmware/cirrus/cs_dsp_test_utils.h | 46 +++ 7 files changed, 444 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/cirrus/test/Makefile create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_regmap.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_utils.c create mode 100644 include/linux/firmware/cirrus/cs_dsp_test_utils.h
MAINTAINERS +2 -2
@@ -5501,8 +5501,8 @@ L: [email protected] S: Supported W: https://github.com/CirrusLogic/linux-drivers/wiki T: git https://github.com/CirrusLogic/linux-drivers.git -F: drivers/firmware/cirrus/* -F: include/linux/firmware/cirrus/* +F: drivers/firmware/cirrus/ +F: include/linux/firmware/cirrus/ CIRRUS LOGIC EP93XX ETHERNET DRIVER M: Hartley Sweeten <[email protected]>
drivers/firmware/cirrus/Kconfig +6 -0
@@ -3,3 +3,9 @@ config FW_CS_DSP tristate default n + +config FW_CS_DSP_KUNIT_TEST_UTILS + tristate + depends on KUNIT + select REGMAP + select FW_CS_DSP
drivers/firmware/cirrus/Makefile +2 -0
@@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 # obj-$(CONFIG_FW_CS_DSP) += cs_dsp.o + +obj-y += test/
drivers/firmware/cirrus/test/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# + +cs_dsp_test_utils-objs := \ + cs_dsp_mock_regmap.o \ + cs_dsp_mock_utils.o + +obj-$(CONFIG_FW_CS_DSP_KUNIT_TEST_UTILS) += cs_dsp_test_utils.o
drivers/firmware/cirrus/test/cs_dsp_mock_regmap.c new file +367 -0
367 lines not on this page · raw message
drivers/firmware/cirrus/test/cs_dsp_mock_utils.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Utility module for cs_dsp KUnit testing. +// +// Copyright (C) 2024 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. + +#include <linux/module.h> + +MODULE_DESCRIPTION ("Utilities for Cirrus Logic DSP driver testing" ); +MODULE_AUTHOR ("Richard Fitzgerald <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS ("FW_CS_DSP" );
include/linux/firmware/cirrus/cs_dsp_test_utils.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 2/12 firmware: cs_dsp: Add mock DSP memory map for KUnit testing
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_mock_mem_maps.c | 751 ++++++++++++++++++ .../linux/firmware/cirrus/cs_dsp_test_utils.h | 63 ++ 3 files changed, 815 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_mem_maps.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -2,6 +2,7 @@ # cs_dsp_test_utils-objs := \ + cs_dsp_mock_mem_maps.o \ cs_dsp_mock_regmap.o \ cs_dsp_mock_utils.o
drivers/firmware/cirrus/test/cs_dsp_mock_mem_maps.c new file +751 -0
751 lines not on this page · raw message
include/linux/firmware/cirrus/cs_dsp_test_utils.h +63 -0
74 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 3/12 firmware: cs_dsp: Add mock wmfw file generator for KUnit testing
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 3 +- .../firmware/cirrus/test/cs_dsp_mock_wmfw.c | 473 ++++++++++++++++++ .../linux/firmware/cirrus/cs_dsp_test_utils.h | 33 ++ 3 files changed, 508 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_wmfw.c
drivers/firmware/cirrus/test/Makefile +2 -1
@@ -4,6 +4,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_mock_mem_maps.o \ cs_dsp_mock_regmap.o \ - cs_dsp_mock_utils.o + cs_dsp_mock_utils.o \ + cs_dsp_mock_wmfw.o obj-$(CONFIG_FW_CS_DSP_KUNIT_TEST_UTILS) += cs_dsp_test_utils.o
drivers/firmware/cirrus/test/cs_dsp_mock_wmfw.c new file +473 -0
473 lines not on this page · raw message
include/linux/firmware/cirrus/cs_dsp_test_utils.h +33 -0
@@ -53,6 +53,17 @@ struct cs_dsp_mock_alg_def {unsigned int zm_size_words; }; +struct cs_dsp_mock_coeff_def { +const char *shortname; +const char *fullname; +const char *description; +u16 type; +u16 flags; +u16 mem_type; +unsigned int offset_dsp_words; +unsigned int length_bytes; +}; +/** * struct cs_dsp_mock_xm_header - XM header builder *
@@ -66,6 +77,8 @@ struct cs_dsp_mock_xm_header {size_t blob_size_bytes; }; +struct cs_dsp_mock_wmfw_builder ; +extern const unsigned int cs_dsp_mock_adsp2_32bit_sysbase;extern const unsigned int cs_dsp_mock_adsp2_16bit_sysbase;extern const unsigned int cs_dsp_mock_halo_core_base;
@@ -107,3 +120,23 @@ void cs_dsp_mock_regmap_drop_bytes(struct cs_dsp_test *priv, unsigned int first_reg, size_t num_bytes);void cs_dsp_mock_regmap_drop_system_regs (struct cs_dsp_test *priv);bool cs_dsp_mock_regmap_is_dirty (struct cs_dsp_test *priv,bool drop_system_regs); + +struct cs_dsp_mock_wmfw_builder *cs_dsp_mock_wmfw_init (struct cs_dsp_test *priv, +int format_version); +void cs_dsp_mock_wmfw_add_raw_block (struct cs_dsp_mock_wmfw_builder *builder, +int mem_region,unsigned int mem_offset_dsp_words, +const void *payload_data,size_t payload_len_bytes); +void cs_dsp_mock_wmfw_add_info (struct cs_dsp_mock_wmfw_builder *builder, +const char *info); +void cs_dsp_mock_wmfw_add_data_block (struct cs_dsp_mock_wmfw_builder *builder, +int mem_region,unsigned int mem_offset_dsp_words, +const void *payload_data,size_t payload_len_bytes); +void cs_dsp_mock_wmfw_start_alg_info_block (struct cs_dsp_mock_wmfw_builder *builder, +unsigned int alg_id, +const char *name, +const char *description); +void cs_dsp_mock_wmfw_add_coeff_desc (struct cs_dsp_mock_wmfw_builder *builder, +const struct cs_dsp_mock_coeff_def *def); +void cs_dsp_mock_wmfw_end_alg_info_block (struct cs_dsp_mock_wmfw_builder *builder); +struct firmware *cs_dsp_mock_wmfw_get_firmware (struct cs_dsp_mock_wmfw_builder *builder); +int cs_dsp_mock_wmfw_format_version (struct cs_dsp_mock_wmfw_builder *builder);
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 4/12 firmware: cs_dsp: Add mock bin file generator for KUnit testing
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../firmware/cirrus/test/cs_dsp_mock_bin.c | 199 ++++++++++++++++++ .../linux/firmware/cirrus/cs_dsp_test_utils.h | 18 ++ 3 files changed, 218 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_mock_bin.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -3,6 +3,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_mock_mem_maps.o \ + cs_dsp_mock_bin.o \ cs_dsp_mock_regmap.o \ cs_dsp_mock_utils.o \ cs_dsp_mock_wmfw.o
drivers/firmware/cirrus/test/cs_dsp_mock_bin.c new file +199 -0
199 lines not on this page · raw message
include/linux/firmware/cirrus/cs_dsp_test_utils.h +18 -0
@@ -78,6 +78,7 @@ struct cs_dsp_mock_xm_header { };struct cs_dsp_mock_wmfw_builder ; +struct cs_dsp_mock_bin_builder ;extern const unsigned int cs_dsp_mock_adsp2_32bit_sysbase;extern const unsigned int cs_dsp_mock_adsp2_16bit_sysbase;
@@ -121,6 +122,23 @@ void cs_dsp_mock_regmap_drop_bytes(struct cs_dsp_test *priv,void cs_dsp_mock_regmap_drop_system_regs (struct cs_dsp_test *priv);bool cs_dsp_mock_regmap_is_dirty (struct cs_dsp_test *priv,bool drop_system_regs); +struct cs_dsp_mock_bin_builder *cs_dsp_mock_bin_init (struct cs_dsp_test *priv, +int format_version, +unsigned int fw_version); +void cs_dsp_mock_bin_add_raw_block (struct cs_dsp_mock_bin_builder *builder, +unsigned int alg_id,unsigned int alg_ver, +int type,unsigned int offset, +const void *payload_data,size_t payload_len_bytes); +void cs_dsp_mock_bin_add_info (struct cs_dsp_mock_bin_builder *builder, +const char *info); +void cs_dsp_mock_bin_add_name (struct cs_dsp_mock_bin_builder *builder, +const char *name); +void cs_dsp_mock_bin_add_patch (struct cs_dsp_mock_bin_builder *builder, +unsigned int alg_id,unsigned int alg_ver, +int mem_region,unsigned int reg_addr_offset, +const void *payload_data,size_t payload_len_bytes); +struct firmware *cs_dsp_mock_bin_get_firmware (struct cs_dsp_mock_bin_builder *builder); +struct cs_dsp_mock_wmfw_builder *cs_dsp_mock_wmfw_init (struct cs_dsp_test *priv,int format_version); void cs_dsp_mock_wmfw_add_raw_block(struct cs_dsp_mock_wmfw_builder *builder,
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 5/12 firmware: cs_dsp: Add KUnit testing of bin file download
In reply to Richard FitzgeraldThis 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.
--- drivers/firmware/cirrus/Kconfig | 14 + drivers/firmware/cirrus/test/Makefile | 5 + .../firmware/cirrus/test/cs_dsp_test_bin.c | 2557 +++++++++++++++++ drivers/firmware/cirrus/test/cs_dsp_tests.c | 14 + 4 files changed, 2590 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_bin.c create mode 100644 drivers/firmware/cirrus/test/cs_dsp_tests.c
drivers/firmware/cirrus/Kconfig +14 -0
@@ -9,3 +9,17 @@ config FW_CS_DSP_KUNIT_TEST_UTILS depends on KUNIT select REGMAP select FW_CS_DSP + +config FW_CS_DSP_KUNIT_TEST + tristate "KUnit tests for Cirrus Logic cs_dsp" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + select REGMAP + select FW_CS_DSP + select FW_CS_DSP_KUNIT_TEST_UTILS + help + This builds KUnit tests for cs_dsp. + For more information on KUnit and unit tests in general, + please refer to the KUnit documentation in + Documentation/dev-tools/kunit/. + If in doubt, say "N".
drivers/firmware/cirrus/test/Makefile +5 -0
@@ -8,4 +8,9 @@ cs_dsp_test_utils-objs := \ cs_dsp_mock_utils.o \ cs_dsp_mock_wmfw.o +cs_dsp_test-objs := \ + cs_dsp_test_bin.o \ + cs_dsp_tests.o + obj-$(CONFIG_FW_CS_DSP_KUNIT_TEST_UTILS) += cs_dsp_test_utils.o +obj-$(CONFIG_FW_CS_DSP_KUNIT_TEST) += cs_dsp_test.o
drivers/firmware/cirrus/test/cs_dsp_test_bin.c new file +2557 -0
2,557 lines not on this page · raw message
drivers/firmware/cirrus/test/cs_dsp_tests.c new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Utility module for cs_dsp KUnit testing. +// +// Copyright (C) 2024 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. + +#include <linux/module.h> + +MODULE_DESCRIPTION ("KUnit tests for Cirrus Logic DSP driver" ); +MODULE_AUTHOR ("Richard Fitzgerald <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS ("FW_CS_DSP" ); +MODULE_IMPORT_NS ("FW_CS_DSP_KUNIT_TEST_UTILS" );
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 6/12 firmware: cs_dsp: Add KUnit testing of wmfw download
In reply to Richard FitzgeraldThis 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../firmware/cirrus/test/cs_dsp_test_wmfw.c | 2211 +++++++++++++++++ 2 files changed, 2212 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_wmfw.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -10,6 +10,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_test-objs := \ cs_dsp_test_bin.o \ + cs_dsp_test_wmfw.o \ cs_dsp_tests.o obj-$(CONFIG_FW_CS_DSP_KUNIT_TEST_UTILS) += cs_dsp_test_utils.o
drivers/firmware/cirrus/test/cs_dsp_test_wmfw.c new file +2211 -0
2,211 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 7/12 firmware: cs_dsp: Add KUnit testing of control parsing
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_test_control_parse.c | 1851 +++++++++++++++++ 2 files changed, 1852 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -10,6 +10,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_test-objs := \ cs_dsp_test_bin.o \ + cs_dsp_test_control_parse.o \ cs_dsp_test_wmfw.o \ cs_dsp_tests.o
drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c new file +1851 -0
1,851 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 8/12 firmware: cs_dsp: Add KUnit testing of control cache
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_test_control_cache.c | 3282 +++++++++++++++++ 2 files changed, 3283 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_control_cache.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -11,6 +11,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_test-objs := \ cs_dsp_test_bin.o \ cs_dsp_test_control_parse.o \ + cs_dsp_test_control_cache.o \ cs_dsp_test_wmfw.o \ cs_dsp_tests.o
drivers/firmware/cirrus/test/cs_dsp_test_control_cache.c new file +3282 -0
2,993 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.5
Part of the diff is not shown here. View the raw message.
Richard Fitzgerald
maintainerPATCH 9/12 firmware: cs_dsp: Add KUnit testing of control read/write
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_test_control_rw.c | 2669 +++++++++++++++++ 2 files changed, 2670 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_control_rw.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -12,6 +12,7 @@ cs_dsp_test-objs := \ cs_dsp_test_bin.o \ cs_dsp_test_control_parse.o \ cs_dsp_test_control_cache.o \ + cs_dsp_test_control_rw.o \ cs_dsp_test_wmfw.o \ cs_dsp_tests.o
drivers/firmware/cirrus/test/cs_dsp_test_control_rw.c new file +2669 -0
2,669 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 10/12 firmware: cs_dsp: Add KUnit testing of bin error cases
In reply to Richard FitzgeraldAdd tests for various types of errors and illegal values in bin files. This covers buffer overflows as well as general unsupported field values.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_test_bin_error.c | 600 ++++++++++++++++++ 2 files changed, 601 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_bin_error.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -10,6 +10,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_test-objs := \ cs_dsp_test_bin.o \ + cs_dsp_test_bin_error.o \ cs_dsp_test_control_parse.o \ cs_dsp_test_control_cache.o \ cs_dsp_test_control_rw.o \
drivers/firmware/cirrus/test/cs_dsp_test_bin_error.c new file +600 -0
600 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 11/12 firmware: cs_dsp: Add KUnit testing of wmfw error cases
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_test_wmfw_error.c | 1347 +++++++++++++++++ 2 files changed, 1348 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_wmfw_error.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -15,6 +15,7 @@ cs_dsp_test-objs := \ cs_dsp_test_control_cache.o \ cs_dsp_test_control_rw.o \ cs_dsp_test_wmfw.o \ + cs_dsp_test_wmfw_error.o \ cs_dsp_tests.o obj-$(CONFIG_FW_CS_DSP_KUNIT_TEST_UTILS) += cs_dsp_test_utils.o
drivers/firmware/cirrus/test/cs_dsp_test_wmfw_error.c new file +1347 -0
1,347 lines not on this page · raw message
Signature · 1 line
2.39.5
Richard Fitzgerald
maintainerPATCH 12/12 firmware: cs_dsp: Add KUnit testing of client callbacks
In reply to Richard FitzgeraldTest 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
--- drivers/firmware/cirrus/test/Makefile | 1 + .../cirrus/test/cs_dsp_test_callbacks.c | 688 ++++++++++++++++++ 2 files changed, 689 insertions(+) create mode 100644 drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c
drivers/firmware/cirrus/test/Makefile +1 -0
@@ -11,6 +11,7 @@ cs_dsp_test_utils-objs := \ cs_dsp_test-objs := \ cs_dsp_test_bin.o \ cs_dsp_test_bin_error.o \ + cs_dsp_test_callbacks.o \ cs_dsp_test_control_parse.o \ cs_dsp_test_control_cache.o \ cs_dsp_test_control_rw.o \
drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c new file +688 -0
688 lines not on this page · raw message
Signature · 1 line
2.39.5
Quoted 10 lines · Richard Fitzgerald
This series adds KUnit tests for the
cs_dspmodule.Most of the functionality in
cs_dspis for downloading firmware to DSP memory and interacting with "control" words defined in that memory. This doesn't require any emulation of running firmware, because it is only reading and writing registers. So the testing can be done using a dummy regmap. The way this is used to perform testing is described in more detail in the commit message for each test.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/12] firmware: cs_dsp: Add mock regmap for KUnit testing
commit: d54a3fc6bf3db0db0e16cfdf7f48a8bbb803f6b0
[02/12] firmware: cs_dsp: Add mock DSP memory map for KUnit testing
commit: 41e78c0f44f97c958afcda3f82b23f4f4a05b968
[03/12] firmware: cs_dsp: Add mock wmfw file generator for KUnit testing
commit: 5cf1b7b471803f7cc654a29ee16cb085ad69c097
[04/12] firmware: cs_dsp: Add mock bin file generator for KUnit testing
commit: 7c052c6615297ff32032105130cd5f02059f7ae4
[05/12] firmware: cs_dsp: Add KUnit testing of bin file download
commit: dd0b6b1f29b92202d03a6d2dd7d65ecead27941a
[06/12] firmware: cs_dsp: Add KUnit testing of wmfw download
commit: a2b2f2c1cd2a8b21c23bd1ec33131d2266c7568a
[07/12] firmware: cs_dsp: Add KUnit testing of control parsing
commit: 83baecd92e7c2a44ac963fab8fd4476c71e19ddd
[08/12] firmware: cs_dsp: Add KUnit testing of control cache
commit: 9b33a4fc500cedc1adc9c0ee01e30ffd50e5887a
[09/12] firmware: cs_dsp: Add KUnit testing of control read/write
commit: fe54fd5474f746f07f2b587f2f5e3311bf611970
[10/12] firmware: cs_dsp: Add KUnit testing of bin error cases
commit: cd8c058499b65e8605cd3c387bb1f76e2954870e
[11/12] firmware: cs_dsp: Add KUnit testing of wmfw error cases
commit: feb5fb0615f321ab514f4fbbab777f3591f7e4b5
[12/12] firmware: cs_dsp: Add KUnit testing of client callbacks
commit: 75a4a6ef615e2f4e9458051641f185498273ce02All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark