From patchwork Fri Feb 17 10:38:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9579551 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 7FEE6600F6 for ; Fri, 17 Feb 2017 10:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F7D9280B0 for ; Fri, 17 Feb 2017 10:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CF1628383; Fri, 17 Feb 2017 10:38:42 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 CEBCA280B0 for ; Fri, 17 Feb 2017 10:38:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932742AbdBQKil (ORCPT ); Fri, 17 Feb 2017 05:38:41 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:36743 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932556AbdBQKik (ORCPT ); Fri, 17 Feb 2017 05:38:40 -0500 Received: by mail-wm0-f53.google.com with SMTP id c85so10887925wmi.1 for ; Fri, 17 Feb 2017 02:38:40 -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=oNH9VpjYMfo3Dr+OpIQqC0VpF5kE2hfuY6l+DB8EtZk=; b=E0zUCR+5L++2g4ZLvE6QPGqpKXG4/g5SLzcHoM+bJCxjdBub6WDa8+8aT5GlEJ6ug0 /ax61pwVQlRN6IUjNRgv/yAjAePOpBdddJmySE0pRVarlMsV11faHgSGv9Gt7Qi3oKbz RGao9RGI2pe75VgPgg8jY08oU7k+v3VNPhR6JmNKLL3Xf0tCbxIRSS3it2cTJXvxt6ND BJAIbuXatjWRV+HMh2ysUL2NlTJTvlAcxLMhri5jrsDwDENIuGmCTmdaoyKl4KhkUEVm UWJXf0iItjZQ3B25xZOnIpgimVdPa6tMDM67U3XO1gArRPMKHMlGjpLYNFZ9O79Zn6b9 eljg== 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=oNH9VpjYMfo3Dr+OpIQqC0VpF5kE2hfuY6l+DB8EtZk=; b=ctZGFfqFfih2iX0YIwd5mtWWE/O4oIuM9dcSIpYNYvU/wE9j4snGE1sIyavhJ1X8lW NzRStVWW12svPy6IP48T2NL2eZ5UHeVHVXwafRTHT/zvRzMe3OLd91vix3gbRFaB8Nyf c2McZcxEtVQjeSsn5tvKgyOp+3q2niFkaiYT/iYPCxo8XeU5KAqQ9QLm3dd5Y8yh1sMK ea61+2+3k+Z5blaku9aC8Y+2YxVL8AlNGlFerbPFDqu2FBSeko48mATlv8TbO6PBe+aL i2P/kdl4gsxS1gxit5NzM+07O1gbvfFxnsmchKKW58SdP8IniHZP+7OhyTaYfExQVIMN +iHA== X-Gm-Message-State: AMke39kIYO2qFWzyFVX4R3scX1fyY0PjU2YkLijRxHwiVj+qhEhyKgW3ODt699lHZ+4NUOds X-Received: by 10.28.140.140 with SMTP id o134mr2726192wmd.87.1487327919243; Fri, 17 Feb 2017 02:38:39 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y80sm12531459wrb.12.2017.02.17.02.38.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 02:38:38 -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 v2 3/6] spi: davinci: use rx buffer as dummy tx buffer Date: Fri, 17 Feb 2017 11:38:21 +0100 Message-Id: <1487327904-28311-4-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487327904-28311-1-git-send-email-fisaksen@baylibre.com> References: <1487327904-28311-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 9823908..2632ae0 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -656,6 +656,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); @@ -958,7 +964,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;