Skip to content

Commit 5e85a71

Browse files
committed
audio: module_adapter: remove unnecessary IRQ lock/unlock
In the past, the module adapter prepare and free methods called buffer_attach() and buffer_detach() directly. To call these methods safely, it was required to disable IRQs. See commit 3e3d0cd ("buffer: prevent cache corruption") for history and rationale. However, in commit ecc55f8 ("buf: split sink_list connector to 2 fields") the direct calls to buffer.h were removed. The locks were still kept. Reviewing the code today, the protected operations work on buffer list maintained in "mod->raw_data_buffers_list". This list is used only by the module adapter itself. External connections go through component "dev->bsink_list" and "dev->bsource_list", which are separate objects and only used in prepare() by the module adapter. As the pipeline code will ensure module's copy() is not called concurrently with prepare() and free(), it is no longer required to use locks to protect against list operations on the internal list. Removing direct calls to disable interrupts allows to run this code in user-space. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 6f1170c commit 5e85a71

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ int module_adapter_prepare(struct comp_dev *dev)
640640
buff_size, memory_flags,
641641
PLATFORM_DCACHE_ALIGN,
642642
BUFFER_USAGE_NOT_SHARED);
643-
uint32_t flags;
644643

645644
if (!buffer) {
646645
comp_err(dev, "failed to allocate local buffer");
@@ -650,9 +649,7 @@ int module_adapter_prepare(struct comp_dev *dev)
650649

651650
vregion_get(md->resources.alloc->vreg);
652651

653-
irq_local_disable(flags);
654652
list_item_prepend(&buffer->buffers_list, &mod->raw_data_buffers_list);
655-
irq_local_enable(flags);
656653

657654
buffer_set_params(buffer, mod->stream_params, BUFFER_UPDATE_FORCE);
658655
audio_buffer_reset(&buffer->audio_buffer);
@@ -682,11 +679,8 @@ int module_adapter_prepare(struct comp_dev *dev)
682679
list_for_item_safe(blist, _blist, &mod->raw_data_buffers_list) {
683680
struct comp_buffer *buffer = container_of(blist, struct comp_buffer,
684681
buffers_list);
685-
uint32_t flags;
686682

687-
irq_local_disable(flags);
688683
list_item_del(&buffer->buffers_list);
689-
irq_local_enable(flags);
690684
buffer_free(buffer);
691685
}
692686

@@ -1474,11 +1468,7 @@ void module_adapter_free(struct comp_dev *dev)
14741468
list_for_item_safe(blist, _blist, &mod->raw_data_buffers_list) {
14751469
struct comp_buffer *buffer = container_of(blist, struct comp_buffer,
14761470
buffers_list);
1477-
uint32_t flags;
1478-
1479-
irq_local_disable(flags);
14801471
list_item_del(&buffer->buffers_list);
1481-
irq_local_enable(flags);
14821472
buffer_free(buffer);
14831473
}
14841474

0 commit comments

Comments
 (0)