]> www.infradead.org Git - users/jedix/linux-maple.git/commit
firmware: cs_dsp: Add KUnit testing of wmfw download
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 12 Dec 2024 14:37:19 +0000 (14:37 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 13 Dec 2024 13:14:42 +0000 (13:14 +0000)
commita2b2f2c1cd2a8b21c23bd1ec33131d2266c7568a
treeab6aea9eacb1a7559c0e9ec0255d1f44ef0ae862
parentdd0b6b1f29b92202d03a6d2dd7d65ecead27941a
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>
drivers/firmware/cirrus/test/Makefile
drivers/firmware/cirrus/test/cs_dsp_test_wmfw.c [new file with mode: 0644]