From patchwork Fri Jan 31 11:54:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 3561371 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C0BABC02DC for ; Fri, 31 Jan 2014 11:54:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4E22201FE for ; Fri, 31 Jan 2014 11:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF96520200 for ; Fri, 31 Jan 2014 11:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932198AbaAaLyt (ORCPT ); Fri, 31 Jan 2014 06:54:49 -0500 Received: from moutng.kundenserver.de ([212.227.17.9]:62880 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbaAaLyt (ORCPT ); Fri, 31 Jan 2014 06:54:49 -0500 Received: from axis700.grange (dslb-146-060-127-137.pools.arcor-ip.net [146.60.127.137]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0Luron-1V9IY824vJ-00zkoI; Fri, 31 Jan 2014 12:54:29 +0100 Received: by axis700.grange (Postfix, from userid 1000) id 25E6340BB4; Fri, 31 Jan 2014 12:54:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 1A96B40BB3; Fri, 31 Jan 2014 12:54:29 +0100 (CET) Date: Fri, 31 Jan 2014 12:54:29 +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 2/3] mmc: sh-mmcif: add DMA SG synchronisation In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:s3W0qYd/K2ZAHm6gMeVMqNqxow522VV6N6CQ/zQ38Ww XeLBDNf45fxlIsbfX0swS8fqyFFAlWqtxsEP79ehye+C3tPysN VNCZCSbRkpxUzwEuG+3VCEgLM4n7yJdMU3Jk0vnLYsspEUDFrr gK7i1LRBoI5Wjg2REVUqGEwi75gsfUo1w/1DosdhSUYEDdhv1U aQCD8u8BhF69c3rG0tcgnayAQwZ8N0uvN9BLcMnpyTHvi93CA0 SX41VBbumR+QvyPdKp5hDEcYKsRUeYMeja8aoTfZfhOvuIiwbl oelUn1oc+wfKiF6SqF0BgLYwb/z2TCXafMRhyLeLt0nYONIKcN ZVJTy4Ciph2IQprYI+i8ZvM26+KTFa+ZEBoA0rlNWEQZnPAbsk cek1gk+GAUYQA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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/sh_mmcif.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index d032b08..902780c 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -345,6 +345,8 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) DMA_TO_DEVICE); if (ret > 0) { host->dma_active = true; + dma_sync_sg_for_device(chan->device->dev, sg, data->sg_len, + DMA_TO_DEVICE); desc = dmaengine_prep_slave_sg(chan, sg, ret, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); } @@ -1118,14 +1120,14 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host) time = wait_for_completion_interruptible_timeout(&host->dma_complete, host->timeout); - if (data->flags & MMC_DATA_READ) - dma_unmap_sg(host->chan_rx->device->dev, - data->sg, data->sg_len, - DMA_FROM_DEVICE); - else - dma_unmap_sg(host->chan_tx->device->dev, - data->sg, data->sg_len, - DMA_TO_DEVICE); + if (data->flags & MMC_DATA_READ) { + struct device *dev = host->chan_rx->device->dev; + dma_unmap_sg(dev, data->sg, data->sg_len, DMA_FROM_DEVICE); + dma_sync_sg_for_cpu(dev, data->sg, data->sg_len, DMA_FROM_DEVICE); + } else { + struct device *dev = host->chan_tx->device->dev; + dma_unmap_sg(dev, data->sg, data->sg_len, DMA_TO_DEVICE); + } if (host->sd_error) { dev_err(host->mmc->parent,