hda: dma preload timeout

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
This commit is contained in:
Janusz Jankowski 2018-12-27 12:30:45 +01:00 committed by Liam Girdwood
parent dd07c8e3b0
commit 8d6c712fcf
1 changed files with 9 additions and 2 deletions

View File

@ -328,12 +328,19 @@ static int hda_dma_host_preload(struct dma *dma, struct hda_chan_data *chan)
int i; int i;
int period_cnt; int period_cnt;
uint64_t deadline = platform_timer_get(platform_timer) +
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, 1) *
PLATFORM_HOST_DMA_TIMEOUT / 1000;
/* waiting for buffer full after start /* waiting for buffer full after start
* first try is unblocking, then blocking * first try is unblocking, then blocking
*/ */
while (!(host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BF) && while (!(host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BF) &&
(chan->state & HDA_STATE_BF_WAIT)) (chan->state & HDA_STATE_BF_WAIT)) {
; /* TODO: this should timeout and not wait forever */ if (deadline < platform_timer_get(platform_timer)) {
return -ETIME;
}
}
if (host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BF) { if (host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BF) {
chan->state &= ~(HDA_STATE_HOST_PRELOAD | HDA_STATE_BF_WAIT); chan->state &= ~(HDA_STATE_HOST_PRELOAD | HDA_STATE_BF_WAIT);