From patchwork Mon Dec 8 19:14:26 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Tikhonov X-Patchwork-Id: 12846 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id BBA79474C7 for ; Tue, 9 Dec 2008 06:25:50 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from ocean.emcraft.com (ocean.emcraft.com [213.221.7.182]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7C720DDD0C for ; Tue, 9 Dec 2008 06:24:15 +1100 (EST) Received: from [172.17.0.11] (helo=iron.emcraft.com) by ocean.emcraft.com with esmtp (Exim 4.43) id 1L9liE-0005sB-DU; Mon, 08 Dec 2008 22:24:10 +0300 From: Yuri Tikhonov To: linux-raid@vger.kernel.org Subject: [PATCH] ASYNC_TX: async_xor mapping fix Date: Mon, 8 Dec 2008 22:14:26 +0300 User-Agent: KMail/1.9.4 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200812082214.26811.yur@emcraft.com> Cc: linuxppc-dev@ozlabs.org, Dan Williams , wd@denx.de, dzu@denx.de, Ilya Yanok X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org The destination address may be present in the source list, so we should map the addresses from the source list first. Otherwise, if page corresponding to destination is not marked as write- through (with regards to CPU cache), then mapping it with DMA_FROM_DEVICE may lead to data loss, and finally to an incorrect result of calculations. Signed-off-by: Yuri Tikhonov --- crypto/async_tx/async_xor.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c index 91dbf07..291f517 100644 --- a/crypto/async_tx/async_xor.c +++ b/crypto/async_tx/async_xor.c @@ -53,10 +53,10 @@ do_async_xor(struct dma_chan *chan, struct page *dest, struct page **src_list, int xor_src_cnt; dma_addr_t dma_dest; - dma_dest = dma_map_page(dma->dev, dest, offset, len, DMA_FROM_DEVICE); for (i = 0; i < src_cnt; i++) dma_src[i] = dma_map_page(dma->dev, src_list[i], offset, len, DMA_TO_DEVICE); + dma_dest = dma_map_page(dma->dev, dest, offset, len, DMA_FROM_DEVICE); while (src_cnt) { async_flags = flags;