Skip to content

Commit 759d07c

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 ea9edfb commit 759d07c

3 files changed

Lines changed: 14 additions & 11 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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 6 additions & 5 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/module_adapter/module/generic.h>
1112
#include <sof/lib/fast-get.h>
1213
#include <rtos/alloc.h>
1314
#include <rtos/cache.h>
@@ -125,7 +126,7 @@ 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
{
130131
#if CONFIG_USERSPACE
131132
bool current_is_userspace = thread_is_userspace(k_current_get());
@@ -220,7 +221,7 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
220221
* SRAM copy will be allocated on its own heap, so it will have access
221222
* to it
222223
*/
223-
ret = sof_heap_alloc(heap, alloc_flags, alloc_size, alloc_align);
224+
ret = sof_heap_alloc(alloc->heap, alloc_flags, alloc_size, alloc_align);
224225
if (!ret)
225226
goto out;
226227

@@ -232,7 +233,7 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
232233

233234
if (err < 0) {
234235
LOG_ERR("failed to grant access err=%d", err);
235-
sof_heap_free(heap, ret);
236+
sof_heap_free(alloc->heap, ret);
236237
ret = NULL;
237238
goto out;
238239
}
@@ -266,7 +267,7 @@ static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data *
266267
return NULL;
267268
}
268269

269-
void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_ptr)
270+
void fast_put(struct mod_alloc_ctx *alloc, struct k_mem_domain *mdom, const void *sram_ptr)
270271
{
271272
struct sof_fast_get_data *data = &fast_get_data;
272273
struct sof_fast_get_entry *entry;
@@ -283,7 +284,7 @@ void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_p
283284

284285
if (!entry->refcount) {
285286
LOG_DBG("freeing buffer %p", sram_ptr);
286-
sof_heap_free(heap, entry->sram_ptr);
287+
sof_heap_free(alloc->heap, entry->sram_ptr);
287288
}
288289

289290
#if CONFIG_USERSPACE

0 commit comments

Comments
 (0)