From patchwork Sat Jun 2 15:27:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10444913 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 09A486028E for ; Sat, 2 Jun 2018 15:28:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB77028A0F for ; Sat, 2 Jun 2018 15:28:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEF8A28A4B; Sat, 2 Jun 2018 15:28:13 +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, HK_RANDOM_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 E0AC428A0F for ; Sat, 2 Jun 2018 15:28:12 +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=nJuujEhYdHQi9d1CeZWJKGYv7hhWTNz0DivFNEC6MvQ=; b=LUi 5hXlSqeKcRCDB2tlyKnb3OUp44/TUPL7XBFL4Bj0CfIlONPzuGNkcNR9iPBTFLiM/2ieWPkzQZonX skBXHXLrw6r1xpuSlzvp6E6gSk8asezZHLT/bt4TnGmvJGw96ga421LFv0nUKkU+Ue2AQz7cw9Kx2 2gACfaafR0bx38n061tthOV/n04EVQC0bdy1K3dVp6FlQZXF017rR7kLr8TwEQ9NwsnqsWEWmMiS/ NTeyu1sB343hlPu3jJ3bweOUsod46j0N9zyOQTnBpOrvogEZWkIXrWbN2+6pNtnlBIZu64XmKRrRK 1JwJiOBgTsi0Jr6GUeT1VSLk+t51uhA==; 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 1fP8Rq-0000T9-QV; Sat, 02 Jun 2018 15:28:06 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fP8Rn-0000Gi-74 for linux-arm-kernel@lists.infradead.org; Sat, 02 Jun 2018 15:28:04 +0000 Received: by mail-lf0-x243.google.com with SMTP id y72-v6so18983824lfd.2 for ; Sat, 02 Jun 2018 08:27:51 -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=vX4c2wiclTLm/np+fx0tJ7uWPmck3OQmM5IbObk4Uzo=; b=hpfUiVuzg2KueJ4DJAh8K/hkyZDBhO+mNZsulL0H5CWQtSjk38xXRkIXo7jpCH5trF 3l303ek8CxE4E5K6zHaba65oUM3YUt8RsfVfChIlUhkM2hpyStCkceKhDHNwlC1x7H5M frsJ2k/KbewuGKHzL79XzxU0H5jf8Mff6u0fskz8NdiVs6VpIDaqsPsyX+uBDqyx2b5r KfIfoA/YdqZvPm32x6hl9uhzR1UNSg5bt2+SSR1oT2xXNhcaigOO09/xwpdDq9LqWvLv a6Qkm3SAxr/bQnz20gYTj9M+GxtQ+IURCtWY6w3vfuouZ/VXtGkU5TKPKeu4RG/v9jmQ HBqA== 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=vX4c2wiclTLm/np+fx0tJ7uWPmck3OQmM5IbObk4Uzo=; b=MP+wG5+mkixU4vaslF3MZqmO+ihrV2vCtYGg4hnpGrBaH0rK6/SpdmmEe/IW/6qI7C 6B9veyBExJ666vAllR59/K0pHmkcS/CiOIafsqWG7l7o73fW+hXpZtUtfEKYNZFix6mV ZMn3xJLpTMy2M4cyCJjY/PGe8C9Ctc1HvLQ3fSFgX6kIHOuD6hkR7qpgX+VgVaWaAnl9 HdRTIjNO4K2dIPPeVnVCWJYeKUlpDjApYQeL7jO2xi+tDc0maZAT78gaKQ8mXNy9JWIr c4iCExJY9Y/pNSR6qLmTepyRKIaI5XI4uJ9RMhJ8/QghKq53RgP3p/m4vRG5a1daD7Lp Z4ZQ== X-Gm-Message-State: ALKqPwfBwu97Pjba11IBNDr0+SFAatmfc1KbXKGScLSrlNJ48NgrL43B PXF7hns343ZJk7XrsF33img= X-Google-Smtp-Source: ADUXVKJATshII/xjWDPsJYwM1DiUV+52fciFAwNXrMvWSPRsa53z6zyFK2jx4lPTrknoxnQPBM4yzA== X-Received: by 2002:a19:12c7:: with SMTP id 68-v6mr9644169lfs.10.1527953270052; Sat, 02 Jun 2018 08:27:50 -0700 (PDT) Received: from localhost.localdomain ([31.0.82.127]) by smtp.gmail.com with ESMTPSA id q4-v6sm4683993ljh.31.2018.06.02.08.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 08:27:48 -0700 (PDT) From: Janusz Krzysztofik To: Vinod Koul Subject: [PATCH v2] DMA: OMAP: fix OMAP1510 incorrect residue_granularity Date: Sat, 2 Jun 2018 17:27:19 +0200 Message-Id: <20180602152719.28464-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-20180602_082803_277471_801819FA X-CRM114-Status: GOOD ( 15.45 ) 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: apply the patch against omap-dma.c moved to drivers/dma/ti/ 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);