From patchwork Thu Nov 17 12:16:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 9434195 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 4B0896047D for ; Thu, 17 Nov 2016 12:29:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CD0C29407 for ; Thu, 17 Nov 2016 12:29:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31B682947A; Thu, 17 Nov 2016 12:29:16 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 B5DAB29407 for ; Thu, 17 Nov 2016 12:29:15 +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 1c7LmO-0002ik-9B; Thu, 17 Nov 2016 12:27:00 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c7Lld-0002Mr-9t for linux-arm-kernel@lists.infradead.org; Thu, 17 Nov 2016 12:26:14 +0000 Received: by mail-pg0-x243.google.com with SMTP id x23so17539406pgx.3 for ; Thu, 17 Nov 2016 04:25:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=y66ygaZm7/2ZgBplyDw6vdX+PVCJcnCidYee96bASGo=; b=MqH8oLKvxvOruNtEYK8P+/o7tDCdYBYBDCinCN0Jm6hvP364qupbyNWCz3FEc4egRT fvkdvBBYOFMFBnYwSFdoVRX+L+KKS/6Vg2DuIcrKuvAyA1ZqXSogUzioN93LdP9BIeMX F/MYzw2BcjcZ4KyobQs95cntwzgzZrz9SBG21ZB76p+KKeElm8lsshAbo5Lh000RgJR1 InK26b79ARewIbvXUYSWYmDDCuzYRzumnrg1muaFhFIpc1sQLchDHrpjkR4jxKho1PMv +yiUb0tBfhb+69RsHfxoK5S50OBxFQ/e+wDEe2xbDtQFddrVqRYzNTXelTm+4TR6Qn4x UbBA== 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:in-reply-to:references; bh=y66ygaZm7/2ZgBplyDw6vdX+PVCJcnCidYee96bASGo=; b=fthWJvXQaNWQBjtRnsPIPbvlzcXDV33daxmQ6/193S1mj47O4q/qel7Ch0kH7bTvCE TPkvI2rqdN94EWlbR/8G7xcdHyHMiJ4Vd6va/NdFU8l2HMbV9TsixgbMzKhUk9F1yrHC L8N8w1gyJVubyWc51AcFg8YQsp5Gi2zhdsZoAN7AY+rF17WF7jF6hpvfFqnblNS4cJZe 4njDeI9ERdHD04v/a5wPQ9XCheNLZyIX97h1ZZ2qcHXV5xBdWflPuxirm9uDGOkRUc/c AkJ2iydlJ0L+6V5Xvq53vyvf9Qfnb4JJNx04wXNLGk7v2puH8U/kCxy/CRGItlcLfjTo KIQg== X-Gm-Message-State: ABUngveRB2anMrCvCjYtHlG3fIqyvHmVEqIBgnjEErVF5LJ5HYMpZp4bPZV+1MKmiU5vMg== X-Received: by 10.99.219.21 with SMTP id e21mr7077957pgg.136.1479385554832; Thu, 17 Nov 2016 04:25:54 -0800 (PST) Received: from localhost ([115.115.243.34]) by smtp.gmail.com with ESMTPSA id u1sm7147272pfb.96.2016.11.17.04.25.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Nov 2016 04:25:54 -0800 (PST) From: Sanchayan Maity To: broonie@kernel.org Subject: [PATCH 2/4] spi: spi-fsl-dspi: Fix incorrect DMA setup Date: Thu, 17 Nov 2016 17:46:49 +0530 Message-Id: X-Mailer: git-send-email 2.10.2 In-Reply-To: References: <20161111122036.fubv7b4jc5vkdxhc@sirena.org.uk> In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161117_042613_449591_868A785E X-CRM114-Status: GOOD ( 10.59 ) 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: Sanchayan Maity , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, stefan@agner.ch, linux-kernel@vger.kernel.org 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 Currently dmaengine_prep_slave_single was being called with length set to the complete DMA buffer size. This resulted in unwanted bytes being transferred to the SPI register leading to clock and MOSI lines having unwanted data even after chip select got deasserted and the required bytes having been transferred. Signed-off-by: Sanchayan Maity --- drivers/spi/spi-fsl-dspi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index b1ee1f5..aee8c88 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -265,7 +265,10 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi) dma->tx_desc = dmaengine_prep_slave_single(dma->chan_tx, dma->tx_dma_phys, - DSPI_DMA_BUFSIZE, DMA_MEM_TO_DEV, + dma->curr_xfer_len * + DMA_SLAVE_BUSWIDTH_4_BYTES / + (tx_word ? 2 : 1), + DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!dma->tx_desc) { dev_err(dev, "Not able to get desc for DMA xfer\n"); @@ -281,7 +284,10 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi) dma->rx_desc = dmaengine_prep_slave_single(dma->chan_rx, dma->rx_dma_phys, - DSPI_DMA_BUFSIZE, DMA_DEV_TO_MEM, + dma->curr_xfer_len * + DMA_SLAVE_BUSWIDTH_4_BYTES / + (tx_word ? 2 : 1), + DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!dma->rx_desc) { dev_err(dev, "Not able to get desc for DMA xfer\n");