Commit 6d09634
committed
zephyr: lib: alloc: fine-tune logic in z_impl_sof_heap_alloc()
Modify the special handling of SOF_MEM_FLAG_USER_SHARED_BUFFER and
SOF_MEM_FLAG_LARGE_BUFFER in z_impl_sof_heap_alloc().
First make the shared user heap special handling conditional on
CONFIG_SOF_USERSPACE_USE_SHARED_HEAP. This flag is a special case as it
is not a hint to the allocator but rather an explicit selector for a
specific heap (similar to SOF_MEM_FLAG_L3). If defined in build, and the
flag is passed to sof_heap_alloc(), the heap argument is ignored, and
instead the shared user heap instance is always used. No functional
change to current code.
Unlike the shared heap flag, SOF_MEM_FLAG_LARGE_BUFFER is a more
traditional flag, which serves as a hint to the allocator. Modify the
implementation to ignore this flag if the caller has passed a non-NULL
heap. Assumption here is that the heap user has passed is more suitable
for large buffers than use of default rballoc_align(), so the hint can
be ignored. This is especially important for cases where e.g. the caller
is allocating memory to a different memory domain and using default
rballoc_align() would result in access errors. If no heap is passed, the
existing logic to use rballoc_align() is used. Functionality is modified
only for cases where a custom heap is passed to alloc.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>1 parent 59a3f0d commit 6d09634
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
635 | 640 | | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
636 | 651 | | |
637 | | - | |
638 | 652 | | |
| 653 | + | |
639 | 654 | | |
640 | 655 | | |
641 | 656 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
0 commit comments