sof _ctx_alloc() followup: Remove the ctx_alloc.h header and move the implementation into rtos/alloc.h.#10831
sof _ctx_alloc() followup: Remove the ctx_alloc.h header and move the implementation into rtos/alloc.h.#10831jsarha wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the dedicated sof/ctx_alloc.h header and relocates the mod_alloc_ctx + sof_ctx_{alloc,zalloc,free}() inline allocation helpers into rtos/alloc.h, updating various SOF headers/sources to stop including the removed header.
Changes:
- Deleted
src/include/sof/ctx_alloc.hand moved its contents intozephyr/include/rtos/alloc.h. - Removed now-obsolete
#include <sof/ctx_alloc.h>from several headers and sources. - Centralized ctx-based allocation helpers behind the RTOS allocation header (for Zephyr).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
zephyr/include/rtos/alloc.h |
Adds struct mod_alloc_ctx and sof_ctx_{alloc,zalloc,free}() inline helpers (moved from sof/ctx_alloc.h). |
src/include/sof/lib/dai-zephyr.h |
Drops sof/ctx_alloc.h include. |
src/include/sof/audio/component.h |
Drops sof/ctx_alloc.h include. |
src/audio/module_adapter/module/generic.c |
Drops sof/ctx_alloc.h include. |
src/audio/buffers/ring_buffer.c |
Drops sof/ctx_alloc.h include. |
src/audio/buffers/comp_buffer.c |
Drops sof/ctx_alloc.h include. |
src/include/sof/ctx_alloc.h |
Deleted (content moved to rtos/alloc.h). |
| struct mod_alloc_ctx { | ||
| struct k_heap *heap; | ||
| struct vregion *vreg; | ||
| }; | ||
|
|
54db2cb to
b73659a
Compare
|
Fixed !CONFIG_SOF_VREGIONS build. Nope, I did not. The !CONFIG_SOF_VREGIONS build is hard to fix properly, due to need of rmalloc() in vregions.h header. Do we really need to create a dummy vregion object? Can't and shouldn't we fail already the vregion_create()-call? I'll try that. |
b73659a to
4f71ecd
Compare
|
|
||
| vr->use_count = 1; | ||
| return vr; | ||
| return NULL; |
There was a problem hiding this comment.
@lgirdwood , @lyakh I just went and removed the vregion refcounting code from !CONFIG_SOF_VREGIONS build. What was the original reason for adding it? Does it still apply?
There was a problem hiding this comment.
@lgirdwood , @lyakh I just went and removed the vregion refcounting code from !CONFIG_SOF_VREGIONS build. What was the original reason for adding it? Does it still apply?
@jsarha no, please bring it back. It's needed because, e.g. in the DP case not only module objects but also buffer objects have to be allocated from the same vregion. That's why refcounting is needed. Check where vregion_get() and vregion_put() are called.
There was a problem hiding this comment.
@lyakh do you mean we need the refcounted dummy vregion objects even when we do not have vregions configured in our build, e.g. CONFIG_SOF_VREGIONS=n ?
This only affect CONFIG_SOF_VREGIONS=n builds. All the cases that I tested work even with CONFIG_SOF_VREGIONS=n configuration. The only case that changes a bit is CONFIG_SOF_VREGIONS=n CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP=n CONFIG_USERSPACE=y configuration when module_adapter_dp_heap_new() fails. With the dummy vregion code it would get a way by allocating a dummy vregion object, but it will still fail a bit later when trying to allocate memory from the dummy vregion object. The refcounting still works fine when we have functional vregions. My change only takes away the dummy vregion objects when CONFIG_SOF_VREGIONS=n. So, @lyakh , could you lift the -1 ? |
…build Remove need to include rtos/alloc.h in !CONFIG_SOF_VREGIONS build. We do not need the dummy vregion objects for anything, so get rid of them. From now on creating a vregion object when CONFIG_SOF_VREGIONS is not defined will fail. Also make sure the vregions is not tried to be used if its not enabled. Even before this change the failure would have happened couple of lines later. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Remove the ctx_alloc.h header and move the implementation into rtos/alloc.h. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
ab33679 to
65d5912
Compare
|
The only change was to making sure the vregion_create() is not called in module_adapter_mem_alloc() when CONFIG_SOF_VREGIONS=n. |
Remove the ctx_alloc.h header and move the implementation into rtos/alloc.h.
Added based on this discussion:
#10802 (comment)
My revised version was just a little bit late and the old version was merged before I pushed the new one.