Skip to contentSkip to conversation

ALSA: hda: fix the missing ptr initialization

PATCH Applied Vinod Koul 2 participants 5 messages May 5, 2016 – May 9, 2016 Sound

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH v2 1/2 ALSA: hda: fix the missing ptr initialization

ebus is a member of extended device and was never initialized, so do this at device creation.

---
 sound/hda/ext/hdac_ext_bus.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/ext/hdac_ext_bus.c +1 -0
index 2433f7c81472..64de0a3d6d93 100644
@@ -144,6 +144,7 @@ int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr)
 	if (!edev)
 		return -ENOMEM;
 	hdev = &edev->hdac;
+	edev->ebus = ebus;
 
 	snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr);
 
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 2/2 ALSA: hda: fix to wait for RIRB & CORB DMA to set

From: Jeeja KP <[email protected]>

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.

---
changes in v2:
- use common wait routine as suggested by Takashi

 sound/hda/hdac_controller.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/hda/hdac_controller.c +17 -0
index 8c486235c905..9fee464e5d49 100644
@@ -80,6 +80,22 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
 }
 EXPORT_SYMBOL_GPL(snd_hdac_bus_init_cmd_io);
 
+/* wait for cmd dmas till they are stopped */
+static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus)
+{
+	unsigned long timeout;
+
+	timeout = jiffies + msecs_to_jiffies(100);
+	while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN)
+		&& time_before(jiffies, timeout))
+		udelay(10);
+
+	timeout = jiffies + msecs_to_jiffies(100);
+	while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN)
+		&& time_before(jiffies, timeout))
+		udelay(10);
+}
+
 /**
  * snd_hdac_bus_stop_cmd_io - clean up CORB/RIRB buffers
  * @bus: HD-audio core bus
@@ -90,6 +106,7 @@ void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus)
 	/* disable ringbuffer DMAs */
 	snd_hdac_chip_writeb(bus, RIRBCTL, 0);
 	snd_hdac_chip_writeb(bus, CORBCTL, 0);
+	hdac_wait_for_cmd_dmas(bus);
 	/* disable unsolicited responses */
 	snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0);
 	spin_unlock_irq(&bus->reg_lock);
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v2 2/2] ALSA: hda: fix to wait for RIRB & CORB DMA to set

Quoted 31 lines · Vinod Koul

From: Jeeja KP <[email protected]>

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.

---
changes in v2:
- use common wait routine as suggested by Takashi

 sound/hda/hdac_controller.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/hda/hdac_controller.c +4 -0
index 8c486235c905..9fee464e5d49 100644
@@ -80,6 +80,22 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
 }
 EXPORT_SYMBOL_GPL(snd_hdac_bus_init_cmd_io);
 
+/* wait for cmd dmas till they are stopped */
+static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus)
+{
+	unsigned long timeout;

sound/hda/hdac_controller.c void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus) · line 96

Quoted 10 lines
sound/hda/hdac_controller.c +10 -0
+
+	timeout = jiffies + msecs_to_jiffies(100);
+	while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN)
+		&& time_before(jiffies, timeout))
+		udelay(10);
+
+	timeout = jiffies + msecs_to_jiffies(100);
+	while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN)
+		&& time_before(jiffies, timeout))
+		udelay(10);

This will end up with doubled timeout. But it doesn't matter so much in practice. So I applied the patch as is.

thanks,

Takashi

Quoted 16 lines
sound/hda/hdac_controller.c +3 -0
+}
+
 /**
  * snd_hdac_bus_stop_cmd_io - clean up CORB/RIRB buffers
  * @bus: HD-audio core bus
@@ -90,6 +106,7 @@ void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus)
 	/* disable ringbuffer DMAs */
 	snd_hdac_chip_writeb(bus, RIRBCTL, 0);
 	snd_hdac_chip_writeb(bus, CORBCTL, 0);
+	hdac_wait_for_cmd_dmas(bus);
 	/* disable unsolicited responses */
 	snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0);
 	spin_unlock_irq(&bus->reg_lock);
Signature · 1 line
1.9.1
author
#3 lore raw

Re: [PATCH v2 2/2] ALSA: hda: fix to wait for RIRB & CORB DMA to set

Quoted 9 lines · Takashi Iwai
Quoted 9 lines
sound/hda/hdac_controller.c +9 -0
+/* wait for cmd dmas till they are stopped */
+static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus)
+{
+	unsigned long timeout;
+
+	timeout = jiffies + msecs_to_jiffies(100);
+	while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN)
+		&& time_before(jiffies, timeout))
+		udelay(10);
Quoted 8 lines

sound/hda/hdac_controller.c void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus) · line 96

Quoted 5 lines
sound/hda/hdac_controller.c +5 -0
+
+	timeout = jiffies + msecs_to_jiffies(100);
+	while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN)
+		&& time_before(jiffies, timeout))
+		udelay(10);

This will end up with doubled timeout. But it doesn't matter so much in practice. So I applied the patch as is.

Thanks Takashi

Signature · 1 line
~Vinod
Applied
#4 lore raw
In reply to Vinod Koul
Quoted 6 lines · Vinod Koul

ebus is a member of extended device and was never initialized, so do this at device creation.

Applied, thanks.

Takashi

Quoted 19 lines
---
 sound/hda/ext/hdac_ext_bus.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/ext/hdac_ext_bus.c +1 -0
index 2433f7c81472..64de0a3d6d93 100644
@@ -144,6 +144,7 @@ int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr)
 	if (!edev)
 		return -ENOMEM;
 	hdev = &edev->hdac;
+	edev->ebus = ebus;
 
 	snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr);
 
Signature · 1 line
1.9.1