From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH] ALSA - HDA - Add period time constraint to hda-intel Date: Tue, 24 May 2011 08:09:12 +0200 Message-ID: References: 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 mx1.suse.de (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 8AB2F103854 for ; Tue, 24 May 2011 08:09:14 +0200 (CEST) In-Reply-To: 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: Raymond Yau Cc: ALSA Development Mailing List List-Id: alsa-devel@alsa-project.org At Tue, 24 May 2011 12:15:05 +0800, Raymond Yau wrote: > > As there is a 10 seconds schedule_timeout in alsa-kernel > > The following error occur when aplay/arecord using a period time > longer than 10 seconds for for those hda codec which support rate > lower than 32000 when prealloc = 4096 > > ALSA hda_intel.c:1680: azx_pcm_prepare: bufsize=0x1aeb00, format=0x4111 > ... > ALSA pcm_native.c:1531: playback drain error (DMA or IRQ trouble?) Wouldn't it be better to fix the PCM timeout itself? Does the patch below work? thanks, Takashi --- diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index abfeff16..a754722 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1756,8 +1756,16 @@ static int wait_for_avail(struct snd_pcm_substream *substream, wait_queue_t wait; int err = 0; snd_pcm_uframes_t avail = 0; + long wait_time = 10; /* 10 seconds timeout as default */ long tout; + if (runtime->rate) { + long t = (runtime->period_size * 2 + runtime->rate - 1) / + runtime->rate; + wait_time = max(t, wait_time); + } + wait_time = msecs_to_jiffies(wait_time * 1000); + init_waitqueue_entry(&wait, current); add_wait_queue(&runtime->tsleep, &wait); for (;;) { @@ -1767,7 +1775,7 @@ static int wait_for_avail(struct snd_pcm_substream *substream, } set_current_state(TASK_INTERRUPTIBLE); snd_pcm_stream_unlock_irq(substream); - tout = schedule_timeout(msecs_to_jiffies(10000)); + tout = schedule_timeout(wait_time); snd_pcm_stream_lock_irq(substream); switch (runtime->status->state) { case SNDRV_PCM_STATE_SUSPENDED: