Skip to content

Commit 1fd682f

Browse files
committed
module: add an allocation function with flags
Add a new mod_alloc_ext() allocation function with support for allocator flags. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 8e42749 commit 1fd682f

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/audio/module_adapter/module/generic.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,16 @@ void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignm
215215
EXPORT_SYMBOL(mod_balloc_align);
216216

217217
/**
218-
* Allocates aligned memory block for module.
218+
* Allocates aligned memory block with flags for module.
219219
* @param mod Pointer to the module this memory block is allocatd for.
220+
* @param flags Allocator flags.
220221
* @param bytes Size in bytes.
221222
* @param alignment Alignment in bytes.
222223
* @return Pointer to the allocated memory or NULL if failed.
223224
*
224225
* The allocated memory is automatically freed when the module is unloaded.
225226
*/
226-
void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment)
227+
void *mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t size, size_t alignment)
227228
{
228229
struct module_resources *res = &mod->priv.resources;
229230
struct module_resource *container;
@@ -242,7 +243,7 @@ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignme
242243
}
243244

244245
/* Allocate memory for module */
245-
ptr = sof_heap_alloc(res->heap, 0, size, alignment);
246+
ptr = sof_heap_alloc(res->heap, flags, size, alignment);
246247
if (!ptr) {
247248
comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.",
248249
size, alignment, dev_comp_id(mod->dev));
@@ -261,7 +262,7 @@ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignme
261262

262263
return ptr;
263264
}
264-
EXPORT_SYMBOL(mod_alloc_align);
265+
EXPORT_SYMBOL(mod_alloc_ext);
265266

266267
/**
267268
* Creates a blob handler and releases it when the module is unloaded

src/include/sof/audio/module_adapter/module/generic.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,27 @@ struct module_processing_data {
191191
int module_load_config(struct comp_dev *dev, const void *cfg, size_t size);
192192
int module_init(struct processing_module *mod);
193193
void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment);
194+
void *mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t size, size_t alignment);
195+
196+
/**
197+
* Allocates aligned memory block for module.
198+
* @param mod Pointer to the module this memory block is allocated for.
199+
* @param bytes Size in bytes.
200+
* @param alignment Alignment in bytes.
201+
* @return Pointer to the allocated memory or NULL if failed.
202+
*
203+
* The allocated memory is automatically freed when the module is unloaded.
204+
*/
205+
static inline void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment)
206+
{
207+
return mod_alloc_ext(mod, 0, size, alignment);
208+
}
209+
194210
static inline void *mod_balloc(struct processing_module *mod, size_t size)
195211
{
196212
return mod_balloc_align(mod, size, 0);
197213
}
198214

199-
void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment);
200215
static inline void *mod_alloc(struct processing_module *mod, size_t size)
201216
{
202217
return mod_alloc_align(mod, size, 0);

0 commit comments

Comments
 (0)