From patchwork Wed Oct 31 13:57:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 1679031 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id 0BA0240060 for ; Wed, 31 Oct 2012 13:57:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TTYnW-00005x-5e; Wed, 31 Oct 2012 13:57:34 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TTYnU-00005l-EA for spi-devel-general@lists.sourceforge.net; Wed, 31 Oct 2012 13:57:32 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.210.175 as permitted sender) client-ip=209.85.210.175; envelope-from=omaplinuxkernel@gmail.com; helo=mail-ia0-f175.google.com; Received: from mail-ia0-f175.google.com ([209.85.210.175]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1TTYnO-0006JB-O4 for spi-devel-general@lists.sourceforge.net; Wed, 31 Oct 2012 13:57:32 +0000 Received: by mail-ia0-f175.google.com with SMTP id b35so1096838iac.34 for ; Wed, 31 Oct 2012 06:57:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.43.104.200 with SMTP id dn8mr31380434icc.43.1351691841309; Wed, 31 Oct 2012 06:57:21 -0700 (PDT) Received: by 10.42.228.10 with HTTP; Wed, 31 Oct 2012 06:57:21 -0700 (PDT) In-Reply-To: <651D981E4B29F74ABD63CE74C2E4788E08A612E22A@SLOMAILPRD01.polycom.com> References: <651D981E4B29F74ABD63CE74C2E4788E08A612E22A@SLOMAILPRD01.polycom.com> Date: Wed, 31 Oct 2012 19:27:21 +0530 Message-ID: Subject: Re: [REGRESSION] d7b4394e breaks bi-directional DMA transfers on omap2-mcspi From: Shubhrajyoti Datta To: =?ISO-8859-1?Q?S=F8rensen=2C_Stefan?= X-Spam-Score: -1.2 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (omaplinuxkernel[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.4 AWL AWL: From: address is in the auto white-list X-Headers-End: 1TTYnO-0006JB-O4 Cc: "spi-devel-general@lists.sourceforge.net" , "broonie@opensource.wolfsonmicro.com" , "shubhrajyoti@ti.com" X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net On Wed, Oct 31, 2012 at 5:46 PM, Sørensen, Stefan wrote: > Bi-directional SPI transfers using DMA no longer works on omap2-mcspi after > this commit: My bad. > > commit d7b4394e780b02511c8a7a499380cdd56316c770 > Author: Shubhrajyoti D > Date: Tue Sep 11 12:13:20 2012 +0530 > > spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function > > Currently in omap2_mcspi_txrx_dma the tx and the rx support is > interleaved. Make the rx related code in omap2_mcspi_rx_dma > and the tx related code omap2_mcspi_tx_dma and call the functions. > > While at it remove the braces in the if statements which has only > one line. > Also fix ["foo * bar" to "foo *bar"] warn for the rx and tx variables. > > Only a cleanup no functional change. > > Signed-off-by: Shubhrajyoti D > Tested-by: Felipe Balbi > Signed-off-by: Mark Brown > > > Basically the patch changes the pattern > start_tx(); > start_rx(); > wait_for_completion(tx); > wait_for_completion(tx); > into > start_tx(); > wait_for_completion(tx); > start_rx(); > wait_for_completion(tx); > which will stall the transfer since the rx channel is not serviced. So moving the tx completion. Apologies for breaking in the original commit. Will test and get back with a proper patch. --- drivers/spi/spi-omap2-mcspi.c | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-) mcspi_dma = &mcspi->dma_channels[spi->chip_select]; @@ -528,6 +511,21 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) if (rx != NULL) return omap2_mcspi_rx_dma(spi, xfer, cfg, es); + chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; + wait_for_completion(&mcspi_dma->dma_tx_completion); + dma_unmap_single(mcspi->dev, xfer->tx_dma, count, + DMA_TO_DEVICE); + + /* for TX_ONLY mode, be sure all words have shifted out */ + if (rx == NULL) { + if (mcspi_wait_for_reg_bit(chstat_reg, + OMAP2_MCSPI_CHSTAT_TXS) < 0) + dev_err(&spi->dev, "TXS timed out\n"); + else if (mcspi_wait_for_reg_bit(chstat_reg, + OMAP2_MCSPI_CHSTAT_EOT) < 0) + dev_err(&spi->dev, "EOT timed out\n"); + } + return count; } diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 3542fdc..e8e5bbc 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -323,18 +323,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, struct omap2_mcspi *mcspi; struct omap2_mcspi_dma *mcspi_dma; unsigned int count; - u8 * rx; const u8 * tx; - void __iomem *chstat_reg; - struct omap2_mcspi_cs *cs = spi->controller_state; mcspi = spi_master_get_devdata(spi->master); mcspi_dma = &mcspi->dma_channels[spi->chip_select]; count = xfer->len; - rx = xfer->rx_buf; tx = xfer->tx_buf; - chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; if (mcspi_dma->dma_tx) { struct dma_async_tx_descriptor *tx; @@ -359,19 +354,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, dma_async_issue_pending(mcspi_dma->dma_tx); omap2_mcspi_set_dma_req(spi, 0, 1); - wait_for_completion(&mcspi_dma->dma_tx_completion); - dma_unmap_single(mcspi->dev, xfer->tx_dma, count, - DMA_TO_DEVICE); - - /* for TX_ONLY mode, be sure all words have shifted out */ - if (rx == NULL) { - if (mcspi_wait_for_reg_bit(chstat_reg, - OMAP2_MCSPI_CHSTAT_TXS) < 0) - dev_err(&spi->dev, "TXS timed out\n"); - else if (mcspi_wait_for_reg_bit(chstat_reg, - OMAP2_MCSPI_CHSTAT_EOT) < 0) - dev_err(&spi->dev, "EOT timed out\n"); - } } static unsigned @@ -492,6 +474,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) struct dma_slave_config cfg; enum dma_slave_buswidth width; unsigned es; + void __iomem *chstat_reg; mcspi = spi_master_get_devdata(spi->master);