* [PATCH] ALSA: usb-audio: Increase max buffer size @ 2022-04-07 21:27 Takashi Iwai 2022-04-08 7:15 ` Jaroslav Kysela 2022-04-09 20:36 ` Geraldo Nascimento 0 siblings, 2 replies; 7+ messages in thread From: Takashi Iwai @ 2022-04-07 21:27 UTC (permalink / raw) To: alsa-devel The current limit of max buffer size 1MB seems too small for modern devices with lots of channels and high sample rates. Let's make bigger, 4MB. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/usb/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 6a460225f2e3..37ee6df8b15a 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -659,7 +659,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) #define hwc_debug(fmt, args...) do { } while(0) #endif -#define MAX_BUFFER_BYTES (1024 * 1024) +#define MAX_BUFFER_BYTES (4 * 1024 * 1024) #define MAX_PERIOD_BYTES (512 * 1024) static const struct snd_pcm_hardware snd_usb_hardware = -- 2.31.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Increase max buffer size 2022-04-07 21:27 [PATCH] ALSA: usb-audio: Increase max buffer size Takashi Iwai @ 2022-04-08 7:15 ` Jaroslav Kysela 2022-04-09 20:36 ` Geraldo Nascimento 1 sibling, 0 replies; 7+ messages in thread From: Jaroslav Kysela @ 2022-04-08 7:15 UTC (permalink / raw) To: Takashi Iwai; +Cc: ALSA development On 07. 04. 22 23:27, Takashi Iwai wrote: > The current limit of max buffer size 1MB seems too small for modern > devices with lots of channels and high sample rates. > Let's make bigger, 4MB. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Thanks, Jaroslav > > Signed-off-by: Takashi Iwai <tiwai@suse.de> > --- > sound/usb/pcm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index 6a460225f2e3..37ee6df8b15a 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -659,7 +659,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > #define hwc_debug(fmt, args...) do { } while(0) > #endif > > -#define MAX_BUFFER_BYTES (1024 * 1024) > +#define MAX_BUFFER_BYTES (4 * 1024 * 1024) > #define MAX_PERIOD_BYTES (512 * 1024) > > static const struct snd_pcm_hardware snd_usb_hardware = -- Jaroslav Kysela <perex@perex.cz> Linux Sound Maintainer; ALSA Project; Red Hat, Inc. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Increase max buffer size 2022-04-07 21:27 [PATCH] ALSA: usb-audio: Increase max buffer size Takashi Iwai 2022-04-08 7:15 ` Jaroslav Kysela @ 2022-04-09 20:36 ` Geraldo Nascimento 2022-04-09 20:43 ` Jaroslav Kysela 1 sibling, 1 reply; 7+ messages in thread From: Geraldo Nascimento @ 2022-04-09 20:36 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel On Thu, Apr 07, 2022 at 11:27:40PM +0200, Takashi Iwai wrote: > The current limit of max buffer size 1MB seems too small for modern > devices with lots of channels and high sample rates. > Let's make bigger, 4MB. Hi Takashi, I did some math and 4MB is still too little for some extreme hardware like the Behringer Wing, which is USB 2.0 by the way. According to my calculations, at 192 KHz and 48 channels, even with this 4MB patch, we would still have only 151.7 ms of buffer for the Wing. Therefore my suggestion is to expose the MAX_BUFFER_BYTES as Kconf. Do you think this is plausible? Thanks, Geraldo Nascimento > > Signed-off-by: Takashi Iwai <tiwai@suse.de> > --- > sound/usb/pcm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index 6a460225f2e3..37ee6df8b15a 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -659,7 +659,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > #define hwc_debug(fmt, args...) do { } while(0) > #endif > > -#define MAX_BUFFER_BYTES (1024 * 1024) > +#define MAX_BUFFER_BYTES (4 * 1024 * 1024) > #define MAX_PERIOD_BYTES (512 * 1024) > > static const struct snd_pcm_hardware snd_usb_hardware = > -- > 2.31.1 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Increase max buffer size 2022-04-09 20:36 ` Geraldo Nascimento @ 2022-04-09 20:43 ` Jaroslav Kysela 2022-04-09 21:11 ` Geraldo Nascimento 2022-04-10 7:40 ` Takashi Iwai 0 siblings, 2 replies; 7+ messages in thread From: Jaroslav Kysela @ 2022-04-09 20:43 UTC (permalink / raw) To: Geraldo Nascimento, Takashi Iwai; +Cc: alsa-devel On 09. 04. 22 22:36, Geraldo Nascimento wrote: > On Thu, Apr 07, 2022 at 11:27:40PM +0200, Takashi Iwai wrote: >> The current limit of max buffer size 1MB seems too small for modern >> devices with lots of channels and high sample rates. >> Let's make bigger, 4MB. > > Hi Takashi, > > I did some math and 4MB is still too little for some extreme hardware > like the Behringer Wing, which is USB 2.0 by the way. According to my > calculations, at 192 KHz and 48 channels, even with this 4MB patch, we > would still have only 151.7 ms of buffer for the Wing. > > Therefore my suggestion is to expose the MAX_BUFFER_BYTES as Kconf. > > Do you think this is plausible? I think that much better behaviour may be to calculate and limit the max buffer size at runtime depending on the max channels / rate / sample bits obtained from the USB descriptors by default. For standard hardware, those big buffers do not make much sense and there's usually a mix of the USB sound hardware in the system. Jaroslav > > Thanks, > Geraldo Nascimento > >> >> Signed-off-by: Takashi Iwai <tiwai@suse.de> >> --- >> sound/usb/pcm.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c >> index 6a460225f2e3..37ee6df8b15a 100644 >> --- a/sound/usb/pcm.c >> +++ b/sound/usb/pcm.c >> @@ -659,7 +659,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) >> #define hwc_debug(fmt, args...) do { } while(0) >> #endif >> >> -#define MAX_BUFFER_BYTES (1024 * 1024) >> +#define MAX_BUFFER_BYTES (4 * 1024 * 1024) >> #define MAX_PERIOD_BYTES (512 * 1024) >> >> static const struct snd_pcm_hardware snd_usb_hardware = >> -- >> 2.31.1 >> -- Jaroslav Kysela <perex@perex.cz> Linux Sound Maintainer; ALSA Project; Red Hat, Inc. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Increase max buffer size 2022-04-09 20:43 ` Jaroslav Kysela @ 2022-04-09 21:11 ` Geraldo Nascimento 2022-04-09 22:24 ` Geraldo Nascimento 2022-04-10 7:40 ` Takashi Iwai 1 sibling, 1 reply; 7+ messages in thread From: Geraldo Nascimento @ 2022-04-09 21:11 UTC (permalink / raw) To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel On Sat, Apr 09, 2022 at 10:43:13PM +0200, Jaroslav Kysela wrote: > On 09. 04. 22 22:36, Geraldo Nascimento wrote: > > On Thu, Apr 07, 2022 at 11:27:40PM +0200, Takashi Iwai wrote: > >> The current limit of max buffer size 1MB seems too small for modern > >> devices with lots of channels and high sample rates. > >> Let's make bigger, 4MB. > > > > Hi Takashi, > > > > I did some math and 4MB is still too little for some extreme hardware > > like the Behringer Wing, which is USB 2.0 by the way. According to my > > calculations, at 192 KHz and 48 channels, even with this 4MB patch, we > > would still have only 151.7 ms of buffer for the Wing. > > > > Therefore my suggestion is to expose the MAX_BUFFER_BYTES as Kconf. > > > > Do you think this is plausible? > > I think that much better behaviour may be to calculate and limit the max > buffer size at runtime depending on the max channels / rate / sample bits > obtained from the USB descriptors by default. Hi Jaroslav, Yes, I agree, your approach seems to be the most cost-effective way of dealing with extreme USB sound hardware, plus if it's calculated at runtime the users won't need to recompile their kernels for new devices and the whole thing is painless from the perspective of the end-user. > For standard hardware, those big > buffers do not make much sense and there's usually a mix of the USB sound > hardware in the system. That is true, thanks for pointing it out. Thank you, Geraldo Nascimento > > Jaroslav > > > > > Thanks, > > Geraldo Nascimento > > > >> > >> Signed-off-by: Takashi Iwai <tiwai@suse.de> > >> --- > >> sound/usb/pcm.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > >> index 6a460225f2e3..37ee6df8b15a 100644 > >> --- a/sound/usb/pcm.c > >> +++ b/sound/usb/pcm.c > >> @@ -659,7 +659,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > >> #define hwc_debug(fmt, args...) do { } while(0) > >> #endif > >> > >> -#define MAX_BUFFER_BYTES (1024 * 1024) > >> +#define MAX_BUFFER_BYTES (4 * 1024 * 1024) > >> #define MAX_PERIOD_BYTES (512 * 1024) > >> > >> static const struct snd_pcm_hardware snd_usb_hardware = > >> -- > >> 2.31.1 > >> > > > -- > Jaroslav Kysela <perex@perex.cz> > Linux Sound Maintainer; ALSA Project; Red Hat, Inc. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Increase max buffer size 2022-04-09 21:11 ` Geraldo Nascimento @ 2022-04-09 22:24 ` Geraldo Nascimento 0 siblings, 0 replies; 7+ messages in thread From: Geraldo Nascimento @ 2022-04-09 22:24 UTC (permalink / raw) To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel Hi Takashi and Jaroslav, On Sat, Apr 09, 2022 at 06:11:54PM -0300, Geraldo Nascimento wrote: > On Sat, Apr 09, 2022 at 10:43:13PM +0200, Jaroslav Kysela wrote: > > On 09. 04. 22 22:36, Geraldo Nascimento wrote: > > > On Thu, Apr 07, 2022 at 11:27:40PM +0200, Takashi Iwai wrote: > > >> The current limit of max buffer size 1MB seems too small for modern > > >> devices with lots of channels and high sample rates. > > >> Let's make bigger, 4MB. > > > > > > Hi Takashi, > > > > > > I did some math and 4MB is still too little for some extreme hardware > > > like the Behringer Wing, which is USB 2.0 by the way. According to my > > > calculations, at 192 KHz and 48 channels, even with this 4MB patch, we > > > would still have only 151.7 ms of buffer for the Wing. This is wrong by the way. The Wing goes up to 48 KHz. They claim A/D Conversion of up to 192 KHz but doing that sample rate though USB 2.0 would be exceeding known physical limits :) Sorry about that, Geraldo Nascimento > > > > > > Therefore my suggestion is to expose the MAX_BUFFER_BYTES as Kconf. > > > > > > Do you think this is plausible? > > > > I think that much better behaviour may be to calculate and limit the max > > buffer size at runtime depending on the max channels / rate / sample bits > > obtained from the USB descriptors by default. > > Hi Jaroslav, > > Yes, I agree, your approach seems to be the most cost-effective way of > dealing with extreme USB sound hardware, plus if it's calculated at > runtime the users won't need to recompile their kernels for new devices > and the whole thing is painless from the perspective of the end-user. > > > For standard hardware, those big > > buffers do not make much sense and there's usually a mix of the USB sound > > hardware in the system. > > That is true, thanks for pointing it out. > > Thank you, > Geraldo Nascimento > > > > > Jaroslav > > > > > > > > Thanks, > > > Geraldo Nascimento > > > > > >> > > >> Signed-off-by: Takashi Iwai <tiwai@suse.de> > > >> --- > > >> sound/usb/pcm.c | 2 +- > > >> 1 file changed, 1 insertion(+), 1 deletion(-) > > >> > > >> diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > > >> index 6a460225f2e3..37ee6df8b15a 100644 > > >> --- a/sound/usb/pcm.c > > >> +++ b/sound/usb/pcm.c > > >> @@ -659,7 +659,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > > >> #define hwc_debug(fmt, args...) do { } while(0) > > >> #endif > > >> > > >> -#define MAX_BUFFER_BYTES (1024 * 1024) > > >> +#define MAX_BUFFER_BYTES (4 * 1024 * 1024) > > >> #define MAX_PERIOD_BYTES (512 * 1024) > > >> > > >> static const struct snd_pcm_hardware snd_usb_hardware = > > >> -- > > >> 2.31.1 > > >> > > > > > > -- > > Jaroslav Kysela <perex@perex.cz> > > Linux Sound Maintainer; ALSA Project; Red Hat, Inc. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Increase max buffer size 2022-04-09 20:43 ` Jaroslav Kysela 2022-04-09 21:11 ` Geraldo Nascimento @ 2022-04-10 7:40 ` Takashi Iwai 1 sibling, 0 replies; 7+ messages in thread From: Takashi Iwai @ 2022-04-10 7:40 UTC (permalink / raw) To: Jaroslav Kysela; +Cc: alsa-devel, Geraldo Nascimento On Sat, 09 Apr 2022 22:43:13 +0200, Jaroslav Kysela wrote: > > On 09. 04. 22 22:36, Geraldo Nascimento wrote: > > On Thu, Apr 07, 2022 at 11:27:40PM +0200, Takashi Iwai wrote: > >> The current limit of max buffer size 1MB seems too small for modern > >> devices with lots of channels and high sample rates. > >> Let's make bigger, 4MB. > > > > Hi Takashi, > > > > I did some math and 4MB is still too little for some extreme hardware > > like the Behringer Wing, which is USB 2.0 by the way. According to my > > calculations, at 192 KHz and 48 channels, even with this 4MB patch, we > > would still have only 151.7 ms of buffer for the Wing. > > > > Therefore my suggestion is to expose the MAX_BUFFER_BYTES as Kconf. > > > > Do you think this is plausible? > > I think that much better behaviour may be to calculate and limit the > max buffer size at runtime depending on the max channels / rate / > sample bits obtained from the USB descriptors by default. For standard > hardware, those big buffers do not make much sense and there's usually > a mix of the USB sound hardware in the system. IMO, one good way would be to leave buffer and period bytes max unlimited, while limiting buffer and period max time instead. It should cover all combinations. But involving the buffer/period time may have some alignment issue with bytes and frame sizes, so we need to check whether it works reliably (although I believe it'd work in that case). My concern by removing the limit is, however, the behavior change in certain applications. It can't be known until we really hit the issue, though. Let's see. thanks, Takashi ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-10 7:41 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-07 21:27 [PATCH] ALSA: usb-audio: Increase max buffer size Takashi Iwai 2022-04-08 7:15 ` Jaroslav Kysela 2022-04-09 20:36 ` Geraldo Nascimento 2022-04-09 20:43 ` Jaroslav Kysela 2022-04-09 21:11 ` Geraldo Nascimento 2022-04-09 22:24 ` Geraldo Nascimento 2022-04-10 7:40 ` Takashi Iwai
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.