Skip to contentSkip to conversation

ALSA: sb: Don't allow changing the DMA mode during operations

PATCH New Takashi Iwai 1 participant 2 messages Jun 10, 2025 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ALSA: sb: Don't allow changing the DMA mode during operations

When a PCM stream is already running, one shouldn't change the DMA mode via kcontrol, which may screw up the hardware. Return -EBUSY instead.

---
 sound/isa/sb/sb16_main.c | 3 +++
 1 file changed, 3 insertions(+)
sound/isa/sb/sb16_main.c +3 -0
index 74db11525003..c4930efd44e3 100644
@@ -703,6 +703,9 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ct
 	unsigned char nval, oval;
 	int change;
 	
+	if (chip->mode & (SB_MODE_PLAYBACK | SB_MODE_CAPTURE))
+		return -EBUSY;
+
 	nval = ucontrol->value.enumerated.item[0];
 	if (nval > 2)
 		return -EINVAL;
Signature · 1 line
2.49.0
#1 lore raw

PATCH 2/2 ALSA: sb: Force to disable DMAs once when DMA mode is changed

When the DMA mode is changed on the (still real!) SB AWE32 after playing a stream and closing, the previous DMA setup was still silently kept, and it can confuse the hardware, resulting in the unexpected noises. As a workaround, enforce the disablement of DMA setups when the DMA setup is changed by the kcontrol.

https://bugzilla.kernel.org/show_bug.cgi?id=218185

---
 sound/isa/sb/sb16_main.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/isa/sb/sb16_main.c +4 -0
index c4930efd44e3..5a083eecaa6b 100644
@@ -714,6 +714,10 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ct
 	change = nval != oval;
 	snd_sb16_set_dma_mode(chip, nval);
 	spin_unlock_irqrestore(&chip->reg_lock, flags);
+	if (change) {
+		snd_dma_disable(chip->dma8);
+		snd_dma_disable(chip->dma16);
+	}
 	return change;
 }
 
Signature · 1 line
2.49.0