Skip to content

Commit 49e1138

Browse files
kv2019ilgirdwood
authored andcommitted
module: share the fast_get copies of LL modules in the LL fast_get area
LL modules in user mode get a private copy of their fast_get data, such as SRC coefficients, in the module memory. Every instance makes its own copy, and LL threads can write it. Get the copies with fast_get_ll() instead, and release them with fast_put_ll(), so instances share a read-only copy in the fast_get area of the LL memory region. The resource is tracked as before, in user mode. When the area is full, fall back to a private copy. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 94ef2a1 commit 49e1138

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

‎src/audio/module_adapter/module/generic.c‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,13 @@ const void *z_impl_mod_fast_get(struct processing_module *mod, const void * cons
489489
return NULL;
490490
}
491491

492-
ptr = fast_get(res->alloc, dram_ptr, size);
492+
#if CONFIG_SOF_USERSPACE_LL
493+
/* only LL modules use their resources in user mode, see mod_res_user() */
494+
if (k_is_user_context())
495+
ptr = fast_get_ll(dram_ptr, size);
496+
else
497+
#endif
498+
ptr = fast_get(res->alloc, dram_ptr, size);
493499
if (!ptr) {
494500
container_put(mod, container);
495501
mod_res_unlock();
@@ -525,6 +531,12 @@ static int free_contents(struct processing_module *mod, struct module_resource *
525531
#endif
526532
#if CONFIG_FAST_GET
527533
case MOD_RES_FAST_GET:
534+
#if CONFIG_SOF_USERSPACE_LL
535+
if (k_is_user_context()) {
536+
fast_put_ll(container->sram_ptr);
537+
return 0;
538+
}
539+
#endif
528540
#if CONFIG_USERSPACE
529541
mdom = mod->mdom;
530542
#else
@@ -678,9 +690,9 @@ EXPORT_SYMBOL(mod_data_blob_set);
678690
#if CONFIG_FAST_GET
679691
#if CONFIG_SOF_USERSPACE_LL
680692
/*
681-
* fast_get() keeps its state in kernel memory, so LL modules in user mode
682-
* get a private copy in the module memory instead of a shared one. The
683-
* copy is a heap resource, so mod_fast_put() frees it with mod_free().
693+
* When the fast_get area of the LL memory region is full, LL modules get a
694+
* private copy in the module memory instead of a shared one. The copy is a
695+
* heap resource, so mod_fast_put() frees it with mod_free().
684696
*/
685697
static const void *mod_fast_get_copy(struct processing_module *mod,
686698
const void * const dram_ptr, size_t size)
@@ -701,8 +713,11 @@ const void *mod_fast_get(struct processing_module *mod, const void * const dram_
701713
size_t size)
702714
{
703715
#if CONFIG_SOF_USERSPACE_LL
704-
if (mod_res_user(mod))
705-
return mod_fast_get_copy(mod, dram_ptr, size);
716+
if (mod_res_user(mod)) {
717+
const void *ptr = z_impl_mod_fast_get(mod, dram_ptr, size);
718+
719+
return ptr ? ptr : mod_fast_get_copy(mod, dram_ptr, size);
720+
}
706721
#endif
707722

708723
return mod_dp_fast_get(mod, dram_ptr, size);

0 commit comments

Comments
 (0)