Host: fix error return handlings for some dma invokings.

Add hanle for error on dma_set_config(), dma_start() and dma_copy().

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
This commit is contained in:
Keyon Jie 2018-04-03 18:59:33 +08:00 committed by Liam Girdwood
parent 970bd97b82
commit c8586154c4
1 changed files with 28 additions and 6 deletions

View File

@ -462,14 +462,19 @@ static int host_trigger(struct comp_dev *dev, int cmd)
ret = comp_set_state(dev, cmd); ret = comp_set_state(dev, cmd);
if (ret < 0) if (ret < 0)
return ret; goto out;
switch (cmd) { switch (cmd) {
case COMP_TRIGGER_STOP: case COMP_TRIGGER_STOP:
ret = host_stop(dev); ret = host_stop(dev);
break; break;
case COMP_TRIGGER_START: case COMP_TRIGGER_START:
dma_start(hd->dma, hd->chan); ret = dma_start(hd->dma, hd->chan);
if (ret < 0) {
trace_host_error("TsF");
trace_error_value(ret);
goto out;
}
/* preload first playback period for preloader task */ /* preload first playback period for preloader task */
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) { if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) {
@ -485,6 +490,7 @@ static int host_trigger(struct comp_dev *dev, int cmd)
break; break;
} }
out:
return ret; return ret;
} }
@ -700,7 +706,12 @@ static int host_params(struct comp_dev *dev)
trace_host_error("eDC"); trace_host_error("eDC");
return -ENODEV; return -ENODEV;
} }
dma_set_config(hd->dma, hd->chan, &hd->config); err = dma_set_config(hd->dma, hd->chan, &hd->config);
if (err < 0) {
trace_host_error("eDc");
dma_channel_put(hd->dma, hd->chan);
return err;
}
#endif #endif
return 0; return 0;
@ -844,6 +855,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);
struct dma_sg_elem *local_elem; struct dma_sg_elem *local_elem;
int ret;
tracev_host("cpy"); tracev_host("cpy");
@ -888,13 +900,23 @@ static int host_copy(struct comp_dev *dev)
host_gw_dma_update(dev); host_gw_dma_update(dev);
/* tell gateway to copy another period */ /* tell gateway to copy another period */
dma_copy(hd->dma, hd->chan, hd->period_bytes); ret = dma_copy(hd->dma, hd->chan, hd->period_bytes);
if (ret < 0)
goto out;
#else #else
/* do DMA transfer */ /* do DMA transfer */
dma_set_config(hd->dma, hd->chan, &hd->config); ret = dma_set_config(hd->dma, hd->chan, &hd->config);
dma_start(hd->dma, hd->chan); if (ret < 0)
goto out;
ret = dma_start(hd->dma, hd->chan);
if (ret < 0)
goto out;
#endif #endif
return dev->frames; return dev->frames;
out:
trace_host_error("CpF");
trace_error_value(ret);
return ret;
} }
struct comp_driver comp_host = { struct comp_driver comp_host = {