From patchwork Sat Jun 2 14:22:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10444881 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 0B3AF601D3 for ; Sat, 2 Jun 2018 14:22:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE2652894E for ; Sat, 2 Jun 2018 14:22:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E26B328A48; Sat, 2 Jun 2018 14:22:17 +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,HK_RANDOM_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 EC9802894E for ; Sat, 2 Jun 2018 14:22:16 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A7BBF267903; Sat, 2 Jun 2018 16:22:14 +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 9039B267904; Sat, 2 Jun 2018 16:22:11 +0200 (CEST) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by alsa0.perex.cz (Postfix) with ESMTP id 7D3B4267902 for ; Sat, 2 Jun 2018 16:22:08 +0200 (CEST) Received: by mail-lf0-f67.google.com with SMTP id q11-v6so18856573lfc.7 for ; Sat, 02 Jun 2018 07:22: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=Vnj9iYt8ToctaMzgnPcr9dlOmX40u4aRGyf3p6JvbAk=; b=hED40gQZ9DKwwM+kemzbS0MiVb4Q3D5mBC4qlEN0b6pTTzMxT3MXXmPjNSoRRkPogL cb/d4pHndLZ2vELh8tJIcpJfYH+9ATyAf8cIXSrj2qZ5A9PKJCcz/6kVfDmSc0VW4Pi2 OeCG6rV5W1/+r0QlCcZq3rE5zScqLpt+A56ASIkY/va96gvjNSWr3Hk3Ciy48svPzyNB o2eoWvydX4zzQxVPoGCRqjxjoS32uA0z305R/CNx6N66ltYng1twa7ZuI+vhyEnXed9A 9kKb0HbTuAih6y5jSPUgmyDvC+129dkkR3PDuERYVC2qBVrpnXULooKE3msfgY0SsNUy PKGw== 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=Vnj9iYt8ToctaMzgnPcr9dlOmX40u4aRGyf3p6JvbAk=; b=pre55V7bW7ft0UK3DHWWpswQxDoHRfa1rlhfwO+hLc2Smf0LWYhvMZTyoYntP+ueQs KIbaCjLIoawqfgrficppYWqs0nql1CWCHw3E/3mTf3YbrAAOwHR0LsibcauHhlIX7kHO 8ulhGaoLnksJavv0f7zc67IISlmeTSfDZ6wcT4FkhlgP2WPcPQrom6yv36z7wX8M8jCE iZtPjnkoeDPbihl5iRce3bCqSNxJu0h4Gf//y0JUvCGsrvezTfaHFkxS3SFG34lzw4br 36YlUQbdW0hjrzzbJPTm+LMEy48yg4x895vZ6hNhtZdnICj2ron01C2DROke/Ne8sgE9 XcyQ== X-Gm-Message-State: ALKqPwfjy0hWTdRVvu4WLGiNRRsKjgQMD86TAzoG95Arm4Jbc2nitzGI 0mdm+2OiAB4skT4os39E3uo= X-Google-Smtp-Source: ADUXVKKg0tgRtmFX/jDn2RkU6H5vF0SITvLMCS0YxnAw5S0RUFbfytDUWR5svDwOtDWQB+XPn7xwJQ== X-Received: by 2002:a19:9855:: with SMTP id a82-v6mr8815921lfe.87.1527949327644; Sat, 02 Jun 2018 07:22:07 -0700 (PDT) Received: from localhost.localdomain ([31.0.82.127]) by smtp.gmail.com with ESMTPSA id p85-v6sm2166591lje.29.2018.06.02.07.22.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 07:22:06 -0700 (PDT) From: Janusz Krzysztofik To: Vinod Koul Date: Sat, 2 Jun 2018 16:22:04 +0200 Message-Id: <20180602142204.17460-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] DMA: OMAP: 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/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 drivers/dma/omap-dma.c. Let's do the latter. Created and tested against next-20180531 tag from linux-next tree. Signed-off-by: Janusz Krzysztofik --- drivers/dma/omap-dma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index d21c19822feb..56399bd45179 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/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);