ALSA: hda: Add dma stop delay variable
authorMohan Kumar <mkumard@nvidia.com>
Wed, 5 Aug 2020 09:52:20 +0000 (15:22 +0530)
committerTakashi Iwai <tiwai@suse.de>
Wed, 5 Aug 2020 10:27:47 +0000 (12:27 +0200)
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 <mkumard@nvidia.com>
Link: https://lore.kernel.org/r/20200805095221.5476-3-mkumard@nvidia.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/hdaudio.h
sound/hda/hdac_stream.c

index c1f78d9a6e47d66590caafe0b86f045f731c1bdd..6eed61e6cf8accecfb12569455d8658f46532780 100644 (file)
@@ -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;
index a38a2af1654f72a0bf50b5c8e07b3d108980c856..abe7a1b16fe1eacbc5a312232a2818eebf848ef5 100644 (file)
@@ -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;
@@ -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);