drivers/firmware/cirrus/test/cs_dsp_test_wmfw_error.c
Source file repositories/reference/linux-study-clean/drivers/firmware/cirrus/test/cs_dsp_test_wmfw_error.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/cirrus/test/cs_dsp_test_wmfw_error.c- Extension
.c- Size
- 45449 bytes
- Lines
- 1362
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/device.hkunit/resource.hkunit/static_stub.hkunit/test.hlinux/build_bug.hlinux/firmware/cirrus/cs_dsp.hlinux/firmware/cirrus/cs_dsp_test_utils.hlinux/firmware/cirrus/wmfw.hlinux/random.hlinux/regmap.hlinux/string.hlinux/vmalloc.h../cs_dsp.h
Detected Declarations
struct cs_dsp_test_localstruct cs_dsp_wmfw_test_paramfunction wmfw_load_with_unknown_blocksfunction wmfw_err_wrong_magicfunction wmfw_err_too_short_for_headerfunction wmfw_err_bad_header_lengthfunction wmfw_err_bad_core_typefunction wmfw_too_short_for_block_headerfunction wmfw_too_short_for_block_payloadfunction wmfw_block_payload_len_garbagefunction wmfw_too_short_for_alg_headerfunction wmfw_v1_alg_name_unterminatedfunction wmfw_v2_alg_name_exceeds_blockfunction wmfw_v2_alg_description_exceeds_blockfunction wmfw_v1_coeff_count_exceeds_blockfunction wmfw_v2_coeff_count_exceeds_blockfunction wmfw_v2_coeff_block_size_exceeds_blockfunction wmfw_v1_coeff_name_unterminatedfunction wmfw_v2_coeff_shortname_exceeds_blockfunction wmfw_v2_coeff_fullname_exceeds_blockfunction wmfw_v2_coeff_description_exceeds_blockfunction cs_dsp_wmfw_err_test_can_emit_message_hookfunction cs_dsp_wmfw_err_test_common_initfunction cs_dsp_wmfw_err_test_halo_initfunction cs_dsp_wmfw_err_test_adsp2_32bit_initfunction cs_dsp_wmfw_err_test_adsp2_32bit_wmfw0_initfunction cs_dsp_wmfw_err_test_adsp2_32bit_wmfw1_initfunction cs_dsp_wmfw_err_test_adsp2_32bit_wmfw2_initfunction cs_dsp_wmfw_err_test_adsp2_16bit_initfunction cs_dsp_wmfw_err_test_adsp2_16bit_wmfw0_initfunction cs_dsp_wmfw_err_test_adsp2_16bit_wmfw1_initfunction cs_dsp_wmfw_err_test_adsp2_16bit_wmfw2_initfunction cs_dsp_wmfw_err_block_types_desc
Annotated Snippet
struct cs_dsp_test_local {
struct cs_dsp_mock_xm_header *xm_header;
struct cs_dsp_mock_wmfw_builder *wmfw_builder;
int wmfw_version;
};
struct cs_dsp_wmfw_test_param {
int block_type;
};
static const struct cs_dsp_mock_alg_def cs_dsp_wmfw_err_test_mock_algs[] = {
{
.id = 0xfafa,
.ver = 0x100000,
.xm_size_words = 164,
.ym_size_words = 164,
.zm_size_words = 164,
},
};
static const struct cs_dsp_mock_coeff_def mock_coeff_template = {
.shortname = "Dummy Coeff",
.type = WMFW_CTL_TYPE_BYTES,
.mem_type = WMFW_ADSP2_YM,
.flags = WMFW_CTL_FLAG_VOLATILE,
.length_bytes = 4,
};
/* Load a wmfw containing unknown blocks. They should be skipped. */
static void wmfw_load_with_unknown_blocks(struct kunit *test)
{
struct cs_dsp_test *priv = test->priv;
struct cs_dsp_test_local *local = priv->local;
struct firmware *wmfw;
unsigned int reg_addr;
u8 *payload_data, *readback;
u8 random_data[8];
const unsigned int payload_size_bytes = 64;
/* Add dummy XM header payload to wmfw */
cs_dsp_mock_wmfw_add_data_block(local->wmfw_builder,
WMFW_ADSP2_XM, 0,
local->xm_header->blob_data,
local->xm_header->blob_size_bytes);
payload_data = kunit_kmalloc(test, payload_size_bytes, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, payload_data);
get_random_bytes(payload_data, payload_size_bytes);
readback = kunit_kzalloc(test, payload_size_bytes, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, readback);
/* Add some unknown blocks at the start of the wmfw */
get_random_bytes(random_data, sizeof(random_data));
cs_dsp_mock_wmfw_add_raw_block(local->wmfw_builder, 0xf5, 0,
random_data, sizeof(random_data));
cs_dsp_mock_wmfw_add_raw_block(local->wmfw_builder, 0xc0, 0, random_data,
sizeof(random_data));
cs_dsp_mock_wmfw_add_raw_block(local->wmfw_builder, 0x33, 0, NULL, 0);
/* Add a single payload to be written to DSP memory */
cs_dsp_mock_wmfw_add_data_block(local->wmfw_builder,
WMFW_ADSP2_YM, 0,
payload_data, payload_size_bytes);
wmfw = cs_dsp_mock_wmfw_get_firmware(local->wmfw_builder);
/* Sanity-check that the good wmfw loads ok */
KUNIT_EXPECT_EQ(test,
cs_dsp_power_up(priv->dsp, wmfw, "wmfw", NULL, NULL, "misc"),
0);
cs_dsp_power_down(priv->dsp);
KUNIT_EXPECT_EQ(test,
cs_dsp_power_up(priv->dsp, wmfw, "mock_wmfw", NULL, NULL, "misc"),
0);
/* Check that the payload was written to memory */
reg_addr = cs_dsp_mock_base_addr_for_mem(priv, WMFW_ADSP2_YM);
KUNIT_EXPECT_EQ(test,
regmap_raw_read(priv->dsp->regmap, reg_addr, readback, payload_size_bytes),
0);
KUNIT_EXPECT_MEMEQ(test, readback, payload_data, payload_size_bytes);
}
/* Load a wmfw that doesn't have a valid magic marker. */
static void wmfw_err_wrong_magic(struct kunit *test)
{
struct cs_dsp_test *priv = test->priv;
struct cs_dsp_test_local *local = priv->local;
Annotation
- Immediate include surface: `kunit/device.h`, `kunit/resource.h`, `kunit/static_stub.h`, `kunit/test.h`, `linux/build_bug.h`, `linux/firmware/cirrus/cs_dsp.h`, `linux/firmware/cirrus/cs_dsp_test_utils.h`, `linux/firmware/cirrus/wmfw.h`.
- Detected declarations: `struct cs_dsp_test_local`, `struct cs_dsp_wmfw_test_param`, `function wmfw_load_with_unknown_blocks`, `function wmfw_err_wrong_magic`, `function wmfw_err_too_short_for_header`, `function wmfw_err_bad_header_length`, `function wmfw_err_bad_core_type`, `function wmfw_too_short_for_block_header`, `function wmfw_too_short_for_block_payload`, `function wmfw_block_payload_len_garbage`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.