From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A8E2C31E4B for ; Fri, 14 Jun 2019 15:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D417B2133D for ; Fri, 14 Jun 2019 15:24:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="p8zwtPkK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725981AbfFNPY0 (ORCPT ); Fri, 14 Jun 2019 11:24:26 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:13227 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725923AbfFNPY0 (ORCPT ); Fri, 14 Jun 2019 11:24:26 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 14 Jun 2019 08:24:24 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 14 Jun 2019 08:24:23 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 14 Jun 2019 08:24:23 -0700 Received: from [10.26.11.12] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 14 Jun 2019 15:24:20 +0000 Subject: Re: [PATCH v1] dmaengine: tegra-apb: Support per-burst residue granularity From: Jon Hunter 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> Message-ID: <7ab96aa5-0be2-dc01-d187-eb718093eb99@nvidia.com> Date: Fri, 14 Jun 2019 16:24:18 +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: <5fbe4374-cc9a-8212-017e-05f4dee64443@nvidia.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL108.nvidia.com (172.18.146.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1560525864; bh=0mSBcKWqOYxnxNpld6CfaZzNunQ0sKFY9+OjRr2Ywtk=; h=X-PGP-Universal:Subject:From:To:CC:References:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=p8zwtPkKM1iChXZx4eQOBwQDgKZWerv8qawpNcGLhzLBCLih1NQVCNz+b8zsK0Hb9 6I3m4dtR/hqWTY+AY33YhhIXrOqeZOcpGSEq+IRaEC1bdKYv7QnPzEfjh95MjjIpKi +uVPlgpkQaKMAJ3o5+X9rz4lL3mnkWOrVuX6VNdbTdmui1TQPZ0W2K8BgygxEyxSmY zXWPAIfxWxEWrvuWJh7ieraEwrzCy5HbsjnnICCvtGqEoc9Y2sgR+EGo22uYN/jrk/ xai8p9VmnY29FaexIOgLsSjDL5mH5ZDOMr2e3g9fzii6UpM7e8aGAZPah7tY+G2v/C wIlUsAgZP1oHA== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org 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 burst >> of data, hence it can report transfer's residual with more fidelity which >> 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 tested >> on Tegra20 and Tegra30 devices. >> >> [1] https://lore.kernel.org/lkml/20190424162348.23692-1-ben.dooks@codethink.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-dma.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_chan *dc) >> return 0; >> } >> >> +static unsigned int tegra_dma_update_residual(struct tegra_dma_channel *tdc, >> + struct tegra_dma_sg_req *sg_req, >> + struct tegra_dma_desc *dma_desc, >> + unsigned int residual) >> +{ >> + unsigned long status, wcount = 0; >> + >> + if (!list_is_first(&sg_req->node, &tdc->pending_sg_req)) >> + return residual; >> + >> + if (tdc->tdma->chip_data->support_separate_wcount_reg) >> + wcount = tdc_read(tdc, TEGRA_APBDMA_CHAN_WORD_TRANSFER); >> + >> + status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS); >> + >> + if (!tdc->tdma->chip_data->support_separate_wcount_reg) >> + wcount = 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 = to_tegra_dma_chan(dc); >> + struct tegra_dma_sg_req *sg_req = 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 = dma_desc->bytes_requested - >> (dma_desc->bytes_transferred % >> dma_desc->bytes_requested); >> + residual = 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. Jon -- nvpublic