Skip to content

Commit 4106820

Browse files
mkumardtiwai
authored andcommitted
ALSA: hda: Add dma stop delay variable
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]>
1 parent 6c17e9d commit 4106820

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/sound/hdaudio.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ struct hdac_bus {
347347

348348
int bdl_pos_adj; /* BDL position adjustment */
349349

350+
/* delay time in us for dma stop */
351+
unsigned int dma_stop_delay;
352+
350353
/* locks */
351354
spinlock_t reg_lock;
352355
struct mutex cmd_mutex;

sound/hda/hdac_stream.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
150150
{
151151
unsigned char val;
152152
int timeout;
153+
int dma_run_state;
153154

154155
snd_hdac_stream_clear(azx_dev);
155156

157+
dma_run_state = snd_hdac_stream_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START;
158+
156159
snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
157160
udelay(3);
158161
timeout = 300;
@@ -162,6 +165,10 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
162165
if (val)
163166
break;
164167
} while (--timeout);
168+
169+
if (azx_dev->bus->dma_stop_delay && dma_run_state)
170+
udelay(azx_dev->bus->dma_stop_delay);
171+
165172
val &= ~SD_CTL_STREAM_RESET;
166173
snd_hdac_stream_writeb(azx_dev, SD_CTL, val);
167174
udelay(3);

0 commit comments

Comments
 (0)