Skip to content

Commit

Permalink
ALSA: hda: Add dma stop delay variable
Browse files Browse the repository at this point in the history
A variable dma_stop_delay is added as a new member in hdac_bus
structure to avoid memory decode error incase DMA RUN bit is not
disabled in the given timeout from snd_hdac_stream_sync function and
followed by stream reset which results in memory decode error between
reset set and clear operation.

Signed-off-by: Mohan Kumar <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
mkumard authored and tiwai committed Aug 5, 2020
1 parent 6c17e9d commit 4106820
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/sound/hdaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ struct hdac_bus {

int bdl_pos_adj; /* BDL position adjustment */

/* delay time in us for dma stop */
unsigned int dma_stop_delay;

/* locks */
spinlock_t reg_lock;
struct mutex cmd_mutex;
Expand Down
7 changes: 7 additions & 0 deletions sound/hda/hdac_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
{
unsigned char val;
int timeout;
int dma_run_state;

snd_hdac_stream_clear(azx_dev);

dma_run_state = snd_hdac_stream_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START;

snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
udelay(3);
timeout = 300;
Expand All @@ -162,6 +165,10 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
if (val)
break;
} while (--timeout);

if (azx_dev->bus->dma_stop_delay && dma_run_state)
udelay(azx_dev->bus->dma_stop_delay);

val &= ~SD_CTL_STREAM_RESET;
snd_hdac_stream_writeb(azx_dev, SD_CTL, val);
udelay(3);
Expand Down

0 comments on commit 4106820

Please sign in to comment.