Skip to content

Commit 64cadca

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 913a776 commit 64cadca

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/audio/module_adapter/module_adapter_ipc3.c

Lines changed: 9 additions & 5 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;
188187

189188
comp_dbg(dev, "num_of_elem %d, elem remain %d msg_index %u",
190189
cdata->num_elems, cdata->elems_remaining, cdata->msg_index);
191190

192-
/* set the fragment position, data offset and config data size */
191+
/*
192+
* The total fragmented-transfer size is kept per instance in
193+
* mod->runtime_params_size; a file-scope static would be shared across
194+
* all module_adapter components and corrupted by interleaved transfers.
195+
*/
193196
if (!cdata->msg_index) {
194-
size = cdata->num_elems + cdata->elems_remaining;
195-
data_offset_size = size;
197+
mod->runtime_params_size = cdata->num_elems + cdata->elems_remaining;
198+
data_offset_size = mod->runtime_params_size;
196199
if (cdata->elems_remaining)
197200
pos = MODULE_CFG_FRAGMENT_FIRST;
198201
else
199202
pos = MODULE_CFG_FRAGMENT_SINGLE;
200203
} else {
201-
data_offset_size = size - (cdata->num_elems + cdata->elems_remaining);
204+
data_offset_size = mod->runtime_params_size -
205+
(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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ struct processing_module {
203203
struct userspace_context *user_ctx;
204204
struct k_mem_domain *mdom;
205205
#endif /* CONFIG_USERSPACE */
206+
207+
/* total size of a fragmented runtime-params (get/set) transfer, kept
208+
* per instance so concurrent transfers to different components do not
209+
* corrupt each other's reassembly state. Appended here to avoid shifting
210+
* the offsets of the fields above.
211+
*/
212+
uint32_t runtime_params_size;
206213
#endif /* SOF_MODULE_PRIVATE */
207214
};
208215

0 commit comments

Comments
 (0)