From patchwork Fri Jan 31 11:54:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 3561341 Return-Path: X-Original-To: patchwork-linux-sh@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 341559F382 for ; Fri, 31 Jan 2014 11:54:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54C8F2020E for ; Fri, 31 Jan 2014 11:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77F07201FE for ; Fri, 31 Jan 2014 11:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932198AbaAaLyY (ORCPT ); Fri, 31 Jan 2014 06:54:24 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:57099 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbaAaLyX (ORCPT ); Fri, 31 Jan 2014 06:54:23 -0500 Received: from axis700.grange (dslb-146-060-127-137.pools.arcor-ip.net [146.60.127.137]) by mrelayeu.kundenserver.de (node=mreue003) with ESMTP (Nemesis) id 0MT3vW-1VjS2s0RWw-00S4vj; Fri, 31 Jan 2014 12:54:20 +0100 Received: by axis700.grange (Postfix, from userid 1000) id B4B7240BB4; Fri, 31 Jan 2014 12:54:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id A9BFC40BB3; Fri, 31 Jan 2014 12:54:19 +0100 (CET) Date: Fri, 31 Jan 2014 12:54:19 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-mmc@vger.kernel.org cc: Chris Ball , linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:TlA5tatc28bNAwygwQtBbHxHpuD4/7i7zj7lYbgdXD8 G8ugPSw6xLs8gD4DltD1DkeGlkISGUWJU0yRA4Xz8Qa5yaX3lq m5PzFjoK41sdhTEIgDAK1ZHhaxb/yv9GISERAe02xCpuQgZItJ XU6JGVkPXJZrjCWKZYa/qRbL4JLgJH7w2OJL33Na4sWH9CsjVE hIigA1LJ/elmxLHswizFFRSADFmt6D+zFXk7jbj5SIg4bNbpkP VR8tnBlAIQXvJZ263UeNOKaa5d+lsL+VD5xB54A7/Iect26UW+ aHfUxI/ISlcId2YRzaimdEaOdChM74SKsCudn9xVu5RfUpBnVk eFocnklKL1o8IT+1j3q2kNwi5Zb+4DY/L/7jl8WP8Ms93t9Guz CCvMLK++NS5ew== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 According to the DMA API data has to be synchronised before starting a DMA transfer to device and after completing a DMA transfer from device. Signed-off-by: Guennadi Liakhovetski Acked-by: Simon Horman --- drivers/mmc/host/tmio_mmc_dma.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c index 65edb4a..a997b94 100644 --- a/drivers/mmc/host/tmio_mmc_dma.c +++ b/drivers/mmc/host/tmio_mmc_dma.c @@ -168,9 +168,12 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host) } ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE); - if (ret > 0) + if (ret > 0) { + dma_sync_sg_for_device(chan->device->dev, sg, host->sg_len, + DMA_TO_DEVICE); desc = dmaengine_prep_slave_sg(chan, sg, ret, DMA_MEM_TO_DEV, DMA_CTRL_ACK); + } if (desc) { cookie = dmaengine_submit(desc); @@ -247,14 +250,14 @@ static void tmio_mmc_tasklet_fn(unsigned long arg) if (!host->data) goto out; - if (host->data->flags & MMC_DATA_READ) - dma_unmap_sg(host->chan_rx->device->dev, - host->sg_ptr, host->sg_len, - DMA_FROM_DEVICE); - else - dma_unmap_sg(host->chan_tx->device->dev, - host->sg_ptr, host->sg_len, - DMA_TO_DEVICE); + if (host->data->flags & MMC_DATA_READ) { + struct device *dev = host->chan_rx->device->dev; + dma_unmap_sg(dev, host->sg_ptr, host->sg_len, DMA_FROM_DEVICE); + dma_sync_sg_for_cpu(dev, host->sg_ptr, host->sg_len, DMA_FROM_DEVICE); + } else { + struct device *dev = host->chan_tx->device->dev; + dma_unmap_sg(dev, host->sg_ptr, host->sg_len, DMA_TO_DEVICE); + } tmio_mmc_do_data_irq(host); out: