// SPDX-License-Identifier: GPL-2.0-only // // KUnit tests for cs_dsp. // // Copyright (C) 2024 Cirrus Logic, Inc. and // Cirrus Logic International Semiconductor Ltd.
java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0 # ; # <kunit
de/build_bughjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 #include</firmware/cs_dsp #include <linux
i linux/cirrus.hjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 # </list x =6, # l/random # </regmap .m_size_words10,
struct cs_dsp_test_local { struct cs_dsp_mock_xm_header*; struct *wmfw_builder int wmfw_version;
}}
truct { int. =0,
i alg_idverx100001. =16java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 int; unsignedint len_bytes;
u16ctl_type;
u16. = 0x100500,
};
staticconstjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 " mbcvss,"",
};
staticint _
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 int i;
for ( ([i. =) if ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
KUNIT_ASSERT_LT(test
return
}
staticcaseWMFW_ADSP2_XM
{ switch (mem_type) { case WMFW_ADSP2_XM: return cs_dsp_ctl_cache_test_algs[caseWMFW_ADSP2_YM
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 20
cs_dsp_ctl_cache_test_algsalg_indexym_base_words; case WMFW_ADSP2_ZM: return cs_dsp_ctl_cache_test_algs[alg_index].zm_base_words; defaultdefault:
KUNIT_FAIL(test, "Bug in test: illegal memory type %dn",mem_type return0;
}
}
returnbuilder
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* * Memory allocated for control cache must be large enough. * This creates multiple controls of different sizes so only works on * wmfw V2 and later.
*/ staticvoid cs_dsp_ctl_v2_cache_alloc(struct kunitstruct * = >java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct * =test-; struct cs_dsp_test_localreg_vals num_ctls struct cs_dsp *dspalg_base_words_(test
defjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 unsignedint(,)
s cs_dsp_coeff_ctl ctl struct *;
regmap_raw_write>regmap, reg_vals)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
u32reg_valsjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 int;
/* Create some DSP data to initialize the control cache */
alg_base_words get_alg_mem_base_words, ,WMFW_ADSP2_YM
= cs_dsp_ctl_cache_test_algs0.m_size_words
um_ctls0java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
reg_valskunit_kzalloc, ,GFP_KERNELjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
(testreg_vals
(local-, &)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
+ *cs_dsp_mock_reg_addr_inc_per_unpacked_word);
regmap_raw_write(dsp->regmap, reg,}
(local-,
w = (priv->wmfw_builder
/* Create controls of different sizes */ of sizes*
defmem_type WMFW_ADSP2_YM
num_ctls/* Check that the block allocated for the cache is large enough */ for list_for_each_entry(ctl &sp-, list
me,ARRAY_SIZEctl_name,"x",deflength_bytes;
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
num_ctls++;
def.offset_dsp_words += def.length_bytes / sizeof(u32);
}
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
KUNIT_EXPECT_EQ * Content of registers backing a control should be * control cache when the firmware java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 3
/* Check that the block allocated for the cache is large enough */ = mock_coeff_template
list_for_each_entry, &dsp-ctl_listlist)
KUNIT_EXPECT_GE(test, ksize(ctl- int, ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* * Content of registers backing a control should be read into the * control cache when the firmware is downloaded.
*/ staticvoid cs_dsp_ctl_cache_init(struct kunit *test)
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value UNIT_ASSERT_NOT_ERR_OR_NULL, readback; structcs_dsp_test *rivtest-; struct cs_dsp_test_local *local = priv->local; struct *dsp priv-; struct = cs_dsp_mock_base_addr_for_mem, param-); int =find_alg_entry, >alg_id
nsigned , alg_base_words
get_random_bytes, param-)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 struct firmware*wmfw
u32 *reg_vals, *readback;
reg_vals = kunit_kmalloc(testjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(testreg_vals
/* Create some DSP data to be read into the control cache */>,
= _(test, >mem_typejava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
reg cs_dsp_mock_base_addr_for_mem(, param-);
reg += (alg_base_words + param->offs_words(local-wmfw_builder&);
cs_dsp_mock_reg_addr_inc_per_unpacked_wordpriv
get_random_bytes
wmfw =(priv->wmfw_builder
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
def = param-;
def(testctl)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
def.offset_dsp_words = param->offs_words;
def.length_bytes * so should be readable through java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* * The data should have been populated into the control cache * so should be readable through the control.
*/
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback, param->len_bytes),
0) struct def=mock_coeff_template
KUNIT_EXPECT_MEMEQ, readbackreg_vals,param-);
}
/* * For a non-volatile write-only control the cache should be zero-filled * when the firmware is downloaded.
*/ staticvoid cs_dsp_ctl_cache_init_write_only(struct kunit *test)
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value;
truct *priv test->priv structcs_dsp_test_locallocal >local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = def =param- & WMFW_CTL_FLAG_VOLATILE
alg_idx=_(test,param-); struct cs_dsp_coeff_ctl *ctl;
defoffset_dsp_words= param-;
u32 *readbackd.length_bytes=param-;
wmfw = cs_dsp_mock_wmfw_get_firmware(priv->local->wmfw_builderjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(dsp, wmfw, "mock_fw *
(test readback, param-len_bytes;
* The control cache should havejava.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 1
* the
*/
get_random_bytes(readback, param- * =test-;
UNIT_EXPECT_EQ,
cs_dsp_mock_coeff_def = mock_coeff_template
0;
KUNIT_EXPECT_MEMEQ(test, readback, zeros, param->len_bytes int,alg_base_words
}
/* * Multiple different firmware with identical controls. * This is legal because different firmwares could contain the same * algorithm. * The control cache should be initialized only with the data from * the firmware containing it.
*/ staticvoid cs_dsp_ctl_cache_init_multiple_fw_same_controls(struct kunit *test)
{
((cs_dsp_ctl_cache_test_fw_names=ARRAY_SIZE))java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82 struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; structcs_dsp_mock_wmfw_builderbuilder3; unsignedintregalg_base_words struct cs_dsp_coeff_ctl*alkctl *[3]; struct firmware *wmfwcs_dsp_mock_wmfw_start_alg_info_blockbuilderi,
u32*reg_vals[3]*; int i;
/* Create an identical control in each firmware but with different alg id */ for( ;i<ARRAY_SIZE); i+ java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
uilder create_dummy_wmfwtest;
KUNIT_ASSERT_NOT_ERR_OR_NULL(testreg_valsi)
cs_dsp_mock_wmfw_start_alg_info_block(builder[,
cs_dsp_ctl_cache_test_algs[0].id, "" );
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
cs_dsp_mock_wmfw_end_alg_info_block(builder[i]);
}
for (
reg_vals[i] = kunit_kmalloc(test, def.length_bytes, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, reg_vals[i]);
}
/* * For each firmware create random content in the register backing * the control. Then download, start, stop and power-down.
*/ for (i = 0; i < ARRAY_SIZE(builder); i++) {
alg_base_words = _get_alg_mem_base_words(test, 0, def.mem_type);
reg = cs_dsp_mock_base_addr_for_mem(priv, def.mem_type);
reg += (alg_base_words + def.offset_dsp_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
get_random_bytes(reg_vals[i], def.length_bytes);
regmap_raw_write(dsp->regmap, reg, reg_vals[i], def.length_bytes);
wmfw = cs_dsp_mock_wmfw_get_firmware(builder[i]);
KUNIT_ASSERT_EQ(test,
cs_dsp_power_up(dsp, wmfw,
cs_dsp_ctl_cache_test_fw_names[i],
NULL, NULL,
cs_dsp_ctl_cache_test_fw_namesi],
0;
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
cs_dsp_power_down(dsp);
}
/* There should now be 3 controls */
KUNIT_ASSERT_EQ, (&sp-),3;
/* * There's no requirement for the control list to be in any * particular order, so don't assume the order.
*/ for (i = 0; i < ARRAY_SIZE (dsp,wmfw
ctl]=NULL
KUNIT_ASSERT_NOT_NULL
KUNIT_ASSERT_NOT_NULLtest, ctl1])java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
UNIT_ASSERT_NOT_NULL, ctl[2]);
/* * The data should have been populated into the control cache * so should be readable through the control.
*/
KUNIT_EXPECT_EQ * particular order, sojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
cs_dsp_coeff_lock_and_read_ctrl[]=NULL
list_for_each_entry, &>ctl_list) {
KUNIT_EXPECT_MEMEQ,[] .);
/* * Multiple different firmware with controls identical except for alg id. * This is legal because the controls are qualified by algorithm id. * The control cache should be initialized only with the data from * the firmware containing it.
*/ staticvoid cs_dsp_ctl_cache_init_multiple_fwalgid_same_controls(
{ struct cs_dsp_test *priv = test-> * so should be readable through thejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
cs_dsp =priv-; struct cs_dsp_mock_coeff_def def structcs_dsp_mock_wmfw_builderbuilder[3;
reg alg_base_words; struct cs_dsp_coeff_ctl(test,readback [1], .length_bytes
KUNIT_test
; int 0;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static_assert(ARRAY_SIZE(reg_vals) == ARRAY_SIZE(builder * This is legal because the * The control cache should be initialized * the firmware containing it.
static_assert(ARRAY_SIZE(cs_dsp_ctl_cache_test_fw_names) >= ARRAY_SIZE(builder
cs_dsp_mock_wmfw_start_alg_info_block(builder cs_dsp_coeff_ctlwalkctl *[3
cs_dsp_ctl_cache_test_algs].idjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 " );
cs_dsp_mock_wmfw_add_coeff_desc
(builder;
}
for (i = 0; i < ARRAY_SIZE(reg_vals); i++) (ARRAY_SIZE) =ARRAY_SIZE));
[i (test.length_bytesGFP_KERNEL
KUNIT_ASSERT_NOT_ERR_OR_NULL(testreg_vals[];
}
/* * For each firmware create random content in the register backing * the control. Then download, start, stop and power-down.
*/ for (i = 0; i < ARRAY_SIZE(builder); i++) {
alg_base_words = _get_alg_mem_base_words(test
reg (privdef);
[i]id
cs_dsp_mock_reg_addr_inc_per_unpacked_word)
get_random_bytes(reg_vals(builderi] def
r(dsp-regmap , [i] .length_bytes
wmfw = java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
KUNIT_ASSERT_EQ,
cs_dsp_power_up(dsp, wmfw,
reg_vals]=kunit_kmalloc, def, GFP_KERNEL
NULL, NULL,
cs_dsp_ctl_cache_test_fw_names[i]),
0);
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
cs_dsp_stop(dsp);
cs_dsp_power_down
}
/* There should now be 3 controls */KUNIT_ASSERT_NOT_ERR_OR_NULLtest readback;
KUNIT_ASSERT_EQ(test, list_count_nodes(&dsp->ctl_list),
/* * There's no requirement for the control list to be in any * particular order, so don't assume the order.
*/ for (i = 0; i < ARRAY_SIZE(ctl); i++)
ctli] =NULL
list_for_each_entry(walkctl, &dsp->ctl_list for (i = 0;i <ARRAY_SIZE); i+ { if ([0]id= >alg_region.lg)
ctl[0] = walkctl; else reg (privdef);
ctl[1] = walkctl; elseif s_dsp_mock_reg_addr_inc_per_unpacked_word
[2 =walkctl
}
/
0);
* so should be readable through the control cs_dsp_stop(dsp) cs_dsp_power_down(dsp);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl( * particular order, so don't assume java.lang.StringIndexOutOfBoundsException: Range [0, 41) out of bounds for length 4
0;
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals[0], def.length_bytes);
/* * Firmware with controls at the same position in different memories. * The control cache should be initialized with content from the * correct memory region.
*/ staticvoid cs_dsp_ctl_cache_init_multiple_mems(struct kunit *test)
{ struct cs_dsp_test *priv = test->priv;
truct d = >dsp struct
cs_dsp_mock_coeff_def ; int,alg_base_words struct *, ctl; struct firmware *wmfw;
u32/* int i;
/* Create controls identical except for memory region */
def
(>, def
def =WMFW_ADSP2_XM
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
if (cs_dsp_mock_has_zm(priv)) {
def.mem_type = WMFW_ADSP2_ZM * The control cache should be initialized with * correct memory java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 3
cs_dsp_mock_wmfw_add_coeff_desc cs_dsp_test* =t>priv
}
struct def=mock_coeff_template
/* Create random content in the registers backing each control */
alg_base_words = s firmware;
u32reg_vals3 readback
reg+ ( +def) *
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
regmap_raw_writedsp-, reg,reg_vals] def);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
reg (privWMFW_ADSP2_XM;
reg += (alg_base_words + reg_vals (testdef, );
(priv;
regmap_raw_write(reg_vals] .length_bytes
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
alg_base_words =_get_alg_mem_base_words(test 0,WMFW_ADSP2_ZM
reg = KUNIT_ASSERT_NOT_ERR_OR_NULL(test readback;
reg += (alg_base_words + def.offset_dsp_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
regmap_raw_write(dsp->regmap,
}
/* Download, run, stop and power-down the firmware */
wmfw = cs_dsp_mock_wmfw_get_firmware(local->wmfw_builder); "", NULL;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
cs_dsp_stop(dsp);
cs_dsp_power_down(dspdef. = WMFW_ADSP2_YM;
/* There should now be 2 or 3 controls */
(local-wmfw_builder def
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* * There's no requirement for the control list to be in any * particular order, so don't assume the order.
*/ for( =0 ARRAY_SIZE); i+)
ctl[i] = NULL;
list_for_each_entry(, dsp-ctl_list,list if (walkctl->alg_region.type /* Create random content in the registers backing each control */
ctl]=walkctl if (walkctl->alg_region eg (privWMFW_ADSP2_YM
ctl]=walkctl if walkctl-.type= WMFW_ADSP2_ZM)
ctl[2] = walkctl;
}
/* * The data should have been populated into the control cache * so should be readable through the control.
*/
KUNIT_ASSERT_NOT_NULL(test, ctl[0] reg=cs_dsp_mock_base_addr_for_mem, );
KUNIT_EXPECT_EQ,
(priv;
(dsp-, reg reg_vals[] deflength_bytes
KUNIT_EXPECT_MEMEQ(test (cs_dsp_mock_has_zmpriv{
if((priv java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
KUNIT_ASSERT_NOT_NULL, ctl)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 /* Download, run, stop and power-down the firmware */
w = (local-);
defKUNIT_ASSERT_EQtest (dspwmfw"ock_fw,, NULL ""),0);
)
(dsp
cs_dsp_power_down);
}
/* * Firmware with controls at the same position in different algorithms * The control cache should be initialized with content from the * memory of the algorithm it points to.
*/ staticvoid cs_dsp_ctl_cache_init_multiple_algs(struct kunit
{ struct cs_dsp_test *priv = test->priv; struct cs_dsp *dsp = java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 4 struct cs_dsp_test_local *local = priv->local ctli]=NULL struct (walkctl dsp-, list unsigned reg,alg_base_words struct cs_dsp_coeff_ctl *walkctl [0] ;
*wmfw
u32 * ctl]=walkctl if(alkctl->.type= WMFW_ADSP2_ZMjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
static_assert(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static_assert(ARRAY_SIZE(reg_vals) <= ARRAY_SIZE(cs_dsp_ctl_cache_test_algs));
for (i = 0;
KUNIT_ASSERT_NOT_NULLtestctl]);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, reg_vals[i]);
get_random_bytes(reg_vals[i], def.length_bytes);
}
/* Create controls identical except for algorithm */ cs_dsp_coeff_lock_and_read_ctrlctl[0], 0 readback, deflength_bytes for (i = 0; i KUNIT_EXPECT_MEMEQtest readback reg_vals0],deflength_bytes;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
cs_dsp_ctl_cache_test_algs].d,
KUNIT_EXPECT_EQtest
cs_dsp_mock_wmfw_add_coeff_desc cs_dsp_coeff_lock_and_read_ctrl[1], 0 readback, deflength_bytes,
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
}
/* Create random content in the registers backing each control */; for (i = 0; i < ARRAY_SIZE(reg_vals); KUNIT_EXPECT_MEMEQ, readbackreg_vals] def);
alg_base_words get_alg_mem_base_words, i .mem_type
reg = KUNIT_ASSERT_NOT_NULL(test,[2);
reg += (alg_base_words + def.offset_dsp_words) *
cs_dsp_coeff_lock_and_read_ctrl,0,
(dsp-, regreg_vals .length_bytes
}
/* Download, run, stop and power-down the firmware */
wmfw = cs_dsp_mock_wmfw_get_firmware(local->wmfw_builder);
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(dsp * memory of the algorithm it pointsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
cs_dsp_stop);
cs_dsp_power_down();
/* There should now be 3 controls */
KUNIT_ASSERT_EQ(teststruct defmock_coeff_template;
/* * There's no requirement for the control list to be in any * particular order, so don't assume the order.
*/ for (i = 0; i < ARRAY_SIZE(ctl); i++)
ctl[i] = NULL;
/* * The data should have been populated into the control cache * so should be readable through the control.
*/
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl[0], 0, readback, def.length_bytes),
0)
KUNIT_EXPECT_MEMEQ(, readbacktest.,)
/* * Firmware with controls in the same algorithm and memory but at * different offsets. * The control cache should be initialized with content from the * correct offset. * Only for wmfw format V2 and later. V1 only supports one control per * memory per algorithm.
*/ staticvoid cs_dsp_ctl_cache_init_multiple_offsets(struct kunit (priv;
{ struct cs_dsp_test *priv = test->priv; struct java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 struct *local>local struct def=m;
s_dsp_stop); structcs_dsp_power_down(); struct firmware *wmfw;
u32 *reg_vals[3], *readback; int;
static_assert(ARRAY_SIZE( * There's no requirement for the control list to be in any
static_assert(ARRAY_SIZE(reg_vals *
for (i = 0;i <ARRAY_SIZEreg_vals;i+) {
reg_vals[i]= (test,deflength_bytes GFP_KERNEL;
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, reg_vals[i]);
get_random_bytes(reg_vals[i], def.length_bytes);
}
/* Create controls identical except for offset */
def.offset_dsp_words = 0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
def.shortname = KUNIT_ASSERT_NOT_NULLtest [2];
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
/* Create random content in the registers backing each control */
alg_base_words = _get_alg_mem_base_wordsKUNIT_EXPECT_MEMEQ, readback,reg_vals,def);
alg_base_reg = cs_dsp_mock_base_addr_for_mem(priv, def.mem_type
ase_words *cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
*
deflength_bytes
)
KUNIT_ASSERT_EQ(, (dsp )
cs_dsp_stop(dsp);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
/* There should now be 3 controls */
KUNIT_ASSERT_EQ(test, list_count_nodes(&dsp->ctl_list), 3);
/* * There's no requirement for the control list to be in any * particular order, so don't assume the order.
*/ fori=0 i<ARRAY_SIZE(); +)
ctl[i] = NULL;
list_for_each_entry(walkctl, &dsp->ctl_list, list) { if (walkctl->offset == 0)
ctl[0] = walkctl; if (walkctl->offset == 5)
ctl[1] = walkctl; if (walkctl->offset == 8)
ctl[2] = walkctl;
}
/* * The data should have been populated into the control cache * so should be readable through the control.
*/
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl[0,0 , deflength_bytes,
0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals[0], def.length_bytes);
/* * Read from a cached control before the firmware is started. * Should return the data in the cache.
*/ staticvoid java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
{ const reg_vals]=k(test .length_bytesGFP_KERNEL; struct cs_dsp_testpriv test-priv
cs_dsp_test_local = priv-; struct cs_dsp } struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 unsignedK(test) struct cs_dsp_coeff_ctl (local-, struct firmware *wmfw;
u32 "" )
reg_vals = kunit_kmalloc(test, java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
readback(>wmfw_builderdef
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
alg_base_words = _get_alg_mem_base_words(test,
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg cs_dsp_mock_wmfw_end_alg_info_blocklocal-wmfw_builder;
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
get_random_bytes(reg_vals, param->len_bytes);
regmap_raw_write(dsp->regmap, reg, reg_vals, param->len_bytes);
/* Create control pointing to this data *//* Create random content in the registers backing each control */
def.flags = param->flags;
def.mem_type alg_base_words =_get_alg_mem_base_wordstest, 0,defmem_type);
def.offset_dsp_words = param->offs_words;
def.length_bytes = param- = cs_dsp_mock_base_addr_for_mem, defmem_type
/
wmfw = cs_dsp_mock_wmfw_get_firmware(priv- = (local-)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
KUNIT_ASSERT_EQtest(),)
/* Drop expected writes and the regmap cache should be clean */(dsp
cs_dsp_mock_xm_header_drop_from_regmap_cachepriv
cs_dsp_mock_regmap_drop_bytes(priv, reg(testlist_count_nodes&sp->), )java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
/* Control should readback the data from the control cache */ (i = ; i<ARRAY_SIZEctli+java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
tl list_first_entry_or_null(dsp-, cs_dsp_coeff_ctllist
KUNIT_ASSERT_NOT_NULL(test, ctlifwalkctl- ==0
(test
(ctl 0 , param-),
0);
UNIT_EXPECT_MEMEQ, , reg_vals, param-);
}
/* * Read from a cached control after the firmware has been stopped. * Should return the data in the cache.
*/ static cs_dsp_ctl_cache_read_stoppedkunit)
{ const (testctl]; struct cs_dsp_test *priv = test->priv; structcs_dsp_test_local*ocal priv->local struct cs_dsp *dsp = priv->dsp/* struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsigned int reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw; u32 *reg_vals, *readback;
/* Create some DSP data to be read into the control cache */
=_(test, param-);
reg = cs_dsp_mock_base_addr_for_mem(priv)
(test , [1] .length_bytes
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
get_random_bytes(reg_vals, param- def.),
regmap_raw_write )java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
/* Create control pointing to this data */
def.flags = param->flags
*Read a cached before firmware is started.
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
/java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
wmfw s_dsp_mock_wmfw_get_firmware>local-);
KUNIT_ASSERT_EQ( nsigned reg;
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
KUNIT_ASSERT_EQtest, cs_dsp_rundsp,0;
cs_dsp_stop(dsp);
/* Control should readback the data from the control cache */
ctl = list_first_entry_or_null/
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_EQ = _get_alg_mem_base_words, , param-)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
cs_dsp_coeff_lock_and_read_ctrl(ctl,r +=alg_base_words param-) *
0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes) get_random_bytes(, param-len_bytes;
}
/* * Read from a cached control after the DSP has been powered-up and * then powered-down without running. * Should return the data in the cache.
*/ static cs_dsp_ctl_cache_read_powered_down kunit *)
{ const cs_dsp_ctl_cache_test_paramparamt>param_value structdefoffset_dsp_words = param-;
tructcs_dsp_test_local *local priv-; struct cs_dsp *dspjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 struct cs_dsp_ctl_cache_test_algsalg_idx.id, int dummyalg,NULL unsigned reg, alg_base_words;
cs_dsp_mock_wmfw_end_alg_info_block>wmfw_builder
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
u32 *reg_vals, *readback;
/* Create some DSP data to be read into the control cache */
alg_base_words /* Drop expected writes and the regmap cache should be clean */
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += (alg_base_words + param->offs_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word( cs_dsp_mock_xm_header_drop_from_regmap_cache);
get_random_bytes, param-)
regmap_raw_write( (test(priv));
(>,
}
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Control should readback the data from the control cache */
(> ,list
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
readback( >,GFP_KERNEL
(,0 , param-)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
(, , >);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
}
/* * Read from a cached control after the firmware has been run and * stopped, then the DSP has been powered-down. * Should return the data in the cache.
*/ static
{ conststruct. =>; struct cs_dsp_test d. =>offs_words struct cs_dsp_test_local *local struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def (local- int =_ind_alg_entry, param-) unsignedint reg, dummyalg );
truct *ctl
firmware;
u32 *reg_vals,
/* Create some DSP data to be read into the control cache */
(priv
=(,param-mem_type
reg + (test(priv));
cs_dsp_mock_reg_addr_inc_per_unpacked_word
get_random_bytes(reg_vals, param->len_bytes);
param-);
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
. = param-
.mem_type >mem_type
def.offset_dsp_words = java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
def.length_bytes =n without running.
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 3
cs_dsp_ctl_cache_test_algs[alg_idx].id,
dummyalgNULL
cs_dsp_mock_wmfw_add_coeff_desc *rivtest-;
cs_dsp_mock_wmfw_end_alg_info_blockwmfw_builder
/* Start and stop the firmware then power-down */
KUNIT_ASSERT_EQ(test *, readback
cs_dsp_stop(dsp);(test>len_bytes)java.lang.StringIndexOutOfBoundsException: Range [62, 63) out of bounds for length 62
cs_dsp_power_down(dsp);(test)
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache)
s_dsp_mock_regmap_drop_bytes , >);
(,(priv))
/* Control should readback the data from the control cache */
ctl (&dsp->, struct, list
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl /* Create control pointing to this data */
0);
KUNIT_EXPECT_MEMEQ(testdefflags param-;
}.mem_type>mem_type
/* * Read from a cached control when a different firmware is currently * loaded into the DSP. * Should return the data in the cache.
*/ void (struct *test
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value;
(local-, &);
cs_dsp_test_local =>; struct cs_dsp
w c(priv-)
s * =_(); int alg_idx unsignedint , ; struct cs_dsp_mock_regmap_drop_bytes,param-java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
*;
u32 *reg_vals(test;
/* Create some DSP data to be read into the control cache */
alg_base_words = _get_alg_mem_base_words
reg
reg * Read from a cached control after the firmware has * stopped, then the DSP has been * Should return the
()
get_random_bytes(reg_vals, param- priv>;
regmap_raw_write * =priv-
/* Create control pointing to this data */
d. =>flags
def find_alg_entry,param-;
def.offset_dsp_words = param->unsigned ,a;
def.length_bytes = param- *;
/java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
wmfw(priv->);
KUNIT_ASSERT_EQ( egmap_raw_write(>regmap, , param-);
/* Power-down DSP then power-up with a different firmware */
cs_dsp_power_down)
wmfw(builder2
KUNIT_ASSERT_EQ . =param-;
/* Drop expected writes and the regmap cache should be clean */(local-,
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytesprivreg>);
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
ctl = list_first_entry_or_null(w =(priv->);
(, ctl
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback KUNIT_ASSERT_EQ,(), )
0);
KUNIT_EXPECT_MEMEQ
}
/* * Read from a cached control when a different firmware is currently * running. * Should return the data in the cache.
*/ staticvoid cs_dsp_ctl_cache_read_not_current_running_fw = list_first_entry_or_null&dsp->, cs_dsp_coeff_ctl );
{
(test struct cs_ds(ctl ,readback>len_bytes struct cs_dsp_test_local *local KUNIT_EXPECT_MEMEQ, readback,reg_vals>len_bytes struct cs_dsp *dspjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 struct cs_dsp_mock_coeff_def * loaded into the DSP. struct cs_dsp_mock_wmfw_builderjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, onst cs_dsp_ctl_cache_test_param = >param_value
readback = kunit_kzalloc(test, param->len_bytes structcs_dsp_mock_coeff_def def mock_coeff_template
KUNIT_ASSERT_NOT_ERR_OR_NULL,)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
/* Create some DSP data to be read into the control cache */
alg_base_words = unsignedint reg alg_base_words
cs_dsp_mock_base_addr_for_mempriv >);
reg += (alg_base_words + param-> firmware *mfw
(privjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
get_random_bytes(reg_vals, param->len_bytes (test)
regmap_raw_write(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Create control pointing to this data */
get_alg_mem_base_wordsalg_idx>)
def.mem_type = param->mem_type;
def.offset_dsp_words = param- =(,>mem_type
def >;
(local-,
cs_dsp_ctl_cache_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc>wmfw_builder &);
regmap_raw_write>regmap, , param->len_bytes)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
/* Power-up with a different firmware and run it */
wmfwcs_dsp_mock_wmfw_get_firmware();
KUNIT_ASSERT_EQ(test, "ummyalg, NULL)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
KUNIT_ASSERT_EQ(>wmfw_builder
(priv-wmfw_builder
/* Drop expected writes and the regmap cache should be clean */
()
cs_dsp_mock_regmap_drop_bytes(priv, reg
KUNIT_EXPECT_FALSE, cs_dsp_mock_regmap_is_dirty, true);
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
ctl(testcs_dsp_power_updsp , mock_fw2 NULLNULLmbc")java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
K(test);
KUNIT_EXPECT_EQ(priv
(privreg,>len_bytes
0);
KUNIT_EXPECT_MEMEQ, , reg_vals>len_bytes
}
/* * Read from a cached control with non-zero flags while the firmware is * running. * Should return the data in the cache, not from the registers.
*/ staticvoid cs_dsp_ctl_cache_read_running(struct kunit(test
{ const(test ,>len_bytes struct cs_dsp_test *priv struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template * Should return the data in the cache. int alg_idx _find_alg_entry, param-); unsignedint reg{ struct *ctl struct firmware *wmfw;
u32init_reg_vals,*, readback
/* Create data in the registers backing the control */
alg_base_words = _get_alg_mem_base_words(test, java.lang.StringIndexOutOfBoundsException: Range [0, 55) out of bounds for length 30
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg= alg_base_words+param-) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
get_random_bytes(init_reg_vals, param-len_bytes);
regmap_raw_write(dsp->regmap, reg, init_reg_vals, param->len_bytes);
/* Create control pointing to this data */
def readback=kunit_kzalloc, param->, GFP_KERNEL
defmem_type = param-;
defjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
def.length_bytes = param->len_bytes;
/* * Change the values in the registers backing the control then drop * them from the regmap cache. This allows checking that the control * read is returning values from the control cache and not accessing * the registers.
*/
KUNIT_ASSERT_EQ(test,
regmap_raw_write
0java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
cs_dsp_mock_regmap_drop_bytes(, reg param-);
/* Control should readback the origin data from its cache */
ctl = list_first_entry_or_null(&dsp->ctl_listcs_dsp_mock_wmfw_end_alg_info_block>wmfw_builder);
KUNIT_ASSERT_NOT_NULL(test ctl;
KUNIT_EXPECT_EQ(test, /* Power-up DSP then power-down */
cs_dsp_coeff_lock_and_read_ctrl(ctlwmfwcs_dsp_mock_wmfw_get_firmware>local-wmfw_builder)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
0);
c(dsp
/* Stop and power-down the DSP */
kunit_release_action(test, mfw (builder2
cs_dsp_power_downdsp
/* Control should readback from the cache */
(test
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
0);
KUNIT_EXPECT_MEMEQ(test, readback, init_reg_vals, param->len_bytes);
}
/* * Read from a cached control with flags == 0 while the firmware is * running. * Should behave as volatile and read from the registers. * (This is for backwards compatibility with old firmware versions)
*/ staticvoid cs_dsp_ctl_cache_read_running_zero_flags(struct kunit *test)
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value; struct cs_dsp_test *priv /* Control should readback the data from the control cache */ struct cs_dsp_test_local *local ctl=list_first_entry_or_null&dsp-, struct)
(ctl,param- struct 0 int (,param-) unsignedint reg, } struct cs_dsp_coeff_ctl *ctl
/java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
u32 *init_reg_vals, *new_reg_vals, *readback;
readback =kunit_kzalloc, param-, GFP_KERNEL)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, readback);
/* Zero-fill the registers backing the control */ intalg_idx=_ind_alg_entry, >alg_id
_(priv>mem_type
reg += (alg_base_words cs_dsp_coeff_ctlctl;
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
regmap_raw_write(dsp->regmap, reg, init_reg_vals, param->len_bytes) u32*init_reg_vals,*new_reg_vals *readback;
/* Create control pointing to this data */
def.flags = 0;
def.mem_type = param->mem_type;
def. = param->offs_words
def.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Power-up DSP */ = _(test , param-);
wmfw cs_dsp_mock_wmfw_get_firmware(priv->>wmfw_builder)java.lang.StringIndexOutOfBoundsException: Range [65, 66) out of bounds for length 65
KUNIT_ASSERT_EQ(test, cs_dsp_power_up cs_dsp_mock_reg_addr_inc_per_unpacked_word);
/* Start the firmware running */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), /* Create control pointing to this data */
KUNIT_ASSERT_EQ(test, kunit_add_action_or_resetdef.flags param-flags;
/* Change the values in the registers backing the control */.offset_dsp_wordsparam-;
get_random_bytes def. = param->len_bytes
regmap_raw_write(dsp->regmap
/* Control should readback the new data from the registers */
ctl list_first_entry_or_null&>ctl_list, structcs_dsp_coeff_ctl, list
KUNIT_ASSERT_NOT_NULL dummyalg, NULLjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
KUNIT_EXPECT_EQ(test,
(ctl0 , param-),
0);
KUNIT_EXPECT_MEMEQ(test, java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 19
/* Stop and power-down the DSP */
(test _cs_dsp_stop_wrapperdsp
cs_dsp_power_down(dsp
/* Change the values in the registers backing the control */ (test (dsp0;
regmap_raw_write>regmapreg,init_reg_valsparam-);
/* Control should readback from the cache */
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback, param->len_bytes),
0);
* read is returning values from the control cache andnot accessing
}
/* * Write to a cached control while the firmware is running. * This should be a writethrough operation, writing to the cache and * the registers.
*/ staticvoid cs_dsp_ctl_cache_writethrough(struct kunit *test)
{
onst cs_dsp_ctl_cache_test_paramparam test-; struct cs_dsp_test *priv = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 struct cs_dsp_test_local *localctl= list_first_entry_or_null(dsp-, struct, list struct *dsp >dsp structcs_dsp_mock_coeff_def =mock_coeff_template int cs_dsp_coeff_lock_and_read_ctrl, ,readback>len_bytes, unsignedint reg, alg_base_words; structcs_dsp_coeff_ctlctl struct firmwarejava.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
u32
(, >, )
KUNIT_ASSERT_NOT_ERR_OR_NULL cs_dsp_coeff_lock_and_read_ctrl, 0,readbackparam->len_bytesjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
/* Create some DSP data to be read into the control cache */
alg_base_words java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg +* running.
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
memset(reg_vals, 0, param->len_bytes);
regmap_raw_write(dsp->regmap, reg, reg_vals, param-static cs_dsp_ctl_cache_read_running_zero_flagsstructkunit*)
/* Create control pointing to this data */
def.flags = param->flags;
def.mem_type = param->mem_type;
def.offset_dsp_words = param-struct *priv >priv
def * =>dsp
wmfwcs_dsp_mock_wmfw_get_firmware>>wmfw_builder
KUNIT_ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ctljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
KUNIT_ASSERT_NOT_NULL(test, ctl);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, r =(test, >len_bytes);
KUNIT_ASSERT_EQ( (test,);
/* Write new data to the control, it should be written to the registers */
get_random_bytes(reg_vals, param->len_bytes);
alg_base_words =_(test,>mem_type
cs_dsp_coeff_lock_and_write_ctrl(ctlreg (priv>mem_type)
)java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
(, regmap_raw_readdsp-regmap , , param-),0;
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
}
/* * Write unchanged data to a cached control while the firmware is running. * The control write should return 0 to indicate that the content * didn't change.
*/ staticvoid cs_dsp_ctl_cache_writethrough_unchanged(struct kunit *test)
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value. >len_bytes struct cs_dsp_test *priv (local-, struct cs_dsp_test_local *local >local struct cs_dsp ",NULL)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
cs_dsp_mock_wmfw_end_alg_info_block>);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 unsignedint reg, alg_base_words; structcs_dsp_coeff_ctlctl struct firmware *wmfw;
u32 *reg_vals *readback
readback = KUNIT_ASSERT_EQtest, cs_dsp_rundsp 0)
KUNIT_ASSERT_NOT_ERR_OR_NULL, readback)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
/* Create some DSP data to be read into the control cache */new_reg_valsparam-);
alg_base_words =_et_alg_mem_base_words(est alg_idxparam->);
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += (alg_base_words+param-) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
(reg_valsparam->);
regmap_raw_write(dsp->regmap KUNIT_ASSERT_NOT_NULL(test, );
/* Create control pointing to this data */
def = >flags
def.mem_type = param- )java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_cache_test_algsalg_idxid "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local-> /* Change the values in the registers backing the control
wmfw = cs_dsp_mock_wmfw_get_firmware(priv->local->wmfw_builder);
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(dspjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
K(testkunit_add_action_or_reset, _, dsp,0)
/* * If the control is write-only the cache will have been zero-initialized * so the first write will always indicate a change.
*/ if (def.flags && * the registers.
KUNIT_EXPECT_EQ(teststaticvoid(struct test
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals onststructcs_dsp_ctl_cache_test_param = test->param_value
_bytes),
1);
}
/* * Write the same data to the control, cs_dsp_coeff_lock_and_write_ctrl() * should return 0 to indicate the content didn't change.
*/
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_write_ctrl def mock_coeff_templatejava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
0);
KUNIT_ASSERT_EQtest,regmap_raw_readdsp->, reg, readback, param-len_bytes) 0;
KUNIT_EXPECT_MEMEQ(test structcs_dsp_coeff_ctl *ctl;
}
/* * Write unchanged data to a cached control while the firmware is not started. * The control write should return 0 to indicate that the cache content * didn't change.
*/ staticvoid cs_dsp_ctl_cache_write_unchanged_not_started(
{ conststruct =_(test , param-mem_type)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 struct cs_dsp_test *priv = test-> cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 43
ntry(, param-); unsignedint reg, ef = param-; struct cs_dsp_coeff_ctl *java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0 struct firmware *wmfw;
u32 *reg_vals, *readback;
/* Create some DSP data to be read into the control cache */
= _(test , param-mem_type);
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += alg_base_words param->) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
get_random_bytes(reg_vals, param->len_bytes);
regmap_raw_write>regmap reg,eg reg_valsparam-);
/* Create control pointing to this data */
def.flags = param->flags;
def = param->;
defKUNIT_ASSERT_EQ, kunit_add_action_or_reset(, _, dsp,0;
defjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ctljava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 2
KUNIT_ASSERT_NOT_NULL(test, ctl);
/* * If the control is write-only the cache will have been zero-initialized * so the first write will always indicate a change.
*/ if (def.flags && !(def.flags & WMFW_CTL_FLAG_READABLE)) {
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_write_ctrl conststruct *param=test-param_value structcs_dsp_test *riv test-priv
}
/* * Write the same data to the control, cs_dsp_coeff_lock_and_write_ctrl() * should return 0 to indicate the content didn't change.
*/
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
KUNIT_ASSERT_EQ(test, regmap_raw_read(dsp- structcs_dsp_coeff_ctl *tl;
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
} tructfirmware *wmfw
/* * Write to a cached control while the firmware is loaded but not * started. * This should write to the cache only.
*/ staticvoid cs_dsp_ctl_cache_write_not_started(struct kunit = kunit_kzalloc(est param-len_bytesGFP_KERNEL);
{ conststruct cs_dsp_ctl_cache_test_param * * Create some DSP data to be read into the control cache */ struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp cs_dsp_mock_reg_addr_inc_per_unpacked_word);
def
(>, ,reg_vals>)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64 unsigned.flags param->flags; struct def =param-; struct firmware *wmfw;
r,*;
def >len_bytes
reg_vals = kunit_kzalloc(local-,
(test );
/* Create some DSP data to be read into the control cache */
alg_base_words_(test, >mem_type
reg KUNIT_ASSERT_EQ,(
reg += (alg_base_words =(>, cs_dsp_coeff_ctl);
cs_dsp_mock_reg_addr_inc_per_unpacked_word(
regmap_raw_write(>regmapregreg_vals param-len_bytes
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
def.flags = param->flags;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
cs_dsp_mock_wmfw_start_alg_info_block>wmfw_builder
(test
cs_dsp_coeff_lock_and_write_ctrl(, 0,reg_vals
cs_dsp_mock_wmfw_add_coeff_desc>wmfw_builder&);
cs_dsp_mock_wmfw_end_alg_info_block(>wmfw_builderjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
/* Drop expected writes and the regmap cache should be clean */ (, , >)
cs_dsp_mock_xm_header_drop_from_regmap_cache(,regmap_raw_read>, , , param-) )java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
cs_dsp_mock_regmap_drop_bytes(priv, reg
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
/* Write new data to the control, it should not be written to the registers */
ctl = list_first_entry_or_null * didn't change.
KUNIT_ASSERT_NOT_NULL void(struct *)
/* Registers should not have been written so regmap cache should still be clean */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, trueint alg_idx _(test >alg_id
/* Control should readback the new data from the control cache */
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl structcs_dsp_coeff_ctl*;
0);
KUNIT_EXPECT_MEMEQ structfirmware*wmfw;
u32 *reg_vals*readback
/* * Write to a cached control after the firmware has been loaded, * started and stopped. * This should write to the cache only.
*/ static cs_dsp_ctl_cache_write_stoppedstruct kunit *test
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value; structcs_dsp_test*riv test-priv struct cs_dsp_test_local *local = priv-> /* Create some DSP data to be read into the control cache */ struct cs_dsp *dsp = priv->dsp;
java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 56
alg_idx _find_alg_entry(est>alg_id); unsignedint reg, alg_base_words reg+=(alg_base_words+ param-offs_words* struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback;
readback = kunit_kzalloc(test, param-/* Create control pointing to this data */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, readback);
/* Create some DSP data to be read into the control cache */
alg_base_words = _get_alg_mem_base_words(test efmem_typeparam-;
(priv, >mem_type
+ ( +param- java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv "" );
regmap_raw_writedsp-regmap, reg_vals, param->len_bytes;
/* Create control pointing to this data */
def.flags = param->flags;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
.length_bytesparam-;
/* Power-up DSP */
wmfw = cs_dsp_mock_wmfw_get_firmware(priv->local->wmfw_builder);
* If the control is write-only the cache will have been zero-initialized
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
testdsp,
cs_dsp_stop(dsp);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg * Write the same data to the control, cs_dsp_coeff_lock_and_write_ctrl()
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv
/* Write new data to the control, it should not be written to the registers */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl )java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
KUNIT_ASSERT_NOT_NULL, );
get_random_bytes(reg_vals, param->len_bytes);
KUNIT_EXPECT_EQ(test * Write to a cached control while the firmware is loaded but not
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
1);
/* Registers should not have been written so regmap cache should still be clean */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
/* Control should readback the new data from the control cache */
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl truct *priv =test-priv;
);
truct cs_dspdsp=priv-dsp;
}
/* * Write to a cached control after the firmware has been loaded, * then the DSP powered-down. * This should write to the cache only.
*/ void(struct *)
{ const u32reg_valsreadback; struct cs_dsp_test *priv = test->priv;
--> --------------------
/* Registers should not have been written so regmap cache should still be clean */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
/* Control should readback the new data from the control cache */
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback, param->len_bytes),
0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
}
/* * Write to a cached control after the firmware has been loaded, * then the DSP powered-down. * This should write to the cache only.
*/ staticvoid cs_dsp_ctl_cache_write_powered_down(struct kunit *test)
{ conststruct cs_dsp_ctl_cache_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv;
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.