@@ -156,12 +156,12 @@ static void comp_buffer_free(struct sof_audio_buffer *audio_buffer)
156156
157157 struct mod_alloc_ctx * alloc = buffer -> audio_buffer .alloc ;
158158
159- #ifdef CONFIG_SOF_USERSPACE_LL
160- assert ( alloc );
161- sof_ctx_free (alloc , buffer -> stream . addr );
162- #else
163- rfree ( buffer -> stream . addr );
164- #endif
159+ assert (! IS_ENABLED ( CONFIG_SOF_USERSPACE_LL ) || alloc );
160+
161+ if (alloc )
162+ sof_ctx_free ( alloc , buffer -> stream . addr );
163+ else
164+ sof_heap_free ( sof_sys_user_heap_get (), buffer -> stream . addr );
165165
166166 if (alloc && alloc -> vreg ) {
167167 vregion_free (alloc -> vreg , buffer );
@@ -255,12 +255,14 @@ struct comp_buffer *buffer_alloc(struct mod_alloc_ctx *alloc, size_t size, uint3
255255 return NULL ;
256256 }
257257
258- #ifdef CONFIG_SOF_USERSPACE_LL
259- assert (alloc );
260- stream_addr = sof_ctx_alloc (alloc , flags , size , align );
261- #else
262- stream_addr = rballoc_align (flags , size , align );
263- #endif
258+ assert (!IS_ENABLED (CONFIG_SOF_USERSPACE_LL ) || alloc );
259+
260+ if (alloc )
261+ stream_addr = sof_ctx_alloc (alloc , flags , size , align );
262+ else
263+ stream_addr = sof_heap_alloc (sof_sys_user_heap_get (),
264+ flags | SOF_MEM_FLAG_LARGE_BUFFER , size , align );
265+
264266 if (!stream_addr ) {
265267 tr_err (& buffer_tr , "could not alloc size = %zu bytes of flags = 0x%x" ,
266268 size , flags );
@@ -270,12 +272,11 @@ struct comp_buffer *buffer_alloc(struct mod_alloc_ctx *alloc, size_t size, uint3
270272 buffer = buffer_alloc_struct (alloc , stream_addr , size , flags , is_shared );
271273 if (!buffer ) {
272274 tr_err (& buffer_tr , "could not alloc buffer structure" );
273- #ifdef CONFIG_SOF_USERSPACE_LL
274- assert (alloc );
275- sof_ctx_free (alloc , stream_addr );
276- #else
277- rfree (stream_addr );
278- #endif
275+
276+ if (alloc )
277+ sof_ctx_free (alloc , stream_addr );
278+ else
279+ sof_heap_free (sof_sys_user_heap_get (), stream_addr );
279280 }
280281
281282 return buffer ;
@@ -302,13 +303,16 @@ struct comp_buffer *buffer_alloc_range(struct mod_alloc_ctx *alloc, size_t prefe
302303 if (preferred_size % minimum_size )
303304 preferred_size += minimum_size - preferred_size % minimum_size ;
304305
306+ assert (!IS_ENABLED (CONFIG_SOF_USERSPACE_LL ) || alloc );
307+
305308 for (size = preferred_size ; size >= minimum_size ; size -= minimum_size ) {
306- #ifdef CONFIG_SOF_USERSPACE_LL
307- assert (alloc );
308- stream_addr = sof_ctx_alloc (alloc , flags , size , align );
309- #else
310- stream_addr = rballoc_align (flags , size , align );
311- #endif
309+ if (alloc )
310+ stream_addr = sof_ctx_alloc (alloc , flags , size , align );
311+ else
312+ stream_addr = sof_heap_alloc (sof_sys_user_heap_get (),
313+ flags | SOF_MEM_FLAG_LARGE_BUFFER , size ,
314+ align );
315+
312316 if (stream_addr )
313317 break ;
314318 }
@@ -324,12 +328,11 @@ struct comp_buffer *buffer_alloc_range(struct mod_alloc_ctx *alloc, size_t prefe
324328 buffer = buffer_alloc_struct (alloc , stream_addr , size , flags , is_shared );
325329 if (!buffer ) {
326330 tr_err (& buffer_tr , "could not alloc buffer structure" );
327- #ifdef CONFIG_SOF_USERSPACE_LL
328- assert (alloc );
329- sof_ctx_free (alloc , stream_addr );
330- #else
331- rfree (stream_addr );
332- #endif
331+
332+ if (alloc )
333+ sof_ctx_free (alloc , stream_addr );
334+ else
335+ sof_heap_free (sof_sys_user_heap_get (), stream_addr );
333336 }
334337
335338 return buffer ;
@@ -350,9 +353,7 @@ void buffer_zero(struct comp_buffer *buffer)
350353int buffer_set_size (struct comp_buffer * buffer , uint32_t size , uint32_t alignment )
351354{
352355 void * new_ptr = NULL ;
353- #ifdef CONFIG_SOF_USERSPACE_LL
354356 struct mod_alloc_ctx * alloc = buffer -> audio_buffer .alloc ;
355- #endif
356357
357358 CORE_CHECK_STRUCT (& buffer -> audio_buffer );
358359
@@ -365,12 +366,14 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignmen
365366 if (size == audio_stream_get_size (& buffer -> stream ))
366367 return 0 ;
367368
368- #ifdef CONFIG_SOF_USERSPACE_LL
369- assert (alloc );
370- new_ptr = sof_ctx_alloc (alloc , buffer -> flags , size , alignment );
371- #else
372- new_ptr = rballoc_align (buffer -> flags , size , alignment );
373- #endif
369+ assert (!IS_ENABLED (CONFIG_SOF_USERSPACE_LL ) || alloc );
370+
371+ if (alloc )
372+ new_ptr = sof_ctx_alloc (alloc , buffer -> flags , size , alignment );
373+ else
374+ new_ptr = sof_heap_alloc (sof_sys_user_heap_get (),
375+ buffer -> flags | SOF_MEM_FLAG_LARGE_BUFFER , size ,
376+ alignment );
374377
375378 /* we couldn't allocate bigger chunk */
376379 if (!new_ptr && size > audio_stream_get_size (& buffer -> stream )) {
@@ -381,12 +384,11 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignmen
381384
382385 /* use bigger chunk, else just use the old chunk but set smaller */
383386 if (new_ptr ) {
384- #ifdef CONFIG_SOF_USERSPACE_LL
385- assert (alloc );
386- sof_ctx_free (alloc , audio_stream_get_addr (& buffer -> stream ));
387- #else
388- rfree (audio_stream_get_addr (& buffer -> stream ));
389- #endif
387+ if (alloc )
388+ sof_ctx_free (alloc , audio_stream_get_addr (& buffer -> stream ));
389+ else
390+ sof_heap_free (sof_sys_user_heap_get (), audio_stream_get_addr (& buffer -> stream ));
391+
390392 audio_stream_set_addr (& buffer -> stream , new_ptr );
391393 }
392394
@@ -401,9 +403,7 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
401403 const size_t actual_size = audio_stream_get_size (& buffer -> stream );
402404 void * new_ptr = NULL ;
403405 size_t new_size ;
404- #ifdef CONFIG_SOF_USERSPACE_LL
405406 struct mod_alloc_ctx * alloc = buffer -> audio_buffer .alloc ;
406- #endif
407407
408408 CORE_CHECK_STRUCT (& buffer -> audio_buffer );
409409
@@ -421,14 +421,17 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
421421 if (preferred_size == actual_size )
422422 return 0 ;
423423
424+ assert (!IS_ENABLED (CONFIG_SOF_USERSPACE_LL ) || alloc );
425+
424426 for (new_size = preferred_size ; new_size >= minimum_size ;
425427 new_size -= minimum_size ) {
426- #ifdef CONFIG_SOF_USERSPACE_LL
427- assert (alloc );
428- new_ptr = sof_ctx_alloc (alloc , buffer -> flags , new_size , alignment );
429- #else
430- new_ptr = rballoc_align (buffer -> flags , new_size , alignment );
431- #endif
428+ if (alloc )
429+ new_ptr = sof_ctx_alloc (alloc , buffer -> flags , new_size , alignment );
430+ else
431+ new_ptr = sof_heap_alloc (sof_sys_user_heap_get (),
432+ buffer -> flags | SOF_MEM_FLAG_LARGE_BUFFER ,
433+ new_size , alignment );
434+
432435 if (new_ptr )
433436 break ;
434437 }
@@ -442,12 +445,11 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
442445
443446 /* use bigger chunk, else just use the old chunk but set smaller */
444447 if (new_ptr ) {
445- #ifdef CONFIG_SOF_USERSPACE_LL
446- assert (alloc );
447- sof_ctx_free (alloc , audio_stream_get_addr (& buffer -> stream ));
448- #else
449- rfree (audio_stream_get_addr (& buffer -> stream ));
450- #endif
448+ if (alloc )
449+ sof_ctx_free (alloc , audio_stream_get_addr (& buffer -> stream ));
450+ else
451+ sof_heap_free (sof_sys_user_heap_get (), audio_stream_get_addr (& buffer -> stream ));
452+
451453 audio_stream_set_addr (& buffer -> stream , new_ptr );
452454 }
453455
0 commit comments