This patch adds a new trace feature to send any error states/values after the trace messages to mbox and modifes users of trace_value() to use trace_error_value().
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- Tested with Minnowboard Turbot with RT5651 Kernel: https://github.com/plbossart/sound.git branch: topic/sof-v4.14 SOF: https://github.com/ranj063/sof.git branch: debug/trace_test SOFT: 1.1-stable --- --- src/audio/buffer.c | 2 +- src/audio/component.c | 14 +++++++------- src/audio/dai.c | 18 +++++++++--------- src/audio/eq_fir.c | 2 +- src/audio/eq_iir.c | 2 +- src/audio/host.c | 6 +++--- src/audio/pipeline.c | 16 ++++++++-------- src/audio/src.c | 14 +++++++------- src/audio/volume.c | 14 +++++++------- src/drivers/dw-dma.c | 12 ++++++------ src/drivers/hda-dma.c | 4 ++-- src/include/reef/audio/component.h | 4 ++-- src/include/reef/trace.h | 6 ++++++ src/include/reef/wait.h | 4 ++-- src/ipc/intel-ipc.c | 24 ++++++++++++------------ src/ipc/ipc.c | 16 ++++++++-------- src/lib/alloc.c | 4 ++-- 17 files changed, 84 insertions(+), 78 deletions(-)
diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 360ad6b..a5d92b2 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -55,7 +55,7 @@ struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc) /* validate request */ if (desc->size == 0 || desc->size > HEAP_BUFFER_SIZE) { trace_buffer_error("ebg"); - trace_value(desc->size); + trace_error_value(desc->size); return NULL; }
diff --git a/src/audio/component.c b/src/audio/component.c index f27f350..1802278 100644 --- a/src/audio/component.c +++ b/src/audio/component.c @@ -79,7 +79,7 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp) drv = get_drv(comp->type); if (drv == NULL) { trace_comp_error("eCD"); - trace_value(comp->type); + trace_error_value(comp->type); return NULL; }
@@ -127,7 +127,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) dev->state = COMP_STATE_ACTIVE; } else { trace_comp_error("CES"); - trace_value(dev->state); + trace_error_value(dev->state); ret = -EINVAL; } break; @@ -136,7 +136,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) dev->state = COMP_STATE_ACTIVE; } else { trace_comp_error("CEr"); - trace_value(dev->state); + trace_error_value(dev->state); ret = -EINVAL; } break; @@ -146,7 +146,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) dev->state = COMP_STATE_PREPARE; } else { trace_comp_error("CEs"); - trace_value(dev->state); + trace_error_value(dev->state); ret = -EINVAL; } break; @@ -156,7 +156,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) dev->state = COMP_STATE_PAUSED; else { trace_comp_error("CEp"); - trace_value(dev->state); + trace_error_value(dev->state); ret = -EINVAL; } break; @@ -166,7 +166,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) if (dev->state == COMP_STATE_ACTIVE || dev->state == COMP_STATE_PAUSED) { trace_comp_error("CER"); - trace_value(dev->state); + trace_error_value(dev->state); ret = 0; } break; @@ -176,7 +176,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) dev->state = COMP_STATE_PREPARE; } else { trace_comp_error("CEP"); - trace_value(dev->state); + trace_error_value(dev->state); ret = -EINVAL; } break; diff --git a/src/audio/dai.c b/src/audio/dai.c index 061af5e..f1b4a8e 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -278,10 +278,10 @@ static int dai_playback_params(struct comp_dev *dev) err = buffer_set_size(dma_buffer, buffer_size); if (err < 0) { trace_dai_error("ep1"); - trace_value(source_config->periods_sink); - trace_value(dd->period_bytes); - trace_value(buffer_size); - trace_value(dma_buffer->alloc_size); + trace_error_value(source_config->periods_sink); + trace_error_value(dd->period_bytes); + trace_error_value(buffer_size); + trace_error_value(dma_buffer->alloc_size); return err; }
@@ -346,10 +346,10 @@ static int dai_capture_params(struct comp_dev *dev) err = buffer_set_size(dma_buffer, buffer_size); if (err < 0) { trace_dai_error("ec1"); - trace_value(sink_config->periods_sink); - trace_value(dd->period_bytes); - trace_value(buffer_size); - trace_value(dma_buffer->alloc_size); + trace_error_value(sink_config->periods_sink); + trace_error_value(dd->period_bytes); + trace_error_value(buffer_size); + trace_error_value(dma_buffer->alloc_size); return err; }
@@ -576,7 +576,7 @@ static int dai_cmd(struct comp_dev *dev, int cmd, void *data) ret = wait_for_completion_timeout(&dd->complete); if (ret < 0) { trace_dai_error("ed0"); - trace_value(cmd); + trace_error_value(cmd); } break; default: diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c index b6ec58f..52988cd 100644 --- a/src/audio/eq_fir.c +++ b/src/audio/eq_fir.c @@ -386,7 +386,7 @@ static int fir_cmd_set_data(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdat } } else { trace_eq_error("une"); - trace_value(cdata->index); + trace_error_value(cdata->index); return -EINVAL; } break; diff --git a/src/audio/eq_iir.c b/src/audio/eq_iir.c index 2a1dd59..bbcd66b 100644 --- a/src/audio/eq_iir.c +++ b/src/audio/eq_iir.c @@ -382,7 +382,7 @@ static int iir_cmd_set_data(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdat } } else { trace_eq_iir_error("une"); - trace_value(cdata->index); + trace_error_value(cdata->index); return -EINVAL; } break; diff --git a/src/audio/host.c b/src/audio/host.c index 744ca02..9177d99 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -671,15 +671,15 @@ static int host_params(struct comp_dev *dev) err = buffer_set_size(hd->dma_buffer, buffer_size); if (err < 0) { trace_host_error("eSz"); - trace_value(buffer_size); + trace_error_value(buffer_size); return err; }
/* component buffer size must be divisor of host buffer size */ if (hd->host_size % hd->period_bytes) { trace_comp_error("eHB"); - trace_value(hd->host_size); - trace_value(hd->period_bytes); + trace_error_value(hd->host_size); + trace_error_value(hd->period_bytes); return -EINVAL; }
diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c index c7f8aed..1b7f248 100644 --- a/src/audio/pipeline.c +++ b/src/audio/pipeline.c @@ -392,7 +392,7 @@ static int component_op_downstream(struct op_data *op_data, case COMP_OPS_BUFFER: /* handled by other API call */ default: trace_pipe_error("eOi"); - trace_value(op_data->op); + trace_error_value(op_data->op); return -EINVAL; }
@@ -473,7 +473,7 @@ static int component_op_upstream(struct op_data *op_data, case COMP_OPS_BUFFER: /* handled by other API call */ default: trace_pipe_error("eOi"); - trace_value(op_data->op); + trace_error_value(op_data->op); return -EINVAL; }
@@ -647,8 +647,8 @@ int pipeline_cmd(struct pipeline *p, struct comp_dev *host, int cmd,
if (ret < 0) { trace_ipc_error("pc0"); - trace_value(host->comp.id); - trace_value(cmd); + trace_error_value(host->comp.id); + trace_error_value(cmd); }
spin_unlock(&p->lock); @@ -693,7 +693,7 @@ int pipeline_params(struct pipeline *p, struct comp_dev *host,
if (ret < 0) { trace_ipc_error("pp0"); - trace_value(host->comp.id); + trace_error_value(host->comp.id); }
spin_unlock(&p->lock); @@ -723,7 +723,7 @@ int pipeline_reset(struct pipeline *p, struct comp_dev *host)
if (ret < 0) { trace_ipc_error("pr0"); - trace_value(host->comp.id); + trace_error_value(host->comp.id); }
spin_unlock(&p->lock); @@ -774,7 +774,7 @@ static int pipeline_copy_from_upstream(struct comp_dev *start, err = pipeline_copy_from_upstream(start, buffer->source); if (err < 0) { trace_pipe_error("ePU"); - trace_value(current->comp.id); + trace_error_value(current->comp.id); return err; } } @@ -837,7 +837,7 @@ static int pipeline_copy_to_downstream(struct comp_dev *start, err = pipeline_copy_to_downstream(start, buffer->sink); if (err < 0) { trace_pipe_error("ePD"); - trace_value(current->comp.id); + trace_error_value(current->comp.id); return err; } } diff --git a/src/audio/src.c b/src/audio/src.c index cca0cbc..a579fa9 100644 --- a/src/audio/src.c +++ b/src/audio/src.c @@ -645,10 +645,10 @@ static int src_params(struct comp_dev *dev) params->channels, dev->frames, frames_is_for_source); if (err < 0) { trace_src_error("sr1"); - trace_value(source_rate); - trace_value(sink_rate); - trace_value(params->channels); - trace_value(dev->frames); + trace_error_value(source_rate); + trace_error_value(sink_rate); + trace_error_value(params->channels); + trace_error_value(dev->frames); return err; }
@@ -666,7 +666,7 @@ static int src_params(struct comp_dev *dev) delay_lines_size); if (!cd->delay_lines) { trace_src_error("sr3"); - trace_value(delay_lines_size); + trace_error_value(delay_lines_size); return -EINVAL; }
@@ -721,8 +721,8 @@ static int src_params(struct comp_dev *dev) err = buffer_set_size(sink, q * dev->frames * dev->frame_bytes); if (err < 0) { trace_src_error("eSz"); - trace_value(sink->alloc_size); - trace_value(q * dev->frames * dev->frame_bytes); + trace_error_value(sink->alloc_size); + trace_error_value(q * dev->frames * dev->frame_bytes); return err; }
diff --git a/src/audio/volume.c b/src/audio/volume.c index df926c5..1a3f436 100644 --- a/src/audio/volume.c +++ b/src/audio/volume.c @@ -943,15 +943,15 @@ static int volume_prepare(struct comp_dev *dev) /* validate */ if (cd->sink_period_bytes == 0) { trace_volume_error("vp1"); - trace_value(dev->frames); - trace_value(sinkb->sink->frame_bytes); + trace_error_value(dev->frames); + trace_error_value(sinkb->sink->frame_bytes); ret = -EINVAL; goto err; } if (cd->source_period_bytes == 0) { trace_volume_error("vp2"); - trace_value(dev->frames); - trace_value(sourceb->source->frame_bytes); + trace_error_value(dev->frames); + trace_error_value(sourceb->source->frame_bytes); ret = -EINVAL; goto err; } @@ -970,9 +970,9 @@ static int volume_prepare(struct comp_dev *dev) goto found; } trace_volume_error("vp3"); - trace_value(cd->source_format); - trace_value(cd->sink_format); - trace_value(dev->params.channels); + trace_error_value(cd->source_format); + trace_error_value(cd->sink_format); + trace_error_value(dev->params.channels);
err: comp_set_state(dev, COMP_CMD_RESET); diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c index 8cb8e31..1a3c7a9 100644 --- a/src/drivers/dw-dma.c +++ b/src/drivers/dw-dma.c @@ -374,9 +374,9 @@ static int dw_dma_start(struct dma *dma, int channel) (dw_read(dma, DW_DMA_CHAN_EN) & (0x1 << channel))) { ret = -EBUSY; trace_dma_error("eS0"); - trace_value(dw_read(dma, DW_DMA_CHAN_EN)); - trace_value(dw_read(dma, DW_CFG_LOW(channel))); - trace_value(p->chan[channel].status); + trace_error_value(dw_read(dma, DW_DMA_CHAN_EN)); + trace_error_value(dw_read(dma, DW_CFG_LOW(channel))); + trace_error_value(p->chan[channel].status); goto out; }
@@ -480,7 +480,7 @@ static int dw_dma_stop(struct dma *dma, int channel) /* is channel stii active ? */ if ((dw_read(dma, DW_DMA_CHAN_EN) & (0x1 << channel))) { trace_dma_error("ea0"); - trace_value(channel); + trace_error_value(channel); }
p->chan[channel].status = COMP_STATE_PREPARE; @@ -912,7 +912,7 @@ static void dw_dma_irq_handler(void *data) status_intr = dw_read(dma, DW_INTR_STATUS); if (!status_intr) { trace_dma_error("eDI"); - trace_value(status_intr); + trace_error_value(status_intr); }
tracev_dma("irq"); @@ -1078,7 +1078,7 @@ static void dw_dma_irq_handler(void *data) status_block_new = dw_read(dma, DW_STATUS_BLOCK); if (status_block_new) { trace_dma_error("eI2"); - trace_value(status_block_new); + trace_error_value(status_block_new); }
for (i = 0; i < DW_MAX_CHAN; i++) { diff --git a/src/drivers/hda-dma.c b/src/drivers/hda-dma.c index caea70e..c00fb2e 100644 --- a/src/drivers/hda-dma.c +++ b/src/drivers/hda-dma.c @@ -192,8 +192,8 @@ static int hda_dma_start(struct dma *dma, int channel) (dgcs & DGCS_GEN)) { ret = -EBUSY; trace_host_error("eS0"); - trace_value(dgcs); - trace_value(p->chan[channel].status); + trace_error_value(dgcs); + trace_error_value(p->chan[channel].status); goto out; }
diff --git a/src/include/reef/audio/component.h b/src/include/reef/audio/component.h index f25ad3d..538d476 100644 --- a/src/include/reef/audio/component.h +++ b/src/include/reef/audio/component.h @@ -250,8 +250,8 @@ static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data) && ((cdata->data->magic != SOF_ABI_MAGIC) || (cdata->data->abi != SOF_ABI_VERSION))) { trace_comp_error("abi"); - trace_value(cdata->data->magic); - trace_value(cdata->data->abi); + trace_error_value(cdata->data->magic); + trace_error_value(cdata->data->abi); return -EINVAL; }
diff --git a/src/include/reef/trace.h b/src/include/reef/trace.h index 2e22b16..7afbd23 100644 --- a/src/include/reef/trace.h +++ b/src/include/reef/trace.h @@ -103,6 +103,7 @@
void _trace_event(uint32_t event); void _trace_error(uint32_t event); +void _trace_error_value(uint32_t event); void _trace_event_atomic(uint32_t event); void _trace_error_atomic(uint32_t event); void trace_off(void); @@ -139,9 +140,14 @@ void trace_init(struct reef * reef); _trace_error_atomic(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2]) #define trace_error_atomic(__c, __e) \ _trace_error_atomic(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2]) +/* write back error value to mbox*/ +#define trace_error_value(x) _trace_error_atomic(x) +#define trace_error_value_atomic(x) _trace_error_atomic(x) #else #define trace_error(__c, __e) #define trace_error_atomic(__c, __e) +#define trace_error_value(x) +#define trace_error_value_atomic(x) #endif
#else diff --git a/src/include/reef/wait.h b/src/include/reef/wait.h index a598d48..e9737ec 100644 --- a/src/include/reef/wait.h +++ b/src/include/reef/wait.h @@ -139,8 +139,8 @@ static inline int wait_for_completion_timeout(completion_t *comp) return 0; } else { /* timeout */ - trace_value(c->timeout); - trace_value(c->complete); + trace_error_value(c->timeout); + trace_error_value(c->complete); return -ETIME; } } diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index fbe0b6e..5c062be 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -238,14 +238,14 @@ static int ipc_stream_pcm_params(uint32_t stream) pcm_dev = ipc_get_comp(_ipc, pcm_params->comp_id); if (pcm_dev == NULL) { trace_ipc_error("eAC"); - trace_value(pcm_params->comp_id); + trace_error_value(pcm_params->comp_id); return -EINVAL; }
/* sanity check comp */ if (pcm_dev->cd->pipeline == NULL) { trace_ipc_error("eA1"); - trace_value(pcm_params->comp_id); + trace_error_value(pcm_params->comp_id); return -EINVAL; }
@@ -350,7 +350,7 @@ static int ipc_stream_pcm_free(uint32_t header) /* sanity check comp */ if (pcm_dev->cd->pipeline == NULL) { trace_ipc_error("eF1"); - trace_value(free_req->comp_id); + trace_error_value(free_req->comp_id); return -EINVAL; }
@@ -470,7 +470,7 @@ static int ipc_stream_trigger(uint32_t header) cmd, NULL); if (ret < 0) { trace_ipc_error("eRc"); - trace_value(ipc_cmd); + trace_error_value(ipc_cmd); }
return ret; @@ -516,8 +516,8 @@ static int ipc_dai_config(uint32_t header) dai = dai_get(config->type, config->id); if (dai == NULL) { trace_ipc_error("eDi"); - trace_value(config->type); - trace_value(config->id); + trace_error_value(config->type); + trace_error_value(config->id); return -ENODEV; }
@@ -543,7 +543,7 @@ static int ipc_glb_dai_message(uint32_t header) //return ipc_comp_set_value(header, COMP_CMD_LOOPBACK); default: trace_ipc_error("eDc"); - trace_value(header); + trace_error_value(header); return -EINVAL; } } @@ -747,7 +747,7 @@ static int ipc_glb_debug_message(uint32_t header) return ipc_dma_trace_config(header); default: trace_ipc_error("eDc"); - trace_value(header); + trace_error_value(header); return -EINVAL; } } @@ -769,7 +769,7 @@ static int ipc_comp_value(uint32_t header, uint32_t cmd) comp_dev = ipc_get_comp(_ipc, data->comp_id); if (comp_dev == NULL){ trace_ipc_error("eVg"); - trace_value(data->comp_id); + trace_error_value(data->comp_id); return -ENODEV; } @@ -800,7 +800,7 @@ static int ipc_glb_comp_message(uint32_t header) return ipc_comp_value(header, COMP_CMD_GET_DATA); default: trace_ipc_error("eCc"); - trace_value(header); + trace_error_value(header); return -EINVAL; } } @@ -929,7 +929,7 @@ static int ipc_glb_tplg_message(uint32_t header) return ipc_glb_tplg_free(header, ipc_buffer_free); default: trace_ipc_error("eTc"); - trace_value(header); + trace_error_value(header); return -EINVAL; } } @@ -970,7 +970,7 @@ int ipc_cmd(void) return ipc_glb_debug_message(hdr->cmd); default: trace_ipc_error("eGc"); - trace_value(type); + trace_error_value(type); return -EINVAL; } } diff --git a/src/ipc/ipc.c b/src/ipc/ipc.c index 762bbf5..0b52cb2 100644 --- a/src/ipc/ipc.c +++ b/src/ipc/ipc.c @@ -108,7 +108,7 @@ int ipc_comp_new(struct ipc *ipc, struct sof_ipc_comp *comp) icd = ipc_get_comp(ipc, comp->id); if (icd != NULL) { trace_ipc_error("eCe"); - trace_value(comp->id); + trace_error_value(comp->id); return -EINVAL; }
@@ -162,7 +162,7 @@ int ipc_buffer_new(struct ipc *ipc, struct sof_ipc_buffer *desc) ibd = ipc_get_comp(ipc, desc->comp.id); if (ibd != NULL) { trace_ipc_error("eBe"); - trace_value(desc->comp.id); + trace_error_value(desc->comp.id); return -EINVAL; }
@@ -215,14 +215,14 @@ int ipc_comp_connect(struct ipc *ipc, icd_source = ipc_get_comp(ipc, connect->source_id); if (icd_source == NULL) { trace_ipc_error("eCr"); - trace_value(connect->source_id); + trace_error_value(connect->source_id); return -EINVAL; }
icd_sink = ipc_get_comp(ipc, connect->sink_id); if (icd_sink == NULL) { trace_ipc_error("eCn"); - trace_value(connect->sink_id); + trace_error_value(connect->sink_id); return -EINVAL; }
@@ -237,8 +237,8 @@ int ipc_comp_connect(struct ipc *ipc, icd_source->cd, icd_sink->cb); else { trace_ipc_error("eCt"); - trace_value(connect->source_id); - trace_value(connect->sink_id); + trace_error_value(connect->source_id); + trace_error_value(connect->sink_id); return -EINVAL; } } @@ -255,7 +255,7 @@ int ipc_pipeline_new(struct ipc *ipc, ipc_pipe = ipc_get_comp(ipc, pipe_desc->comp_id); if (ipc_pipe != NULL) { trace_ipc_error("ePi"); - trace_value(pipe_desc->comp_id); + trace_error_value(pipe_desc->comp_id); return -EINVAL; }
@@ -263,7 +263,7 @@ int ipc_pipeline_new(struct ipc *ipc, icd = ipc_get_comp(ipc, pipe_desc->sched_id); if (icd == NULL) { trace_ipc_error("ePs"); - trace_value(pipe_desc->sched_id); + trace_error_value(pipe_desc->sched_id); return -EINVAL; } if (icd->type != COMP_TYPE_COMPONENT) { diff --git a/src/lib/alloc.c b/src/lib/alloc.c index 27916e3..4803456 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -378,8 +378,8 @@ find:
error: trace_mem_error("eMm"); - trace_value(bytes); - trace_value(caps); + trace_error_value(bytes); + trace_error_value(caps); return NULL; }