Skip to content

Commit 38b19ed

Browse files
kpjeejatiwai
authored andcommitted
ALSA: hda: fix to wait for RIRB & CORB DMA to set
If the DMAs are not being quiesced properly, it may lead to stability issues, so the recommendation is to wait till DMAs are stopped. After setting the stop bit of RIRB/CORB DMA, we should wait for stop bit to be set. Signed-off-by: Jeeja KP <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 94e9080 commit 38b19ed

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sound/hda/hdac_controller.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
8080
}
8181
EXPORT_SYMBOL_GPL(snd_hdac_bus_init_cmd_io);
8282

83+
/* wait for cmd dmas till they are stopped */
84+
static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus)
85+
{
86+
unsigned long timeout;
87+
88+
timeout = jiffies + msecs_to_jiffies(100);
89+
while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN)
90+
&& time_before(jiffies, timeout))
91+
udelay(10);
92+
93+
timeout = jiffies + msecs_to_jiffies(100);
94+
while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN)
95+
&& time_before(jiffies, timeout))
96+
udelay(10);
97+
}
98+
8399
/**
84100
* snd_hdac_bus_stop_cmd_io - clean up CORB/RIRB buffers
85101
* @bus: HD-audio core bus
@@ -90,6 +106,7 @@ void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus)
90106
/* disable ringbuffer DMAs */
91107
snd_hdac_chip_writeb(bus, RIRBCTL, 0);
92108
snd_hdac_chip_writeb(bus, CORBCTL, 0);
109+
hdac_wait_for_cmd_dmas(bus);
93110
/* disable unsolicited responses */
94111
snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0);
95112
spin_unlock_irq(&bus->reg_lock);

0 commit comments

Comments
 (0)