From cc347532dd2f1a1ca844e1dc865d261c1dbae54e Mon Sep 17 00:00:00 2001 From: Tomasz Lauda Date: Mon, 13 May 2019 11:25:45 +0200 Subject: [PATCH] hda-dma: add safe check to waiting functions Adds safe check to waiting functions in case we've got preempted after read, but before deadline check. Signed-off-by: Tomasz Lauda --- src/drivers/intel/cavs/hda-dma.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/drivers/intel/cavs/hda-dma.c b/src/drivers/intel/cavs/hda-dma.c index 24e435a678c7..d075799471f0 100644 --- a/src/drivers/intel/cavs/hda-dma.c +++ b/src/drivers/intel/cavs/hda-dma.c @@ -275,6 +275,11 @@ static int hda_dma_wait_for_buffer_full(struct dma *dma, while (!(host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BF)) { if (deadline < platform_timer_get(platform_timer)) { + /* safe check in case we've got preempted after read */ + if (host_dma_reg_read(dma, chan->index, DGCS) & + DGCS_BF) + return 0; + trace_hddma_error("hda-dmac: %d wait for buffer full " "timeout", dma->plat_data.id); return -ETIME; @@ -293,6 +298,11 @@ static int hda_dma_wait_for_buffer_empty(struct dma *dma, while (host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BNE) { if (deadline < platform_timer_get(platform_timer)) { + /* safe check in case we've got preempted after read */ + if (!(host_dma_reg_read(dma, chan->index, DGCS) & + DGCS_BNE)) + return 0; + trace_hddma_error("hda-dmac: %d wait for buffer empty " "timeout", dma->plat_data.id); return -ETIME;