Skip to contentSkip to conversation

snd_pcm_stop() lock fixes

PATCH NAK Takashi Iwai 6 participants 23 messages Jul 15, 2013 – Jul 16, 2013

Subsystems (9)
Media (V4L/DVB) Sound Staging ASoC +5 more subsystems
lore
Share & tools
lore
#0 lore raw

cover snd_pcm_stop() lock fixes

Hi,

while reviewing another patch series, I stumbled on the snd_pcm_lock() call in an unlocked context. Then I started looking through the whole tree, and found a bunch of drivers doing it wrong, too. So here is a patch series to fix them.

[PATCH 01/10] ALSA: asihpi: Fix unlocked snd_pcm_stop() call [PATCH 02/10] ALSA: atiixp: Fix unlocked snd_pcm_stop() call [PATCH 03/10] ALSA: 6fire: Fix unlocked snd_pcm_stop() call [PATCH 04/10] ALSA: ua101: Fix unlocked snd_pcm_stop() call [PATCH 05/10] ALSA: usx2y: Fix unlocked snd_pcm_stop() call [PATCH 06/10] ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call [PATCH 07/10] ASoC: atmel: Fix unlocked snd_pcm_stop() call [PATCH 08/10] ASoC: s6000: Fix unlocked snd_pcm_stop() call [PATCH 09/10] [media] saa7134: Fix unlocked snd_pcm_stop() call [PATCH 10/10] staging: line6: Fix unlocked snd_pcm_stop() call

Takashi

#1 lore raw

PATCH 1/10 ALSA: asihpi: Fix unlocked snd_pcm_stop() call

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/pci/asihpi/asihpi.c | 3 +++
 1 file changed, 3 insertions(+)
sound/pci/asihpi/asihpi.c +3 -0
index 185d54a..dc632cd 100644
@@ -769,7 +769,10 @@ static void snd_card_asihpi_timer_function(unsigned long data)
 						s->number);
 				ds->drained_count++;
 				if (ds->drained_count > 20) {
+					unsigned long flags;
+					snd_pcm_stream_lock_irqsave(s, flags);
 					snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
+					snd_pcm_stream_unlock_irqrestore(s, flags);
 					continue;
 				}
 			} else {
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/10 ALSA: atiixp: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/pci/atiixp.c       | 2 ++
 sound/pci/atiixp_modem.c | 2 ++
 2 files changed, 4 insertions(+)
sound/pci/atiixp.c +2 -0
index fe4c61b..f6dec3e 100644
@@ -689,7 +689,9 @@ static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
 	if (! dma->substream || ! dma->running)
 		return;
 	snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type);
+	snd_pcm_stream_lock(dma->substream);
 	snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
+	snd_pcm_stream_unlock(dma->substream);
 }
 
 /*
sound/pci/atiixp_modem.c +2 -0
index cf29b9a..289563e 100644
@@ -638,7 +638,9 @@ static void snd_atiixp_xrun_dma(struct atiixp_modem *chip,
 	if (! dma->substream || ! dma->running)
 		return;
 	snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type);
+	snd_pcm_stream_lock(dma->substream);
 	snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
+	snd_pcm_stream_unlock(dma->substream);
 }
 
 /*
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/10 ALSA: 6fire: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/usb/6fire/pcm.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
sound/usb/6fire/pcm.c +10 -2
index c5b9cac..2aa4e13 100644
@@ -639,17 +639,25 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
 void usb6fire_pcm_abort(struct sfire_chip *chip)
 {
 	struct pcm_runtime *rt = chip->pcm;
+	unsigned long flags;
 	int i;
 
 	if (rt) {
 		rt->panic = true;
 
-		if (rt->playback.instance)
+		if (rt->playback.instance) {
+			snd_pcm_stream_lock_irqsave(rt->playback.instance, flags);
 			snd_pcm_stop(rt->playback.instance,
 					SNDRV_PCM_STATE_XRUN);
-		if (rt->capture.instance)
+			snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags);
+		}
+
+		if (rt->capture.instance) {
+			snd_pcm_stream_lock_irqsave(rt->capture.instance, flags);
 			snd_pcm_stop(rt->capture.instance,
 					SNDRV_PCM_STATE_XRUN);
+			snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags);
+		}
 
 		for (i = 0; i < PCM_N_URBS; i++) {
 			usb_poison_urb(&rt->in_urbs[i].instance);
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/10 ALSA: ua101: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/usb/misc/ua101.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
sound/usb/misc/ua101.c +12 -2
index 8b5d2c5..5093159 100644
@@ -613,14 +613,24 @@ static int start_usb_playback(struct ua101 *ua)
 
 static void abort_alsa_capture(struct ua101 *ua)
 {
-	if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states))
+	unsigned long flags;
+
+	if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) {
+		snd_pcm_stream_lock_irqsave(ua->capture.substream, flags);
 		snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stream_unlock_irqrestore(ua->capture.substream, flags);
+	}
 }
 
 static void abort_alsa_playback(struct ua101 *ua)
 {
-	if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states))
+	unsigned long flags;
+
+	if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) {
+		snd_pcm_stream_lock_irqsave(ua->playback.substream, flags);
 		snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stream_unlock_irqrestore(ua->playback.substream, flags);
+	}
 }
 
 static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream,
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 5/10 ALSA: usx2y: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/usb/usx2y/usbusx2yaudio.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/usb/usx2y/usbusx2yaudio.c +4 -0
index 4967fe9..63fb521 100644
@@ -273,7 +273,11 @@ static void usX2Y_clients_stop(struct usX2Ydev *usX2Y)
 		struct snd_usX2Y_substream *subs = usX2Y->subs[s];
 		if (subs) {
 			if (atomic_read(&subs->state) >= state_PRERUNNING) {
+				unsigned long flags;
+
+				snd_pcm_stream_lock_irqsave(subs->pcm_substream, flags);
 				snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN);
+				snd_pcm_stream_unlock_irqrestore(subs->pcm_substream, flags);
 			}
 			for (u = 0; u < NRURBS; u++) {
 				struct urb *urb = subs->urb[u];
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 6/10 ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/arm/pxa2xx-pcm-lib.c | 2 ++
 1 file changed, 2 insertions(+)
sound/arm/pxa2xx-pcm-lib.c +2 -0
index 76e0d56..823359e 100644
@@ -166,7 +166,9 @@ void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id)
 	} else {
 		printk(KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
 			rtd->params->name, dma_ch, dcsr);
+		snd_pcm_stream_lock(substream);
 		snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stream_unlock(substream);
 	}
 }
 EXPORT_SYMBOL(pxa2xx_pcm_dma_irq);
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 7/10 ASoC: atmel: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/soc/atmel/atmel-pcm-dma.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/atmel/atmel-pcm-dma.c +2 -0
index 1d38fd0..d128265 100644
@@ -81,7 +81,9 @@ static void atmel_pcm_dma_irq(u32 ssc_sr,
 
 		/* stop RX and capture: will be enabled again at restart */
 		ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable);
+		snd_pcm_stream_lock(substream);
 		snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stream_unlock(substream);
 
 		/* now drain RHR and read status to remove xrun condition */
 		ssc_readx(prtd->ssc->regs, SSC_RHR);
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 8/10 ASoC: s6000: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 sound/soc/s6000/s6000-pcm.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/s6000/s6000-pcm.c +2 -0
index 1358c7d..3aaf6f6 100644
@@ -128,7 +128,9 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data)
 		    substream->runtime &&
 		    snd_pcm_running(substream)) {
 			dev_dbg(pcm->dev, "xrun\n");
+			snd_pcm_stream_lock(substream);
 			snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+			snd_pcm_substream_unlock(substream);
 			ret = IRQ_HANDLED;
 		}
 
Signature · 1 line
1.8.3.1
#13 lore raw

Re: [PATCH 08/10] ASoC: s6000: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

Nack

sound/soc/s6000/s6000-pcm.c static irqreturn_t s6000_pcm_irq(int irq, void *data) · line 133

Quoted 9 lines · Takashi Iwai
sound/soc/s6000/s6000-pcm.c +2 -0
@@ -128,7 +128,9 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data)
 		    substream->runtime &&
 		    snd_pcm_running(substream)) {
 			dev_dbg(pcm->dev, "xrun\n");
+			snd_pcm_stream_lock(substream);
 			snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+			snd_pcm_substream_unlock(substream);

I think this is supposed to be a call to snd_pcm_stream_unlock.

Daniel

Signature · 7 lines
Dipl.-Math. Daniel Glöckner, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11,
Bertha-von-Suttner-Straße 9, 37085 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Dr. Uwe Kracke, Ust-IdNr.: DE 205 198 055

emlix - your embedded linux partner
#14 lore raw

Re: [PATCH 08/10] ASoC: s6000: Fix unlocked snd_pcm_stop() call

At Mon, 15 Jul 2013 18:02:48 +0200,

Quoted 4 lines · Daniel Glöckner

Nack

On Mon, Jul 15, 2013 at 03:06:20PM +0200, Takashi Iwai wrote:

Quoted 11 lines

sound/soc/s6000/s6000-pcm.c static irqreturn_t s6000_pcm_irq(int irq, void *data) · line 133

Quoted 9 lines
sound/soc/s6000/s6000-pcm.c +2 -0
@@ -128,7 +128,9 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data)
 		    substream->runtime &&
 		    snd_pcm_running(substream)) {
 			dev_dbg(pcm->dev, "xrun\n");
+			snd_pcm_stream_lock(substream);
 			snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+			snd_pcm_substream_unlock(substream);

I think this is supposed to be a call to snd_pcm_stream_unlock.

Bah, thanks, fixed now.

This didn't go through my build test, obviously...

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#15 lore raw

PATCH 9/10 saa7134: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 drivers/media/pci/saa7134/saa7134-alsa.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/pci/saa7134/saa7134-alsa.c +2 -0
index 10460fd..dbcdfbf 100644
@@ -172,7 +172,9 @@ static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
 		dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
 			dev->dmasound.bufsize, dev->dmasound.blocks);
 		spin_unlock(&dev->slock);
+		snd_pcm_stream_lock(dev->dmasound.substream);
 		snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stream_unlock(dev->dmasound.substream);
 		return;
 	}
 
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 10/10 staging: line6: Fix unlocked snd_pcm_stop() call

In reply to Takashi Iwai

snd_pcm_stop() must be called in the PCM substream lock context.

---
 drivers/staging/line6/pcm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/line6/pcm.c +4 -1
index 02f77d7..a7856ba 100644
@@ -385,8 +385,11 @@ static int snd_line6_pcm_free(struct snd_device *device)
 */
 static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
 {
-	if (substream->runtime && snd_pcm_running(substream))
+	if (substream->runtime && snd_pcm_running(substream)) {
+		snd_pcm_stream_lock_irq(substream);
 		snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
+		snd_pcm_stream_unlock_irq(substream);
+	}
 }
 
 /*
Signature · 1 line
1.8.3.1
maintainer
#17 lore raw
In reply to Takashi Iwai
Quoted 7 lines · Takashi Iwai

Hi,

while reviewing another patch series, I stumbled on the snd_pcm_lock() call in an unlocked context. Then I started looking through the whole tree, and found a bunch of drivers doing it wrong, too. So here is a patch series to fix them.

Quoted 10 lines

[PATCH 01/10] ALSA: asihpi: Fix unlocked snd_pcm_stop() call [PATCH 02/10] ALSA: atiixp: Fix unlocked snd_pcm_stop() call [PATCH 03/10] ALSA: 6fire: Fix unlocked snd_pcm_stop() call [PATCH 04/10] ALSA: ua101: Fix unlocked snd_pcm_stop() call [PATCH 05/10] ALSA: usx2y: Fix unlocked snd_pcm_stop() call [PATCH 06/10] ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call [PATCH 07/10] ASoC: atmel: Fix unlocked snd_pcm_stop() call [PATCH 08/10] ASoC: s6000: Fix unlocked snd_pcm_stop() call [PATCH 09/10] [media] saa7134: Fix unlocked snd_pcm_stop() call [PATCH 10/10] staging: line6: Fix unlocked snd_pcm_stop() call

Probably, it may be better to introduce 'snd_pcm_stop_dolock()' helper (inline?) in include/sound/pcm.h .

Jaroslav

Signature · 3 lines
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.
#18 lore raw

At Mon, 15 Jul 2013 15:12:07 +0200,

Quoted 20 lines · Jaroslav Kysela
Quoted 7 lines · Takashi Iwai

Hi,

while reviewing another patch series, I stumbled on the snd_pcm_lock() call in an unlocked context. Then I started looking through the whole tree, and found a bunch of drivers doing it wrong, too. So here is a patch series to fix them.

Quoted 10 lines

[PATCH 01/10] ALSA: asihpi: Fix unlocked snd_pcm_stop() call [PATCH 02/10] ALSA: atiixp: Fix unlocked snd_pcm_stop() call [PATCH 03/10] ALSA: 6fire: Fix unlocked snd_pcm_stop() call [PATCH 04/10] ALSA: ua101: Fix unlocked snd_pcm_stop() call [PATCH 05/10] ALSA: usx2y: Fix unlocked snd_pcm_stop() call [PATCH 06/10] ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call [PATCH 07/10] ASoC: atmel: Fix unlocked snd_pcm_stop() call [PATCH 08/10] ASoC: s6000: Fix unlocked snd_pcm_stop() call [PATCH 09/10] [media] saa7134: Fix unlocked snd_pcm_stop() call [PATCH 10/10] staging: line6: Fix unlocked snd_pcm_stop() call

Quoted 2 lines

Probably, it may be better to introduce 'snd_pcm_stop_dolock()' helper (inline?) in include/sound/pcm.h .

Yes, it'll be the next step. These patches are done in open-coded way so that they can be applied easily to each stable kernel.

thanks,

Takashi

#19 lore raw

At Mon, 15 Jul 2013 15:17:58 +0200,

Quoted 23 lines · Takashi Iwai

At Mon, 15 Jul 2013 15:12:07 +0200,

Quoted 20 lines · Jaroslav Kysela
Quoted 17 lines · Takashi Iwai

Hi,

while reviewing another patch series, I stumbled on the snd_pcm_lock() call in an unlocked context. Then I started looking through the whole tree, and found a bunch of drivers doing it wrong, too. So here is a patch series to fix them.

[PATCH 01/10] ALSA: asihpi: Fix unlocked snd_pcm_stop() call [PATCH 02/10] ALSA: atiixp: Fix unlocked snd_pcm_stop() call [PATCH 03/10] ALSA: 6fire: Fix unlocked snd_pcm_stop() call [PATCH 04/10] ALSA: ua101: Fix unlocked snd_pcm_stop() call [PATCH 05/10] ALSA: usx2y: Fix unlocked snd_pcm_stop() call [PATCH 06/10] ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call [PATCH 07/10] ASoC: atmel: Fix unlocked snd_pcm_stop() call [PATCH 08/10] ASoC: s6000: Fix unlocked snd_pcm_stop() call [PATCH 09/10] [media] saa7134: Fix unlocked snd_pcm_stop() call [PATCH 10/10] staging: line6: Fix unlocked snd_pcm_stop() call

Quoted 5 lines
Quoted 2 lines

Probably, it may be better to introduce 'snd_pcm_stop_dolock()' helper (inline?) in include/sound/pcm.h .

Yes, it'll be the next step. These patches are done in open-coded way so that they can be applied easily to each stable kernel.

BTW the conversion I thought of is a patch like below.

Takashi

---

include/sound/pcm.h +1 -0
index 84b10f9..96eda75 100644
@@ -502,6 +502,7 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 		   struct snd_pcm_status *status);
 int snd_pcm_start(struct snd_pcm_substream *substream);
 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
+int snd_pcm_lock_and_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
 int snd_pcm_drain_done(struct snd_pcm_substream *substream);
 #ifdef CONFIG_PM
 int snd_pcm_suspend(struct snd_pcm_substream *substream);
sound/core/pcm_native.c +21 -2
index f928181..56582ac 100644
@@ -809,9 +809,10 @@ static int snd_pcm_action_lock_irq(struct action_ops *ops,
 				   struct snd_pcm_substream *substream,
 				   int state)
 {
+	unsigned long flags;
 	int res;
 
-	read_lock_irq(&snd_pcm_link_rwlock);
+	read_lock_irqsave(&snd_pcm_link_rwlock, flags);
 	if (snd_pcm_stream_linked(substream)) {
 		spin_lock(&substream->group->lock);
 		spin_lock(&substream->self_group.lock);
@@ -823,7 +824,7 @@ static int snd_pcm_action_lock_irq(struct action_ops *ops,
 		res = snd_pcm_action_single(ops, substream, state);
 		spin_unlock(&substream->self_group.lock);
 	}
-	read_unlock_irq(&snd_pcm_link_rwlock);
+	read_unlock_irqrestore(&snd_pcm_link_rwlock, flags);
 	return res;
 }
 
@@ -900,6 +901,8 @@ static struct action_ops snd_pcm_action_start = {
  * @substream: the PCM substream instance
  *
  * Return: Zero if successful, or a negative error code.
+ *
+ * Note that this function must be called in substream lock context.
  */
 int snd_pcm_start(struct snd_pcm_substream *substream)
 {
@@ -955,6 +958,8 @@ static struct action_ops snd_pcm_action_stop = {
  * The state of each stream is then changed to the given state unconditionally.
  *
  * Return: Zero if succesful, or a negative error code.
+ *
+ * Note that this function must be called in substream lock context.
  */
 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)
 {
@@ -964,6 +969,20 @@ int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)
 EXPORT_SYMBOL(snd_pcm_stop);
 
 /**
+ * snd_pcm_lock_and_stop - lock substream and call snd_pcm_stop()
+ * @substream: the PCM substream instance
+ * @state: PCM state after stopping the stream
+ *
+ * Call this function instead of snd_pcm_stop() when need to stop a
+ * PCM stream outside the stream lock context.
+ */
+int snd_pcm_lock_and_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)
+{
+	return snd_pcm_action_lock_irq(&snd_pcm_action_stop, substream, state);
+}
+EXPORT_SYMBOL_GPL(snd_pcm_lock_and_stop);
+
+/**
  * snd_pcm_drain_done - stop the DMA only when the given stream is playback
  * @substream: the PCM substream
  *
#20 lore raw

On 07/16/2013 04:48 PM, Takashi Iwai wrote:
[...]

Quoted 1 line

+int snd_pcm_lock_and_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)

The name makes it sound as if the lock will still be held after the function call has completed. How about snd_pcm_stop_locked()?

- Lars

#21 lore raw

At Tue, 16 Jul 2013 16:54:14 +0200,

Quoted 7 lines · Lars-Peter Clausen

On 07/16/2013 04:48 PM, Takashi Iwai wrote:
[...]

Quoted 1 line

+int snd_pcm_lock_and_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)

The name makes it sound as if the lock will still be held after the function call has completed.

Yeah, I agree with my bad sense of naming...

Quoted 1 line

How about snd_pcm_stop_locked()?

Hrm, it's also unclear whether it's called in a locked context or it does lock by itself.

Takashi

#22 lore raw
Quoted 10 lines · Takashi Iwai

At Tue, 16 Jul 2013 16:54:14 +0200,

Quoted 7 lines · Lars-Peter Clausen

On 07/16/2013 04:48 PM, Takashi Iwai wrote:
[...]

Quoted 1 line

+int snd_pcm_lock_and_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)

The name makes it sound as if the lock will still be held after the function call has completed.

Quoted 6 lines

Yeah, I agree with my bad sense of naming...

Quoted 1 line

How about snd_pcm_stop_locked()?

Hrm, it's also unclear whether it's called in a locked context or it does lock by itself.

Hm, I always thought that ..._locked() was mainly used for functions that take the lock, but a quick grep revealed that both meanings are used and it's split about 50/50 :/

- Lars