From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A76CC433E1 for ; Thu, 13 Aug 2020 08:45:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E17D62078B for ; Thu, 13 Aug 2020 08:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726750AbgHMIpO (ORCPT ); Thu, 13 Aug 2020 04:45:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:37448 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbgHMIpO (ORCPT ); Thu, 13 Aug 2020 04:45:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 86D17B5EC; Thu, 13 Aug 2020 08:45:34 +0000 (UTC) Date: Thu, 13 Aug 2020 10:45:11 +0200 Message-ID: From: Takashi Iwai To: Yu-Hsuan Hsu Cc: "Lu, Brent" , Pierre-Louis Bossart , Guennadi Liakhovetski , "alsa-devel@alsa-project.org" , Andy Shevchenko , Kuninori Morimoto , Kai Vehmanen , "linux-kernel@vger.kernel.org" , "Rojewski, Cezary" , Jie Yang , Takashi Iwai , Liam Girdwood , Sam McNally , Mark Brown , Ranjani Sridharan , Daniel Stuart , "yuhsuan@google.com" , Damian van Soelen Subject: Re: [PATCH v3 2/2] ASoC: Intel: Add period size constraint on strago board In-Reply-To: References: <3f3baf5e-f73d-9cd6-cbfb-36746071e126@linux.intel.com> <20200811145353.GG6967@sirena.org.uk> <20200811172209.GM6967@sirena.org.uk> <0714b222-d3fc-5744-1147-bfac7df2651e@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Aug 2020 10:36:57 +0200, Yu-Hsuan Hsu wrote: > > Lu, Brent 於 2020年8月13日 週四 下午3:55寫道: > > > > > > > > > > > > CRAS calls snd_pcm_hw_params_set_buffer_size_max() to use as large > > > > > buffer as possible. So the period size is an arbitrary number in > > > > > different platforms. Atom SST platform happens to be 256, and CML > > > > > SOF platform is 1056 for example. > > > > > > > > ok, but earlier in this thread it was mentioned that values such as > > > > 432 are not suitable. the statement above seems to mean the period > > > > actual value is a "don't care", so I don't quite see why this specific > > > > patch2 restricting the value to 240 is necessary. Patch1 is needed for > > > > sure, > > > > Patch2 is where Takashi and I are not convinced. > > > > > > I have downloaded the patch1 but it does not work. After applying patch1, > > > the default period size changes to 320. However, it also has the same issue > > > with period size 320. (It can be verified by aplay.) > > > > The period_size is related to the audio latency so it's decided by application > > according to the use case it's running. That's why there are concerns about > > patch 2 and also you cannot find similar constraints in other machine driver. > You're right. However, the problem here is the provided period size > does not work. Like 256, setting the period size to 320 also makes > users have big latency in the DSP ring buffer. > > localhost ~ # aplay -Dhw:1,0 --period-size=320 --buffer-size=640 > /dev/zero -d 1 -f dat --test-position > Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 > Hz, Stereo > Suspicious buffer position (1 total): avail = 0, delay = 2640, buffer = 640 > Suspicious buffer position (2 total): avail = 0, delay = 2640, buffer = 640 > Suspicious buffer position (3 total): avail = 0, delay = 2720, buffer = 640 > ... It means that the delay value returned from the driver is bogus. I suppose it comes pcm_delay value calculated in sst_calc_tstamp(), but haven't followed the code closely yet. Maybe checking the debug outputs can help to trace what's going wrong. Takashi > > > > > Another problem is the buffer size. Too large buffer is not just wasting memories. > > It also creates problems to memory allocator since continuous pages are not > > always there. Using a small period_count like 2 or 4 should be sufficient for audio > > data transfer. > > > > buffer_size = period_size * period_count * 1000000 / sample_rate; > > snd_pcm_hw_params_set_buffer_time_near(mPcmDevice, params, &buffer_size, NULL); > > > > And one more problem here: you need to decide period_size and period_count > > first in order to calculate the buffer size... > It's a good point. I will bring it up to our team and see whether we > can use the smaller buffer size. Thanks! > > > > > > Regards, > > Brent > > Thanks, > Yu-Hsuan > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EB66C433DF for ; Thu, 13 Aug 2020 08:46:16 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1AAC32078B for ; Thu, 13 Aug 2020 08:46:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="sLn9fkpH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AAC32078B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9D21C84B; Thu, 13 Aug 2020 10:45:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9D21C84B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597308374; bh=6NTKIST8VusyD35KSv9RJ8cf8sxTpY8cqsSll9LzBXE=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sLn9fkpH1t5MZnegaXVDi4v5wbj6cZt+23veg6X3Di3HOkhQoT7CQNOqeJJFryGfA +EvKmPCwNRGUWWTnjlK+B+dWt+A0vQ8p1QKFWqL3peY3NHzVYmgSNjCi/EsT86kBbc ctqR/vcI5NKwoAUZtzMvSukVIpq9SJE7DakGdA6I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3E6D3F80100; Thu, 13 Aug 2020 10:45:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 532EFF800D3; Thu, 13 Aug 2020 10:45:23 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 794BCF800D3 for ; Thu, 13 Aug 2020 10:45:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 794BCF800D3 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 86D17B5EC; Thu, 13 Aug 2020 08:45:34 +0000 (UTC) Date: Thu, 13 Aug 2020 10:45:11 +0200 Message-ID: From: Takashi Iwai To: Yu-Hsuan Hsu Subject: Re: [PATCH v3 2/2] ASoC: Intel: Add period size constraint on strago board In-Reply-To: References: <3f3baf5e-f73d-9cd6-cbfb-36746071e126@linux.intel.com> <20200811145353.GG6967@sirena.org.uk> <20200811172209.GM6967@sirena.org.uk> <0714b222-d3fc-5744-1147-bfac7df2651e@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Guennadi Liakhovetski , "alsa-devel@alsa-project.org" , Kai Vehmanen , Kuninori Morimoto , "Rojewski, Cezary" , Takashi Iwai , Jie Yang , Pierre-Louis Bossart , "linux-kernel@vger.kernel.org" , Liam Girdwood , Sam McNally , Mark Brown , "yuhsuan@google.com" , Ranjani Sridharan , Daniel Stuart , Andy Shevchenko , "Lu, Brent" , Damian van Soelen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Thu, 13 Aug 2020 10:36:57 +0200, Yu-Hsuan Hsu wrote: > > Lu, Brent 於 2020年8月13日 週四 下午3:55寫道: > > > > > > > > > > > > CRAS calls snd_pcm_hw_params_set_buffer_size_max() to use as large > > > > > buffer as possible. So the period size is an arbitrary number in > > > > > different platforms. Atom SST platform happens to be 256, and CML > > > > > SOF platform is 1056 for example. > > > > > > > > ok, but earlier in this thread it was mentioned that values such as > > > > 432 are not suitable. the statement above seems to mean the period > > > > actual value is a "don't care", so I don't quite see why this specific > > > > patch2 restricting the value to 240 is necessary. Patch1 is needed for > > > > sure, > > > > Patch2 is where Takashi and I are not convinced. > > > > > > I have downloaded the patch1 but it does not work. After applying patch1, > > > the default period size changes to 320. However, it also has the same issue > > > with period size 320. (It can be verified by aplay.) > > > > The period_size is related to the audio latency so it's decided by application > > according to the use case it's running. That's why there are concerns about > > patch 2 and also you cannot find similar constraints in other machine driver. > You're right. However, the problem here is the provided period size > does not work. Like 256, setting the period size to 320 also makes > users have big latency in the DSP ring buffer. > > localhost ~ # aplay -Dhw:1,0 --period-size=320 --buffer-size=640 > /dev/zero -d 1 -f dat --test-position > Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 > Hz, Stereo > Suspicious buffer position (1 total): avail = 0, delay = 2640, buffer = 640 > Suspicious buffer position (2 total): avail = 0, delay = 2640, buffer = 640 > Suspicious buffer position (3 total): avail = 0, delay = 2720, buffer = 640 > ... It means that the delay value returned from the driver is bogus. I suppose it comes pcm_delay value calculated in sst_calc_tstamp(), but haven't followed the code closely yet. Maybe checking the debug outputs can help to trace what's going wrong. Takashi > > > > > Another problem is the buffer size. Too large buffer is not just wasting memories. > > It also creates problems to memory allocator since continuous pages are not > > always there. Using a small period_count like 2 or 4 should be sufficient for audio > > data transfer. > > > > buffer_size = period_size * period_count * 1000000 / sample_rate; > > snd_pcm_hw_params_set_buffer_time_near(mPcmDevice, params, &buffer_size, NULL); > > > > And one more problem here: you need to decide period_size and period_count > > first in order to calculate the buffer size... > It's a good point. I will bring it up to our team and see whether we > can use the smaller buffer size. Thanks! > > > > > > Regards, > > Brent > > Thanks, > Yu-Hsuan >