From patchwork Tue Jun 5 16:59:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10448663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D3A0860284 for ; Tue, 5 Jun 2018 17:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 935B629A0E for ; Tue, 5 Jun 2018 17:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 859BB29B17; Tue, 5 Jun 2018 17:01:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 297CD29A49 for ; Tue, 5 Jun 2018 17:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=EsvvrUbnjyLKb+uEwYv6628sBqS8Olvf4clHOFxIKwM=; b=de0 X3LHby2BGpwC98/0UW6eSGelpOoedPCJSQuU5TL2tyhoxV3Rrzh8qBRmyX93yFXcw3lkrpheqPBSE Gjg5NHdaCAt5waZuyDSkbn6NldlLai5IlY9TIU8fe4Mi9kM6C/2wMittDc/4iA7nVgwJ90E/ACAFL +Bl1bICAPrv3viriBwFbh81iybuD2Mqxmbny2bTFNYWBZtCwVrJ2xpiZedIpjckL209YkODZ1N9e+ lWVpUWgPALI+6pVJY1lEfFQSMDMs6u6lQfATNw0nirNpGJ+7xK6eQBC6vCyOHWVPuK7quZrJEqXDp dJp548OUlqoR2E+8rcsA7j8pI6nKwKw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQFK6-0004G6-2m; Tue, 05 Jun 2018 17:00:42 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQFJj-0002vU-P6 for linux-arm-kernel@lists.infradead.org; Tue, 05 Jun 2018 17:00:35 +0000 Received: by mail-lf0-x241.google.com with SMTP id g21-v6so2709624lfb.4 for ; Tue, 05 Jun 2018 10:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fOvUHB6ySJXePp08XRhJpgHzGzn+XhLjoBzkr1E+cVE=; b=WEVw0W7OjfRNAv9ji7Ybkw4XA3+Em1tzq1pe6vcxqnk4YU6TpYF8SAbxPaljDvLKps JMI/1BYs3PrLzpVQt3n09GGOq6fHR4fI3nacpv4PXTvnmokeWherxqevYNo7XBUqRpO1 vYwJETOH2DTfCm0sHK6PPek+QCJ/nBC+3bhx6v3txvu48Uv7aHuUUuTGATYSJhyd1ad/ BTLbQSei5LZxRIg2a6L9GBBZ8XqwS/CaCMb/KEMDe5RrBHabIlmdLwHaY8Lg3ZSnUN2I w6Geo92cmnv3nMAz6GL2G9i6y5RETdrakQZpBm+18aMqEGu5GxUMtXYwQjrz/+LiBL8s 3fxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fOvUHB6ySJXePp08XRhJpgHzGzn+XhLjoBzkr1E+cVE=; b=FkE+ewniUn7c/J4pFi6W5bk++Z5XmPQTSL+o23E1hUNwkKOWoXJMdsw4Vqnm1EZgO7 +52/WkzCnR9f93/lfpEfzPkhRPoP2gSMOL93YeYHWs5iA3sz5AC4Jocy1KqgT7OoTTJJ Pj/S94ewX7ZO+p+6xB1xUHbnP5FXF0HhRm5w6j0cAC+R5uLdXidIz3VAFVTMaNqJIXGs +55DNvhXHg6AAaL5IBtAH43L2GOpNLf6gCZgBww2QdBlxL68gCpXZ9BcqMzJx6scTsVz k56jdEmXVz+0IkA2aQ+jp/SsQnL/cED2DWvFNi1iF/IPli1AOGzX09WRsY5wo/1yXlNO oU5w== X-Gm-Message-State: ALKqPwd+hg7KW5Id9C4JTgYu4hetIFxtvWpIa/4orF2+caIor+jLXGIw 6BoxXUPqje6fApU+c9rIcac= X-Google-Smtp-Source: ADUXVKL8jjSwxuIts9+ygAJ0dBfZ4tJJU8qqHncjXAUZkINKBrNqc1JDlHKW1ncvwozK2NG/YS/IXg== X-Received: by 2002:a2e:9187:: with SMTP id f7-v6mr16089364ljg.98.1528218006925; Tue, 05 Jun 2018 10:00:06 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id j103-v6sm5148759lfi.58.2018.06.05.10.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 10:00:05 -0700 (PDT) From: Janusz Krzysztofik To: Vinod Koul Subject: [PATCH v2] dmaengine: ti: omap-dma: Fix OMAP1510 incorrect residue_granularity Date: Tue, 5 Jun 2018 18:59:57 +0200 Message-Id: <20180605165957.29616-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180605_100019_839358_1087B627 X-CRM114-Status: GOOD ( 14.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, Aaro Koskinen , Tony Lindgren , Takashi Iwai , Janusz Krzysztofik , linux-kernel@vger.kernel.org, Liam Girdwood , Peter Ujfalusi , Mark Brown , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, Jaroslav Kysela , Jarkko Nikula MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 0198d7bb8a0c ("ASoC: omap-mcbsp: Convert to use the sdma-pcm instead of omap-pcm") resulted in broken audio playback on OMAP1510 (discovered on Amstrad Delta). When running on OMAP1510, omap-pcm used to obtain DMA offset from snd_dmaengine_pcm_pointer_no_residue() based on DMA interrupt triggered software calculations instead of snd_dmaengine_pcm_pointer() which depended on residue value calculated from omap_dma_get_src_pos(). Similar code path is still available in now used sound/soc/soc-generic-dmaengine-pcm.c but it is not triggered. It was verified already before that omap_get_dma_src_pos() from arch/arm/plat-omap/dma.c didn't work correctly for OMAP1510 - see commit 1bdd7419910c ("ASoC: OMAP: fix OMAP1510 broken PCM pointer callback") for details. Apparently the same applies to its successor, omap_dma_get_src_pos() from drivers/dma/ti/omap-dma.c. On the other hand, snd_dmaengine_pcm_pointer_no_residue() is described as depreciated and discouraged for use in new drivers because of its unreliable accuracy. However, it seems the only working option for OPAM1510 now, as long as a software calculated residue is not implemented as OMAP1510 fallback in omap-dma. Using snd_dmaengine_pcm_pointer_no_residue() code path instead of snd_dmaengine_pcm_pointer() in sound/soc/soc-generic-dmaengine-pcm.c can be triggered in two ways: - by passing pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE from sound/soc/omap/sdma-pcm.c, - by passing dma_caps.residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR from DMA engine. Let's do the latter. Created and tested against next-20180531 tag from linux-next tree. Signed-off-by: Janusz Krzysztofik Acked-by: Peter Ujfalusi --- Changelog: v2: fix subject as requested by Peter. drivers/dma/ti/omap-dma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c index b73fb51fbc81..96b5096c26dd 100644 --- a/drivers/dma/ti/omap-dma.c +++ b/drivers/dma/ti/omap-dma.c @@ -1485,7 +1485,11 @@ static int omap_dma_probe(struct platform_device *pdev) od->ddev.src_addr_widths = OMAP_DMA_BUSWIDTHS; od->ddev.dst_addr_widths = OMAP_DMA_BUSWIDTHS; od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); - od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; + if (__dma_omap15xx(od->plat->dma_attr)) + od->ddev.residue_granularity = + DMA_RESIDUE_GRANULARITY_DESCRIPTOR; + else + od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; od->ddev.max_burst = SZ_16M - 1; /* CCEN: 24bit unsigned */ od->ddev.dev = &pdev->dev; INIT_LIST_HEAD(&od->ddev.channels);