Skip to content

Commit 07a7ee7

Browse files
committed
fast-get: switch to module allocation context
fast-get has to choose which allocation method to use, it needs access to the full module allocation context. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 971ba3c commit 07a7ee7

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/audio/module_adapter/module/generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ const void *z_impl_mod_fast_get(struct processing_module *mod, const void * cons
323323
if (!container)
324324
return NULL;
325325

326-
ptr = fast_get(res->alloc->heap, dram_ptr, size);
326+
ptr = fast_get(res->alloc, dram_ptr, size);
327327
if (!ptr) {
328328
container_put(mod, container);
329329
return NULL;
@@ -362,7 +362,7 @@ static int free_contents(struct processing_module *mod, struct module_resource *
362362
#else
363363
mdom = NULL;
364364
#endif
365-
fast_put(res->alloc->heap, mdom, container->sram_ptr);
365+
fast_put(res->alloc, mdom, container->sram_ptr);
366366
return 0;
367367
#endif
368368
default:

src/include/sof/lib/fast-get.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
#include <stddef.h>
1212

13-
struct k_heap;
1413
struct k_mem_domain;
14+
struct mod_alloc_ctx;
1515

1616
/*
1717
* When built for SOF, fast_get() and fast_put() are only needed when DRAM
@@ -25,14 +25,16 @@ struct k_mem_domain;
2525
#if (CONFIG_COLD_STORE_EXECUTE_DRAM && \
2626
(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE || !defined(LL_EXTENSION_BUILD))) || \
2727
!CONFIG_SOF_FULL_ZEPHYR_APPLICATION
28-
const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size);
29-
void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_ptr);
28+
const void *fast_get(struct mod_alloc_ctx *alloc, const void * const dram_ptr, size_t size);
29+
void fast_put(struct mod_alloc_ctx *alloc, struct k_mem_domain *mdom, const void *sram_ptr);
3030
#else
31-
static inline const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size)
31+
static inline const void *fast_get(struct mod_alloc_ctx *alloc, const void * const dram_ptr,
32+
size_t size)
3233
{
3334
return dram_ptr;
3435
}
35-
static inline void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_ptr) {}
36+
static inline void fast_put(struct mod_alloc_ctx *alloc, struct k_mem_domain *mdom,
37+
const void *sram_ptr) {}
3638
#endif
3739

3840
#endif /* __SOF_LIB_FAST_GET_H__ */

zephyr/lib/fast-get.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stdint.h>
99
#include <errno.h>
1010

11+
#include <sof/audio/component.h>
1112
#include <sof/lib/fast-get.h>
1213
#include <rtos/alloc.h>
1314
#include <rtos/cache.h>
@@ -125,8 +126,9 @@ static int fast_get_access_grant(struct k_mem_domain *mdom, void *addr, size_t s
125126
}
126127
#endif /* CONFIG_USERSPACE */
127128

128-
const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
129+
const void *fast_get(struct mod_alloc_ctx *alloc, const void *dram_ptr, size_t size)
129130
{
131+
struct k_heap *heap = alloc ? alloc->heap : NULL;
130132
#if CONFIG_USERSPACE
131133
bool current_is_userspace = thread_is_userspace(k_current_get());
132134
#endif
@@ -266,8 +268,9 @@ static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data *
266268
return NULL;
267269
}
268270

269-
void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_ptr)
271+
void fast_put(struct mod_alloc_ctx *alloc, struct k_mem_domain *mdom, const void *sram_ptr)
270272
{
273+
struct k_heap *heap = alloc ? alloc->heap : NULL;
271274
struct sof_fast_get_data *data = &fast_get_data;
272275
struct sof_fast_get_entry *entry;
273276
k_spinlock_key_t key;

0 commit comments

Comments
 (0)