Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/drivers/intel/cavs/hda-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,31 @@ static void hda_dma_post_copy(struct dma *dma, struct hda_chan_data *chan)
pm_runtime_put(PM_RUNTIME_HOST_DMA_L1, 0);
}

static int hda_dma_tx_wait(struct dma *dma, struct hda_chan_data *chan,
int min_bytes, uint32_t timeout_us)
{
uint64_t deadline = platform_timer_get(platform_timer) +
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, 1) *
timeout_us / 1000;

while (hda_dma_get_free_size(dma, chan->index) < min_bytes) {
if (deadline < platform_timer_get(platform_timer)) {
trace_hddma_error("hda-dmac: %d tx timeout",
dma->plat_data.id);
return -ETIME;
}

idelay(PLATFORM_DEFAULT_DELAY);
}

return 0;
}

static int hda_dma_link_copy_ch(struct dma *dma, struct hda_chan_data *chan,
int bytes)
{
uint32_t dgcs = 0;
int ret = 0;

tracev_hddma("hda-dmac: %d channel %d -> copy 0x%x bytes",
dma->plat_data.id, chan->index, bytes);
Expand All @@ -403,8 +424,11 @@ static int hda_dma_link_copy_ch(struct dma *dma, struct hda_chan_data *chan,

/* make sure that previous transfer is complete (playback only) */
if (chan->direction == DMA_DIR_MEM_TO_DEV) {
while (hda_dma_get_free_size(dma, chan->index) < bytes)
idelay(PLATFORM_DEFAULT_DELAY);
ret = hda_dma_tx_wait(dma, chan, bytes,
PLATFORM_LINK_DMA_TIMEOUT);

if (ret)
goto fail;
}

/*
Expand All @@ -417,7 +441,8 @@ static int hda_dma_link_copy_ch(struct dma *dma, struct hda_chan_data *chan,
hda_dma_get_dbg_vals(chan, HDA_DBG_POST, HDA_DBG_LINK);
hda_dma_ptr_trace(chan, "link copy", HDA_DBG_LINK);

return 0;
fail:
return ret;
}

static int hda_dma_host_copy_ch(struct dma *dma, struct hda_chan_data *chan,
Expand Down
6 changes: 6 additions & 0 deletions src/platform/apollolake/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ struct sof;
/* DMA host transfer timeouts in microseconds */
#define PLATFORM_HOST_DMA_TIMEOUT 50

/* DMA link transfer timeouts in microseconds
* TODO: timeout should be reduced
* (DMA might needs some further changes to do that)
*/
#define PLATFORM_LINK_DMA_TIMEOUT 1000

/* WorkQ window size in microseconds */
#define PLATFORM_WORKQ_WINDOW 2000

Expand Down
6 changes: 6 additions & 0 deletions src/platform/baytrail/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ struct sof;
/* DMA host transfer timeouts in microseconds */
#define PLATFORM_HOST_DMA_TIMEOUT 50

/* DMA link transfer timeouts in microseconds
* TODO: timeout should be reduced
* (DMA might needs some further changes to do that)
*/
#define PLATFORM_LINK_DMA_TIMEOUT 1000

/* WorkQ window size in microseconds */
#define PLATFORM_WORKQ_WINDOW 2000

Expand Down
6 changes: 6 additions & 0 deletions src/platform/cannonlake/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ struct sof;
/* DMA host transfer timeouts in microseconds */
#define PLATFORM_HOST_DMA_TIMEOUT 50

/* DMA link transfer timeouts in microseconds
* TODO: timeout should be reduced
* (DMA might needs some further changes to do that)
*/
#define PLATFORM_LINK_DMA_TIMEOUT 1000

/* WorkQ window size in microseconds */
#define PLATFORM_WORKQ_WINDOW 2000

Expand Down
6 changes: 6 additions & 0 deletions src/platform/haswell/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ struct sof;
/* DMA host transfer timeouts in microseconds */
#define PLATFORM_HOST_DMA_TIMEOUT 50

/* DMA link transfer timeouts in microseconds
* TODO: timeout should be reduced
* (DMA might needs some further changes to do that)
*/
#define PLATFORM_LINK_DMA_TIMEOUT 1000

/* WorkQ window size in microseconds */
#define PLATFORM_WORKQ_WINDOW 2000

Expand Down
6 changes: 6 additions & 0 deletions src/platform/icelake/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ struct sof;
/* DMA host transfer timeouts in microseconds */
#define PLATFORM_HOST_DMA_TIMEOUT 50

/* DMA link transfer timeouts in microseconds
* TODO: timeout should be reduced
* (DMA might needs some further changes to do that)
*/
#define PLATFORM_LINK_DMA_TIMEOUT 1000

/* WorkQ window size in microseconds */
#define PLATFORM_WORKQ_WINDOW 2000

Expand Down
6 changes: 6 additions & 0 deletions src/platform/suecreek/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ struct sof;
/* DMA host transfer timeouts in microseconds */
#define PLATFORM_HOST_DMA_TIMEOUT 50

/* DMA link transfer timeouts in microseconds
* TODO: timeout should be reduced
* (DMA might needs some further changes to do that)
*/
#define PLATFORM_LINK_DMA_TIMEOUT 1000

/* WorkQ window size in microseconds */
#define PLATFORM_WORKQ_WINDOW 2000

Expand Down