From: Takashi Iwai Subject: Re: [PATCH] ALSA: snd-aloop: make preallocated buffer size configurable Date: Wed, 21 Sep 2011 16:38:45 +0200 Message-ID: References: <1316545332-2229-1-git-send-email-pierre-louis.bossart@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id F325B2452C for ; Wed, 21 Sep 2011 16:38:48 +0200 (CEST) In-Reply-To: <000901cc7862$115987b0$340c9710$@bossart@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Wed, 21 Sep 2011 08:26:27 -0500, Pierre-Louis Bossart wrote: > > > > Default of 2MB of physically-contiguous memory can be > > > too high for embedded solutions, make the size configurable. > > > > Hm, maybe better to have an option for global limit of preallocation? > > The problem is not necessarily specific to snd-aloop. > > Not sure I understand the comment. This code is essentially the same as the > configuration option for HDAudio, and the parameter value defines the amount > of preallocated memory, with a limit to 32MB. I meant to have a kconfig option to limit the upper-bound of pre-alloc buffer sizes for all drivers. That is, a patch like below (untested) Takashi --- diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 475455c..525ed28 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -204,6 +204,15 @@ config SND_PCM_XRUN_DEBUG sound clicking when system is loaded, it may help to determine the process or driver which causes the scheduling gaps. +config SND_PCM_MAX_PREALLOC_SIZE + int "Maximum pre-allocated buffer size" + range 0 32768 + default 0 + depends on EMBEDDED + help + Specifies the default upper-limit of PCM pre-allocation + buffer sizes in kB. Zero means unlimited. + config SND_VMASTER bool diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 150cb7e..a09425c 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -270,6 +270,9 @@ int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, int type, struct device *data, size_t size, size_t max) { + if (CONFIG_SND_PCM_MAX_PREALLOC_SIZE && + max > CONFIG_PCM_SND_MAX_PREALLOC_SIZE * 1024) + max = CONFIG_SND_PCM_PREALLOC_SIZE * 1024; substream->dma_buffer.dev.type = type; substream->dma_buffer.dev.dev = data; return snd_pcm_lib_preallocate_pages1(substream, size, max);