Skip to content
Merged
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
28 changes: 21 additions & 7 deletions src/drivers/intel/cavs/hda-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ trace_event(TRACE_CLASS_HOST, __e, ##__VA_ARGS__)
#define HDA_STATE_PRELOAD BIT(0)
#define HDA_STATE_BF_WAIT BIT(1)
#define HDA_STATE_INIT BIT(2)
#define HDA_STATE_RELEASE BIT(3)

struct hda_chan_data {
struct dma *dma;
Expand Down Expand Up @@ -252,7 +253,7 @@ static int hda_dma_copy_ch(struct dma *dma, struct hda_chan_data *chan,
hda_dma_inc_fp(dma, chan->index, bytes);

spin_lock_irq(&dma->lock, flags);
if (chan->cb) {
if (chan->cb && !(chan->state & HDA_STATE_RELEASE)) {
next.src = DMA_RELOAD_LLI;
next.dest = DMA_RELOAD_LLI;
next.size = DMA_RELOAD_LLI;
Expand Down Expand Up @@ -286,22 +287,29 @@ static void hda_dma_init(struct dma *dma, int channel)
/* full buffer is copied at startup */
p->chan[channel].desc_avail = p->chan[channel].desc_count;

p->chan[channel].state &= ~HDA_STATE_INIT;

pm_runtime_put(PM_RUNTIME_HOST_DMA_L1, 0);

/* start link output transfer now */
if (p->chan[channel].direction == DMA_DIR_MEM_TO_DEV)
if (p->chan[channel].direction == DMA_DIR_MEM_TO_DEV &&
Comment thread
slawblauciak marked this conversation as resolved.
Outdated
!(p->chan[channel].state & HDA_STATE_RELEASE))
hda_dma_inc_link_fp(dma, channel,
p->chan[channel].buffer_bytes);

p->chan[channel].state &= ~(HDA_STATE_INIT | HDA_STATE_RELEASE);

spin_unlock_irq(&dma->lock, flags);
}

static uint64_t hda_dma_work(void *data, uint64_t delay)
{
struct hda_chan_data *chan = (struct hda_chan_data *)data;

/* align pointers on release */
if (chan->state & HDA_STATE_RELEASE) {
hda_dma_inc_link_fp(chan->dma, chan->index,
chan->period_bytes);
}

if (chan->state & HDA_STATE_INIT)
hda_dma_init(chan->dma, chan->index);
else
Expand Down Expand Up @@ -428,16 +436,21 @@ static int hda_dma_start(struct dma *dma, int channel)

static int hda_dma_release(struct dma *dma, int channel)
{
/* Implementation left for future alignment
*of dma pointers (if needed)
*/
struct dma_pdata *p = dma_get_drvdata(dma);

uint32_t flags;

spin_lock_irq(&dma->lock, flags);

trace_host("hda-dma-release dma-ptr: %p channel-number: %u",
(uint32_t)dma, channel);

/*
* Prepare for the handling of release condition on the first work cb.
* This flag will be unset afterwards.
*/
p->chan[channel].state |= HDA_STATE_RELEASE;
Comment thread
slawblauciak marked this conversation as resolved.
Outdated

spin_unlock_irq(&dma->lock, flags);
return 0;
}
Expand Down Expand Up @@ -477,6 +490,7 @@ static int hda_dma_stop(struct dma *dma, int channel)
/* disable the channel */
hda_update_bits(dma, channel, DGCS, DGCS_GEN | DGCS_FIFORDY, 0);
p->chan[channel].status = COMP_STATE_PREPARE;
p->chan[channel].state = 0;

spin_unlock_irq(&dma->lock, flags);
return 0;
Expand Down