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: 10448659 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 1A4DD60234 for ; Tue, 5 Jun 2018 17:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD26029AC5 for ; Tue, 5 Jun 2018 17:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C89F529A4A; Tue, 5 Jun 2018 17:00:22 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15CF729A16 for ; Tue, 5 Jun 2018 17:00:15 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 193F1267A71; Tue, 5 Jun 2018 19:00:12 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C2288267A72; Tue, 5 Jun 2018 19:00:09 +0200 (CEST) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by alsa0.perex.cz (Postfix) with ESMTP id CFEA7267A6C for ; Tue, 5 Jun 2018 19:00:07 +0200 (CEST) Received: by mail-lf0-f65.google.com with SMTP id t134-v6so4694894lff.6 for ; Tue, 05 Jun 2018 10:00:07 -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=TYa+4SYbkUa8dzLqXNbknLpzKCsISxONErT8ETNwdQQzjvDEy3Ghxr65NG9BuT52Lw z7Z5KldYwjAAA7CA0U6Vj6/ulhYKpPRaa6hoaK3zp+EW3giQGVz4quUsY0juJz4My3fW YDV7FGnOkktt89tT7+bnAKBIxC4V59zBvcg6lnqj+I1DxtQxVyjbHtWgwT5hpFc4MAlz KXoQx1o6xObzT2tkitzH4Qb/aipBJIjQUTKlEaGm9DiQSneRjx9QOdqARbmc8KRxh0UL Hlb8r6cU0YjyzpD5R8PXhJL0gv5HzVUuJuYFoQpx1Rsx/Z3MMZcflXskI1Yt/TtSsSTE n1lQ== X-Gm-Message-State: ALKqPwfLfs2uKBVX/yQiqwED+5VIBA9PAsMrvKn1dSUOYGFTq8Wpq8Fz 1gCJGQGO+nnshskRCDogFOA= 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 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 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, Jarkko Nikula Subject: [alsa-devel] [PATCH v2] dmaengine: ti: omap-dma: Fix OMAP1510 incorrect residue_granularity X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.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);