Skip to contentSkip to conversation

ALSA: pcm: minor enhancements

PATCH New Takashi Iwai 1 participant 3 messages Nov 5, 2019 Sound

lore
Share & tools
lore
#0 lore raw

cover ALSA: pcm: minor enhancements

Hi,

here are a couple of more small enhnacements on PCM memory allocation stuff.

Takashi

===

Takashi Iwai (2):
ALSA: pcm: Warn if doubly preallocated
ALSA: pcm: Create proc files only for non-empty preallocations

 sound/core/pcm_memory.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 6 lines
2.16.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw

PATCH 1/2 ALSA: pcm: Warn if doubly preallocated

Warn if snd_pcm_lib_preallocate_pages*() is applied to the stream that has already the preallocated buffers and skip the allocation. It's a clearly a driver bug.

---
 sound/core/pcm_memory.c | 2 ++
 1 file changed, 2 insertions(+)
sound/core/pcm_memory.c +2 -0
index 7600dcdf5fd4..19407f79b638 100644
@@ -221,6 +221,8 @@ void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
 				  int type, struct device *data,
 				  size_t size, size_t max)
 {
+	if (snd_BUG_ON(substream->dma_buffer.dev.type))
+		return;
 	substream->dma_buffer.dev.type = type;
 	substream->dma_buffer.dev.dev = data;
 	snd_pcm_lib_preallocate_pages1(substream, size, max);
Signature · 6 lines
2.16.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#2 lore raw

PATCH 2/2 ALSA: pcm: Create proc files only for non-empty preallocations

In reply to Takashi Iwai

It makes little sense to create prealloc proc files for streams that have the zero max size, which is a typical case for vmalloc buffers. Skip the proc file creations to save resources in such a case.

---
 sound/core/pcm_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/pcm_memory.c +2 -1
index 19407f79b638..17ee361ce791 100644
@@ -203,7 +203,8 @@ static void snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
 	if (substream->dma_buffer.bytes > 0)
 		substream->buffer_bytes_max = substream->dma_buffer.bytes;
 	substream->dma_max = max;
-	preallocate_info_init(substream);
+	if (max > 0)
+		preallocate_info_init(substream);
 }
 
 
Signature · 6 lines
2.16.4

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