Skip to content

Commit 0c0e552

Browse files
committed
module_adapter: make fragmented-transfer size per-instance
The reassembly size for fragmented runtime-params transfers was a file-scope static shared by every component, so interleaved transfers to different components corrupted each other's state. Move it into per-instance module state. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 6890f78 commit 0c0e552

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/audio/module_adapter/module_adapter_ipc3.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,25 @@ static int module_adapter_get_set_params(struct comp_dev *dev, struct sof_ipc_ct
184184
const struct module_interface *const interface = mod->dev->drv->adapter_ops;
185185
enum module_cfg_fragment_position pos;
186186
uint32_t data_offset_size;
187-
static uint32_t size;
187+
/* per-instance reassembly size; a file-scope static would be shared
188+
* across all module_adapter components and corrupted by interleaved
189+
* fragmented transfers
190+
*/
191+
uint32_t *size = &mod->runtime_params_size;
188192

189193
comp_dbg(dev, "num_of_elem %d, elem remain %d msg_index %u",
190194
cdata->num_elems, cdata->elems_remaining, cdata->msg_index);
191195

192196
/* set the fragment position, data offset and config data size */
193197
if (!cdata->msg_index) {
194-
size = cdata->num_elems + cdata->elems_remaining;
195-
data_offset_size = size;
198+
*size = cdata->num_elems + cdata->elems_remaining;
199+
data_offset_size = *size;
196200
if (cdata->elems_remaining)
197201
pos = MODULE_CFG_FRAGMENT_FIRST;
198202
else
199203
pos = MODULE_CFG_FRAGMENT_SINGLE;
200204
} else {
201-
data_offset_size = size - (cdata->num_elems + cdata->elems_remaining);
205+
data_offset_size = *size - (cdata->num_elems + cdata->elems_remaining);
202206
if (cdata->elems_remaining)
203207
pos = MODULE_CFG_FRAGMENT_MIDDLE;
204208
else

src/include/module/module/base.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ struct processing_module {
118118
uint32_t deep_buff_bytes; /**< copy start threshold */
119119
uint32_t output_buffer_size; /**< size of local buffer to save produced samples */
120120

121+
/* total size of a fragmented runtime-params (get/set) transfer, kept
122+
* per instance so concurrent transfers to different components do not
123+
* corrupt each other's reassembly state
124+
*/
125+
uint32_t runtime_params_size;
126+
121127
/* number of sinks / sources and (when in use) input_buffers / input_buffers */
122128
uint32_t num_of_sources;
123129
uint32_t num_of_sinks;

0 commit comments

Comments
 (0)