From patchwork Thu Sep 3 03:20:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koro Chen X-Patchwork-Id: 7114641 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B50E4BEEC1 for ; Thu, 3 Sep 2015 03:22:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB4C420717 for ; Thu, 3 Sep 2015 03:22:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D988C20712 for ; Thu, 3 Sep 2015 03:22:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXL6O-0007z4-3X; Thu, 03 Sep 2015 03:22:16 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXL6K-0007wS-CO for linux-mediatek@lists.infradead.org; Thu, 03 Sep 2015 03:22:14 +0000 X-Listener-Flag: 11101 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1725645889; Thu, 03 Sep 2015 11:21:28 +0800 Received: from mtkslt301 (10.21.14.114) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Thu, 3 Sep 2015 11:21:27 +0800 Received: by mtkslt301 (Postfix, from userid 11333) id 4A7BF183AC6; Thu, 3 Sep 2015 11:21:27 +0800 (CST) From: Koro Chen To: , , Subject: [RFC PATCH (alsa-lib)] pcm: Modify check condition in snd_pcm_sw_params_set_avail_min Date: Thu, 3 Sep 2015 11:20:54 +0800 Message-ID: <1441250454-38271-1-git-send-email-koro.chen@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150902_202212_656022_C06574A8 X-CRM114-Status: GOOD ( 12.48 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, linux-mediatek@lists.infradead.org, Koro Chen , srv_heupstream@mediatek.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we use a ping-ping buffer in capture, and if hw_ptr reported at IRQ is a little smaller than period_size: |xxxxxxxxxxxxxxxxxxxxxxxxxxxx--|-----------------------------| hw_ptr < period_size This available buffer will not be read since its size is smaller than avail_min (which is set to be period_size), and read thread continues to sleep. If the next hw_ptr is just a little larger than buffer_size, overrun occurs. This could be resolved by setting a small avail_min to kernel, for example, 1, so read thread wakes up and reads every data at IRQ. But current alsa-lib only allows avail_min to be at least period_size. Remove the constraint and only check for zero case. Signed-off-by: Koro Chen --- src/pcm/pcm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index f5fc728..8492689 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -5958,12 +5958,8 @@ int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, #endif { assert(pcm && params); - /* Fix avail_min if it's below period size. The period_size - * defines the minimal wake-up timing accuracy, so it doesn't - * make sense to set below that. - */ - if (val < pcm->period_size) - val = pcm->period_size; + if (!val) + val = 1; params->avail_min = val; return 0; }