Skip to content

Commit b2bc199

Browse files
committed
heap: simplify heap API.
Use a Linux kernel like heap API now that zephyr allocator deals with the complexity. Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
1 parent 60e7a0a commit b2bc199

File tree

157 files changed

+441
-503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+441
-503
lines changed

src/arch/xtensa/lib/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void alloc_shared_secondary_cores_objects(void)
4646
{
4747
uint8_t *dynamic_vectors;
4848

49-
dynamic_vectors = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, 0, SOF_DYNAMIC_VECTORS_SIZE);
49+
dynamic_vectors = rzalloc(SOF_MEM_FLAG_COHERENT, 0, SOF_DYNAMIC_VECTORS_SIZE);
5050
if (dynamic_vectors == NULL)
5151
sof_panic(SOF_IPC_PANIC_MEM);
5252

src/arch/xtensa/schedule/task.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void task_context_set(void *task_ctx)
6565

6666
int task_context_alloc(void **task_ctx)
6767
{
68-
*task_ctx = rzalloc(SOF_MEM_ZONE_SYS_RUNTIME, 0, SOF_MEM_CAPS_RAM,
68+
*task_ctx = rzalloc(SOF_MEM_FLAG_USER,
6969
sizeof(xtos_task_context));
7070
if (!*task_ctx)
7171
return -ENOMEM;
@@ -83,7 +83,7 @@ int task_context_init(void *task_ctx, void *entry, void *arg0, void *arg1,
8383
ctx->stack_base = stack;
8484
ctx->stack_size = stack_size;
8585
} else {
86-
ctx->stack_base = rballoc(0, SOF_MEM_CAPS_RAM,
86+
ctx->stack_base = rballoc(SOF_MEM_FLAG_USER,
8787
PLATFORM_TASK_DEFAULT_STACK_SIZE);
8888
if (!ctx->stack_base)
8989
return -ENOMEM;

src/audio/aria/aria.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int aria_init(struct processing_module *mod)
126126
list_init(&dev->bsource_list);
127127
list_init(&dev->bsink_list);
128128

129-
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
129+
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
130130
if (!cd) {
131131
return -ENOMEM;
132132
}
@@ -145,7 +145,7 @@ static int aria_init(struct processing_module *mod)
145145
}
146146
mod_data->private = cd;
147147

148-
buf = rballoc(0, SOF_MEM_CAPS_RAM, req_mem);
148+
buf = rballoc(SOF_MEM_FLAG_USER, req_mem);
149149

150150
if (!buf) {
151151
rfree(cd);

src/audio/asrc/asrc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int asrc_init(struct processing_module *mod)
217217
return -EINVAL;
218218
}
219219

220-
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
220+
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
221221
if (!cd)
222222
return -ENOMEM;
223223

@@ -261,7 +261,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
261261
buffer_size = src_obj->buffer_length * sizeof(int32_t);
262262

263263
for (ch = 0; ch < src_obj->num_channels; ch++) {
264-
buf_32 = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, buffer_size);
264+
buf_32 = rzalloc(SOF_MEM_FLAG_USER, buffer_size);
265265

266266
if (!buf_32)
267267
return -ENOMEM;
@@ -272,7 +272,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
272272
buffer_size = src_obj->buffer_length * sizeof(int16_t);
273273

274274
for (ch = 0; ch < src_obj->num_channels; ch++) {
275-
buf_16 = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, buffer_size);
275+
buf_16 = rzalloc(SOF_MEM_FLAG_USER, buffer_size);
276276

277277
if (!buf_16)
278278
return -ENOMEM;
@@ -614,7 +614,7 @@ static int asrc_prepare(struct processing_module *mod,
614614
cd->buf_size = (cd->source_frames_max + cd->sink_frames_max) *
615615
frame_bytes;
616616

617-
cd->buf = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
617+
cd->buf = rzalloc(SOF_MEM_FLAG_USER,
618618
cd->buf_size);
619619
if (!cd->buf) {
620620
cd->buf_size = 0;
@@ -640,7 +640,7 @@ static int asrc_prepare(struct processing_module *mod,
640640
goto err_free_buf;
641641
}
642642

643-
cd->asrc_obj = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
643+
cd->asrc_obj = rzalloc(SOF_MEM_FLAG_USER,
644644
cd->asrc_size);
645645
if (!cd->asrc_obj) {
646646
comp_err(dev, "asrc_prepare(), allocation fail for size %d",

src/audio/base_fw_intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ __cold static int basefw_mem_state_info(uint32_t *data_offset, char *data)
182182
info.page_alloc_struct.page_alloc_count * sizeof(uint32_t);
183183
size = ALIGN(size, 4);
184184
/* size is also saved as tuple length */
185-
tuple_data = rballoc(0, SOF_MEM_CAPS_RAM, size);
185+
tuple_data = rballoc(SOF_MEM_FLAG_USER, size);
186186

187187
/* save memory info in data array since info length is variable */
188188
index = 0;

src/audio/buffers/comp_buffer.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ static struct comp_buffer *buffer_alloc_struct(void *stream_addr, size_t size, u
189189
tr_dbg(&buffer_tr, "buffer_alloc_struct()");
190190

191191
/* allocate new buffer */
192-
enum mem_zone zone = is_shared ? SOF_MEM_ZONE_RUNTIME_SHARED : SOF_MEM_ZONE_RUNTIME;
192+
int alloc_flags = is_shared ? SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT : SOF_MEM_FLAG_USER;
193193

194-
buffer = rzalloc(zone, 0, SOF_MEM_CAPS_RAM, sizeof(*buffer));
194+
buffer = rzalloc(alloc_flags, sizeof(*buffer));
195195

196196
if (!buffer) {
197197
tr_err(&buffer_tr, "buffer_alloc_struct(): could not alloc structure");
@@ -233,7 +233,7 @@ struct comp_buffer *buffer_alloc(size_t size, uint32_t caps, uint32_t flags, uin
233233
return NULL;
234234
}
235235

236-
stream_addr = rballoc_align(0, caps, size, align);
236+
stream_addr = rballoc_align(SOF_MEM_FLAG_USER, size, align);
237237
if (!stream_addr) {
238238
tr_err(&buffer_tr, "buffer_alloc(): could not alloc size = %zu bytes of type = %u",
239239
size, caps);
@@ -270,7 +270,7 @@ struct comp_buffer *buffer_alloc_range(size_t preferred_size, size_t minimum_siz
270270
preferred_size += minimum_size - preferred_size % minimum_size;
271271

272272
for (size = preferred_size; size >= minimum_size; size -= minimum_size) {
273-
stream_addr = rballoc_align(0, caps, size, align);
273+
stream_addr = rballoc_align(SOF_MEM_FLAG_USER, size, align);
274274
if (stream_addr)
275275
break;
276276
}
@@ -321,10 +321,10 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignmen
321321

322322
if (!alignment)
323323
new_ptr = rbrealloc(audio_stream_get_addr(&buffer->stream), SOF_MEM_FLAG_NO_COPY,
324-
buffer->caps, size, audio_stream_get_size(&buffer->stream));
324+
size, audio_stream_get_size(&buffer->stream));
325325
else
326326
new_ptr = rbrealloc_align(audio_stream_get_addr(&buffer->stream),
327-
SOF_MEM_FLAG_NO_COPY, buffer->caps, size,
327+
SOF_MEM_FLAG_NO_COPY, size,
328328
audio_stream_get_size(&buffer->stream), alignment);
329329
/* we couldn't allocate bigger chunk */
330330
if (!new_ptr && size > audio_stream_get_size(&buffer->stream)) {
@@ -369,15 +369,15 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
369369
if (!alignment) {
370370
for (new_size = preferred_size; new_size >= minimum_size;
371371
new_size -= minimum_size) {
372-
new_ptr = rbrealloc(ptr, SOF_MEM_FLAG_NO_COPY, buffer->caps, new_size,
372+
new_ptr = rbrealloc(ptr, SOF_MEM_FLAG_NO_COPY, new_size,
373373
actual_size);
374374
if (new_ptr)
375375
break;
376376
}
377377
} else {
378378
for (new_size = preferred_size; new_size >= minimum_size;
379379
new_size -= minimum_size) {
380-
new_ptr = rbrealloc_align(ptr, SOF_MEM_FLAG_NO_COPY, buffer->caps, new_size,
380+
new_ptr = rbrealloc_align(ptr, SOF_MEM_FLAG_NO_COPY, new_size,
381381
actual_size, alignment);
382382
if (new_ptr)
383383
break;

src/audio/buffers/ring_buffer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,10 @@ struct ring_buffer *ring_buffer_create(size_t min_available, size_t min_free_spa
280280

281281
/* allocate ring_buffer structure */
282282
if (is_shared)
283-
ring_buffer = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM,
283+
ring_buffer = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
284284
sizeof(*ring_buffer));
285285
else
286-
ring_buffer = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
287-
sizeof(*ring_buffer));
286+
ring_buffer = rzalloc(SOF_MEM_FLAG_USER, sizeof(*ring_buffer));
288287
if (!ring_buffer)
289288
return NULL;
290289

@@ -354,7 +353,7 @@ struct ring_buffer *ring_buffer_create(size_t min_available, size_t min_free_spa
354353
ring_buffer->data_buffer_size =
355354
ALIGN_UP(ring_buffer->data_buffer_size, PLATFORM_DCACHE_ALIGN);
356355
ring_buffer->_data_buffer = (__sparse_force __sparse_cache void *)
357-
rballoc_align(0, 0, ring_buffer->data_buffer_size, PLATFORM_DCACHE_ALIGN);
356+
rballoc_align(SOF_MEM_FLAG_USER, ring_buffer->data_buffer_size, PLATFORM_DCACHE_ALIGN);
358357
if (!ring_buffer->_data_buffer)
359358
goto err;
360359

src/audio/chain_dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ __cold static int chain_task_init(struct comp_dev *dev, uint8_t host_dma_id, uin
605605

606606
fifo_size = ALIGN_UP_INTERNAL(fifo_size, addr_align);
607607
/* allocate not shared buffer */
608-
cd->dma_buffer = buffer_alloc(fifo_size, SOF_MEM_CAPS_DMA, 0, addr_align, false);
608+
cd->dma_buffer = buffer_alloc(fifo_size, 0, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_DMA, addr_align, false);
609609

610610
if (!cd->dma_buffer) {
611611
comp_err(dev, "chain_task_init(): failed to alloc dma buffer");
@@ -668,7 +668,7 @@ __cold static struct comp_dev *chain_task_create(const struct comp_driver *drv,
668668
if (!dev)
669669
return NULL;
670670

671-
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
671+
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
672672
if (!cd)
673673
goto error;
674674

src/audio/copier/copier.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int mic_privacy_configure(struct comp_dev *dev, struct copier_data *cd)
8787
struct mic_privacy_data *mic_priv_data;
8888
int ret;
8989

90-
mic_priv_data = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
90+
mic_priv_data = rzalloc(SOF_MEM_FLAG_USER,
9191
sizeof(struct mic_privacy_data));
9292
if (!mic_priv_data)
9393
return -ENOMEM;
@@ -144,7 +144,7 @@ __cold static int copier_init(struct processing_module *mod)
144144

145145
assert_can_be_cold();
146146

147-
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
147+
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
148148
if (!cd)
149149
return -ENOMEM;
150150

@@ -166,7 +166,7 @@ __cold static int copier_init(struct processing_module *mod)
166166
*/
167167
if (copier->gtw_cfg.config_length) {
168168
gtw_cfg_size = copier->gtw_cfg.config_length << 2;
169-
gtw_cfg = rmalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
169+
gtw_cfg = rmalloc(SOF_MEM_FLAG_USER,
170170
gtw_cfg_size);
171171
if (!gtw_cfg) {
172172
ret = -ENOMEM;

src/audio/copier/copier_dai.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ __cold static int copier_dai_init(struct comp_dev *dev,
204204
return ret;
205205
}
206206

207-
dd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*dd));
207+
dd = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, sizeof(*dd));
208208
if (!dd)
209209
return -ENOMEM;
210210

@@ -223,8 +223,7 @@ __cold static int copier_dai_init(struct comp_dev *dev,
223223

224224
/* Allocate gain data if selected for this dai type and set basic params */
225225
if (dai->apply_gain) {
226-
struct copier_gain_params *gain_data = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED,
227-
0, SOF_MEM_CAPS_RAM,
226+
struct copier_gain_params *gain_data = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
228227
sizeof(*gain_data));
229228
if (!gain_data) {
230229
ret = -ENOMEM;

0 commit comments

Comments
 (0)