Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp524611pxa; Wed, 12 Aug 2020 07:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYZfy0pwubXGSgPKq0DhTlvz0dY/rE8OEWDCwh2y9/Fmt4Iqzn6OfluGAhfcHxZ92fMUvO X-Received: by 2002:a17:906:57cc:: with SMTP id u12mr154364ejr.422.1597243823189; Wed, 12 Aug 2020 07:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597243823; cv=none; d=google.com; s=arc-20160816; b=LT7LCdM1imsPOKPhRgxO8Ak3CueTUHXJxQQZrlivjsqpegWuyPF1DOSdkc2htb+A2m WzUCufm4E/aZqrCtBJexN8m5mqJ92tulFNRrk9EyiUInWgr0TZfzopAz5XQde9P18MWP hfws313WTJIEQDyuDlSAhsmqZY6UJaDWjppUN3UIBJ5UBQqhU1wHL4vSkgZZieduEhFE 71ZfDjPdY59dMhE1llUNPCWPAV6LKkaXTbf9E8IKdpbAZ+lhc9P+BJerqc0E+V0mJXoj OQnB+Y+N5t81w0uQlovIVFxw9E7kD9wbDhEsmM3uKbqOqCDB5pux20T/g6bEh1s3Li07 EPgQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=YPV/jIEH/AEZ0vW3hp8mKyJC7xzLeY5JS6Keh4u4WxM=; b=hoS1S3p1RuzKNoeiZw7H2XrXegoOnlk8IWTdeob5a0zsSsindcX3ppfr2IPO0GQ9Se scH94rmnpLvGxuOSvBBpk4+DDR8nhEH/cLdj3i4Uz/1RebhGHwYZKnauk0JN52aEOS5E rky6ZYU0JLnAVniZI54Z7I1BkfJW7y/SPFdoOdFWKQznf6XDmotEEY0t3B9EzCQ5sc9/ O1y8DJnAuVw5yaDL33NxsKVM8iP0j6Ym4/UC9TC51iE0OB6++XxTm+qTaQZFNd4sQFXd fgQMlQVD/MJ1mURDwBMiSQr4kBlWQp+NrxXpxzPNy8uwuCPghh2srot0wBITVKVo3jco LOBA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si1332188ejy.419.2020.08.12.07.49.59; Wed, 12 Aug 2020 07:50:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbgHLOqp (ORCPT + 99 others); Wed, 12 Aug 2020 10:46:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:44428 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbgHLOqp (ORCPT ); Wed, 12 Aug 2020 10:46:45 -0400 IronPort-SDR: TgRbw0C1BDKKoNjdba/I/l3aCUTBPALjXiVRUtaBZJwFIS19pbPznkQp7p0E1IODrDBlilwwD/ U+4V2jOZ7X+Q== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="141808420" X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="141808420" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 07:46:43 -0700 IronPort-SDR: o8Cq+YOgWp9qmw+FblQ9WE1g+XI0I+lCaQ85lcRakeBxWtHTZVHrRkPiUyBFVnvecIHwHDQV7P KVCXC9lOfGfw== X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="469844036" Received: from rkiran1x-mobl1.amr.corp.intel.com (HELO [10.212.203.28]) ([10.212.203.28]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 07:46:42 -0700 Subject: Re: [PATCH v3 2/2] ASoC: Intel: Add period size constraint on strago board To: Takashi Iwai , Yu-Hsuan Hsu Cc: 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 References: <3f3baf5e-f73d-9cd6-cbfb-36746071e126@linux.intel.com> <20200811145353.GG6967@sirena.org.uk> <20200811172209.GM6967@sirena.org.uk> From: Pierre-Louis Bossart Message-ID: Date: Wed, 12 Aug 2020 09:46:40 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>>>> 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 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?