Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp257382pxa; Wed, 12 Aug 2020 00:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw18Hr4DfZ5z5o785J2yrpjooShxZZjMncF4qVL8SQnoi52J+2VTFDIRhJKY/FPhC6TGBtH X-Received: by 2002:a17:907:10db:: with SMTP id rv27mr974053ejb.350.1597218489000; Wed, 12 Aug 2020 00:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597218488; cv=none; d=google.com; s=arc-20160816; b=ExiWAQLbg3DOj1YGMLz+hs7aSHtOmay0nUdy8iDD1NFHoa39wJWQ8MgZda82jHZZN0 jP6o6LT8alr0qpYxtnhWgB+uRfWl5IX7fkqqcp2oegoRgoJyzr2+6uxIUsZOR2/2abAB sxduM6d9e70RJGoKVwhxcPFN0eEqfICqkjCpaWHKP7yqhSPMTiQa+AsqABVN4t1+u93r rmOy73OQfne+dx/eDx9IFrBTE6+Z7HTOxYcNNSL0smischnjJIEgsIVkeXo4fg9ecXgz 81ooDzc7Uaky2Uvui9GHMia1aD1aRGnlVJzyOunU+cGsojkSvjG3ehDwSN2GfdNLID66 Eeeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date; bh=A823J1n+rD1SiVwzIsc/v6zSRijHJbCQK/HnbSZ+vxs=; b=zUZYw/Hr59w5zY8j43O6YOPiCpoM2iJeo//h+TTTftCaQAjcw3UbwIpTZzY94nmT6K bTZ2CfV8Hbve/tHNP7maU+t8VgD8sfBsyxHn8b1nbWPR5g7ZdHRxNhWaL8XV1cmodjku sWBXqmpXwHqNp0PgtOs6G+vCud3EzbcM6UZZyZbgyPpbGZl5PpCvXid98ZhjtJZ7AcM0 26Ko6SpNRqtQJxvQn41WrICkD4hn4ncoXr/n8afkt6370o8lADoL6zw3GAAeUH8JD5/c 2Z/O7hVt+2nMuo/fa9t57AKEcxQfVW8noavPaigAuWDz1EbfGKjnuVuBujfH8XgUTy5b y1cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si688702ejc.49.2020.08.12.00.47.46; Wed, 12 Aug 2020 00:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbgHLHrN (ORCPT + 99 others); Wed, 12 Aug 2020 03:47:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:45850 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgHLHrM (ORCPT ); Wed, 12 Aug 2020 03:47:12 -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 6D6D7AEA8; Wed, 12 Aug 2020 07:47:32 +0000 (UTC) Date: Wed, 12 Aug 2020 09:47:10 +0200 Message-ID: From: Takashi Iwai To: Yu-Hsuan Hsu Cc: Mark Brown , Pierre-Louis Bossart , Guennadi Liakhovetski , "alsa-devel@alsa-project.org" , Kai Vehmanen , Kuninori Morimoto , "Rojewski, Cezary" , Takashi Iwai , Jie Yang , "linux-kernel@vger.kernel.org" , Liam Girdwood , Sam McNally , "yuhsuan@google.com" , Ranjani Sridharan , Daniel Stuart , Andy Shevchenko , "Lu, Brent" , 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> 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 Wed, 12 Aug 2020 09:43:22 +0200, Yu-Hsuan Hsu wrote: > > Takashi Iwai 於 2020年8月12日 週三 下午2:58寫道: > > > > On Wed, 12 Aug 2020 08:53:42 +0200, > > Yu-Hsuan Hsu wrote: > > > > > > Takashi Iwai 於 2020年8月12日 週三 下午2:14寫道: > > > > > > > > On Wed, 12 Aug 2020 05:09:58 +0200, > > > > Yu-Hsuan Hsu wrote: > > > > > > > > > > Mark Brown 於 2020年8月12日 週三 上午1:22寫道: > > > > > > > > > > > > On Tue, Aug 11, 2020 at 11:54:38AM -0500, Pierre-Louis Bossart wrote: > > > > > > > > > > > > > > constraint logic needs to know about this DSP limitation - it seems like > > > > > > > > none of this is going to change without something new going into the > > > > > > > > mix? We at least need a new question to ask about the DSP firmware I > > > > > > > > think. > > > > > > > > > > > > > I just tested aplay -Dhw: on a Cyan Chromebook with the Ubuntu kernel 5.4, > > > > > > > and I see no issues with the 240 sample period. Same with 432, 960, 9600, > > > > > > > etc. > > > > > > > > > > > > > I also tried just for fun what happens with 256 samples, and I don't see any > > > > > > > underflows thrown either, so I am wondering what exactly the problem is? > > > > > > > Something's not adding up. I would definitively favor multiple of 1ms > > > > > > > periods, since it's the only case that was productized, but there's got to > > > > > > > me something a side effect of how CRAS programs the hw_params. > > > > > > > > > > > > Is it something that goes wrong with longer playbacks possibly (eg, > > > > > > someone watching a feature film or something)? > > > > > > > > > > Thanks for testing! > > > > > > > > > > After doing some experiments, I think I can identify the problem more precisely. > > > > > 1. aplay can not reproduce this issue because it writes samples > > > > > immediately when there are some space in the buffer. However, you can > > > > > add --test-position to see how the delay grows with period size 256. > > > > > > aplay -Dhw:1,0 --period-size=256 --buffer-size=480 /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 = 2064, buffer = 512 > > > > > Suspicious buffer position (2 total): avail = 0, delay = 2064, buffer = 512 > > > > > Suspicious buffer position (3 total): avail = 0, delay = 2096, buffer = 512 > > > > > ... > > > > > > > > Isn't this about the alignment of the buffer size against the period > > > > size, not the period size itself? i.e. in the example above, the > > > > buffer size isn't a multiple of period size, and DSP can't handle if > > > > the position overlaps the buffer size in a half way. > > > > > > > > If that's the problem (and it's an oft-seen restriction), the right > > > > constraint is > > > > snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); > > > > > > > > > > > > Takashi > > > Oh sorry for my typo. The issue happens no matter what buffer size is > > > set. Actually, even if I want to set 480, it will change to 512 > > > automatically. > > > Suspicious buffer position (1 total): avail = 0, delay = 2064, buffer > > > = 512 <-this one is the buffer size > > > > OK, then it means that the buffer size alignment is already in place. > > > > And this large delay won't happen if you use period size 240? > > > > > > Takashi > Yes! If I set the period size to 240, it will not print "Suspicious > buffer position ..." So it sounds like DSP handles the delay report incorrectly. Then it comes to another question: the driver supports both SOF and SST. Is there the behavior difference between both DSPs wrt this delay issue? Takashi > > Yu-Hsuan > > > > > > > > 2. Since many samples are moved to DSP(delay), the measured rate of > > > > > the ring-buffer is high. (I measured it by alsa_conformance_test, > > > > > which only test the sampling rate in the ring buffer of kernel not > > > > > DSP) > > > > > > > > > > 3. Since CRAS writes samples with a fixed frequency, this behavior > > > > > will take all samples from the ring buffer, which is seen as underrun > > > > > by CRAS. (It seems that it is not a real underrun because that avail > > > > > does not larger than buffer size. Maybe CRAS should also take dalay > > > > > into account.) > > > > > > > > > > 4. In spite of it is not a real underrun, the large delay is still a > > > > > big problem. Can we apply the constraint to fix it? Or any better > > > > > idea? > > > > > > > > > > Thanks, > > > > > Yu-Hsuan > > > > > > > > >