Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp581331pxa; Wed, 12 Aug 2020 08:55:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn8SLwWGNJAIwcpweGlN8jlS09Yxs8ZmXPDmkncSsGcHKpyb8jiB8lPYqSaqt2nxF1iJY9 X-Received: by 2002:a17:906:54d3:: with SMTP id c19mr471772ejp.408.1597247737137; Wed, 12 Aug 2020 08:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597247737; cv=none; d=google.com; s=arc-20160816; b=OcYB6ddFSPs83lFUnzvvjr0GgeJ5Mr7kVIUbsxLwQBttON7ZO+R7rdRCtCPX1N9leC G5mndp5k7TbzlYueBUe4RbbT+HTm15xIKTLKj01N+n0c/za3NicoBk+M/fZ9WgeF1eHz Tq8yy2OwTnU9EklLdqtx5EGiuxtk/FK3o4bCkVZFYtC1G+W6aZ+wVENQYlj0ViEQ+K2+ l6zOC2KiwnKcq5ol2YRfEMeiSzklv9EfIdcePnc8JBWyvK6JAxCnqWSTESZiikwmaCL6 8gYmrow0wqHjJ5tCDKy5Mi++OY3jpyUKbSG8TTygmUXAVhjfQ7brrvMuobYrdAtoDSsY A7sg== 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=+Sk0UWRQIa1YxdVyi0nn4gko8z4wSYI3grr4NUTtr24=; b=Axo/VtFGmaf6M2p4o6XidtGetUO83ccGMRXtjFpOYhYxJqpLglmdx3SzbJ5E6yRcS2 2ca/5kWCh0dVoGZvYnB3q/KWiq82hIAa7aTd/7aiY30Hfvl73yJCi3RidLlM/yT6mpyI QNrMViKTQ3KSFyA4Hey9UCMh15pl5vJ9GjqD9VdWlcq9w8tkQ8tTV+XhLzUhY8+VbnT8 VeR4gI9XoIYxj5AuN1/CRanSQZy2IY/BVrz/hQqopXz64jtkEDVv+DQRhXrZ1/dVhVVL VeF7eTcGWciOUeiXHfIji2pvptKqf7q//ZVimDgocRBWwWHZwsp8w79lFJ/WqFx8dbhw Yatw== 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 k14si1465793ejs.381.2020.08.12.08.55.13; Wed, 12 Aug 2020 08:55:37 -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 S1726510AbgHLPyf (ORCPT + 99 others); Wed, 12 Aug 2020 11:54:35 -0400 Received: from mga12.intel.com ([192.55.52.136]:27744 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgHLPyf (ORCPT ); Wed, 12 Aug 2020 11:54:35 -0400 IronPort-SDR: s766kbruvfluyUyEvHqBd29GZGOFQXidBcKskApaRfTNX4faI0OodZ2kf/x4CMbpanKVS2B23t tDBxzLpUeujQ== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="133520495" X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="133520495" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 08:54:34 -0700 IronPort-SDR: D+QUvdwEtf6cbV7gegrOvx5tQQPff11Wy+K1Y4rvg6YYj12jUsZTn8OHPKa04ZNRcXPIwXXcD7 qT6i8sXoF05g== X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="495553516" Received: from mbharapa-mobl.amr.corp.intel.com (HELO [10.212.31.62]) ([10.212.31.62]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 08:54:31 -0700 Subject: Re: [PATCH v3 2/2] ASoC: Intel: Add period size constraint on strago board To: Takashi Iwai 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 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 10:54:30 -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 On 8/12/20 9:55 AM, Takashi Iwai wrote: > 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? Yes indeed with the existing driver: root@chrx:~# aplay -Dhw:0,0 --period-size=256 --buffer-size=512 /dev/zero -d 2 -f dat --test-position Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo underrun!!! (at least 0.312 ms long) underrun!!! (at least 0.326 ms long) 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 = 2080, buffer = 512 Suspicious buffer position (4 total): avail = 0, delay = 2080, buffer = 512 Suspicious buffer position (5 total): avail = 0, delay = 2096, buffer = 512 Suspicious buffer position (6 total): avail = 0, delay = 2096, buffer = 512 but the new constraint to force a 1ms step added in the patch1 should preclude this from happening. >> 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] yes, that's 852 periods and 4.260 seconds. Never seen such values :-)