mbox series

[0/3] Fix SND_HDA_PREALLOC issue

Message ID 20210318151122.2493096-1-amadeuszx.slawinski@linux.intel.com (mailing list archive)
Headers show
Series Fix SND_HDA_PREALLOC issue | expand

Message

Amadeusz Sławiński March 18, 2021, 3:11 p.m. UTC
For context it started with user reporting failures when running arecord
without any error or warning in dmesg (after fixing some configuration
problems thet they had).
https://bugzilla.kernel.org/show_bug.cgi?id=201251#c279

After spending time investigating the issue it was narrowed to quite big
setting of CONFIG_SND_HDA_PREALLOC_SIZE (4096).
When looking at code
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/core/pcm_memory.c?id=6417f03132a6952cd17ddd8eaddbac92b61b17e0#n30
there is a limit of memory per card:
max_alloc_per_card = 32UL * 1024UL * 1024UL

When SND_HDA_PREALLOC_SIZE is set to 4096 it only has memory to alloc
for 8 frontends, while Skylake HDA card has 10 of them (6 playback and 4
capture), so preallocated memory is exhausted while probing. In
consequence 2 of FEs end without allocated memory.

It can be workarounded on user side with setting SND_HDA_PREALLOC_SIZE
to lower value, other is changing memory limit per card.

However in order to not waste user memory, change maximum allocation
size on HDA controller to 4MB and force automatical memory allocation
insted of preallocated one.

First patch adds prints, so similar issues can be easily identified in
the future.
Second changes maximum size of hda buffer to reasonable value of 4MB.
And last one reverts patch which allowed setting prealloc size on X86
platforms.

Amadeusz Sławiński (3):
  ALSA: pcm: Add debug print on memory allocation failure
  ALSA: hda: Change AZX_MAX_BUF_SIZE from 1GB to 4MB
  ALSA: hda: Revert "ALSA: hda: Allow setting preallocation again for
    x86"

 include/sound/hda_register.h | 4 ++--
 sound/core/pcm_memory.c      | 8 ++++++++
 sound/hda/Kconfig            | 7 +++----
 3 files changed, 13 insertions(+), 6 deletions(-)

Comments

Cezary Rojewski March 18, 2021, 3:26 p.m. UTC | #1
On 2021-03-18 4:11 PM, Amadeusz Sławiński wrote:
> For context it started with user reporting failures when running arecord
> without any error or warning in dmesg (after fixing some configuration
> problems thet they had).
> https://bugzilla.kernel.org/show_bug.cgi?id=201251#c279
> 
> After spending time investigating the issue it was narrowed to quite big
> setting of CONFIG_SND_HDA_PREALLOC_SIZE (4096).
> When looking at code
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/core/pcm_memory.c?id=6417f03132a6952cd17ddd8eaddbac92b61b17e0#n30
> there is a limit of memory per card:
> max_alloc_per_card = 32UL * 1024UL * 1024UL
> 
> When SND_HDA_PREALLOC_SIZE is set to 4096 it only has memory to alloc
> for 8 frontends, while Skylake HDA card has 10 of them (6 playback and 4
> capture), so preallocated memory is exhausted while probing. In
> consequence 2 of FEs end without allocated memory.
> 
> It can be workarounded on user side with setting SND_HDA_PREALLOC_SIZE
> to lower value, other is changing memory limit per card.
> 
> However in order to not waste user memory, change maximum allocation
> size on HDA controller to 4MB and force automatical memory allocation
> insted of preallocated one.
> 
> First patch adds prints, so similar issues can be easily identified in
> the future.
> Second changes maximum size of hda buffer to reasonable value of 4MB.
> And last one reverts patch which allowed setting prealloc size on X86
> platforms.
> 
> Amadeusz Sławiński (3):
>    ALSA: pcm: Add debug print on memory allocation failure
>    ALSA: hda: Change AZX_MAX_BUF_SIZE from 1GB to 4MB
>    ALSA: hda: Revert "ALSA: hda: Allow setting preallocation again for
>      x86"
> 
>   include/sound/hda_register.h | 4 ++--
>   sound/core/pcm_memory.c      | 8 ++++++++
>   sound/hda/Kconfig            | 7 +++----
>   3 files changed, 13 insertions(+), 6 deletions(-)
> 

For the series:
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>

Nice work Amadeo.

Regards,
Czarek