Skip to content

Commit

Permalink
audio: Put buffer state log under CONFIG_SOF_LOG_DBG_BUFFER switch
Browse files Browse the repository at this point in the history
comp_update_buffer_consume() and comp_update_buffer_produce() generate
too much log output. Usually such amount of logs results in many log
messages been dropped. It is also results in significant CPU load if
selected log backend formats log messages at runtime.

This patch adds a separate switch to enable these logs only when necessary.
Default value is 'n'.

Signed-off-by: Serhiy Katsyuba <[email protected]>
  • Loading branch information
serhiy-katsyuba-intel authored and kv2019i committed Aug 16, 2023
1 parent 6f4084b commit 3813a13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Kconfig.zephyr-log
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ config SOF_LOG_LEVEL
default 3 if SOF_LOG_LEVEL_INF
default 4 if SOF_LOG_LEVEL_DBG

config SOF_LOG_DBG_BUFFER
bool "Log buffer state on each consume/produce call"
default n
help
Dumps buffer struct audio_stream values on each call to comp_update_buffer_consume()
and comp_update_buffer_produce().
WARNING: Produces too much log output which usually results in many log messaged been
dropped! Also, if selected log backend formats log messages at runtime, enabling this
option results in significant CPU load!

endmenu
8 changes: 8 additions & 0 deletions src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,13 @@ void comp_update_buffer_produce(struct comp_buffer __sparse_cache *buffer, uint3

/* return if no bytes */
if (!bytes) {
#if CONFIG_SOF_LOG_DBG_BUFFER
buf_dbg(buffer, "comp_update_buffer_produce(), no bytes to produce, source->comp.id = %u, source->comp.type = %u, sink->comp.id = %u, sink->comp.type = %u",
buffer->source ? dev_comp_id(buffer->source) : (unsigned int)UINT32_MAX,
buffer->source ? dev_comp_type(buffer->source) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_id(buffer->sink) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_type(buffer->sink) : (unsigned int)UINT32_MAX);
#endif
return;
}

Expand All @@ -242,6 +244,7 @@ void comp_update_buffer_produce(struct comp_buffer __sparse_cache *buffer, uint3
notifier_event(cache_to_uncache(buffer), NOTIFIER_ID_BUFFER_PRODUCE,
NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data));

#if CONFIG_SOF_LOG_DBG_BUFFER
buf_dbg(buffer, "comp_update_buffer_produce(), ((buffer->avail << 16) | buffer->free) = %08x, ((buffer->id << 16) | buffer->size) = %08x",
(audio_stream_get_avail_bytes(&buffer->stream) << 16) |
audio_stream_get_free_bytes(&buffer->stream),
Expand All @@ -251,6 +254,7 @@ void comp_update_buffer_produce(struct comp_buffer __sparse_cache *buffer, uint3
(char *)audio_stream_get_addr(&buffer->stream)) << 16 |
((char *)audio_stream_get_wptr(&buffer->stream) -
(char *)audio_stream_get_addr(&buffer->stream)));
#endif
}

void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint32_t bytes)
Expand All @@ -263,11 +267,13 @@ void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint3

/* return if no bytes */
if (!bytes) {
#if CONFIG_SOF_LOG_DBG_BUFFER
buf_dbg(buffer, "comp_update_buffer_consume(), no bytes to consume, source->comp.id = %u, source->comp.type = %u, sink->comp.id = %u, sink->comp.type = %u",
buffer->source ? dev_comp_id(buffer->source) : (unsigned int)UINT32_MAX,
buffer->source ? dev_comp_type(buffer->source) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_id(buffer->sink) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_type(buffer->sink) : (unsigned int)UINT32_MAX);
#endif
return;
}

Expand All @@ -276,6 +282,7 @@ void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint3
notifier_event(cache_to_uncache(buffer), NOTIFIER_ID_BUFFER_CONSUME,
NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data));

#if CONFIG_SOF_LOG_DBG_BUFFER
buf_dbg(buffer, "comp_update_buffer_consume(), (buffer->avail << 16) | buffer->free = %08x, (buffer->id << 16) | buffer->size = %08x, (buffer->r_ptr - buffer->addr) << 16 | (buffer->w_ptr - buffer->addr)) = %08x",
(audio_stream_get_avail_bytes(&buffer->stream) << 16) |
audio_stream_get_free_bytes(&buffer->stream),
Expand All @@ -284,6 +291,7 @@ void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint3
(char *)audio_stream_get_addr(&buffer->stream)) << 16 |
((char *)audio_stream_get_wptr(&buffer->stream) -
(char *)audio_stream_get_addr(&buffer->stream)));
#endif
}

/*
Expand Down

0 comments on commit 3813a13

Please sign in to comment.