Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2381931ybi; Mon, 17 Jun 2019 03:59:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUJpGSxWcLNxtrGYjmmpwfhXHXRrEjeRYo1Tmk4JpAlKb6DNpcreTRNqzcOia0pC876GY8 X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr25976375pjb.115.1560769151925; Mon, 17 Jun 2019 03:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560769151; cv=none; d=google.com; s=arc-20160816; b=FLOm9nXSJfeVYmVx4c7tho4LH3+U0DY3MUbusr1hNujKX/T1rCetBJ16eJFucRgtJA ZFVFtufgNF8rgv/xI/QAm/LsO5OWClfM41ISpb40LWe4KETzSOjt1nCYNhu7MNp3wJna ZJhePOak3YMWpEw+hH8DkyVi2EVBwJXvrdCosQz5VQL2ixN3l7oU9g+r21vdrMWL4f3y dgJAXSyTm/P/Jezo8C4lHPMKG3s1Oglv3u4dAb+Yw5pPyUo/3m+2ByAhbj+GwbQTsfsP lpw5aRvAZPBxrVMukJjM5Tzpz8OndAzBz4V8pUm0gJKCEFW5TmEGFmzifvg7KcnlSmAs v3vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ezUnyuKGHlbPhYjLZf5Spom5VDavEjqfyB+JBE4bVJU=; b=iL0ozu0+ptnwNpwUQUHMpuB8BeI9Z/ev/evveSyVtLPpMx8MuBMBvVOvizRE2f+CMq OCHAWcvw0onZbhq7uvP8W52GBDkUaQx8uhl+HTH9jEY7+i29IpsZNxWF8yhycFNaSlym YnmPF6cfMYFZJdHghN4kiNN5ZCnw0pYSoYNyMDx2IGaTbEcugQlFu/5vuWAmlGqDXiEx FE28a8FpOyxvLxXWDB2b9tFZgvOliSAmQoIeXwYuKJiexrg9NcaQ7xU4QvpZEZBbC1JK loYjENoySklAzGyvrdcWfP06pOSd6Yu7nSQPo/TqWirUlwWQqu7PL0nZ1aHoboBbY/Dc 1MAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=gWIH3E3+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si9430213pjp.56.2019.06.17.03.58.56; Mon, 17 Jun 2019 03:59:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=gWIH3E3+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727605AbfFQK52 (ORCPT + 99 others); Mon, 17 Jun 2019 06:57:28 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:7206 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbfFQK52 (ORCPT ); Mon, 17 Jun 2019 06:57:28 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 17 Jun 2019 03:57:25 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 17 Jun 2019 03:57:25 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 17 Jun 2019 03:57:25 -0700 Received: from [10.21.132.148] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 17 Jun 2019 10:57:23 +0000 Subject: Re: [PATCH v1] dmaengine: tegra-apb: Support per-burst residue granularity To: Dmitry Osipenko , Laxman Dewangan , Vinod Koul , Thierry Reding , Ben Dooks CC: , , References: <20190613210849.10382-1-digetx@gmail.com> <5fbe4374-cc9a-8212-017e-05f4dee64443@nvidia.com> <7ab96aa5-0be2-dc01-d187-eb718093eb99@nvidia.com> <840fcf60-8e24-ff44-a816-ef63a5f18652@gmail.com> From: Jon Hunter Message-ID: Date: Mon, 17 Jun 2019 11:57:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <840fcf60-8e24-ff44-a816-ef63a5f18652@gmail.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL106.nvidia.com (172.18.146.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1560769045; bh=ezUnyuKGHlbPhYjLZf5Spom5VDavEjqfyB+JBE4bVJU=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=gWIH3E3+v+rzCFyiimf1UtBRbcTKw21IjQoX8qYax0Wf6gBrBTLcmUWsqLkh6/UFy XnEHI+bHpHAWxiEQNNpyC3s8qwK0gRHLZUsw+p43zIRlE5esrVIhmBEHrK6ha5IEO5 SwoCWHmt1WDwQGta6Gn11HgPQMDQbwSlDy2VKK0qBuoQU7JZVGPR3iOa1BbQc2Emml RagrWT3XGNyE3x6cgN4POnafe8qguNKYs1BkRdtZ44LxUr5t2jWlFmsegBnDB3SiVF rqyarHsvzvafNb0sOCafZNxoGJVRvFVbaC9NGqQxAlQVVcID3JLhI4YES9cU6AJn8v orsF7W/+m6vuw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/06/2019 17:44, Dmitry Osipenko wrote: > 14.06.2019 18:24, Jon Hunter =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> >> On 14/06/2019 16:21, Jon Hunter wrote: >>> >>> On 13/06/2019 22:08, Dmitry Osipenko wrote: >>>> Tegra's APB DMA engine updates words counter after each transferred bu= rst >>>> of data, hence it can report transfer's residual with more fidelity wh= ich >>>> may be required in cases like audio playback. In particular this fixes >>>> audio stuttering during playback in a chromiuim web browser. The patch= is >>>> based on the original work that was made by Ben Dooks [1]. It was test= ed >>>> on Tegra20 and Tegra30 devices. >>>> >>>> [1] https://lore.kernel.org/lkml/20190424162348.23692-1-ben.dooks@code= think.co.uk/ >>>> >>>> Inspired-by: Ben Dooks >>>> Signed-off-by: Dmitry Osipenko >>>> --- >>>> drivers/dma/tegra20-apb-dma.c | 35 ++++++++++++++++++++++++++++------= - >>>> 1 file changed, 28 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-d= ma.c >>>> index 79e9593815f1..c5af8f703548 100644 >>>> --- a/drivers/dma/tegra20-apb-dma.c >>>> +++ b/drivers/dma/tegra20-apb-dma.c >>>> @@ -797,12 +797,36 @@ static int tegra_dma_terminate_all(struct dma_ch= an *dc) >>>> return 0; >>>> } >>>> =20 >>>> +static unsigned int tegra_dma_update_residual(struct tegra_dma_channe= l *tdc, >>>> + struct tegra_dma_sg_req *sg_req, >>>> + struct tegra_dma_desc *dma_desc, >>>> + unsigned int residual) >>>> +{ >>>> + unsigned long status, wcount =3D 0; >>>> + >>>> + if (!list_is_first(&sg_req->node, &tdc->pending_sg_req)) >>>> + return residual; >>>> + >>>> + if (tdc->tdma->chip_data->support_separate_wcount_reg) >>>> + wcount =3D tdc_read(tdc, TEGRA_APBDMA_CHAN_WORD_TRANSFER); >>>> + >>>> + status =3D tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS); >>>> + >>>> + if (!tdc->tdma->chip_data->support_separate_wcount_reg) >>>> + wcount =3D status; >>>> + >>>> + if (status & TEGRA_APBDMA_STATUS_ISE_EOC) >>>> + return residual - sg_req->req_len; >>>> + >>>> + return residual - get_current_xferred_count(tdc, sg_req, wcount); >>>> +} >>>> + >>>> static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, >>>> dma_cookie_t cookie, struct dma_tx_state *txstate) >>>> { >>>> struct tegra_dma_channel *tdc =3D to_tegra_dma_chan(dc); >>>> + struct tegra_dma_sg_req *sg_req =3D NULL; >>>> struct tegra_dma_desc *dma_desc; >>>> - struct tegra_dma_sg_req *sg_req; >>>> enum dma_status ret; >>>> unsigned long flags; >>>> unsigned int residual; >>>> @@ -838,6 +862,8 @@ static enum dma_status tegra_dma_tx_status(struct = dma_chan *dc, >>>> residual =3D dma_desc->bytes_requested - >>>> (dma_desc->bytes_transferred % >>>> dma_desc->bytes_requested); >>>> + residual =3D tegra_dma_update_residual(tdc, sg_req, dma_desc, >>>> + residual); >>> >>> I had a quick look at this, I am not sure that we want to call >>> tegra_dma_update_residual() here for cases where the dma_desc is on the >>> free_dma_desc list. In fact, couldn't this be simplified a bit for case >>> where the dma_desc is on the free list? In that case I believe that the >>> residual should always be 0. >> >> Actually, no, it could be non-zero in the case the transfer is aborted. >=20 > Looks like everything should be fine as-is. I am still not sure we want to call this for the case where dma_desc is on the free list. > BTW, it's a bit hard to believe that there is any real benefit from the > free_dma_desc list at all, maybe worth to just remove it? I think you need to elaborate a bit more here. I am not a massive fan of this driver, but I am also not in the mood for changing unless there is a good reason. Cheers Jon --=20 nvpublic