]> git.ipfire.org Git - thirdparty/linux.git/commit
ALSA: hda: Set up BDL table at hw_params
authorTakashi Iwai <tiwai@suse.de>
Wed, 21 Feb 2024 10:06:06 +0000 (11:06 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 21 Feb 2024 10:14:11 +0000 (11:14 +0100)
commit04438a06c43d09486e4323928b3bb93bd7407488
treecdb088772c089b244e1e7cce3c0db94a636e5a94
parent52592932405cecaaa0f4b8cb41128d014b96858c
ALSA: hda: Set up BDL table at hw_params

So far the setup of BDL table is performed at the prepare stage, where
all PCM parameters have been already set up.  When something wrong
happens at it, we return -EINVAL; it's supposed to be a rare case
since the involved memory allocation is a small chunk of kmalloc for
the table.

However, when we receive too many small non-contiguous pages in highly
fragmented memories, it may overflow the max table size, resulting in
the same -EINVAL error from the prepare, too.  A bad scenario is that
user-space cannot know what went wrong (as it's an error from the
prepare stage) and -EINVAL, hence it may retry with the same
parameters, failing again repeatedly.

In this patch, we try to set up the BDL table at hw_params right after
the buffer allocation, and return -ENOMEM if it overflows.
This allows user-space knowing that it should reduce the buffer size
request accordingly and may retry with more fitting parameters.

Link: https://lore.kernel.org/r/20240221100607.6565-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_controller.c