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: 10444885 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 3C652601D3 for ; Sat, 2 Jun 2018 14:22:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AF9E2896A for ; Sat, 2 Jun 2018 14:22:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F79028A48; Sat, 2 Jun 2018 14:22:31 +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 CCD512896A for ; Sat, 2 Jun 2018 14:22:30 +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=MNskm7ht1vgP52sGe/CUt2B7i7XywoN9xww/oVjum4w=; b=KbU n3q/LFlb9Vi04BNMS3uW/eonKDEyX8U+YGws3cZav4BNrj2XBI7ALpT2TrxwLgt72gumbACYEyacO V1pLWvSFmOjHe/wZmwAAxA2lLQkpoKF1SiTJZoWqcdvtT9mZMYjoeP/88UWGH6dUnH2twjQRnmbRD cPnuuEmick/rrHPspoyYTLvBXTB6H3yyb1odoFWoHRMxttrUWMAG5QAiy9xOPq++/UtgrYYjJiI8b 8NrPUlCAJzhyuFdQjPiK7P/xeyvwR9XHyWa/1FanF5iGDj1WLDzc7DeM3RkhRY3V5bj2HGMc9sNUn yxzpmfhzlyrrpsFsD0Rebx3frfrzajQ==; 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 1fP7QF-0004lz-3o; Sat, 02 Jun 2018 14:22:23 +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 1fP7QC-0004ie-46 for linux-arm-kernel@lists.infradead.org; Sat, 02 Jun 2018 14:22:21 +0000 Received: by mail-lf0-x243.google.com with SMTP id t134-v6so18841178lff.6 for ; Sat, 02 Jun 2018 07:22:09 -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=IupxwXE0BYEfvVfxfCB4rTdGqlPiKazzUuPQg4j7jp5xQ/KMglQ+g1RdVzjx7iRiM+ Lvw/vXzDiWY9aOKYbheeQH0PeNdoGVUjarIbtt5o8FfEZtFkqBj2QMZ+/qPlNHcc0xKO 0VMbQ8k0wNG597tznxtjocEb0wPZ1EE0+A7RSN0BGFYmO/QRLBDB22L3LuRBILlpTj9v KAX7ZIPrpYaoZ6ZLVGq9L4UVZSlD03KHJghjQi+W18XZzFWkdFCwN7MIsy1jfuAtU8sQ EYTs3WlcZwTox1aQmsMCQvZHPc0q3uKYTDCfZm4dl4cVl9ZtLdtHqyH/HX+fVqEiWXu/ OOiQ== X-Gm-Message-State: ALKqPwdkKcpZaPAsNkoHNcj2hps9xw30R5L9aAU34UI+fk8ns/imGY/+ t25Qrgu0JYQDaG5QLHo/ygY= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180602_072220_165857_5E8A1EA6 X-CRM114-Status: GOOD ( 15.35 ) 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/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);