From patchwork Mon Apr 14 06:30:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 3976731 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 11DA59F2CC for ; Mon, 14 Apr 2014 06:31:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B563201C8 for ; Mon, 14 Apr 2014 06:31:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F30B201C0 for ; Mon, 14 Apr 2014 06:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750872AbaDNGbL (ORCPT ); Mon, 14 Apr 2014 02:31:11 -0400 Received: from mail-pb0-f54.google.com ([209.85.160.54]:65141 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbaDNGbK (ORCPT ); Mon, 14 Apr 2014 02:31:10 -0400 Received: by mail-pb0-f54.google.com with SMTP id ma3so7887287pbc.27 for ; Sun, 13 Apr 2014 23:31:10 -0700 (PDT) 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; bh=5jyFaHrXtKvajteojluMBNTChpvMe5qfV3Fhsw7Uufk=; b=Qeupfh6wKkwYLZLIsCUGiFV7XRo5Wv/aFJ9PMrHps0nln8xmGzxU3Mkynoq7LFM4Ch clF+gqKhkezHWmxiI0t/ZI/CyIGLrNgrh9NoJKMZhRBl48hbpJjz7rwyHlre6MErJas4 cdmNDWR3GY0D5bGeRqHEWPTfBQKatLiEJJSWh1XUVJXIYwKKSSqnQxd7lf0epikTScJ/ uAxTPIeLDigdT6q5tcpPfz3GGF/OEa/q8fIy89yXyD5YGLziN50Y/yBk+vlMm8JJt5YG 1Bh3A1PmwnHv1x2/wBN15pk8wlcv8f8+xnXw+noE3afbdV9Z9OO+otMIth02EGc/50kT RpwA== X-Received: by 10.68.193.100 with SMTP id hn4mr42385745pbc.50.1397457070024; Sun, 13 Apr 2014 23:31:10 -0700 (PDT) Received: from localhost.localdomain ([117.136.8.58]) by mx.google.com with ESMTPSA id cz3sm31653608pbc.9.2014.04.13.23.31.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 13 Apr 2014 23:31:09 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: broonie@kernel.org, linux-spi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, workgroup.linux@csr.com, Qipan Li , Barry Song Subject: [PATCH 5/5] spi: sirf: fix spi full-duplex DMA transferring issue Date: Mon, 14 Apr 2014 14:30:01 +0800 Message-Id: <1397457001-5266-6-git-send-email-21cnbao@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397457001-5266-1-git-send-email-21cnbao@gmail.com> References: <1397457001-5266-1-git-send-email-21cnbao@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Qipan Li sometimes t->tx can be equal with t->rx. for example, spidev will make tx and rx point to spidev->buffer at the same time. currently, for this case, we map the buffer BIDIRECTION to fix the cache consistency. Signed-off-by: Qipan Li Signed-off-by: Barry Song --- drivers/spi/spi-sirf.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 3c12f39..0c039d4 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c @@ -383,7 +383,8 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) struct dma_async_tx_descriptor *rx_desc, *tx_desc; sspi->dst_start = dma_map_single(&spi->dev, - sspi->rx, t->len, DMA_FROM_DEVICE); + sspi->rx, t->len, (t->tx_buf != t->rx_buf) ? + DMA_FROM_DEVICE : DMA_BIDIRECTIONAL); rx_desc = dmaengine_prep_slave_single(sspi->rx_chan, sspi->dst_start, t->len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -391,7 +392,9 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) rx_desc->callback_param = &sspi->rx_done; sspi->src_start = dma_map_single(&spi->dev, - (void *)sspi->tx, t->len, DMA_TO_DEVICE); + (void *)sspi->tx, t->len, + (t->tx_buf != t->rx_buf) ? + DMA_TO_DEVICE : DMA_BIDIRECTIONAL); tx_desc = dmaengine_prep_slave_single(sspi->tx_chan, sspi->src_start, t->len, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);