From patchwork Fri Jan 29 16:10:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 43966 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A30C8B7D25 for ; Sat, 30 Jan 2010 03:14:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755781Ab0A2QNf (ORCPT ); Fri, 29 Jan 2010 11:13:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753919Ab0A2QNe (ORCPT ); Fri, 29 Jan 2010 11:13:34 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:58575 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699Ab0A2QNc (ORCPT ); Fri, 29 Jan 2010 11:13:32 -0500 Received: from cam-owa1.Emea.Arm.com (cam-owa1.emea.arm.com [10.1.255.62]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id o0TGAReI020332; Fri, 29 Jan 2010 16:10:29 GMT Received: from pc1117.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Fri, 29 Jan 2010 16:10:26 +0000 Subject: [PATCH] Call flush_dcache_page around PIO data transfers in libata-aff.c To: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org From: Catalin Marinas Cc: Andrew Morton , Jeff Garzik Date: Fri, 29 Jan 2010 16:10:26 +0000 Message-ID: <20100129160150.22571.28609.stgit@pc1117.cambridge.arm.com> User-Agent: StGit/0.15-36-g53e3 MIME-Version: 1.0 X-OriginalArrivalTime: 29 Jan 2010 16:10:26.0828 (UTC) FILETIME=[91E3DCC0:01CAA0FD] Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Depending on the direction of the transfer, flush_dcache_page() must be called either before (ATA_TFLAG_WRITE) or after (!ATA_TFLAG_WRITE) the data copying to avoid D-cache aliasing with user space or I-D cache coherency issues (when reading data from an ATA device using PIO, the kernel dirties the D-cache but there is no flush_dcache_page() required on Harvard architectures). Signed-off-by: Catalin Marinas Cc: Andrew Morton Cc: Jeff Garzik --- This patch allows the ARM boards to use a rootfs on CompactFlash with the PATA platform driver. As Anfei Zhou mentioned in a recent patch ("flush dcache before writing into page to avoid alias"), on some architectures there may be a performance benefit in differentiating the flush_dcache_page() calls based on whether the kernel or the user page needs flushing. IMHO, we should differentiate based on the direction (kernel reading or writing from/to such page). In the ARM case with PIPT Harvard caches (newer processors), the kernel reading from a page that may be mapped in user space shouldn't need cache flushing. The kernel writing to such page would require D-cache flushing because of coherency with the I-cache. Currently on ARM, the latter happens in both cases. Thanks. drivers/ata/libata-sff.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 741065c..3d3c854 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c @@ -874,6 +874,9 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); + if (do_write) + flush_dcache_page(page); + if (PageHighMem(page)) { unsigned long flags; @@ -893,6 +896,9 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) do_write); } + if (!do_write) + flush_dcache_page(page); + qc->curbytes += qc->sect_size; qc->cursg_ofs += qc->sect_size;