Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion src/audio/buffers/comp_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <rtos/alloc.h>
#include <rtos/cache.h>
#include <sof/lib/vregion.h>
#include <sof/ctx_alloc.h>
#include <sof/list.h>
#include <sof/schedule/dp_schedule.h>
#include <rtos/spinlock.h>
Expand Down
1 change: 0 additions & 1 deletion src/audio/buffers/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <sof/trace/trace.h>
#include <sof/lib/uuid.h>
#include <sof/lib/vregion.h>
#include <sof/ctx_alloc.h>

#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/ring_buffer.h>
Expand Down
1 change: 0 additions & 1 deletion src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <sof/audio/data_blob.h>
#include <sof/lib/fast-get.h>
#include <sof/lib/vregion.h>
#include <sof/ctx_alloc.h>
#include <sof/schedule/dp_schedule.h>
#if CONFIG_IPC_MAJOR_4
#include <ipc4/header.h>
Expand Down
1 change: 0 additions & 1 deletion src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <rtos/idc.h>
#include <rtos/mutex.h>
#include <rtos/userspace_helper.h>
#include <sof/ctx_alloc.h>
#include <sof/lib/dai.h>
#include <sof/schedule/schedule.h>
#include <ipc/control.h>
Expand Down
81 changes: 0 additions & 81 deletions src/include/sof/ctx_alloc.h

This file was deleted.

1 change: 0 additions & 1 deletion src/include/sof/lib/dai-zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <rtos/spinlock.h>
#include <sof/trace/trace.h>
#include <sof/ipc/topology.h>
#include <sof/ctx_alloc.h>
#include <sof/audio/pcm_converter.h>
#include <sof/audio/ipc-config.h>
#include <sof/audio/component.h>
Expand Down
69 changes: 69 additions & 0 deletions zephyr/include/rtos/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,73 @@ size_t get_shared_buffer_heap_size(void);

#endif

#include <sof/lib/vregion.h>
#include <string.h>
Comment on lines +153 to +154
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to do with this PR.


struct mod_alloc_ctx {
struct k_heap *heap;
struct vregion *vreg;
};

Comment on lines +156 to +160
/**
* Allocate memory from a mod_alloc_ctx context.
*
* When the context has a vregion, allocates from the vregion interim
* partition. Coherent memory is used when SOF_MEM_FLAG_COHERENT is set
* in flags. Falls back to sof_heap_alloc() otherwise.
*
* @param ctx Allocation context (heap + optional vregion).
* @param flags Allocation flags (SOF_MEM_FLAG_*).
* @param size Size in bytes.
* @param alignment Required alignment in bytes.
* @return Pointer to allocated memory or NULL on failure.
*/
static inline void *sof_ctx_alloc(struct mod_alloc_ctx *ctx, uint32_t flags,
size_t size, size_t alignment)
{
if (!ctx || !ctx->vreg)
return sof_heap_alloc(ctx ? ctx->heap : NULL, flags, size, alignment);

if (flags & SOF_MEM_FLAG_COHERENT)
return vregion_alloc_coherent_align(ctx->vreg, VREGION_MEM_TYPE_INTERIM,
size, alignment);

return vregion_alloc_align(ctx->vreg, VREGION_MEM_TYPE_INTERIM, size, alignment);
}

/**
* Allocate zero-initialized memory from a mod_alloc_ctx context.
* @param ctx Allocation context.
* @param flags Allocation flags (SOF_MEM_FLAG_*).
* @param size Size in bytes.
* @param alignment Required alignment in bytes.
* @return Pointer to allocated memory or NULL on failure.
*/
static inline void *sof_ctx_zalloc(struct mod_alloc_ctx *ctx, uint32_t flags,
size_t size, size_t alignment)
{
void *ptr = sof_ctx_alloc(ctx, flags, size, alignment);

if (ptr)
memset(ptr, 0, size);

return ptr;
}

/**
* Free memory allocated from a mod_alloc_ctx context.
* @param ctx Allocation context.
* @param ptr Pointer to free.
*/
static inline void sof_ctx_free(struct mod_alloc_ctx *ctx, void *ptr)
{
if (!ptr)
return;

if (ctx && ctx->vreg)
vregion_free(ctx->vreg, ptr);
else
sof_heap_free(ctx ? ctx->heap : NULL, ptr);
}

#endif /* __ZEPHYR_RTOS_ALLOC_H__ */
Loading