Skip to content

Commit 7751211

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 b6c6388 commit 7751211

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
@@ -221,15 +221,16 @@ void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignm
221221
EXPORT_SYMBOL(mod_balloc_align);
222222

223223
/**
224-
* Allocates aligned memory block for module.
224+
* Allocates aligned memory block with flags for module.
225225
* @param mod Pointer to the module this memory block is allocatd for.
226+
* @param flags Allocator flags.
226227
* @param bytes Size in bytes.
227228
* @param alignment Alignment in bytes.
228229
* @return Pointer to the allocated memory or NULL if failed.
229230
*
230231
* The allocated memory is automatically freed when the module is unloaded.
231232
*/
232-
void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment)
233+
void *mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t size, size_t alignment)
233234
{
234235
struct module_resources *res = &mod->priv.resources;
235236
struct module_resource *container;
@@ -248,7 +249,7 @@ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignme
248249
}
249250

250251
/* Allocate memory for module */
251-
ptr = sof_heap_alloc(res->heap, 0, size, alignment);
252+
ptr = sof_heap_alloc(res->heap, flags, size, alignment);
252253
if (!ptr) {
253254
comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.",
254255
size, alignment, dev_comp_id(mod->dev));
@@ -267,7 +268,7 @@ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignme
267268

268269
return ptr;
269270
}
270-
EXPORT_SYMBOL(mod_alloc_align);
271+
EXPORT_SYMBOL(mod_alloc_ext);
271272

272273
/**
273274
* 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)