Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1165002imm; Tue, 5 Jun 2018 10:02:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLK+17uUXy4UA4tzXwrHduhOA8TPE9K2fD8H3iqwZMmLrU4vxBWR718iNLIvnruIJLBaYGW X-Received: by 2002:a62:484d:: with SMTP id v74-v6mr12349497pfa.256.1528218147901; Tue, 05 Jun 2018 10:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528218147; cv=none; d=google.com; s=arc-20160816; b=J4rqLJWTRQduq7ceSHQ7baFAM2hXGndf6w62fyDpSMLugO0Au+kd1fnc7nhu4zNbDK x65AaVn6deE0Ua1yTKuA6FZyTSjA1PtXHZSkJ4nJNIam7vM+63jAZyMF7njmMuiIHQS3 E+mbsCtgtbwfIQFXR3VQ9L+o8lQBBeviVfQR9SUftJgnFD/05YE+zDwAKoYZ+vf8YysY YK3e880Ga5oZqjS6m/oFO16wLfgNHgIR04KskxhVJCN0jtHwvv7EhlnX6T3QVsGVnHWl pW8XLOz43bGC1tNw5pF4GehiqiCjpyYWHXVHLOa38i+pF/8YtNtqA7GJlgWDuOE06G84 mCDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=fOvUHB6ySJXePp08XRhJpgHzGzn+XhLjoBzkr1E+cVE=; b=jjjl1hhYqzG42sqv05/PZmpcGIbGhtWrXoL6YO3dmyYbCyVryO+oSnoNYYUCtPx1L8 +2Obf9YqEXaJtDdaksVhHwKEOwiDzn4P7WrxWjPpmO1xW0pyeDYu2Qw8tMXIoK0KxSbR wTYrKHLx1z87UrZ/yXzhseM0CcWzWCl6g3v5Zp9nrydMaFEvp/WucY74+X1qfbtxhmo5 CV9O9TzIf2l5C91s+7oiHqAI0nxOGn6lLTR4auS+6gnIGWvqOQmr8Gk26gqhBbpFXHtf LuDSeTOLixij3zFr8yBJBHab0HIMDJNEHFO8OpuI/OcnCjBhAoqWGUmWo92g0RFLv6Zu dnuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WEVw0W7O; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a65-v6si22048434pfa.148.2018.06.05.10.02.11; Tue, 05 Jun 2018 10:02:27 -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=@gmail.com header.s=20161025 header.b=WEVw0W7O; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbeFERAK (ORCPT + 99 others); Tue, 5 Jun 2018 13:00:10 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42827 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbeFERAI (ORCPT ); Tue, 5 Jun 2018 13:00:08 -0400 Received: by mail-lf0-f68.google.com with SMTP id v135-v6so4695908lfa.9; 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=aFOmruTxn3DeNKQ3nVnuUiFYRC5nRLkjeuPHF4CrNVUTXw3tcNTuFlgy1QGWpgzn5W ONGZtXdXlKGln92w0tNuQzeo6xjPa7H44YYH571VgFfjjHrKQU4kM/JzaSlv5cRFKT5K 1G7Jga68P2rO8Er45YkiDhr+OSm77BXixqAGNX5nYMsNC+AsKrQlg/nF/L1iAS3FE9Fg +l0b7VwhzHFfRQqjJXhPVP0rI6LfCgoUsMEqBzXDOVRmKIQEIOeYgadprsvNs41XOl9j e69NWKkMh2lHn5ii78E70K58lRxNIEbjJE0fKssXkv+1tR5mXP4pv9D9qQRfjthE2n+h 821g== X-Gm-Message-State: ALKqPwd4hm/KOb9HWnjTUKXTM8irvQGaHVTGiMUyJuLHrQfO/O/7ZYOH mlN/J+MeVz72qU5sgeBQubg= 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 Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Ujfalusi , Jarkko Nikula , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, Aaro Koskinen , Tony Lindgren , linux-arm-kernel@lists.infradead.org, Janusz Krzysztofik 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.16.1