Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp475228ybg; Tue, 28 Jul 2020 10:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtmRXGxcbst6FtaqPIfmhfAOY3YkfTC3SPNtL3logee3YNbxCWQ2ztpxLUbLm0cdxOsVEh X-Received: by 2002:a17:907:405e:: with SMTP id ns22mr25838235ejb.6.1595957549798; Tue, 28 Jul 2020 10:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595957549; cv=none; d=google.com; s=arc-20160816; b=YmY8TjNaHZK3p6fz80K2qIIzyws0RWrDbms7c4syBuO/wyTTFCqL1TwO7F+GGStdmQ 3ZSQC9P24LIjjRGXSXPlIdtrSM4zElTC/N1Nwquf8rPKGLkacJyjl9ZvKy6QjtT6WEG6 yYKgr3zq9CdpIzhpcb7YjUHKPhY8B1QMwCw1bN2ECOq+sL+2kq2uKZoN56X9QVnxrE5C U5ok7Aou6/QYDnzWJuTSBRmvYpNS9P4+k4w3ljKp5cdmfrjdViJPpwp2Vh3OBrTHG9Kf x52OC1LLJkpRGGDjmXu20nStMbeT/v7raz9f6TLF1PgdBi90dmeWWP7mGfONs5Y0+4Y2 Sw9A== 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=WXNr/71v0WqxlRY5HaFljsTGc1BT4tLNOEY8fUfxDio=; b=W7SrdPXTVMMSCMIyQMGCc22Kss+io3UEnhjYWwYrf+otDaUz93mNPsTvt0+TdSXiLn 4Y6oAuLpGdOd3m+eBGBdkkCdLeRWQZtJuD9IXTb1cybyfz91bRgSPrvZU7znrXZFgQ48 +RZ+rDdgkj1sA1DUYmmaKKHY7f9qWdd6I+pPiu8zMPdbw2dzh5Fad+omaInjx75jBCD3 1lcMsUhxDnFdj+wD/ysXKB6HE1o75RlHMlsIFWI+w+2YRZFgRvfH+XLN2CCMCrQnjWLe VMtJS4KfvnifwI0H2uJnSKRggzZJBuDf4mx3Zo+fUWlWHWB5v3r0+4AMWOPCEX5BAdEf h5Mw== 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 d6si5952661ejp.151.2020.07.28.10.32.07; Tue, 28 Jul 2020 10:32:29 -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 S1732055AbgG1Rap (ORCPT + 99 others); Tue, 28 Jul 2020 13:30:45 -0400 Received: from mga01.intel.com ([192.55.52.88]:24865 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731988AbgG1Rap (ORCPT ); Tue, 28 Jul 2020 13:30:45 -0400 IronPort-SDR: RA2b/Jk8wjJJ3P243C7k7YuA6nK3cEDZ6uk3ivoNtn7upawLTc8zP54tCJSHjbcOT6a6Dfefuf hh768PereTdg== X-IronPort-AV: E=McAfee;i="6000,8403,9696"; a="169388602" X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="169388602" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2020 10:30:44 -0700 IronPort-SDR: DwxaHGXDLk42xrkK1saXPf7wGs4U/NCt5iDKo6m7GLtJjdB9RNEc15K7nKAZRrVJDCxtyzYJ2s pqqOuNDOlNKA== X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="312709438" Received: from bsabi-sp.amr.corp.intel.com (HELO [10.212.23.21]) ([10.212.23.21]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2020 10:30:43 -0700 Subject: Re: [PATCH] ASoC: Intel: Atom: use hardware counter to update hw_ptr To: "Lu, Brent" , "alsa-devel@alsa-project.org" Cc: "Rojewski, Cezary" , "linux-kernel@vger.kernel.org" , Jie Yang , Takashi Iwai , Liam Girdwood , Mark Brown References: <1595779727-31404-1-git-send-email-brent.lu@intel.com> <7dec7fcd-0381-d279-4dac-77c27ea5f6fe@linux.intel.com> <14fde5e9-a11a-077d-b533-1e6db4b7a262@linux.intel.com> From: Pierre-Louis Bossart Message-ID: <216b86eb-aec6-dab9-7901-9e0f2cc5af7f@linux.intel.com> Date: Tue, 28 Jul 2020 12:30:42 -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 7/28/20 12:02 PM, Lu, Brent wrote: >> >> So if there are already quirks in atom machine drivers to change the period >> size, why is this patch necessary? >> > > The story is: google implemented the constraint but doesn't know why it works > so asked us to explain. After checking the two counters I realized the increase of > ring buffer pointer follows the period size setting in hw_param (256) but the > period of interrupt is always 5ms instead of 5.33 so it's running little bit too fast. > It seems the LPE keeps tracking the difference of two counters. When the > difference exceeds 2160 samples, the next interrupt will be canceled so the > hardware counter could catch up a little. > > [ 43.208299] intel_sst_acpi 808622A8:00: mrfld ring_buffer_counter 107520 hardware_counter 98880 pcm delay 8640 (in bytes) > [ 43.208306] intel_sst_acpi 808622A8:00: buffer ptr 26880 pcm_delay rep: 2160 > [ 43.208321] sound pcmC1D0p: [Q] pos 26880 hw_ptr 26880 appl_ptr 40000 avail 191680 > => one interrupt is skipped. > [ 43.218299] intel_sst_acpi 808622A8:00: mrfld ring_buffer_counter 108544 hardware_counter 100800 pcm delay 7744 (in bytes) > [ 43.218307] intel_sst_acpi 808622A8:00: buffer ptr 27136 pcm_delay rep: 1936 > [ 43.218336] sound pcmC1D0p: [Q] pos 27136 hw_ptr 27136 appl_ptr 40000 avail 191936 > > So I think why not using the hardware counter? It increases 240 samples every 5ms > perfectly match the 48000 sample rate. The test result is good but I know there must > be a reason for the original designer to use ring buffer counter instead of hardware > counter. I uploaded this patch to see if anyone still remember the reason and share > some insight with me. > > I totally agree that we shouldn't touch this part of design. Do you think it make sense > to add a constraint to enforce the period size in machine driver? If yes then I would > upload patches for Chrome atom machines for google. I think it'd make sense to add this constraint, either in the machine driver or in the platform driver, so that we don't change the position updates and introduce more issues by accident by doing so. As you rightly said, I don't think anyone tested periods multiple of 256 samples so it's not a regression, more aligning with the internal design.