Skip to content

Commit c5ce6e0

Browse files
committed
fast-get: allocate on specific heap
Pass a "heap" argument to fast_get() and fast_put() for user-space DP allocations. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 2cc43c2 commit c5ce6e0

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/audio/module_adapter/module/generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ const void *mod_fast_get(struct processing_module *mod, const void * const dram_
326326
if (!container)
327327
return NULL;
328328

329-
ptr = fast_get(dram_ptr, size);
329+
ptr = fast_get(res->heap, dram_ptr, size);
330330
if (!ptr) {
331331
container_put(mod, container);
332332
return NULL;
@@ -358,7 +358,7 @@ static int free_contents(struct processing_module *mod, struct module_resource *
358358
#endif
359359
#if CONFIG_FAST_GET
360360
case MOD_RES_FAST_GET:
361-
fast_put(container->sram_ptr);
361+
fast_put(res->heap, container->sram_ptr);
362362
return 0;
363363
#endif
364364
default:

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

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

1111
#include <stddef.h>
1212

13-
const void *fast_get(const void * const dram_ptr, size_t size);
14-
void fast_put(const void *sram_ptr);
13+
struct k_heap;
14+
const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size);
15+
void fast_put(struct k_heap *heap, const void *sram_ptr);
1516

1617
#endif /* __SOF_LIB_FAST_GET_H__ */

zephyr/lib/fast-get.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static struct sof_fast_get_entry *fast_get_find_entry(struct sof_fast_get_data *
8080
return NULL;
8181
}
8282

83-
const void *fast_get(const void *dram_ptr, size_t size)
83+
const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
8484
{
8585
struct sof_fast_get_data *data = &fast_get_data;
8686
struct sof_fast_get_entry *entry;
@@ -116,7 +116,7 @@ const void *fast_get(const void *dram_ptr, size_t size)
116116
goto out;
117117
}
118118

119-
ret = rmalloc(SOF_MEM_FLAG_USER, size);
119+
ret = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, size, 0);
120120
if (!ret)
121121
goto out;
122122
entry->size = size;
@@ -146,7 +146,7 @@ static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data *
146146
return NULL;
147147
}
148148

149-
void fast_put(const void *sram_ptr)
149+
void fast_put(struct k_heap *heap, const void *sram_ptr)
150150
{
151151
struct sof_fast_get_data *data = &fast_get_data;
152152
struct sof_fast_get_entry *entry;
@@ -160,7 +160,7 @@ void fast_put(const void *sram_ptr)
160160
}
161161
entry->refcount--;
162162
if (!entry->refcount) {
163-
rfree(entry->sram_ptr);
163+
sof_heap_free(heap, entry->sram_ptr);
164164
memset(entry, 0, sizeof(*entry));
165165
}
166166
out:

0 commit comments

Comments
 (0)