Re: [PATCH] ALSA: pcm: fix buffer_bytes max constrained by preallocated bytes issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/1/19 下午3:09, Takashi Iwai wrote:
On Sun, 19 Jan 2020 04:52:55 +0100,
Keyon Jie wrote:


On 2020/1/17 下午7:12, Takashi Iwai wrote:
On Fri, 17 Jan 2020 11:43:24 +0100,
Keyon Jie wrote:

In SOF driver, we don't use kernel config item like
CONFIG_SND_HDA_PREALLOC_SIZE for HDA, the code for it is:

	snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream,
				      SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
				le32_to_cpu(caps->buffer_size_min),
				le32_to_cpu(caps->buffer_size_max));

So the preallocated size is configured via topology file, that is
caps->buffer_size_min, no chance for PulseAudio to reconfigure it.

So, it looks like we have to change it to this if we don't change the
ALSA core:

	snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream,
				      SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
-				le32_to_cpu(caps->buffer_size_min),
+				le32_to_cpu(caps->buffer_size_max),
				le32_to_cpu(caps->buffer_size_max));

Yes, passing buffer_size_min for the preallocation sounds already
bad.  The default value should be sufficient for usual operations, not
the cost-cutting minimum.  Otherwise there is no merit of
preallocation.

Alternatively, we may pass 0 there, indicating no limitation, too.
But, this would need a bit other adjustment, e.g. snd_pcm_hardware
should have lower buffer_bytes_max.

Thank you Takashi, then let's follow it to pre-allocate with
caps->buffer_size_max, as we don't specify any limitations in
snd_pcm_hardware today, we want to leave it configurable to each
specific topology file for different machines.

How big is caps->buffer_size_max?  Passing the value there means
actually trying to allocate the given size as default, and it'd be a
lot of waste if a too large value (e.g. 32MB) is passed there.

It varies for each stream, most of them are 65536 Bytes only, whereas one for Wake-On-Voice might need a > 4 Seconds buffer could be up to about 1~2MBytes, and another one for deep-buffer playback can be up to about 8MBytes.


I think we can go for passing zero as default, which means skipping
preallocation.  In addition, we may add an upper limit of the total

Just did an experiment and this works for me, I believe we still need to call snd_pcm_set_managed_buffer() though the preallocation is skipped in this, right?

amount of allocation per card, controlled in pcm_memory.c, for
example.  This logic can be applied to the legacy HDA, too.

This should be relatively easy, and I'll provide the patch in the next
week.

OK, that's fine for me also, thank you.

~Keyon



Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux