From patchwork Mon Jun 27 14:54:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 9200779 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 2FECA607D3 for ; Mon, 27 Jun 2016 14:54:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2115A28595 for ; Mon, 27 Jun 2016 14:54:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 158672859C; Mon, 27 Jun 2016 14:54:52 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 401B528595 for ; Mon, 27 Jun 2016 14:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751857AbcF0Oyp (ORCPT ); Mon, 27 Jun 2016 10:54:45 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33568 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbcF0OyO (ORCPT ); Mon, 27 Jun 2016 10:54:14 -0400 Received: by mail-oi0-f67.google.com with SMTP id w141so30995836oia.0; Mon, 27 Jun 2016 07:54:14 -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=T0Sqi2iwr+6QKBkmwLIcI8lyRZKg6KTD0ic9lbiLSpXt82Fu1MytPwozD/B3e6P7JI 4ljjgiZGEeSCWls2BAaNJK1Zk5u32x+9j+Jw3M2daJtX/VQQSz73UWvzCVhjFv13I98O zN3sw+0W9xXnYqcQd58fw2iLZ/wY20FYXttygB/xpST3Bt7icQB7laZbExcpziC6etyG 3b1jxIk33w93B/wXL/Hve/J45oXaDXElAMJARBBNTAofPmLZc07Scjqa0cRhPmVjFv3H YDue5ZxnhDJEqp4dKwQdb6dkb/n9PJhMPg1RXK046xFl23IpAQ4yoo3q87r3kjh8ni1n 3woQ== X-Gm-Message-State: ALyK8tLXtWw2MJdgm8mFBaO64g6QGlrAT/5n5b1/R2e0wSu1RH+QL5ER1z5lrsjyegj00w== X-Received: by 10.202.60.67 with SMTP id j64mr872776oia.145.1467039253613; Mon, 27 Jun 2016 07:54:13 -0700 (PDT) Received: from beast-server.fios-router.home ([108.19.207.229]) by smtp.gmail.com with ESMTPSA id h35sm9017182otb.31.2016.06.27.07.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Jun 2016 07:54:12 -0700 (PDT) From: Franklin S Cooper Jr To: david.s.gordon@intel.com, axboe@fb.com, akpm@linux-foundation.org, ming.l@ssi.samsung.com, linux-kernel@vger.kernel.org, broonie@kernel.org, linux-spi@vger.kernel.org, nsekhar@ti.com, peter.ujfalusi@ti.com Cc: Franklin S Cooper Jr Subject: [RFC] [PATCH v2 2/3] spi: omap2-mcspi: Add comments for RX only DMA buffer workaround Date: Mon, 27 Jun 2016 09:54:08 -0500 Message-Id: <1467039249-7816-3-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1467039249-7816-1-git-send-email-fcooper@ti.com> References: <1467039249-7816-1-git-send-email-fcooper@ti.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.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;