Skip to content

Commit 9ca0771

Browse files
committed
component: dp: Allocate task structure from module driver heap
Allocate task structures from the module's driver heap to enable userspace access. This change allows the DP task to operate in userspace context. Also update LL task allocation to use the same heap for consistency, as the memory release logic is shared and does not differentiate between heaps. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent 8285bc6 commit 9ca0771

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/idc/idc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ static int idc_prepare(uint32_t comp_id)
184184
/* we're running LL on different core, so allocate our own task */
185185
if (!dev->task && dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL) {
186186
/* allocate task for shared component */
187-
dev->task = rzalloc(SOF_MEM_FLAG_USER,
188-
sizeof(*dev->task));
187+
dev->task = module_driver_heap_rzalloc(dev->drv->user_heap, SOF_MEM_FLAG_USER,
188+
sizeof(*dev->task));
189189
if (!dev->task) {
190190
ret = -ENOMEM;
191191
goto out;
@@ -197,7 +197,7 @@ static int idc_prepare(uint32_t comp_id)
197197
dev->priority, comp_task, dev,
198198
dev->ipc_config.core, 0);
199199
if (ret < 0) {
200-
rfree(dev->task);
200+
module_driver_heap_free(dev->drv->user_heap, dev->task);
201201
goto out;
202202
}
203203
}

src/include/sof/audio/component_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static inline void comp_free(struct comp_dev *dev)
5050
if ((dev->is_shared || dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) &&
5151
dev->task) {
5252
schedule_task_free(dev->task);
53-
rfree(dev->task);
53+
module_driver_heap_free(dev->drv->user_heap, dev->task);
5454
dev->task = NULL;
5555
}
5656

src/schedule/zephyr_dp_schedule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ int scheduler_dp_task_init(struct task **task,
477477
size_t stack_size)
478478
{
479479
void __sparse_cache *p_stack = NULL;
480+
struct sys_heap *const user_heap = mod->dev->drv->user_heap;
480481

481482
/* memory allocation helper structure */
482483
struct {
@@ -496,8 +497,8 @@ int scheduler_dp_task_init(struct task **task,
496497
* As the structure contains zephyr kernel specific data, it must be located in
497498
* shared, non cached memory
498499
*/
499-
task_memory = rzalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT,
500-
sizeof(*task_memory));
500+
task_memory = module_driver_heap_rzalloc(user_heap, SOF_MEM_FLAG_USER |
501+
SOF_MEM_FLAG_COHERENT, sizeof(*task_memory));
501502
if (!task_memory) {
502503
tr_err(&dp_tr, "memory alloc failed");
503504
return -ENOMEM;
@@ -542,7 +543,7 @@ int scheduler_dp_task_init(struct task **task,
542543
err:
543544
/* cleanup - free all allocated resources */
544545
rfree((__sparse_force void *)p_stack);
545-
rfree(task_memory);
546+
module_driver_heap_free(user_heap, task_memory);
546547
return ret;
547548
}
548549

0 commit comments

Comments
 (0)