Skip to content

Commit 4d6bc14

Browse files
committed
Revert "module: generic: add mutex to protect module_resources"
This reverts commit 7bb70f5.
1 parent d48ffd4 commit 4d6bc14

2 files changed

Lines changed: 5 additions & 41 deletions

File tree

src/audio/module_adapter/module/generic.c

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313

1414
#include <rtos/symbol.h>
15-
#include <rtos/mutex.h>
1615
#include <sof/compiler_attributes.h>
1716
#include <sof/objpool.h>
1817
#include <sof/audio/module_adapter/module/generic.h>
@@ -89,7 +88,6 @@ void mod_resource_init(struct processing_module *mod)
8988
struct module_resources *res = &mod->priv.resources;
9089

9190
/* Init memory list */
92-
k_mutex_init(&res->lock);
9391
list_init(&res->objpool.list);
9492
res->objpool.heap = res->alloc->heap;
9593
res->objpool.vreg = res->alloc->vreg;
@@ -194,18 +192,13 @@ void *z_impl_mod_balloc_align(struct processing_module *mod, size_t size, size_t
194192

195193
MEM_API_CHECK_THREAD(res);
196194

197-
k_mutex_lock(&res->lock, K_FOREVER);
198-
199195
container = container_get(mod);
200-
if (!container) {
201-
k_mutex_unlock(&res->lock);
196+
if (!container)
202197
return NULL;
203-
}
204198

205199
if (!size) {
206200
comp_err(mod->dev, "requested allocation of 0 bytes.");
207201
container_put(mod, container);
208-
k_mutex_unlock(&res->lock);
209202
return NULL;
210203
}
211204

@@ -217,7 +210,6 @@ void *z_impl_mod_balloc_align(struct processing_module *mod, size_t size, size_t
217210
comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.",
218211
size, alignment, dev_comp_id(mod->dev));
219212
container_put(mod, container);
220-
k_mutex_unlock(&res->lock);
221213
return NULL;
222214
}
223215
/* Store reference to allocated memory */
@@ -229,7 +221,6 @@ void *z_impl_mod_balloc_align(struct processing_module *mod, size_t size, size_t
229221
if (res->heap_usage > res->heap_high_water_mark)
230222
res->heap_high_water_mark = res->heap_usage;
231223

232-
k_mutex_unlock(&res->lock);
233224
return ptr;
234225
}
235226
EXPORT_SYMBOL(z_impl_mod_balloc_align);
@@ -252,18 +243,13 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
252243

253244
MEM_API_CHECK_THREAD(res);
254245

255-
k_mutex_lock(&res->lock, K_FOREVER);
256-
257246
container = container_get(mod);
258-
if (!container) {
259-
k_mutex_unlock(&res->lock);
247+
if (!container)
260248
return NULL;
261-
}
262249

263250
if (!size) {
264251
comp_err(mod->dev, "requested allocation of 0 bytes.");
265252
container_put(mod, container);
266-
k_mutex_unlock(&res->lock);
267253
return NULL;
268254
}
269255

@@ -274,7 +260,6 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
274260
comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.",
275261
size, alignment, dev_comp_id(mod->dev));
276262
container_put(mod, container);
277-
k_mutex_unlock(&res->lock);
278263
return NULL;
279264
}
280265
/* Store reference to allocated memory */
@@ -286,7 +271,6 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
286271
if (res->heap_usage > res->heap_high_water_mark)
287272
res->heap_high_water_mark = res->heap_usage;
288273

289-
k_mutex_unlock(&res->lock);
290274
return ptr;
291275
}
292276
EXPORT_SYMBOL(z_impl_mod_alloc_ext);
@@ -301,32 +285,26 @@ EXPORT_SYMBOL(z_impl_mod_alloc_ext);
301285
#if CONFIG_COMP_BLOB
302286
struct comp_data_blob_handler *z_impl_mod_data_blob_handler_new(struct processing_module *mod)
303287
{
304-
struct module_resources *res = &mod->priv.resources;
288+
struct module_resources * __maybe_unused res = &mod->priv.resources;
305289
struct comp_data_blob_handler *bhp;
306290
struct module_resource *container;
307291

308292
MEM_API_CHECK_THREAD(res);
309293

310-
k_mutex_lock(&res->lock, K_FOREVER);
311-
312294
container = container_get(mod);
313-
if (!container) {
314-
k_mutex_unlock(&res->lock);
295+
if (!container)
315296
return NULL;
316-
}
317297

318298
bhp = comp_data_blob_handler_new_ext(mod->dev, false, NULL, NULL);
319299
if (!bhp) {
320300
container_put(mod, container);
321-
k_mutex_unlock(&res->lock);
322301
return NULL;
323302
}
324303

325304
container->bhp = bhp;
326305
container->size = 0;
327306
container->type = MOD_RES_BLOB_HANDLER;
328307

329-
k_mutex_unlock(&res->lock);
330308
return bhp;
331309
}
332310
EXPORT_SYMBOL(z_impl_mod_data_blob_handler_new);
@@ -349,26 +327,20 @@ const void *z_impl_mod_fast_get(struct processing_module *mod, const void * cons
349327

350328
MEM_API_CHECK_THREAD(res);
351329

352-
k_mutex_lock(&res->lock, K_FOREVER);
353-
354330
container = container_get(mod);
355-
if (!container) {
356-
k_mutex_unlock(&res->lock);
331+
if (!container)
357332
return NULL;
358-
}
359333

360334
ptr = fast_get(res->alloc, dram_ptr, size);
361335
if (!ptr) {
362336
container_put(mod, container);
363-
k_mutex_unlock(&res->lock);
364337
return NULL;
365338
}
366339

367340
container->sram_ptr = ptr;
368341
container->size = 0;
369342
container->type = MOD_RES_FAST_GET;
370343

371-
k_mutex_unlock(&res->lock);
372344
return ptr;
373345
}
374346
EXPORT_SYMBOL(z_impl_mod_fast_get);
@@ -446,12 +418,8 @@ int z_impl_mod_free(struct processing_module *mod, const void *ptr)
446418

447419
/* Find which container holds this memory */
448420
struct mod_res_cb_arg cb_arg = {mod, ptr};
449-
450-
k_mutex_lock(&res->lock, K_FOREVER);
451421
int ret = objpool_iterate(&res->objpool, mod_res_free, &cb_arg);
452422

453-
k_mutex_unlock(&res->lock);
454-
455423
if (ret < 0)
456424
comp_err(mod->dev, "error: could not find memory pointed by %p", ptr);
457425

@@ -765,10 +733,8 @@ void mod_free_all(struct processing_module *mod)
765733
/* Free all contents found in used containers */
766734
struct mod_res_cb_arg cb_arg = {mod, NULL};
767735

768-
k_mutex_lock(&res->lock, K_FOREVER);
769736
objpool_iterate(&res->objpool, mod_res_free, &cb_arg);
770737
objpool_prune(&res->objpool);
771-
k_mutex_unlock(&res->lock);
772738

773739
/* Make sure resource lists and accounting are reset */
774740
mod_resource_init(mod);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef __SOF_AUDIO_MODULE_GENERIC__
1414
#define __SOF_AUDIO_MODULE_GENERIC__
1515

16-
#include <rtos/mutex.h>
1716
#include <sof/objpool.h>
1817
#include <sof/ut.h>
1918
#include <sof/audio/component.h>
@@ -130,7 +129,6 @@ struct module_param {
130129
* when the module unloads.
131130
*/
132131
struct module_resources {
133-
struct k_mutex lock;
134132
struct objpool_head objpool;
135133
size_t heap_usage;
136134
size_t heap_high_water_mark;

0 commit comments

Comments
 (0)