From: Yan Wang yan.wang@linux.intel.com
It will use HOST trace class and component DMA trace API. For trace calling of host_new(), NULL will be passed into trace API because comp_dev 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/host.c | 71 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 31 deletions(-)
diff --git a/src/audio/host.c b/src/audio/host.c index 998c5ca..b23da69 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -47,9 +47,18 @@ #include <arch/cache.h> #include <uapi/ipc.h>
-#define trace_host(__e) trace_event(TRACE_CLASS_HOST, __e) -#define tracev_host(__e) tracev_event(TRACE_CLASS_HOST, __e) -#define trace_host_error(__e) trace_error(TRACE_CLASS_HOST, __e) +#define trace_host(cd, __e) \ + trace_comp_event(cd, NORMAL_LEVEL, TRACE_CLASS_HOST, __e) +#define tracev_host(cd, __e) \ + trace_comp_event(cd, VERBOSE_LEVEL, TRACE_CLASS_HOST, __e) +#define trace_host_error(cd, __e) \ + trace_comp_event_atomic(cd, ERROR_LEVEL, TRACE_CLASS_HOST, __e) +#define trace_host_value(cd, x) \ + trace_comp_value(cd, NORMAL_LEVEL, x) +#define tracev_host_value(cd, x) \ + trace_comp_value(cd, VERBOSE_LEVEL, x) +#define trace_host_error_value(cd, x) \ + trace_comp_value_atomic(cd, ERROR_LEVEL, x)
static int host_copy(struct comp_dev *dev);
@@ -269,7 +278,7 @@ unwind: rfree(e); }
- trace_host_error("el0"); + trace_host_error(dev, "el0"); return -ENOMEM; }
@@ -278,7 +287,7 @@ static int host_trigger(struct comp_dev *dev, int cmd) { int ret = 0;
- trace_host("cmd"); + trace_host(dev, "cmd");
ret = comp_set_state(dev, cmd); if (ret < 0) @@ -317,7 +326,7 @@ static void host_gw_dma_update(struct comp_dev *dev) local_elem = list_first_item(&hd->config.elem_list, struct dma_sg_elem, list);
- tracev_host("upd"); + tracev_host(dev, "upd");
/* update buffer positions */ dma_buffer = hd->dma_buffer; @@ -448,7 +457,7 @@ unwind: rfree(ec); }
- trace_host_error("el0"); + trace_host_error(dev, "el0"); return -ENOMEM; }
@@ -458,7 +467,7 @@ static int host_trigger(struct comp_dev *dev, int cmd) struct host_data *hd = comp_get_drvdata(dev); int ret = 0;
- trace_host("trg"); + trace_host(dev, "trg");
ret = comp_set_state(dev, cmd); if (ret < 0) @@ -472,8 +481,8 @@ static int host_trigger(struct comp_dev *dev, int cmd) case COMP_TRIGGER_START: ret = dma_start(hd->dma, hd->chan); if (ret < 0) { - trace_host_error("TsF"); - trace_error_value(ret); + trace_host_error(dev, "TsF"); + trace_host_error_value(dev, ret); goto out; }
@@ -505,7 +514,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp) struct sof_ipc_comp_host *ipc_host = (struct sof_ipc_comp_host *)comp; struct dma_sg_elem *elem;
- trace_host("new"); + trace_host(NULL, "new");
dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, COMP_SIZE(struct sof_ipc_comp_host)); @@ -539,7 +548,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp) hd->dma = dma_get(DMA_HOST_IN_DMAC); #endif if (hd->dma == NULL) { - trace_host_error("eDM"); + trace_host_error(NULL, "eDM"); goto error; }
@@ -553,7 +562,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp) /* get DMA channel from DMAC */ hd->chan = dma_channel_get(hd->dma, 0); if (hd->chan < 0) { - trace_host_error("eDC"); + trace_host_error(NULL, "eDC"); goto error; }
@@ -578,7 +587,7 @@ static void host_free(struct comp_dev *dev) struct host_data *hd = comp_get_drvdata(dev); struct dma_sg_elem *elem;
- trace_host("fre"); + trace_host(dev, "fre");
elem = list_first_item(&hd->config.elem_list, struct dma_sg_elem, list); @@ -631,7 +640,7 @@ static int host_params(struct comp_dev *dev) uint32_t buffer_size; int err;
- trace_host("par"); + trace_host(dev, "par");
/* host params always installed by pipeline IPC */ hd->host_size = dev->params.buffer.size; @@ -659,14 +668,14 @@ static int host_params(struct comp_dev *dev)
/* validate period count */ if (hd->period_count == 0) { - trace_host_error("eS0"); + trace_host_error(dev, "eS0"); return -EINVAL; }
/* calculate period size based on config */ hd->period_bytes = dev->frames * comp_frame_bytes(dev); if (hd->period_bytes == 0) { - trace_host_error("eS1"); + trace_host_error(dev, "eS1"); return -EINVAL; }
@@ -674,16 +683,16 @@ static int host_params(struct comp_dev *dev) buffer_size = hd->period_count * hd->period_bytes; err = buffer_set_size(hd->dma_buffer, buffer_size); if (err < 0) { - trace_host_error("eSz"); - trace_error_value(buffer_size); + trace_host_error(dev, "eSz"); + trace_host_error_value(dev, 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_error_value(hd->host_size); - trace_error_value(hd->period_bytes); + trace_host_error(dev, "eHB"); + trace_host_error_value(dev, hd->host_size); + trace_host_error_value(dev, hd->period_bytes); return -EINVAL; }
@@ -704,12 +713,12 @@ static int host_params(struct comp_dev *dev) /* get DMA channel from DMAC */ hd->chan = dma_channel_get(hd->dma, dev->params.stream_tag); if (hd->chan < 0) { - trace_host_error("eDC"); + trace_host_error(dev, "eDC"); return -ENODEV; } err = dma_set_config(hd->dma, hd->chan, &hd->config); if (err < 0) { - trace_host_error("eDc"); + trace_host_error(dev, "eDc"); dma_channel_put(hd->dma, hd->chan); return err; } @@ -723,7 +732,7 @@ static int host_prepare(struct comp_dev *dev) struct host_data *hd = comp_get_drvdata(dev); int ret;
- trace_host("pre"); + trace_host(dev, "pre");
ret = comp_set_state(dev, COMP_TRIGGER_PREPARE); if (ret < 0) @@ -805,7 +814,7 @@ static int host_reset(struct comp_dev *dev) struct list_item *elist; struct list_item *tlist;
- trace_host("res"); + trace_host(dev, "res");
/* free all host DMA elements */ list_for_item_safe(elist, tlist, &hd->host.elem_list) { @@ -858,7 +867,7 @@ static int host_copy(struct comp_dev *dev) struct dma_sg_elem *local_elem; int ret;
- tracev_host("cpy"); + tracev_host(dev, "cpy");
if (dev->state != COMP_STATE_ACTIVE) return 0; @@ -883,14 +892,14 @@ static int host_copy(struct comp_dev *dev) if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) { if (hd->dma_buffer->free < local_elem->size) { /* buffer is enough avail, just return. */ - trace_host("Bea"); + trace_host(dev, "Bea"); return 0; } } else {
if (hd->dma_buffer->avail < local_elem->size) { /* buffer is enough empty, just return. */ - trace_host("Bee"); + trace_host(dev, "Bee"); return 0; } } @@ -915,8 +924,8 @@ static int host_copy(struct comp_dev *dev) #endif return dev->frames; out: - trace_host_error("CpF"); - trace_error_value(ret); + trace_host_error(dev, "CpF"); + trace_host_error_value(dev, ret); return ret; }