From: Yan Wang yan.wang@linux.intel.com
It will use PIPE trace class and component DMA trace API. NULL will be passed into trace API when pipeline hasn't been initialized.
Signed-off-by: Yan Wang yan.wang@linux.intel.com --- Test with: CNL nocodec SOF master: c1f2682c210201bbbc96fce7b382b25b90d19775 SOF-Tool master: 86fe688a2b4f68a1ce87e0951686be12a00f1a3c https://github.com/plbossart/sound/tree/topic/sof-v4.14: d09db67c5a9d6dfc85f700669fa2e43c678c8d51 --- src/audio/pipeline.c | 190 ++++++++++++++++++++------------------- src/audio/pipeline_static.c | 2 +- src/include/sof/audio/pipeline.h | 15 +++- 3 files changed, 113 insertions(+), 94 deletions(-)
diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c index 0ed6b95..805a686 100644 --- a/src/audio/pipeline.c +++ b/src/audio/pipeline.c @@ -67,7 +67,7 @@ static void connect_upstream(struct pipeline *p, struct comp_dev *start, { struct list_item *clist;
- tracev_value(current->comp.id); + tracev_pipe_value(p, current->comp.id);
/* complete component init */ current->pipeline = p; @@ -107,7 +107,7 @@ static void connect_downstream(struct pipeline *p, struct comp_dev *start, { struct list_item *clist;
- tracev_value(current->comp.id); + tracev_pipe_value(p, current->comp.id);
/* complete component init */ current->pipeline = p; @@ -139,7 +139,7 @@ static void disconnect_upstream(struct pipeline *p, struct comp_dev *start, { struct list_item *clist;
- tracev_value(current->comp.id); + tracev_pipe_value(p, current->comp.id);
/* complete component init */ current->pipeline = NULL; @@ -168,7 +168,7 @@ static void disconnect_downstream(struct pipeline *p, struct comp_dev *start, { struct list_item *clist;
- tracev_value(current->comp.id); + tracev_pipe_value(p, current->comp.id);
/* complete component init */ current->pipeline = NULL; @@ -237,12 +237,12 @@ struct pipeline *pipeline_new(struct sof_ipc_pipe_new *pipe_desc, { struct pipeline *p;
- trace_pipe("new"); + trace_pipe(NULL, "new");
/* allocate new pipeline */ p = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*p)); if (p == NULL) { - trace_pipe_error("ePN"); + trace_pipe_error(NULL, "ePN"); return NULL; }
@@ -264,11 +264,11 @@ struct pipeline *pipeline_new(struct sof_ipc_pipe_new *pipe_desc, /* pipelines must be inactive */ int pipeline_free(struct pipeline *p) { - trace_pipe("fre"); + trace_pipe(p, "fre");
/* make sure we are not in use */ if (p->sched_comp->state > COMP_STATE_READY) { - trace_pipe_error("epb"); + trace_pipe_error(p, "epb"); return -EBUSY; }
@@ -290,12 +290,12 @@ int pipeline_complete(struct pipeline *p) /* now walk downstream and upstream form "start" component and complete component task and pipeline init */
- trace_pipe("com"); - trace_value(p->ipc_pipe.pipeline_id); + trace_pipe(p, "com"); + trace_pipe_value(p, p->ipc_pipe.pipeline_id);
/* check whether pipeline is already complete */ if (p->status != COMP_STATE_INIT) { - trace_pipe_error("epc"); + trace_pipe_error(p, "epc"); return -EINVAL; }
@@ -309,7 +309,7 @@ int pipeline_complete(struct pipeline *p) int pipeline_comp_connect(struct pipeline *p, struct comp_dev *source_comp, struct comp_buffer *sink_buffer) { - trace_pipe("cnc"); + trace_pipe(p, "cnc");
/* connect source to buffer */ spin_lock(&source_comp->lock); @@ -321,7 +321,7 @@ int pipeline_comp_connect(struct pipeline *p, struct comp_dev *source_comp, if (sink_buffer->source && sink_buffer->sink) sink_buffer->connected = 1;
- tracev_value((source_comp->comp.id << 16) | + tracev_pipe_value(p, (source_comp->comp.id << 16) | sink_buffer->ipc_buffer.comp.id); return 0; } @@ -330,7 +330,7 @@ int pipeline_comp_connect(struct pipeline *p, struct comp_dev *source_comp, int pipeline_buffer_connect(struct pipeline *p, struct comp_buffer *source_buffer, struct comp_dev *sink_comp) { - trace_pipe("cbc"); + trace_pipe(p, "cbc");
/* connect sink to buffer */ spin_lock(&sink_comp->lock); @@ -342,7 +342,7 @@ int pipeline_buffer_connect(struct pipeline *p, if (source_buffer->source && source_buffer->sink) source_buffer->connected = 1;
- tracev_value((source_buffer->ipc_buffer.comp.id << 16) | + tracev_pipe_value(p, (source_buffer->ipc_buffer.comp.id << 16) | sink_comp->comp.id); return 0; } @@ -352,15 +352,16 @@ int pipeline_buffer_connect(struct pipeline *p, * returning an error ( < 0) and returns immediately. Components returning a * positive error code also stop the graph walk on that branch causing the * walk to return to a shallower level in the graph. */ -static int component_op_downstream(struct op_data *op_data, - struct comp_dev *start, struct comp_dev *current, - struct comp_dev *previous) +static int component_op_downstream(struct pipeline *p, struct op_data *op_data, + struct comp_dev *start, + struct comp_dev *current, + struct comp_dev *previous) { struct list_item *clist; int err = 0;
- tracev_pipe("CO-"); - tracev_value(current->comp.id); + tracev_pipe(p, "CO-"); + tracev_pipe_value(p, current->comp.id);
/* do operation on this component */ switch (op_data->op) { @@ -392,20 +393,20 @@ static int component_op_downstream(struct op_data *op_data, break; case COMP_OPS_BUFFER: /* handled by other API call */ default: - trace_pipe_error("eOi"); - trace_error_value(op_data->op); + trace_pipe_error(p, "eOi"); + trace_pipe_error_value(p, op_data->op); return -EINVAL; }
/* don't walk the graph any further if this component fails */ if (err < 0) { - trace_pipe_error("eOp"); + trace_pipe_error(p, "eOp"); return err; } else if (err > 0 || (current != start && current->is_endpoint)) { /* we finish walking the graph if we reach the DAI or component is * currently active and configured already (err > 0). */ - tracev_pipe("C-D"); + tracev_pipe(p, "C-D"); return err; }
@@ -419,8 +420,8 @@ static int component_op_downstream(struct op_data *op_data, if (!buffer->connected) continue;
- err = component_op_downstream(op_data, start, buffer->sink, - current); + err = component_op_downstream(p, op_data, start, buffer->sink, + current); if (err < 0) break; } @@ -433,15 +434,16 @@ static int component_op_downstream(struct op_data *op_data, * returning an error ( < 0) and returns immediately. Components returning a * positive error code also stop the graph walk on that branch causing the * walk to return to a shallower level in the graph. */ -static int component_op_upstream(struct op_data *op_data, - struct comp_dev *start, struct comp_dev *current, - struct comp_dev *previous) +static int component_op_upstream(struct pipeline *p, struct op_data *op_data, + struct comp_dev *start, + struct comp_dev *current, + struct comp_dev *previous) { struct list_item *clist; int err = 0;
- tracev_pipe("CO+"); - tracev_value(current->comp.id); + tracev_pipe(p, "CO+"); + tracev_pipe_value(p, current->comp.id);
/* do operation on this component */ switch (op_data->op) { @@ -473,17 +475,17 @@ static int component_op_upstream(struct op_data *op_data, break; case COMP_OPS_BUFFER: /* handled by other API call */ default: - trace_pipe_error("eOi"); - trace_error_value(op_data->op); + trace_pipe_error(p, "eOi"); + trace_pipe_error_value(p, op_data->op); return -EINVAL; }
/* don't walk the graph any further if this component fails */ if (err < 0) { - trace_pipe_error("eOp"); + trace_pipe_error(p, "eOp"); return err; } else if (err > 0 || (current != start && current->is_endpoint)) { - tracev_pipe("C+D"); + tracev_pipe(p, "C+D"); return 0; }
@@ -497,8 +499,8 @@ static int component_op_upstream(struct op_data *op_data, if (!buffer->connected) continue;
- err = component_op_upstream(op_data, start, buffer->source, - current); + err = component_op_upstream(p, op_data, start, buffer->source, + current); if (err < 0) break; } @@ -508,8 +510,10 @@ static int component_op_upstream(struct op_data *op_data,
/* walk the graph upstream from start component in any pipeline and prepare * the buffer context for each inactive component */ -static int component_prepare_buffers_upstream(struct comp_dev *start, - struct comp_dev *current, struct comp_buffer *buffer) +static int component_prepare_buffers_upstream(struct pipeline *p, + struct comp_dev *start, + struct comp_dev *current, + struct comp_buffer *buffer) { struct list_item *clist; int err = 0; @@ -534,10 +538,11 @@ static int component_prepare_buffers_upstream(struct comp_dev *start, continue;
/* continue downstream */ - err = component_prepare_buffers_upstream(start, buffer->source, - buffer); + err = component_prepare_buffers_upstream(p, start, + buffer->source, + buffer); if (err < 0) { - trace_pipe_error("eBD"); + trace_pipe_error(p, "eBD"); break; } } @@ -548,8 +553,10 @@ static int component_prepare_buffers_upstream(struct comp_dev *start,
/* walk the graph downstream from start component in any pipeline and prepare * the buffer context for each inactive component */ -static int component_prepare_buffers_downstream(struct comp_dev *start, - struct comp_dev *current, struct comp_buffer *buffer) +static int component_prepare_buffers_downstream(struct pipeline *p, + struct comp_dev *start, + struct comp_dev *current, + struct comp_buffer *buffer) { struct list_item *clist; int err = 0; @@ -574,10 +581,11 @@ static int component_prepare_buffers_downstream(struct comp_dev *start, continue;
/* continue downstream */ - err = component_prepare_buffers_downstream(start, buffer->sink, - buffer); + err = component_prepare_buffers_downstream(p, start, + buffer->sink, + buffer); if (err < 0) { - trace_pipe_error("eBD"); + trace_pipe_error(p, "eBD"); break; } } @@ -592,7 +600,7 @@ int pipeline_prepare(struct pipeline *p, struct comp_dev *dev) struct op_data op_data; int ret = -1;
- trace_pipe("pre"); + trace_pipe(p, "pre");
op_data.p = p; op_data.op = COMP_OPS_PREPARE; @@ -602,19 +610,19 @@ int pipeline_prepare(struct pipeline *p, struct comp_dev *dev) /* playback pipelines can be preloaded from host before trigger */ if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) {
- ret = component_op_downstream(&op_data, dev, dev, NULL); + ret = component_op_downstream(p, &op_data, dev, dev, NULL); if (ret < 0) goto out;
/* set up reader and writer positions */ - component_prepare_buffers_downstream(dev, dev, NULL); + component_prepare_buffers_downstream(p, dev, dev, NULL); } else { - ret = component_op_upstream(&op_data, dev, dev, NULL); + ret = component_op_upstream(p, &op_data, dev, dev, NULL); if (ret < 0) goto out;
/* set up reader and writer positions */ - component_prepare_buffers_upstream(dev, dev, NULL); + component_prepare_buffers_upstream(p, dev, dev, NULL); }
out: @@ -629,7 +637,7 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd) int ret; uint32_t flags;
- trace_pipe("cmd"); + trace_pipe(p, "cmd");
op_data.p = p; op_data.op = COMP_OPS_TRIGGER; @@ -639,16 +647,16 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd)
if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* send cmd downstream from host to DAI */ - ret = component_op_downstream(&op_data, host, host, NULL); + ret = component_op_downstream(p, &op_data, host, host, NULL); } else { /* send cmd upstream from host to DAI */ - ret = component_op_upstream(&op_data, host, host, NULL); + ret = component_op_upstream(p, &op_data, host, host, NULL); }
if (ret < 0) { trace_ipc_error("pc0"); - trace_error_value(host->comp.id); - trace_error_value(cmd); + trace_pipe_error_value(p, host->comp.id); + trace_pipe_error_value(p, cmd); }
spin_unlock_irq(&p->lock, flags); @@ -674,7 +682,7 @@ int pipeline_params(struct pipeline *p, struct comp_dev *host, struct op_data op_data; int ret;
- trace_pipe("Par"); + trace_pipe(p, "Par");
op_data.p = p; op_data.op = COMP_OPS_PARAMS; @@ -685,15 +693,15 @@ int pipeline_params(struct pipeline *p, struct comp_dev *host,
if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* send params downstream from host to DAI */ - ret = component_op_downstream(&op_data, host, host, NULL); + ret = component_op_downstream(p, &op_data, host, host, NULL); } else { /* send params upstream from host to DAI */ - ret = component_op_upstream(&op_data, host, host, NULL); + ret = component_op_upstream(p, &op_data, host, host, NULL); }
if (ret < 0) { trace_ipc_error("pp0"); - trace_error_value(host->comp.id); + trace_pipe_error_value(p, host->comp.id); }
spin_unlock(&p->lock); @@ -706,7 +714,7 @@ int pipeline_reset(struct pipeline *p, struct comp_dev *host) struct op_data op_data; int ret;
- trace_pipe("PRe"); + trace_pipe(p, "PRe");
op_data.p = p; op_data.op = COMP_OPS_RESET; @@ -715,15 +723,15 @@ int pipeline_reset(struct pipeline *p, struct comp_dev *host)
if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* send reset downstream from host to DAI */ - ret = component_op_downstream(&op_data, host, host, NULL); + ret = component_op_downstream(p, &op_data, host, host, NULL); } else { /* send reset upstream from host to DAI */ - ret = component_op_upstream(&op_data, host, host, NULL); + ret = component_op_upstream(p, &op_data, host, host, NULL); }
if (ret < 0) { trace_ipc_error("pr0"); - trace_error_value(host->comp.id); + trace_pipe_error_value(p, host->comp.id); }
spin_unlock(&p->lock); @@ -743,14 +751,15 @@ int pipeline_reset(struct pipeline *p, struct comp_dev *host) * individually) and it stops at pipeline endpoints (where a component has no * source or sink components) or where this pipeline joins another pipeline. */ -static int pipeline_copy_from_upstream(struct comp_dev *start, - struct comp_dev *current) +static int pipeline_copy_from_upstream(struct pipeline *p, + struct comp_dev *start, + struct comp_dev *current) { struct list_item *clist; int err = 0;
- tracev_pipe("CP+"); - tracev_value(current->comp.id); + tracev_pipe(p, "CP+"); + tracev_pipe_value(p, current->comp.id);
/* stop going upstream if we reach an end point in this pipeline */ if (current->is_endpoint && current != start) @@ -771,10 +780,10 @@ static int pipeline_copy_from_upstream(struct comp_dev *start, continue;
/* continue upstream */ - err = pipeline_copy_from_upstream(start, buffer->source); + err = pipeline_copy_from_upstream(p, start, buffer->source); if (err < 0) { - trace_pipe_error("ePU"); - trace_error_value(current->comp.id); + trace_pipe_error(p, "ePU"); + trace_pipe_error_value(p, current->comp.id); return err; } } @@ -784,7 +793,7 @@ copy: err = comp_copy(current);
/* return back downstream */ - tracev_pipe("CD+"); + tracev_pipe(p, "CD+"); return err; }
@@ -801,14 +810,15 @@ copy: * individually) and it stops at pipeline endpoints (where a component has no * source or sink components) or where this pipeline joins another pipeline. */ -static int pipeline_copy_to_downstream(struct comp_dev *start, - struct comp_dev *current) +static int pipeline_copy_to_downstream(struct pipeline *p, + struct comp_dev *start, + struct comp_dev *current) { struct list_item *clist; int err = 0;
- tracev_pipe("CP-"); - tracev_value(current->comp.id); + tracev_pipe(p, "CP-"); + tracev_pipe_value(p, current->comp.id);
/* component copy/process to downstream */ if (current != start) { @@ -834,17 +844,17 @@ static int pipeline_copy_to_downstream(struct comp_dev *start, continue;
/* continue downstream */ - err = pipeline_copy_to_downstream(start, buffer->sink); + err = pipeline_copy_to_downstream(p, start, buffer->sink); if (err < 0) { - trace_pipe_error("ePD"); - trace_error_value(current->comp.id); + trace_pipe_error(p, "ePD"); + trace_pipe_error_value(p, current->comp.id); return err; } }
out: /* return back upstream */ - tracev_pipe("CD-"); + tracev_pipe(p, "CD-"); return err; }
@@ -1052,12 +1062,12 @@ static int pipeline_xrun_recover(struct pipeline *p) { int ret;
- trace_pipe_error("pxr"); + trace_pipe_error(p, "pxr");
/* notify all pipeline comps we are in XRUN */ ret = pipeline_trigger(p, p->source_comp, COMP_TRIGGER_XRUN); if (ret < 0) { - trace_pipe_error("px0"); + trace_pipe_error(p, "px0"); return ret; } p->xrun_bytes = 0; @@ -1065,14 +1075,14 @@ static int pipeline_xrun_recover(struct pipeline *p) /* prepare the pipeline */ ret = pipeline_prepare(p, p->source_comp); if (ret < 0) { - trace_pipe_error("px1"); + trace_pipe_error(p, "px1"); return ret; }
/* restart pipeline comps */ ret = pipeline_trigger(p, p->source_comp, COMP_TRIGGER_START); if (ret < 0) { - trace_pipe_error("px2"); + trace_pipe_error(p, "px2"); return ret; }
@@ -1105,7 +1115,7 @@ static void pipeline_task(void *arg) struct comp_dev *dev = p->sched_comp; int err;
- tracev_pipe("PWs"); + tracev_pipe(p, "PWs");
/* are we in xrun ? */ if (p->xrun_bytes) { @@ -1116,7 +1126,7 @@ static void pipeline_task(void *arg) }
/* copy data from upstream source endpoints to downstream endpoints */ - err = pipeline_copy_from_upstream(dev, dev); + err = pipeline_copy_from_upstream(p, dev, dev); if (err < 0) { err = pipeline_xrun_recover(p); if (err < 0) @@ -1124,7 +1134,7 @@ static void pipeline_task(void *arg) goto sched; }
- err = pipeline_copy_to_downstream(dev, dev); + err = pipeline_copy_to_downstream(p, dev, dev); if (err < 0) { err = pipeline_xrun_recover(p); if (err < 0) @@ -1133,7 +1143,7 @@ static void pipeline_task(void *arg) }
sched: - tracev_pipe("PWe"); + tracev_pipe(p, "PWe");
/* now reschedule the task */ /* TODO: add in scheduling cost and any timer drift */ @@ -1144,7 +1154,7 @@ sched: /* init pipeline */ int pipeline_init(void) { - trace_pipe("PIn"); + trace_pipe(NULL, "PIn");
pipe_data = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*pipe_data)); diff --git a/src/audio/pipeline_static.c b/src/audio/pipeline_static.c index cf71a36..3de0025 100644 --- a/src/audio/pipeline_static.c +++ b/src/audio/pipeline_static.c @@ -423,7 +423,7 @@ int init_static_pipeline(struct ipc *ipc) return 0;
error: - trace_pipe_error("ePS"); + trace_pipe_error(NULL, "ePS"); for (i = 0; i < ARRAY_SIZE(pipeline); i++) {
diff --git a/src/include/sof/audio/pipeline.h b/src/include/sof/audio/pipeline.h index 1ef53e5..b83c320 100644 --- a/src/include/sof/audio/pipeline.h +++ b/src/include/sof/audio/pipeline.h @@ -43,9 +43,18 @@ #include <uapi/ipc.h>
/* pipeline tracing */ -#define trace_pipe(__e) trace_event(TRACE_CLASS_PIPE, __e) -#define trace_pipe_error(__e) trace_error(TRACE_CLASS_PIPE, __e) -#define tracev_pipe(__e) tracev_event(TRACE_CLASS_PIPE, __e) +#define trace_pipe(cp, __e) \ + trace_pipeline_event(cp, NORMAL_LEVEL, TRACE_CLASS_PIPE, __e) +#define tracev_pipe(cp, __e) \ + trace_pipeline_event(cp, VERBOSE_LEVEL, TRACE_CLASS_PIPE, __e) +#define trace_pipe_error(cp, __e) \ + trace_pipeline_event_atomic(cp, ERROR_LEVEL, TRACE_CLASS_PIPE, __e) +#define trace_pipe_value(cp, x) \ + trace_pipeline_value(cp, NORMAL_LEVEL, x) +#define tracev_pipe_value(cp, x) \ + trace_pipeline_value(cp, VERBOSE_LEVEL, x) +#define trace_pipe_error_value(cp, x) \ + trace_pipeline_value_atomic(cp, ERROR_LEVEL, x)
struct ipc_pipeline_dev; struct ipc;