• Takashi Iwai's avatar
    ALSA: hda: Set up BDL table at hw_params · 04438a06
    Takashi Iwai authored
    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: default avatarTakashi Iwai <tiwai@suse.de>
    04438a06
hda_controller.c 34.8 KB