Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinszkudlinski committed Sep 1, 2023
1 parent 1a31971 commit 801a3f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
17 changes: 2 additions & 15 deletions src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,6 @@ void buffer_free(struct comp_buffer *buffer)
coherent_free_thread(buffer, c);
}

/*
* comp_update_buffer_produce() and comp_update_buffer_consume() send
* NOTIFIER_ID_BUFFER_PRODUCE and NOTIFIER_ID_BUFFER_CONSUME notifier events
* respectively. The only recipient of those notifications is probes. The
* target for those notifications is always the current core, therefore notifier
* callbacks will be called synchronously from notifier_event() calls. Therefore
* we cannot pass unlocked buffer pointers to probes, because if they try to
* acquire the buffer, that can cause a deadlock. In general locked objects
* shouldn't be passed to potentially asynchronous contexts, but here we have no
* choice but to use our knowledge of the local notifier behaviour and pass
* locked buffers to notification recipients.
*/
void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes)
{
struct buffer_cb_transact cb_data = {
Expand All @@ -225,8 +213,7 @@ void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes)

audio_stream_produce(&buffer->stream, bytes);

/* Notifier looks for the pointer value to match it against registration */
notifier_event(cache_to_uncache(buffer), NOTIFIER_ID_BUFFER_PRODUCE,
notifier_event(buffer, NOTIFIER_ID_BUFFER_PRODUCE,
NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data));

#if CONFIG_SOF_LOG_DBG_BUFFER
Expand Down Expand Up @@ -264,7 +251,7 @@ void comp_update_buffer_consume(struct comp_buffer *buffer, uint32_t bytes)

audio_stream_consume(&buffer->stream, bytes);

notifier_event(cache_to_uncache(buffer), NOTIFIER_ID_BUFFER_CONSUME,
notifier_event(buffer, NOTIFIER_ID_BUFFER_CONSUME,
NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data));

#if CONFIG_SOF_LOG_DBG_BUFFER
Expand Down
10 changes: 5 additions & 5 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,23 +327,23 @@ static inline void module_update_buffer_position(struct input_stream_buffer *inp
}

__must_check static inline
struct module_source_info *module_source_info_acquire(struct module_source_info *msi)
struct module_source_info __sparse_cache *module_source_info_acquire(struct module_source_info *msi)
{
struct coherent *c;
struct coherent __sparse_cache *c;

c = coherent_acquire_thread(&msi->c, sizeof(*msi));

return container_of(c, struct module_source_info, c);
return attr_container_of(c, struct module_source_info __sparse_cache, c, __sparse_cache);
}

static inline void module_source_info_release(struct module_source_info *msi)
static inline void module_source_info_release(struct module_source_info __sparse_cache *msi)
{
coherent_release_thread(&msi->c, sizeof(*msi));
}

/* when source argument is NULL, this function returns the first unused entry */
static inline
int find_module_source_index(struct module_source_info *msi,
int find_module_source_index(struct module_source_info __sparse_cache *msi,
const struct comp_dev *source)
{
int i;
Expand Down

0 comments on commit 801a3f8

Please sign in to comment.