|
26 | 26 | #include <ipc4/pipeline.h> |
27 | 27 | #endif |
28 | 28 |
|
| 29 | +/* The __ZEPHYR__ condition is to keep cmocka tests working */ |
| 30 | +#if CONFIG_MODULE_MEMORY_API_DEBUG && defined(__ZEPHYR__) |
| 31 | +#define MEM_API_CHECK_THREAD(res) do { \ |
| 32 | + if ((res)->rsrc_mngr != k_current_get()) \ |
| 33 | + LOG_WRN("mngr %p != cur %p", (res)->rsrc_mngr, k_current_get()); \ |
| 34 | +} while (0) |
| 35 | +#else |
| 36 | +#define MEM_API_CHECK_THREAD(res) |
| 37 | +#endif |
| 38 | + |
29 | 39 | LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL); |
30 | 40 |
|
31 | 41 | int module_load_config(struct comp_dev *dev, const void *cfg, size_t size) |
@@ -114,6 +124,9 @@ int module_init(struct processing_module *mod) |
114 | 124 | return -EIO; |
115 | 125 | } |
116 | 126 |
|
| 127 | +#if CONFIG_MODULE_MEMORY_API_DEBUG && defined(__ZEPHYR__) |
| 128 | + mod->priv.resources.rsrc_mngr = k_current_get(); |
| 129 | +#endif |
117 | 130 | /* Now we can proceed with module specific initialization */ |
118 | 131 | #if CONFIG_SOF_USERSPACE_APPLICATION |
119 | 132 | if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) |
@@ -179,6 +192,8 @@ void *z_impl_mod_balloc_align(struct processing_module *mod, size_t size, size_t |
179 | 192 | struct module_resources *res = &mod->priv.resources; |
180 | 193 | struct module_resource *container; |
181 | 194 |
|
| 195 | + MEM_API_CHECK_THREAD(res); |
| 196 | + |
182 | 197 | k_mutex_lock(&res->lock, K_FOREVER); |
183 | 198 |
|
184 | 199 | container = container_get(mod); |
@@ -235,6 +250,8 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t |
235 | 250 | struct module_resources *res = &mod->priv.resources; |
236 | 251 | struct module_resource *container; |
237 | 252 |
|
| 253 | + MEM_API_CHECK_THREAD(res); |
| 254 | + |
238 | 255 | k_mutex_lock(&res->lock, K_FOREVER); |
239 | 256 |
|
240 | 257 | container = container_get(mod); |
@@ -288,6 +305,8 @@ struct comp_data_blob_handler *z_impl_mod_data_blob_handler_new(struct processin |
288 | 305 | struct comp_data_blob_handler *bhp; |
289 | 306 | struct module_resource *container; |
290 | 307 |
|
| 308 | + MEM_API_CHECK_THREAD(res); |
| 309 | + |
291 | 310 | k_mutex_lock(&res->lock, K_FOREVER); |
292 | 311 |
|
293 | 312 | container = container_get(mod); |
@@ -328,6 +347,8 @@ const void *z_impl_mod_fast_get(struct processing_module *mod, const void * cons |
328 | 347 | struct module_resource *container; |
329 | 348 | const void *ptr; |
330 | 349 |
|
| 350 | + MEM_API_CHECK_THREAD(res); |
| 351 | + |
331 | 352 | k_mutex_lock(&res->lock, K_FOREVER); |
332 | 353 |
|
333 | 354 | container = container_get(mod); |
@@ -419,6 +440,7 @@ int z_impl_mod_free(struct processing_module *mod, const void *ptr) |
419 | 440 | { |
420 | 441 | struct module_resources *res = &mod->priv.resources; |
421 | 442 |
|
| 443 | + MEM_API_CHECK_THREAD(res); |
422 | 444 | if (!ptr) |
423 | 445 | return 0; |
424 | 446 |
|
@@ -738,6 +760,8 @@ void mod_free_all(struct processing_module *mod) |
738 | 760 | { |
739 | 761 | struct module_resources *res = &mod->priv.resources; |
740 | 762 |
|
| 763 | + MEM_API_CHECK_THREAD(res); |
| 764 | + |
741 | 765 | /* Free all contents found in used containers */ |
742 | 766 | struct mod_res_cb_arg cb_arg = {mod, NULL}; |
743 | 767 |
|
|
0 commit comments