From patchwork Thu Feb 23 18:01:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9588751 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 7778760210 for ; Thu, 23 Feb 2017 18:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C9E12877E for ; Thu, 23 Feb 2017 18:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61AB82878B; Thu, 23 Feb 2017 18:03:08 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 CE5462877E for ; Thu, 23 Feb 2017 18:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751265AbdBWSDH (ORCPT ); Thu, 23 Feb 2017 13:03:07 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:38039 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751049AbdBWSDH (ORCPT ); Thu, 23 Feb 2017 13:03:07 -0500 Received: by mail-wm0-f52.google.com with SMTP id r141so6426862wmg.1 for ; Thu, 23 Feb 2017 10:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7uUHrYEIaOCXAmoZFskqjdaVzK84nT+yWinNOWUDgS4=; b=sc9PLaeuBTfkyEbSL4J3oga8cwUKs0EIpRqbQQa1ldxJv9QyizS21TmHmngfDBh6mR Fr+yO9dlvMufDpwng8dg5tmKIWgaPLlK4/C8uuMfZDST7/CM5kObYAzZSYG3WIfBJdEu mMtK9mVCJmenrB8EtpE2/t5OFwSwQCmiK7Nb2duvzlWkix6/OvShzdtqv+qpSK241sto WTv7VFNfGel65kiqgifRvV4YCYmMuD0oezW6d1qWDDlbAVdYzk9IL9Ojs8CsM3QA5OCz 4wIlNAvh/LYmr5BJYI8KUPK38vCEaTS53wjxsHt2zTvljRiW9qCFO5hoAFmIwl/TEPV6 Wpqw== 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:in-reply-to :references; bh=7uUHrYEIaOCXAmoZFskqjdaVzK84nT+yWinNOWUDgS4=; b=lK2znml63qbpiYtxYt4CLGiH6YF+X8ebxdF49f9MpItEVYrX2h72oiwOTkvw+tKdOL 4iSmWNFYepHvUyjM7y4o0ctoFerFOYSl9dKwtU35ht+BcGFskkLbRnMe3kpqm2Amv5kf kdIwHEz95u9/Jvq28MrP8sA2lTPzgTbuds2ZI1ETss5DM4s7uHhGfffZWM1r+UPXMXZ5 su0S6YvCm/bwdsEg4ld+4Ur+iqqTwyeUmBfGBmyXPtn3/5rZiXdcXjJMvS7M8+qQSOJL seaKSjjr9DEGTkwt5T9jnD0JeKQ24Xx8TwWGFzjdSnLARlSFxMJiajyMaTaes6bM1H6W qrfg== X-Gm-Message-State: AMke39mJQRo5Nr6FLN0ys642bn5yMc0A31hgfw1gVnkOz2uGDWcRtnP+reOn0m/L09R5y50D X-Received: by 10.28.132.2 with SMTP id g2mr5893001wmd.103.1487872985316; Thu, 23 Feb 2017 10:03:05 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id z134sm7739182wmc.20.2017.02.23.10.03.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Feb 2017 10:03:04 -0800 (PST) From: Frode Isaksen To: nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, linux-spi@vger.kernel.org, Frode Isaksen Subject: [PATCH v3 3/6] spi: davinci: use rx buffer as dummy tx buffer Date: Thu, 23 Feb 2017 19:01:58 +0100 Message-Id: <1487872921-26628-4-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487872921-26628-1-git-send-email-fisaksen@baylibre.com> References: <1487872921-26628-1-git-send-email-fisaksen@baylibre.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 When doing rx-only transfer, the transfer will fail if the number of SG entries exceeds 20. This happens because the eDMA DMA engine is limited to 20 SG entries in one transaction, and when the DMA transcation is resumed (which takes > 150us), rx errors occurs because the slave is still transmitting. Fix this by using the rx buffer as the dummy tx buffer, so that resuming the rx transcation happens at the same time as resuming the tx transcation. Signed-off-by: Frode Isaksen --- drivers/spi/spi-davinci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 1e24395..ca12216 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -655,6 +655,12 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) if (!rxdesc) goto err_desc; + if (!t->tx_buf) { + /* use rx buffer as dummy tx buffer */ + t->tx_sg.sgl = t->rx_sg.sgl; + t->tx_sg.nents = t->rx_sg.nents; + } + txdesc = dmaengine_prep_slave_sg(dspi->dma_tx, t->tx_sg.sgl, t->tx_sg.nents, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -957,7 +963,7 @@ static int davinci_spi_probe(struct platform_device *pdev) master->bus_num = pdev->id; master->num_chipselect = pdata->num_chipselect; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16); - master->flags = (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX); + master->flags = SPI_MASTER_MUST_RX; master->setup = davinci_spi_setup; master->cleanup = davinci_spi_cleanup; master->can_dma = davinci_spi_can_dma;