linux-stable/sound
Takashi Iwai 24d0c9f0e7 ALSA: usb-audio: Limit max buffer and period sizes per time
In the previous fix, we increased the max buffer bytes from 1MB to 4MB
so that we can use bigger buffers for the modern HiFi devices with
higher rates, more channels and wider formats.  OTOH, extending this
has a concern that too big buffer is allowed for the lower rates, less
channels and narrower formats; when an application tries to allocate
as big buffer as possible, it'll lead to unexpectedly too huge size.

Also, we had a problem about the inconsistent max buffer and period
bytes for the implicit feedback mode when both streams have different
channels.  This was fixed by the (relatively complex) patch to reduce
the max buffer and period bytes accordingly.

This is an alternative fix for those, a patch to kill two birds with
one stone (*): instead of increasing the max buffer bytes blindly and
applying the reduction per channels, we simply use the hw constraints
for the buffer and period "time".  Meanwhile the max buffer and period
bytes are set unlimited instead.

Since the inconsistency of buffer (and period) bytes comes from the
difference of the channels in the tied streams, as long as we care
only about the buffer (and period) time, it doesn't matter; the buffer
time is same for different channels, although we still allow higher
buffer size.  Similarly, this will allow more buffer bytes for HiFi
devices while it also keeps the reasonable size for the legacy
devices, too.

As of this patch, the max period and buffer time are set to 1 and 2
seconds, which should be large enough for all possible use cases.

(*) No animals were harmed in the making of this patch.

Fixes: 98c27add5d ("ALSA: usb-audio: Cap upper limits of buffer/period bytes for implicit fb")
Fixes: fee2ec8cce ("ALSA: usb-audio: Increase max buffer size")
Link: https://lore.kernel.org/r/20220412130740.18933-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-04-13 09:10:56 +02:00
..
ac97
aoa
arm
atmel
core ALSA: memalloc: Add fallback SG-buffer allocations for x86 2022-04-13 07:48:53 +02:00
drivers ALSA: mtpav: Don't call card private_free at probe error path 2022-04-12 17:58:43 +02:00
firewire ALSA: firewire-lib: fix uninitialized flag for AV/C deferred transaction 2022-03-04 17:23:21 +01:00
hda ALSA: hda: intel-dsp-config: update AlderLake PCI IDs 2022-04-07 10:29:31 +02:00
i2c
isa ALSA: sc6000: Fix the missing snd_card_free() call at probe error 2022-04-12 17:58:17 +02:00
mips ALSA: mips: Use platform_get_irq() to get the interrupt 2022-02-28 16:59:01 +01:00
oss sound/oss/dmasound: fix build when drivers are mixed =y/=m 2022-04-07 10:28:48 +02:00
parisc
pci ALSA: nm256: Don't call card private_free at probe error path 2022-04-12 17:58:44 +02:00
pcmcia
ppc ALSA: ppc: beep: fix clang -Wimplicit-fallthrough 2021-12-07 15:36:56 +01:00
sh
soc ASoC: Fixes for v5.18 2022-03-30 14:04:22 +02:00
sparc ALSA: sparc: no need to initialise statics to 0 2021-12-12 10:01:04 +01:00
spi ALSA: spi: Add check for clk_enable() 2022-02-28 17:00:10 +01:00
synth ALSA: synth: missing check for possible NULL after the call to kstrdup 2021-11-09 07:18:50 +01:00
usb ALSA: usb-audio: Limit max buffer and period sizes per time 2022-04-13 09:10:56 +02:00
virtio virtio: wrap config->reset calls 2022-01-14 18:50:52 -05:00
x86 ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error 2022-04-12 17:58:35 +02:00
xen xen: flag xen_snd_front to be not essential for system boot 2021-11-23 13:43:54 -06:00
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c sound: core: Remove redundant variable and return the last statement 2022-02-28 17:57:14 +01:00