|
17 | 17 | #include <sof/audio/data_blob.h> |
18 | 18 | #include <sof/lib/fast-get.h> |
19 | 19 |
|
| 20 | +#if CONFIG_MODULE_MEMORY_API_DEBUG |
| 21 | +#define MEM_API_CHECK_THREAD(res) __ASSERT((res)->rsrc_mngr == k_current_get(), \ |
| 22 | + "Module memory API opration from wrong thread") |
| 23 | +#else |
| 24 | +#define MEM_API_CHECK_THREAD(res) |
| 25 | +#endif |
| 26 | + |
20 | 27 | LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL); |
21 | 28 |
|
| 29 | + |
22 | 30 | int module_load_config(struct comp_dev *dev, const void *cfg, size_t size) |
23 | 31 | { |
24 | 32 | int ret; |
@@ -99,7 +107,9 @@ int module_init(struct processing_module *mod) |
99 | 107 | list_init(&md->resources.cont_chunk_list); |
100 | 108 | md->resources.heap_usage = 0; |
101 | 109 | md->resources.heap_high_water_mark = 0; |
102 | | - |
| 110 | +#if CONFIG_MODULE_MEMORY_API_DEBUG |
| 111 | + md->resources.rsrc_mngr = k_current_get(); |
| 112 | +#endif |
103 | 113 | /* Now we can proceed with module specific initialization */ |
104 | 114 | ret = interface->init(mod); |
105 | 115 | if (ret) { |
@@ -167,6 +177,7 @@ void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t ali |
167 | 177 | struct module_resources *res = &mod->priv.resources; |
168 | 178 | void *ptr; |
169 | 179 |
|
| 180 | + MEM_API_CHECK_THREAD(res); |
170 | 181 | if (!container) |
171 | 182 | return NULL; |
172 | 183 |
|
@@ -251,6 +262,7 @@ mod_data_blob_handler_new(struct processing_module *mod) |
251 | 262 | struct module_memory *container = container_get(mod); |
252 | 263 | struct comp_data_blob_handler *dbh; |
253 | 264 |
|
| 265 | + MEM_API_CHECK_THREAD(res); |
254 | 266 | if (!container) |
255 | 267 | return NULL; |
256 | 268 |
|
@@ -284,6 +296,7 @@ const void *mod_fast_get(struct processing_module *mod, const void * const dram_ |
284 | 296 | struct module_memory *container = container_get(mod); |
285 | 297 | const void *ptr; |
286 | 298 |
|
| 299 | + MEM_API_CHECK_THREAD(res); |
287 | 300 | if (!container) |
288 | 301 | return NULL; |
289 | 302 |
|
@@ -315,6 +328,7 @@ int mod_free(struct processing_module *mod, void *ptr) |
315 | 328 | struct list_item *mem_list; |
316 | 329 | struct list_item *_mem_list; |
317 | 330 |
|
| 331 | + MEM_API_CHECK_THREAD(res); |
318 | 332 | if (!ptr) |
319 | 333 | return 0; |
320 | 334 |
|
@@ -539,6 +553,7 @@ void mod_free_all(struct processing_module *mod) |
539 | 553 | struct list_item *list; |
540 | 554 | struct list_item *_list; |
541 | 555 |
|
| 556 | + MEM_API_CHECK_THREAD(res); |
542 | 557 | /* Find which container keeps this memory */ |
543 | 558 | list_for_item_safe(list, _list, &res->mem_list) { |
544 | 559 | struct module_memory *mem = container_of(list, struct module_memory, mem_list); |
|
0 commit comments