Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: hda: Change AZX_MAX_BUF_SIZE from 1GB to 4MB

When SND_HDA_PREALLOC_SIZE is set to 0, applications can request as much
memory as there is allowed. With value of AZX_MAX_BUF_SIZE it is 1GB per
stream, which is not realistic use case. Change it 4MB.

Bug: https://bugzilla.kernel.org/show_bug.cgi?id=201251#c322
Suggested-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20210318160618.2504068-3-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Amadeusz Sławiński and committed by
Takashi Iwai
12b2b508 dc85fc9d

+6 -2
+6 -2
include/sound/hda_register.h
··· 140 140 #define BDL_SIZE 4096 141 141 #define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16) 142 142 #define AZX_MAX_FRAG 32 143 - /* max buffer size - no h/w limit, you can increase as you like */ 144 - #define AZX_MAX_BUF_SIZE (1024*1024*1024) 143 + /* 144 + * max buffer size - artificial 4MB limit per stream to avoid big allocations 145 + * In theory it can be really big, but as it is per stream on systems with many streams memory could 146 + * be quickly saturated if userspace requests maximum buffer size for each of them. 147 + */ 148 + #define AZX_MAX_BUF_SIZE (4*1024*1024) 145 149 146 150 /* RIRB int mask: overrun[2], response[0] */ 147 151 #define RIRB_INT_RESPONSE 0x01