Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b97f7d2
ipc: move standalone-test check later in ipc_init()
kv2019i Feb 10, 2026
3541895
audio: component: add comp_grant_access_to_thread()
kv2019i Feb 13, 2026
4f9e962
pipeline: protect component connections with a mutex
kv2019i Feb 12, 2026
b126168
zephyr: lib: make sof_heap_alloc/free system calls
kv2019i Feb 13, 2026
25f0b93
schedule: zephyr_ll_user: make the heap accessible from user-space
kv2019i Feb 13, 2026
f69a256
schedule: zephyr_ll: convert pdata->sem into a dynamic object
kv2019i Feb 13, 2026
fde1f7a
schedule: zephyr_ll_user: move user accessible heap to common partition
kv2019i Feb 13, 2026
ebd9051
dma: dma_sg: allocate on specific heap
kv2019i Feb 16, 2026
c7bed70
buffer: extend ability to allocate on specific heap to all functions
kv2019i Feb 16, 2026
e07dc8b
(section host-zephyr START)
kv2019i Feb 19, 2026
dc115ed
zephyr: userspace: sof_dma: allow circular SG lists
kv2019i Feb 19, 2026
636ba1c
zephyr: lib: dma: make DMA platform data available to user-space
kv2019i Feb 13, 2026
ec83dde
audio: host-zephyr: select heap when allocating host buffers
kv2019i Feb 13, 2026
b351305
audio: host-zephyr: rework calls to DMA driver, remove channel pointer
kv2019i Feb 16, 2026
7ecd7f6
audio: host-zephyr: pass component heap to dma_sg_alloc
kv2019i Feb 16, 2026
700b541
alloc.h: remove rbrelloac() and rbrealloc_align()
kv2019i Feb 16, 2026
c062dd9
audio: host-zephyr: ensure host data heap is set
kv2019i Feb 16, 2026
ef44516
audio: host-zephyr: make component usable from user-space
kv2019i Feb 16, 2026
94e8f33
(section host-zephyr STOP)
kv2019i Feb 19, 2026
765b87d
(section dai-zephyr START)
kv2019i Feb 19, 2026
ed28d58
audio: pcm_converter: make global tables available to user-space
kv2019i Feb 17, 2026
c294841
audio: comp_buffer: do not call notifier interface in user-space
kv2019i Feb 17, 2026
fa1c684
audio: dai-zephyr: make memory allocations user-space compatible
kv2019i Feb 17, 2026
0b2a2bd
lib: dai: make dai_get() and dai_put() compatible with user-space
kv2019i Feb 17, 2026
7a42193
audio: dai-zephyr: rework calls to DMA driver, remove channel pointer
kv2019i Feb 17, 2026
241237a
audio: dai-zephyr: convert spinlock into mutex for properties
kv2019i Feb 17, 2026
9168750
audio: dai-zephyr: migrate to use dai_get_properties_copy()
kv2019i Feb 18, 2026
758108c
(section dai-zephyr STOP)
kv2019i Feb 19, 2026
968f3be
(section audio module infra START)
kv2019i Mar 3, 2026
aab4929
audio: module_adapter: alloc from LL user heap if LL run in user
kv2019i Feb 12, 2026
dff1d0d
audio: copier: export copier endpoint ops to user-space
kv2019i Feb 26, 2026
e616b85
(section schduler changes START)
kv2019i Mar 3, 2026
84b7699
schedule: zephyr_ll: add zephyr_ll_task_free()
kv2019i Feb 26, 2026
4555d75
schedule: zephyr_ll: add zephyr_ll_grant_access()
kv2019i Feb 26, 2026
b1acb18
schedule: zephyr_ll_user: make double-mapping conditional
kv2019i Mar 4, 2026
c423e88
schedule: allocate the scheduler objects with sof_heap_alloc
kv2019i Feb 26, 2026
a06a809
WIP: schedule: limit user-LL to core0
kv2019i Feb 26, 2026
a000ee2
zephyr: schedule: allow user-space to access scheduler list
kv2019i Feb 26, 2026
767a616
zephyr: wrapper: modify platform_dai_wallclock() for user-space
kv2019i Feb 26, 2026
4510838
schedule: add scheduler_init_context() and scheduler_free_context()
kv2019i Feb 27, 2026
b343b2b
schedule: zephyr_ll: implement scheduler_init_context()
kv2019i Feb 26, 2026
9b8f418
schedule: ll_schedule_domain: add domain_thread_init/free ops
kv2019i Mar 4, 2026
b99292c
schedule: zephyr_ll: implement thread_init/free domain ops
kv2019i Mar 4, 2026
47fc114
(section schduler changes END)
kv2019i Mar 3, 2026
13c633a
(section test-case START)
kv2019i Feb 19, 2026
2edba05
zephyr: test: userspace: add pipeline_two_components test
kv2019i Feb 9, 2026
2dce169
(section WIP mandatory changes START)
kv2019i Feb 19, 2026
37b0412
WIP: audio: comp_buffer: do not free the module heap in free()
kv2019i Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions posix/include/rtos/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,6 @@ static inline void *rballoc(uint32_t flags, size_t bytes)
return rballoc_align(flags, bytes, PLATFORM_DCACHE_ALIGN);
}

/**
* Changes size of the memory block allocated.
* @param ptr Address of the block to resize.
* @param flags Flags, see SOF_MEM_FLAG_...
* @param bytes New size in bytes.
* @param old_bytes Old size in bytes.
* @param alignment Alignment in bytes.
* @return Pointer to the resized memory of NULL if failed.
*/
void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes,
size_t old_bytes, uint32_t alignment);

/**
* Similar to rballoc_align(), returns resized buffer aligned to
* PLATFORM_DCACHE_ALIGN.
*/
static inline void *rbrealloc(void *ptr, uint32_t flags,
size_t bytes, size_t old_bytes)
{
return rbrealloc_align(ptr, flags, bytes, old_bytes,
PLATFORM_DCACHE_ALIGN);
}

/**
* Frees the memory block.
* @param ptr Pointer to the memory block.
Expand Down
6 changes: 4 additions & 2 deletions posix/include/sof/lib/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

struct comp_buffer;
struct comp_dev;
struct k_heap;

/** \addtogroup sof_dma_drivers DMA Drivers
* DMA Drivers API specification.
Expand Down Expand Up @@ -511,13 +512,14 @@ static inline void dma_sg_init(struct dma_sg_elem_array *ea)
ea->elems = NULL;
}

int dma_sg_alloc(struct dma_sg_elem_array *ea,
int dma_sg_alloc(struct k_heap *heap,
struct dma_sg_elem_array *ea,
uint32_t flags,
uint32_t direction,
uint32_t buffer_count, uint32_t buffer_bytes,
uintptr_t dma_buffer_addr, uintptr_t external_addr);

void dma_sg_free(struct dma_sg_elem_array *ea);
void dma_sg_free(struct k_heap *heap, struct dma_sg_elem_array *ea);

/**
* \brief Get the total size of SG buffer
Expand Down
63 changes: 32 additions & 31 deletions src/audio/buffers/comp_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,31 @@ static void comp_buffer_free(struct sof_audio_buffer *audio_buffer)

buf_dbg(buffer, "buffer_free()");

#ifndef CONFIG_SOF_USERSPACE_LL
/* TODO: to be replaced with direct function calls */
notifier_event(buffer, NOTIFIER_ID_BUFFER_FREE,
NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data));

/* In case some listeners didn't unregister from buffer's callbacks */
notifier_unregister_all(NULL, buffer);
#endif

struct k_heap *heap = buffer->audio_buffer.heap;

rfree(buffer->stream.addr);
sof_heap_free(heap, buffer->stream.addr);
sof_heap_free(heap, buffer);
#ifndef CONFIG_SOF_USERSPACE_LL
/*
* TODO: this is not the correct place to free up
* mod_heap_user
*/
if (heap) {
struct dp_heap_user *mod_heap_user = container_of(heap, struct dp_heap_user, heap);

if (!--mod_heap_user->client_count)
rfree(mod_heap_user);
}
#endif
}

APP_TASK_DATA static const struct source_ops comp_buffer_source_ops = {
Expand Down Expand Up @@ -218,6 +227,7 @@ static struct comp_buffer *buffer_alloc_struct(struct k_heap *heap,

memset(buffer, 0, sizeof(*buffer));

buffer->heap = heap;
buffer->flags = flags;
/* Force channels to 2 for init to prevent bad call to clz in buffer_init_stream */
buffer->stream.runtime_stream_params.channels = 2;
Expand Down Expand Up @@ -254,7 +264,7 @@ struct comp_buffer *buffer_alloc(struct k_heap *heap, size_t size, uint32_t flag
return NULL;
}

stream_addr = rballoc_align(flags, size, align);
stream_addr = sof_heap_alloc(heap, flags, size, align);
if (!stream_addr) {
tr_err(&buffer_tr, "could not alloc size = %zu bytes of flags = 0x%x",
size, flags);
Expand All @@ -264,9 +274,11 @@ struct comp_buffer *buffer_alloc(struct k_heap *heap, size_t size, uint32_t flag
buffer = buffer_alloc_struct(heap, stream_addr, size, flags, is_shared);
if (!buffer) {
tr_err(&buffer_tr, "could not alloc buffer structure");
rfree(stream_addr);
sof_heap_free(heap, stream_addr);
}

buffer->heap = heap;

return buffer;
}

Expand All @@ -292,7 +304,7 @@ struct comp_buffer *buffer_alloc_range(struct k_heap *heap, size_t preferred_siz
preferred_size += minimum_size - preferred_size % minimum_size;

for (size = preferred_size; size >= minimum_size; size -= minimum_size) {
stream_addr = rballoc_align(flags, size, align);
stream_addr = sof_heap_alloc(heap, flags, size, align);
if (stream_addr)
break;
}
Expand All @@ -308,9 +320,11 @@ struct comp_buffer *buffer_alloc_range(struct k_heap *heap, size_t preferred_siz
buffer = buffer_alloc_struct(heap, stream_addr, size, flags, is_shared);
if (!buffer) {
tr_err(&buffer_tr, "could not alloc buffer structure");
rfree(stream_addr);
sof_heap_free(heap, stream_addr);
}

buffer->heap = heap;

return buffer;
}

Expand Down Expand Up @@ -341,14 +355,8 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignmen
if (size == audio_stream_get_size(&buffer->stream))
return 0;

if (!alignment)
new_ptr = rbrealloc(audio_stream_get_addr(&buffer->stream),
buffer->flags | SOF_MEM_FLAG_NO_COPY,
size, audio_stream_get_size(&buffer->stream));
else
new_ptr = rbrealloc_align(audio_stream_get_addr(&buffer->stream),
buffer->flags | SOF_MEM_FLAG_NO_COPY, size,
audio_stream_get_size(&buffer->stream), alignment);
new_ptr = sof_heap_alloc(buffer->heap, buffer->flags, size, alignment);

/* we couldn't allocate bigger chunk */
if (!new_ptr && size > audio_stream_get_size(&buffer->stream)) {
buf_err(buffer, "resize can't alloc %u bytes of flags 0x%x",
Expand All @@ -357,8 +365,10 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignmen
}

/* use bigger chunk, else just use the old chunk but set smaller */
if (new_ptr)
if (new_ptr) {
sof_heap_free(buffer->heap, audio_stream_get_addr(&buffer->stream));
buffer->stream.addr = new_ptr;
}

buffer_init_stream(buffer, size);

Expand Down Expand Up @@ -389,22 +399,11 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
if (preferred_size == actual_size)
return 0;

if (!alignment) {
for (new_size = preferred_size; new_size >= minimum_size;
new_size -= minimum_size) {
new_ptr = rbrealloc(ptr, buffer->flags | SOF_MEM_FLAG_NO_COPY,
new_size, actual_size);
if (new_ptr)
break;
}
} else {
for (new_size = preferred_size; new_size >= minimum_size;
new_size -= minimum_size) {
new_ptr = rbrealloc_align(ptr, buffer->flags | SOF_MEM_FLAG_NO_COPY,
new_size, actual_size, alignment);
if (new_ptr)
break;
}
for (new_size = preferred_size; new_size >= minimum_size;
new_size -= minimum_size) {
new_ptr = sof_heap_alloc(buffer->heap, buffer->flags, new_size, alignment);
if (new_ptr)
break;
}

/* we couldn't allocate bigger chunk */
Expand All @@ -415,8 +414,10 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
}

/* use bigger chunk, else just use the old chunk but set smaller */
if (new_ptr)
if (new_ptr) {
sof_heap_free(buffer->heap, audio_stream_get_addr(&buffer->stream));
buffer->stream.addr = new_ptr;
}

buffer_init_stream(buffer, new_size);

Expand Down
8 changes: 8 additions & 0 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,3 +699,11 @@ void comp_update_ibs_obs_cpc(struct comp_dev *dev)
#endif
}

#ifdef CONFIG_SOF_USERSPACE_LL
void comp_grant_access_to_thread(const struct comp_dev *dev, struct k_thread *th)
{
assert(dev->list_mutex);
tr_dbg(&ipc_tr, "grant access to mutex %p for thread %p", dev->list_mutex, th);
k_thread_access_grant(th, dev->list_mutex);
}
#endif
4 changes: 2 additions & 2 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ __cold static int copier_unbind(struct processing_module *mod, struct bind_info
return 0;
}

static struct module_endpoint_ops copier_endpoint_ops = {
static APP_TASK_DATA const struct module_endpoint_ops copier_endpoint_ops = {
.get_total_data_processed = copier_get_processed_data,
.position = copier_position,
.dai_ts_config = copier_dai_ts_config_op,
Expand All @@ -1198,7 +1198,7 @@ static struct module_endpoint_ops copier_endpoint_ops = {
.trigger = copier_comp_trigger
};

static const struct module_interface copier_interface = {
static APP_TASK_DATA const struct module_interface copier_interface = {
.init = copier_init,
.prepare = copier_prepare,
.process_audio_stream = copier_process,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ __cold static int copier_dai_init(struct comp_dev *dev,
if (!dd)
return -ENOMEM;
memset(dd, 0, sizeof(*dd));
dd->chan_index = -1;
comp_info(dev, "dd %p initialized, index %d", dd, dd->chan_index);

ret = dai_common_new(dd, dev, dai);
if (ret < 0)
Expand Down
4 changes: 3 additions & 1 deletion src/audio/copier/host_copier.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ struct host_data {
/* local DMA config */
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
struct sof_dma *dma;
int chan_index;
#else
struct dma *dma;
#endif
struct dma_chan_data *chan;
#endif
struct dma_sg_config config;
#ifdef __ZEPHYR__
struct dma_config z_config;
Expand Down Expand Up @@ -112,6 +113,7 @@ struct host_data {
uint64_t next_sync;
uint64_t period_in_cycles;
#endif
struct k_heap *heap;
};

int host_common_new(struct host_data *hd, struct comp_dev *dev,
Expand Down
6 changes: 3 additions & 3 deletions src/audio/dai-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static int dai_playback_params(struct comp_dev *dev, uint32_t period_bytes,

comp_info(dev, "fifo 0x%x", fifo);

err = dma_sg_alloc(&config->elem_array, SOF_MEM_FLAG_USER,
err = dma_sg_alloc(NULL, &config->elem_array, SOF_MEM_FLAG_USER,
config->direction,
period_count,
period_bytes,
Expand Down Expand Up @@ -444,7 +444,7 @@ static int dai_capture_params(struct comp_dev *dev, uint32_t period_bytes,

comp_info(dev, "fifo 0x%x", fifo);

err = dma_sg_alloc(&config->elem_array, SOF_MEM_FLAG_USER,
err = dma_sg_alloc(NULL, &config->elem_array, SOF_MEM_FLAG_USER,
config->direction,
period_count,
period_bytes,
Expand Down Expand Up @@ -709,7 +709,7 @@ void dai_common_reset(struct dai_data *dd, struct comp_dev *dev)
if (!dd->delayed_dma_stop)
dai_dma_release(dd, dev);

dma_sg_free(&config->elem_array);
dma_sg_free(NULL, &config->elem_array);

if (dd->dma_buffer) {
buffer_free(dd->dma_buffer);
Expand Down
Loading
Loading