Skip to content

Commit 768faad

Browse files
Jyri Sarhakv2019i
authored andcommitted
module: generic: remove MEM_API_CHECK_THREAD debug mechanism
Remove the MEM_API_CHECK_THREAD() macro, CONFIG_MODULE_MEMORY_API_DEBUG Kconfig option, and the rsrc_mngr field from struct module_resources. This single-thread-owner check is now redundant: the previous commit added a spinlock that properly serializes all accesses to the resource pool, making the debug-only thread identity warning unnecessary. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 7bb70f5 commit 768faad

3 files changed

Lines changed: 0 additions & 42 deletions

File tree

src/audio/module_adapter/Kconfig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ menu "Processing modules"
1313
containers to allocate at once is selected by this
1414
config option.
1515

16-
config MODULE_MEMORY_API_DEBUG
17-
bool "Turn on memory API thread safety checks"
18-
default y if DEBUG
19-
help
20-
The Module Memory API structures are not protected
21-
by locks. This is because the initialization,
22-
allocation, and freeing of resources should always
23-
be done in the same thread. This option adds an
24-
assert to make sure no other thread makes such
25-
operations.
26-
2716
config CADENCE_CODEC
2817
bool "Cadence codec"
2918
help

src/audio/module_adapter/module/generic.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@
2626
#include <ipc4/pipeline.h>
2727
#endif
2828

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-
3929
LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL);
4030

4131
int module_load_config(struct comp_dev *dev, const void *cfg, size_t size)
@@ -124,9 +114,6 @@ int module_init(struct processing_module *mod)
124114
return -EIO;
125115
}
126116

127-
#if CONFIG_MODULE_MEMORY_API_DEBUG && defined(__ZEPHYR__)
128-
mod->priv.resources.rsrc_mngr = k_current_get();
129-
#endif
130117
/* Now we can proceed with module specific initialization */
131118
#if CONFIG_SOF_USERSPACE_APPLICATION
132119
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
@@ -192,8 +179,6 @@ void *z_impl_mod_balloc_align(struct processing_module *mod, size_t size, size_t
192179
struct module_resources *res = &mod->priv.resources;
193180
struct module_resource *container;
194181

195-
MEM_API_CHECK_THREAD(res);
196-
197182
k_mutex_lock(&res->lock, K_FOREVER);
198183

199184
container = container_get(mod);
@@ -250,8 +235,6 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
250235
struct module_resources *res = &mod->priv.resources;
251236
struct module_resource *container;
252237

253-
MEM_API_CHECK_THREAD(res);
254-
255238
k_mutex_lock(&res->lock, K_FOREVER);
256239

257240
container = container_get(mod);
@@ -305,8 +288,6 @@ struct comp_data_blob_handler *z_impl_mod_data_blob_handler_new(struct processin
305288
struct comp_data_blob_handler *bhp;
306289
struct module_resource *container;
307290

308-
MEM_API_CHECK_THREAD(res);
309-
310291
k_mutex_lock(&res->lock, K_FOREVER);
311292

312293
container = container_get(mod);
@@ -347,8 +328,6 @@ const void *z_impl_mod_fast_get(struct processing_module *mod, const void * cons
347328
struct module_resource *container;
348329
const void *ptr;
349330

350-
MEM_API_CHECK_THREAD(res);
351-
352331
k_mutex_lock(&res->lock, K_FOREVER);
353332

354333
container = container_get(mod);
@@ -440,7 +419,6 @@ int z_impl_mod_free(struct processing_module *mod, const void *ptr)
440419
{
441420
struct module_resources *res = &mod->priv.resources;
442421

443-
MEM_API_CHECK_THREAD(res);
444422
if (!ptr)
445423
return 0;
446424

@@ -760,8 +738,6 @@ void mod_free_all(struct processing_module *mod)
760738
{
761739
struct module_resources *res = &mod->priv.resources;
762740

763-
MEM_API_CHECK_THREAD(res);
764-
765741
/* Free all contents found in used containers */
766742
struct mod_res_cb_arg cb_arg = {mod, NULL};
767743

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
#include <sof/audio/source_api.h>
2222
#include "module_interface.h"
2323

24-
/* The __ZEPHYR__ condition is to keep cmocka tests working */
25-
#if CONFIG_MODULE_MEMORY_API_DEBUG && defined(__ZEPHYR__)
26-
#include <zephyr/kernel/thread.h>
27-
#endif
2824
#include <sof/compiler_attributes.h>
2925

3026
/*
@@ -135,9 +131,6 @@ struct module_resources {
135131
size_t heap_usage;
136132
size_t heap_high_water_mark;
137133
struct mod_alloc_ctx *alloc;
138-
#if CONFIG_MODULE_MEMORY_API_DEBUG && defined(__ZEPHYR__)
139-
k_tid_t rsrc_mngr;
140-
#endif
141134
};
142135

143136
enum mod_resource_type {

0 commit comments

Comments
 (0)