host: add traces with id's

Traces with id's help to read logs,
especially when there are several
pipelines in topology.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2019-08-06 09:47:37 +02:00 committed by Tomasz Lauda
parent d0d4301c9c
commit bdde5013e1
1 changed files with 61 additions and 33 deletions

View File

@ -28,11 +28,31 @@
#define trace_host(__e, ...) \ #define trace_host(__e, ...) \
trace_event(TRACE_CLASS_HOST, __e, ##__VA_ARGS__) trace_event(TRACE_CLASS_HOST, __e, ##__VA_ARGS__)
#define trace_host_with_ids(comp_ptr, format, ...) \
trace_event_with_ids(TRACE_CLASS_HOST, \
comp_ptr->comp.pipeline_id,\
comp_ptr->comp.id, \
format, ##__VA_ARGS__)
#define tracev_host(__e, ...) \ #define tracev_host(__e, ...) \
tracev_event(TRACE_CLASS_HOST, __e, ##__VA_ARGS__) tracev_event(TRACE_CLASS_HOST, __e, ##__VA_ARGS__)
#define tracev_host_with_ids(comp_ptr, format, ...) \
tracev_event_with_ids(TRACE_CLASS_HOST, \
comp_ptr->comp.pipeline_id,\
comp_ptr->comp.id, \
format, ##__VA_ARGS__)
#define trace_host_error(__e, ...) \ #define trace_host_error(__e, ...) \
trace_error(TRACE_CLASS_HOST, __e, ##__VA_ARGS__) trace_error(TRACE_CLASS_HOST, __e, ##__VA_ARGS__)
#define trace_host_error_with_ids(comp_ptr, format, ...) \
trace_error_with_ids(TRACE_CLASS_HOST, \
comp_ptr->comp.pipeline_id,\
comp_ptr->comp.id, \
format, ##__VA_ARGS__)
/** /**
* \brief Host buffer info. * \brief Host buffer info.
*/ */
@ -252,8 +272,9 @@ static int create_local_elems(struct comp_dev *dev, uint32_t buffer_count,
err = dma_sg_alloc(&hd->config.elem_array, RZONE_RUNTIME, err = dma_sg_alloc(&hd->config.elem_array, RZONE_RUNTIME,
dir, 1, 0, 0, 0); dir, 1, 0, 0, 0);
if (err < 0) { if (err < 0) {
trace_host_error("create_local_elems() error: " trace_host_error_with_ids(dev, "create_local_elems() "
"dma_sg_alloc() failed"); "error: dma_sg_alloc() "
"failed");
return err; return err;
} }
} else { } else {
@ -263,7 +284,7 @@ static int create_local_elems(struct comp_dev *dev, uint32_t buffer_count,
err = dma_sg_alloc(elem_array, RZONE_RUNTIME, dir, buffer_count, err = dma_sg_alloc(elem_array, RZONE_RUNTIME, dir, buffer_count,
buffer_bytes, (uintptr_t)(hd->dma_buffer->addr), 0); buffer_bytes, (uintptr_t)(hd->dma_buffer->addr), 0);
if (err < 0) { if (err < 0) {
trace_host_error("create_local_elems() error: " trace_host_error_with_ids(dev, "create_local_elems() error: "
"dma_sg_alloc() failed"); "dma_sg_alloc() failed");
return err; return err;
} }
@ -286,7 +307,7 @@ static int host_trigger(struct comp_dev *dev, int cmd)
struct host_data *hd = comp_get_drvdata(dev); struct host_data *hd = comp_get_drvdata(dev);
int ret = 0; int ret = 0;
trace_host("host_trigger()"); trace_host_with_ids(dev, "host_trigger()");
ret = comp_set_state(dev, cmd); ret = comp_set_state(dev, cmd);
if (ret < 0) if (ret < 0)
@ -304,8 +325,8 @@ static int host_trigger(struct comp_dev *dev, int cmd)
return ret; return ret;
if (hd->chan < 0) { if (hd->chan < 0) {
trace_host_error("host_trigger() error: no dma channel " trace_host_error_with_ids(dev, "host_trigger() error: no dma "
"configured"); "channel configured");
return -EINVAL; return -EINVAL;
} }
@ -313,15 +334,16 @@ static int host_trigger(struct comp_dev *dev, int cmd)
case COMP_TRIGGER_START: case COMP_TRIGGER_START:
ret = dma_start(hd->dma, hd->chan); ret = dma_start(hd->dma, hd->chan);
if (ret < 0) if (ret < 0)
trace_host_error("host_trigger() error: " trace_host_error_with_ids(dev, "host_trigger() error: "
"dma_start() failed, ret = %u", ret); "dma_start() failed, "
"ret = %u", ret);
break; break;
case COMP_TRIGGER_STOP: case COMP_TRIGGER_STOP:
case COMP_TRIGGER_XRUN: case COMP_TRIGGER_XRUN:
ret = dma_stop(hd->dma, hd->chan); ret = dma_stop(hd->dma, hd->chan);
if (ret < 0) if (ret < 0)
trace_host_error("host_trigger(): dma stop failed: %d", trace_host_error_with_ids(dev, "host_trigger(): dma "
ret); "stop failed: %d", ret);
break; break;
default: default:
break; break;
@ -394,7 +416,7 @@ static void host_free(struct comp_dev *dev)
{ {
struct host_data *hd = comp_get_drvdata(dev); struct host_data *hd = comp_get_drvdata(dev);
trace_host("host_free()"); trace_host_with_ids(dev, "host_free()");
dma_put(hd->dma); dma_put(hd->dma);
@ -499,14 +521,15 @@ static int host_params(struct comp_dev *dev)
uint32_t align; uint32_t align;
int err; int err;
trace_event(TRACE_CLASS_HOST, "host_params()"); trace_host_with_ids(dev, "host_params()");
/* host params always installed by pipeline IPC */ /* host params always installed by pipeline IPC */
hd->host_size = dev->params.buffer.size; hd->host_size = dev->params.buffer.size;
err = dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_ALIGNMENT, &align); err = dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_ALIGNMENT, &align);
if (err < 0) { if (err < 0) {
trace_host_error("could not get dma buffer alignment"); trace_host_error_with_ids(dev, "could not get dma buffer "
"alignment");
return err; return err;
} }
@ -555,14 +578,16 @@ static int host_params(struct comp_dev *dev)
/* validate period count */ /* validate period count */
if (!period_count) { if (!period_count) {
trace_host_error("host_params() error: invalid period_count"); trace_host_error_with_ids(dev, "host_params() error: invalid "
"period_count");
return -EINVAL; return -EINVAL;
} }
hd->period_bytes = ALIGN_UP(dev->frames * comp_frame_bytes(dev), align); hd->period_bytes = ALIGN_UP(dev->frames * comp_frame_bytes(dev), align);
if (hd->period_bytes == 0) { if (hd->period_bytes == 0) {
trace_host_error("host_params() error: invalid period_bytes"); trace_host_error_with_ids(dev, "host_params() error: invalid "
"period_bytes");
return -EINVAL; return -EINVAL;
} }
@ -570,9 +595,9 @@ static int host_params(struct comp_dev *dev)
buffer_size = period_count * hd->period_bytes; buffer_size = period_count * hd->period_bytes;
err = buffer_set_size(hd->dma_buffer, buffer_size); err = buffer_set_size(hd->dma_buffer, buffer_size);
if (err < 0) { if (err < 0) {
trace_host_error("host_params() error:" trace_host_error_with_ids(dev, "host_params() error:"
"buffer_set_size() failed, buffer_size = %u", "buffer_set_size() failed, "
buffer_size); "buffer_size = %u", buffer_size);
return err; return err;
} }
@ -595,13 +620,14 @@ static int host_params(struct comp_dev *dev)
*/ */
hd->chan = dma_channel_get(hd->dma, dev->params.stream_tag); hd->chan = dma_channel_get(hd->dma, dev->params.stream_tag);
if (hd->chan < 0) { if (hd->chan < 0) {
trace_host_error("host_params() error: hd->chan < 0"); trace_host_error_with_ids(dev, "host_params() error: "
"hd->chan < 0");
return -ENODEV; return -ENODEV;
} }
err = dma_set_config(hd->dma, hd->chan, &hd->config); err = dma_set_config(hd->dma, hd->chan, &hd->config);
if (err < 0) { if (err < 0) {
trace_host_error("host_params() error: " trace_host_error_with_ids(dev, "host_params() error: "
"dma_set_config() failed"); "dma_set_config() failed");
dma_channel_put(hd->dma, hd->chan); dma_channel_put(hd->dma, hd->chan);
hd->chan = DMA_CHAN_INVALID; hd->chan = DMA_CHAN_INVALID;
@ -612,7 +638,8 @@ static int host_params(struct comp_dev *dev)
&hd->dma_copy_align); &hd->dma_copy_align);
if (err < 0) { if (err < 0) {
trace_host_error("host_params() error: dma_get_attribute()"); trace_host_error_with_ids(dev, "host_params() error: "
"dma_get_attribute()");
return err; return err;
} }
@ -629,7 +656,7 @@ static int host_prepare(struct comp_dev *dev)
struct host_data *hd = comp_get_drvdata(dev); struct host_data *hd = comp_get_drvdata(dev);
int ret; int ret;
trace_host("host_prepare()"); trace_host_with_ids(dev, "host_prepare()");
ret = comp_set_state(dev, COMP_TRIGGER_PREPARE); ret = comp_set_state(dev, COMP_TRIGGER_PREPARE);
if (ret < 0) if (ret < 0)
@ -673,7 +700,7 @@ static int host_reset(struct comp_dev *dev)
{ {
struct host_data *hd = comp_get_drvdata(dev); struct host_data *hd = comp_get_drvdata(dev);
trace_host("host_reset()"); trace_host_with_ids(dev, "host_reset()");
dma_channel_put(hd->dma, hd->chan); dma_channel_put(hd->dma, hd->chan);
@ -700,7 +727,7 @@ static int host_copy(struct comp_dev *dev)
struct host_data *hd = comp_get_drvdata(dev); struct host_data *hd = comp_get_drvdata(dev);
int ret = 0; int ret = 0;
tracev_host("host_copy()"); tracev_host_with_ids(dev, "host_copy()");
if (dev->state != COMP_STATE_ACTIVE) if (dev->state != COMP_STATE_ACTIVE)
return 0; return 0;
@ -715,13 +742,14 @@ static int host_copy(struct comp_dev *dev)
if (ret < 0) { if (ret < 0) {
if (ret == -ENODATA) { if (ret == -ENODATA) {
/* preload not finished, so stop processing */ /* preload not finished, so stop processing */
trace_host("host_copy(), preload not yet " trace_host_with_ids(dev, "host_copy(), preload"
"finished"); " not yet finished");
return PPL_STATUS_PATH_STOP; return PPL_STATUS_PATH_STOP;
} }
trace_host_error("host_copy() error: dma_copy() " trace_host_error_with_ids(dev, "host_copy() error: "
"failed, ret = %u", ret); "dma_copy() failed, "
"ret = %u", ret);
return ret; return ret;
} }
} }
@ -733,11 +761,11 @@ static void host_cache(struct comp_dev *dev, int cmd)
{ {
struct host_data *hd; struct host_data *hd;
trace_event(TRACE_CLASS_HOST, "host_cache(), cmd = %d", cmd); trace_host_with_ids(dev, "host_cache(), cmd = %d", cmd);
switch (cmd) { switch (cmd) {
case CACHE_WRITEBACK_INV: case CACHE_WRITEBACK_INV:
trace_host("host_cache(), CACHE_WRITEBACK_INV"); trace_host_with_ids(dev, "host_cache(), CACHE_WRITEBACK_INV");
hd = comp_get_drvdata(dev); hd = comp_get_drvdata(dev);
@ -750,7 +778,7 @@ static void host_cache(struct comp_dev *dev, int cmd)
break; break;
case CACHE_INVALIDATE: case CACHE_INVALIDATE:
trace_host("host_cache(), CACHE_INVALIDATE"); trace_host_with_ids(dev, "host_cache(), CACHE_INVALIDATE");
dcache_invalidate_region(dev, sizeof(*dev)); dcache_invalidate_region(dev, sizeof(*dev));