From patchwork Thu Jul 7 17:17:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 9219289 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 A43EE60467 for ; Thu, 7 Jul 2016 17:19:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91F7E28406 for ; Thu, 7 Jul 2016 17:19:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8401228408; Thu, 7 Jul 2016 17:19:51 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 342BB28406 for ; Thu, 7 Jul 2016 17:19:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLCwd-0004ap-Lg; Thu, 07 Jul 2016 17:18:35 +0000 Received: from mail-oi0-f67.google.com ([209.85.218.67]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLCwL-0004PM-6Q for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2016 17:18:18 +0000 Received: by mail-oi0-f67.google.com with SMTP id s17so3480538oih.1 for ; Thu, 07 Jul 2016 10:17:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cMvN374jsBRmY25eo9zGRPG6OFJZjy+VNCJTwnLHsaw=; b=FAy2isyejoQ4SRw0oMMeIQjrsvJwZwpm33wY880hsT5G1prssvFjGrD6hUHUvSQqYP MJFzy7L4b01NkTBI8N7y3Ql69zGOAvermRAX52HuygNnOOoI2bXvF3VJ3Iy9+Ce15G4M nNJacU2p4/uNGL16ice7Oqj/KylbNPCcOioattg3UJ4Ar1+gVazD+CCqgAhEZGXaDF8P 1eBtcc4j6x3DNl8FHVb10Fh/+6RNLjubFu5C7bn5bHjzp2U7eaPxmgFmWlb8jOkBeAZC Soy86eC58LCt2oNtJ8ykn5OLNBEwcCapK+98tA9luVkpDZ4S/1hLMfkQNwTltqHrX8M3 QAbA== X-Gm-Message-State: ALyK8tKgHoqp3AZ10DV0x7Cl5wJIoOcTOOZM01IaWLJwG0akyRHcR+8tv71lyeXmjEJOiQ== X-Received: by 10.202.46.19 with SMTP id u19mr826087oiu.56.1467911876623; Thu, 07 Jul 2016 10:17:56 -0700 (PDT) Received: from beast-server.fios-router.home ([108.19.207.229]) by smtp.gmail.com with ESMTPSA id 187sm12288245oid.20.2016.07.07.10.17.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 10:17:55 -0700 (PDT) From: Franklin S Cooper Jr To: tony@atomide.com, robh+dt@kernel.org, broonie@kernel.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, andy.shevchenko@gmail.com, robert.jarzmik@free.fr, nsekhar@ti.com Subject: [RFC] [PATCH v3 1/4] spi: omap2-mcspi: Add comments for RX only DMA buffer workaround Date: Thu, 7 Jul 2016 12:17:48 -0500 Message-Id: <1467911871-4508-2-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1467911871-4508-1-git-send-email-fcooper@ti.com> References: <1467911871-4508-1-git-send-email-fcooper@ti.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160707_101817_302793_4A56D5A4 X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Franklin S Cooper Jr 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 OMAP35x and OMAP37x mentions in the McSPI End-of-Transfer Sequences section that if the McSPI is configured as a Master and only DMA RX is being performed then the DMA transfer size needs to be reduced by 1 or 2. This was originally implemented by: commit 57c5c28dbc83 ("spi: omap2_mcspi rxdma bugfix") This patch adds comments to clarify what is going on in the code since its not obvious what problem its addressing. Signed-off-by: Franklin S Cooper Jr --- drivers/spi/spi-omap2-mcspi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 1d237e9..c47f958 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -459,6 +459,11 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, count = xfer->len; dma_count = xfer->len; + /* + * In the "End-of-Transfer Procedure" section for DMA RX in OMAP35x TRM + * it mentions reducing DMA transfer length by one element in master + * normal mode. + */ if (mcspi->fifo_depth == 0) dma_count -= es; @@ -478,6 +483,10 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, dmaengine_slave_config(mcspi_dma->dma_rx, &cfg); + /* + * Reduce DMA transfer length by one more if McSPI is + * configured in turbo mode. + */ if ((l & OMAP2_MCSPI_CHCONF_TURBO) && mcspi->fifo_depth == 0) dma_count -= es; @@ -507,6 +516,10 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, if (mcspi->fifo_depth > 0) return count; + /* + * Due to the DMA transfer length reduction the missing bytes must + * be read manually to receive all of the expected data. + */ omap2_mcspi_set_enable(spi, 0); elements = element_count - 1;