Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d35622f
ipc: move standalone-test check later in ipc_init()
kv2019i Feb 10, 2026
857b717
audio: component: add comp_grant_access_to_thread()
kv2019i Feb 13, 2026
a2343d5
pipeline: protect component connections with a mutex
kv2019i Feb 12, 2026
4411947
zephyr: lib: make sof_heap_alloc/free system calls
kv2019i Feb 13, 2026
eceaa9f
schedule: zephyr_ll_user: make the heap accessible from user-space
kv2019i Feb 13, 2026
ab1f023
schedule: zephyr_ll: convert pdata->sem into a dynamic object
kv2019i Feb 13, 2026
4a909a0
schedule: zephyr_ll_user: move user accessible heap to common partition
kv2019i Feb 13, 2026
27f84c1
dma: dma_sg: allocate on specific heap
kv2019i Feb 16, 2026
9bf4037
buffer: extend ability to allocate on specific heap to all functions
kv2019i Feb 16, 2026
e12c39a
section host-zephyr START
kv2019i Feb 19, 2026
133e92c
zephyr: userspace: sof_dma: allow circular SG lists
kv2019i Feb 19, 2026
100d169
zephyr: lib: dma: make DMA platform data available to user-space
kv2019i Feb 13, 2026
e8bed4c
audio: host-zephyr: select heap when allocating host buffers
kv2019i Feb 13, 2026
95ceab2
audio: host-zephyr: rework calls to DMA driver, remove channel pointer
kv2019i Feb 16, 2026
a33bac7
audio: host-zephyr: pass component heap to dma_sg_alloc
kv2019i Feb 16, 2026
160153c
alloc.h: remove rbrelloac() and rbrealloc_align()
kv2019i Feb 16, 2026
093a507
audio: host-zephyr: ensure host data heap is set
kv2019i Feb 16, 2026
4656235
audio: host-zephyr: make component usable from user-space
kv2019i Feb 16, 2026
b9f7cf6
section host-zephyr STOP
kv2019i Feb 19, 2026
6516ac2
section dai-zephyr START
kv2019i Feb 19, 2026
23e3d3d
audio: pcm_converter: make global tables available to user-space
kv2019i Feb 17, 2026
1108761
audio: comp_buffer: do not call notifier interface in user-space
kv2019i Feb 17, 2026
8fe5c62
audio: dai-zephyr: make memory allocations user-space compatible
kv2019i Feb 17, 2026
d85a793
lib: dai: make dai_get() and dai_put() compatible with user-space
kv2019i Feb 17, 2026
5f2f019
audio: dai-zephyr: rework calls to DMA driver, remove channel pointer
kv2019i Feb 17, 2026
57ad498
audio: dai-zephyr: convert spinlock into mutex for properties
kv2019i Feb 17, 2026
da0f2d9
audio: dai-zephyr: migrate to use dai_get_properties_copy()
kv2019i Feb 18, 2026
975bf2d
section dai-zephyr STOP
kv2019i Feb 19, 2026
03137b5
section test-case START
kv2019i Feb 19, 2026
96573de
zephyr: test: userspace: add pipeline_two_components test
kv2019i Feb 9, 2026
e0f5317
section WIP mandatory changes START
kv2019i Feb 19, 2026
e3afffe
WIP: audio: comp_buffer: do not free the module heap in free()
kv2019i Feb 17, 2026
ef0a310
audio: module_adapter: alloc from LL user heap if LL run in user
kv2019i Feb 12, 2026
6d4c8bd
section: RD hacks START
kv2019i Feb 19, 2026
9cdb1be
RD: test_ll_task: hack to allow access to DAI copier mutex
kv2019i Feb 18, 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
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