@@ -134,17 +134,20 @@ struct container_chunk {
134134static struct module_memory * container_get (struct processing_module * mod )
135135{
136136 struct module_resources * res = & mod -> priv .resources ;
137+ struct k_heap * mod_heap = res -> heap ;
137138 struct module_memory * container ;
138139
139140 if (list_is_empty (& res -> free_cont_list )) {
140- struct container_chunk * chunk = rzalloc ( SOF_MEM_FLAG_USER , sizeof (* chunk ));
141+ struct container_chunk * chunk = sof_heap_alloc ( mod_heap , 0 , sizeof (* chunk ), 0 );
141142 int i ;
142143
143144 if (!chunk ) {
144145 comp_err (mod -> dev , "allocating more containers failed" );
145146 return NULL ;
146147 }
147148
149+ memset (chunk , 0 , sizeof (* chunk ));
150+
148151 list_item_append (& chunk -> chunk_list , & res -> cont_chunk_list );
149152 for (i = 0 ; i < ARRAY_SIZE (chunk -> containers ); i ++ )
150153 list_item_append (& chunk -> containers [i ].mem_list , & res -> free_cont_list );
@@ -175,6 +178,7 @@ void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t ali
175178{
176179 struct module_memory * container = container_get (mod );
177180 struct module_resources * res = & mod -> priv .resources ;
181+ struct k_heap * mod_heap = res -> heap ;
178182 void * ptr ;
179183
180184 MEM_API_CHECK_THREAD (res );
@@ -188,11 +192,7 @@ void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t ali
188192 }
189193
190194 /* Allocate memory for module */
191- if (alignment )
192- ptr = rballoc_align (SOF_MEM_FLAG_USER , size , alignment );
193- else
194- ptr = rballoc (SOF_MEM_FLAG_USER , size );
195-
195+ ptr = sof_heap_alloc (mod_heap , 0 , size , alignment );
196196 if (!ptr ) {
197197 comp_err (mod -> dev , "mod_alloc: failed to allocate memory for comp %x." ,
198198 dev_comp_id (mod -> dev ));
@@ -324,6 +324,7 @@ EXPORT_SYMBOL(mod_fast_get);
324324int mod_free (struct processing_module * mod , const void * ptr )
325325{
326326 struct module_resources * res = & mod -> priv .resources ;
327+ struct k_heap * mod_heap = res -> heap ;
327328 struct module_memory * mem ;
328329 struct list_item * mem_list ;
329330 struct list_item * _mem_list ;
@@ -339,7 +340,7 @@ int mod_free(struct processing_module *mod, const void *ptr)
339340 if (mem -> free ) {
340341 mem -> free (mem -> ptr );
341342 } else {
342- rfree ( mem -> ptr );
343+ sof_heap_free ( mod_heap , mem -> ptr );
343344 res -> heap_usage -= mem -> size ;
344345 }
345346 list_item_del (& mem -> mem_list );
@@ -550,6 +551,7 @@ int module_reset(struct processing_module *mod)
550551void mod_free_all (struct processing_module * mod )
551552{
552553 struct module_resources * res = & mod -> priv .resources ;
554+ struct k_heap * mod_heap = res -> heap ;
553555 struct list_item * list ;
554556 struct list_item * _list ;
555557
@@ -561,7 +563,7 @@ void mod_free_all(struct processing_module *mod)
561563 if (mem -> free )
562564 mem -> free (mem -> ptr );
563565 else
564- rfree ( mem -> ptr );
566+ sof_heap_free ( mod_heap , mem -> ptr );
565567 list_item_del (& mem -> mem_list );
566568 }
567569
@@ -570,7 +572,7 @@ void mod_free_all(struct processing_module *mod)
570572 container_of (list , struct container_chunk , chunk_list );
571573
572574 list_item_del (& chunk -> chunk_list );
573- rfree ( chunk );
575+ sof_heap_free ( mod_heap , chunk );
574576 }
575577}
576578EXPORT_SYMBOL (mod_free_all );
0 commit comments