Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1720665imm; Sat, 2 Jun 2018 07:22:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJuNpLVOYN+xXOZ7R3cXqiDUEdSXIRYrRgu2Uh3u64pFcpbf9v5YsvkWKuj5HLF6Mzz2BEN X-Received: by 2002:a17:902:bb8a:: with SMTP id m10-v6mr6852560pls.236.1527949374829; Sat, 02 Jun 2018 07:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527949374; cv=none; d=google.com; s=arc-20160816; b=bypT96IwyxiRGjVM6iK8wA0zcx4wyD0DE5v8S2lONMa8WYSRx6F2qFyZexldDhj1Qo QGbaEmB8orCZsyQQuFQek9W+XKLhTNfP9hv/23kvXxlUjIVyGHiyrAiR8IZQI99eMgzd Fi3XzclEdKW6DcC1ZrK4StOH4U0u0HpsJt4Dahvzpzxvt/NXXxbhxejMr4CaNP759ONF c3mGsged/2041esnXMtJ9LBLupWfzod08EKjkirU1A3ALT2fOKpmMvcnvlcQfEjmnPLS 5Is+a8uSKta8KszvU3ZZq/f4bTpksSJILqUXA12gSCNu1HFJjXhYMSdY5XQpwr5tX4uG sb1A== 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=Vnj9iYt8ToctaMzgnPcr9dlOmX40u4aRGyf3p6JvbAk=; b=yh8JXGrjXDBt74ZAJdel97rxeDfYSbSR2aNrPbOvPThHGeSCgIEDp3P06V56RYAtHO 7BUL4s3tAqcHEisu5SxEvrqgUPP221K5bCAKOuk4ek7Vz1uTfIdCGWu6LTigudPtehwY 7cWmUInPly5gfEYx6RQdp/iSx8WRqyJ7wH6eDKeQew6qr/KJPNS/tqrm13vYp4+ku+TP SMRNxGFKxOsdd3pHDBVoThGPHvWWf8BMKRkzTEoTX4bCOrscvP5AWAR7twCrbZ6KSXKb l4B20B+HkBOUXYoVklWSSxC/dr86/2aDtel7Tg44AOQrckvHEb6/TgzLxQLFlBj/LD9o LsHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hED40gQZ; 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 x2-v6si9846362plr.223.2018.06.02.07.22.37; Sat, 02 Jun 2018 07:22:54 -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=hED40gQZ; 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 S1751355AbeFBOWL (ORCPT + 99 others); Sat, 2 Jun 2018 10:22:11 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34501 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750740AbeFBOWJ (ORCPT ); Sat, 2 Jun 2018 10:22:09 -0400 Received: by mail-lf0-f65.google.com with SMTP id o9-v6so18840061lfk.1; 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=cyOvtYCpWX5GXoBRk/P3aetyCJQ7mPXDPZqQUKFOXOTH9dM/h0XSy/n9EIVuGo1rOJ Dcs+uNX4eX2/BFPhVHrJy4g58ws1WnSU6OkU7VODRPZU5ztzzgMijmSSi2Wx9yEcVr/S PI6CrjIm3O1AHrF3CACq6ePZOI79v7ADrD6NzPWjNrORH2CacwkP1376MKGNGpO09AQD LKX4kKQlnGA9J81Wk9y+DuVhowTKGJFqR79HZ7cC9/qlAIAs6d9NEwyfYdfV4JzAvLCt 2n6QPQJzKFWkZ2JfWm4LjBo+UX8jhbV6bwMBKCjYfkbXSlz3oGzNqaP93o8eyCemDyHt SPmg== X-Gm-Message-State: ALKqPwfRhVSKWvN7dml5paXCxF70kJnqYm7akDXYhQH6wzd15XApkVdn zTjbBO1ZlGiV5Ny1UQfYXuk= 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 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] DMA: OMAP: fix OMAP1510 incorrect residue_granularity 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 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/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); -- 2.16.1