comp: buffer: complain loudly if componenst try to under/over run buffers

Complain loudly in trace if we have components overruning or underruning
buffers. Components should check buffer free/avail before use.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This commit is contained in:
Liam Girdwood 2017-08-23 23:57:08 +01:00
parent 6d5723dfd6
commit 803f33a676
1 changed files with 16 additions and 0 deletions

View File

@ -81,6 +81,14 @@ void buffer_free(struct comp_buffer *buffer);
static inline void comp_update_buffer_produce(struct comp_buffer *buffer, static inline void comp_update_buffer_produce(struct comp_buffer *buffer,
uint32_t bytes) uint32_t bytes)
{ {
/* complain loudly if component tries to overrun buffer
* components MUST check for free space first !! */
if (bytes > buffer->free) {
trace_buffer_error("Xxo");
trace_value(buffer->ipc_buffer.comp.id);
return;
}
buffer->w_ptr += bytes; buffer->w_ptr += bytes;
/* check for pointer wrap */ /* check for pointer wrap */
@ -107,6 +115,14 @@ static inline void comp_update_buffer_produce(struct comp_buffer *buffer,
static inline void comp_update_buffer_consume(struct comp_buffer *buffer, static inline void comp_update_buffer_consume(struct comp_buffer *buffer,
uint32_t bytes) uint32_t bytes)
{ {
/* complain loudly if component tries to underrun buffer
* components MUST check for avail space first !! */
if (buffer->avail < bytes) {
trace_buffer_error("Xxu");
trace_value(buffer->ipc_buffer.comp.id);
return;
}
buffer->r_ptr += bytes; buffer->r_ptr += bytes;
/* check for pointer wrap */ /* check for pointer wrap */