Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp529386pxa; Wed, 12 Aug 2020 07:56:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaTX/QKgxzW26BxlDoRkqqOcd/4bB8vAUW+LhcHMZ0SzhF3jyhkidpBpkuZ24x6Dva3p8M X-Received: by 2002:aa7:c259:: with SMTP id y25mr302654edo.130.1597244217502; Wed, 12 Aug 2020 07:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597244217; cv=none; d=google.com; s=arc-20160816; b=XGNg1RnGSWWrFkzskUrz4wTvdQzwFEtqY2wrWD2vHUB/MIQcSrUGz+aNH1Rc1Ee0J1 X0WWbzbI9a5uMAUFA+wPR0AJvmH40zg3LpBUnf4/hGrpunsOn91oXS/7kzVPGIjTBgpP 46Wksvz0DW04gyhaPCdrCluC1OK3+nFuQjpAApNn1ukRtQux+OCNA898Tj2MhjJOhOHF 3hLxfCJ+KA6VX+hM7a5eW9Ec2LF3rYu9JFnj8iePuovtRTOUeUNx5OvOFJciehSKClSW 9Ia3Ea9qLzkItP7BKH2Gv3s9w4ECnH5D/ZEpdLI1KQnntmXMDCONeHYqxJAdP9duP89t MTGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=9nV8Ldg0E2xLTwUVUrFwcEQtrF2B80Abn1dnHz6lPjQ=; b=z2RgjKxWfzoP+ilkPImpb8QK1QLjjLkDvWw4rhQ1zQCbnANoT0ZVbxeBKBU3n5yDsJ BoSiZ2hrtc3vcDcyVZHpnA363aSvk43ClAtThJS1eCq+WowKEtoDBv8imJ3WXBHE0PFp TznG5alizSR7lP2HPZV2m41WNEbe914r/E5FAJxmu6etNlMBUR300KdIUI3UF+KkPh5R eFiwIspzZozDXdtfZS4cirrNSI3Ez7qrnhezm4qsm34uP0PaVfwq2hPoRc5t/1UeMwcX VK8bide6zZ+6jDChkWB1f7whkPLW0m9yZpLM9sCXEeggqa1rSDUq4l2C84nb2Ab2fJR7 ecKQ== 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 f25si1302162eje.338.2020.08.12.07.56.33; Wed, 12 Aug 2020 07:56:57 -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 S1726515AbgHLOzc (ORCPT + 99 others); Wed, 12 Aug 2020 10:55:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:36678 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgHLOzb (ORCPT ); Wed, 12 Aug 2020 10:55:31 -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 2CD5CAC1C; Wed, 12 Aug 2020 14:55:51 +0000 (UTC) Date: Wed, 12 Aug 2020 16:55:29 +0200 Message-ID: From: Takashi Iwai To: Pierre-Louis Bossart Cc: Yu-Hsuan Hsu , 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" , "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=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Aug 2020 16:46:40 +0200, Pierre-Louis Bossart wrote: > > > >>>>>> 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? > > I still don't get what the issue is. The two following cases work fine > with the SST/Atom driver: > > root@chrx:~# aplay -Dhw:0,0 --period-size=240 --buffer-size=480 > /dev/zero -d 2 -f dat --test-position > Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 > Hz, Stereo > root@chrx:~# aplay -Dhw:0,0 --period-size=960 --buffer-size=4800 > /dev/zero -d 2 -f dat --test-position > Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 > Hz, Stereo What if with --period-size=256 --buffer-size=512 and --test-position? Can you reproduce the problem in your side? > The existing code has this: > > /* Make sure, that the period size is always even */ > snd_pcm_hw_constraint_step(substream->runtime, 0, > SNDRV_PCM_HW_PARAM_PERIODS, 2); > > return snd_pcm_hw_constraint_integer(runtime, > SNDRV_PCM_HW_PARAM_PERIODS); > > and with the addition of period size being a multiple of 1ms all > requirements should be met? I also wonder what's really missing, too :) BTW, I took a look back at the thread, and CRAS seems using a very large buffer, namely: [ 52.434791] sound pcmC1D0p: PERIOD_SIZE [240:240] [ 52.434802] sound pcmC1D0p: BUFFER_SIZE [204480:204480] Takashi