From patchwork Tue Feb 2 22:11:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 44312 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 E30DAB7D5E for ; Wed, 3 Feb 2010 09:13:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757007Ab0BBWNS (ORCPT ); Tue, 2 Feb 2010 17:13:18 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:47479 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756995Ab0BBWNR (ORCPT ); Tue, 2 Feb 2010 17:13:17 -0500 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id o12MB9s3008602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Feb 2010 14:11:10 -0800 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id o12MB8cJ017441; Tue, 2 Feb 2010 14:11:09 -0800 Message-Id: <201002022211.o12MB8cJ017441@imap1.linux-foundation.org> Subject: [patch for 2.6.33? 1/1] ata: call flush_dcache_page() around PIO data transfers in libata-aff.c To: jeff@garzik.org Cc: linux-ide@vger.kernel.org, akpm@linux-foundation.org, catalin.marinas@arm.com, jgarzik@pobox.com, stable@kernel.org, tj@kernel.org From: akpm@linux-foundation.org Date: Tue, 02 Feb 2010 14:11:08 -0800 MIME-Version: 1.0 X-Spam-Status: No, hits=-3.518 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Catalin Marinas 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). 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. Signed-off-by: Catalin Marinas Cc: Jeff Garzik Cc: Tejun Heo Cc: Signed-off-by: Andrew Morton --- drivers/ata/libata-sff.c | 6 ++++++ 1 file changed, 6 insertions(+) diff -puN drivers/ata/libata-sff.c~ata-call-flush_dcache_page-around-pio-data-transfers-in-libata-affc drivers/ata/libata-sff.c --- a/drivers/ata/libata-sff.c~ata-call-flush_dcache_page-around-pio-data-transfers-in-libata-affc +++ a/drivers/ata/libata-sff.c @@ -874,6 +874,9 @@ static void ata_pio_sector(struct ata_qu 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_qu do_write); } + if (!do_write) + flush_dcache_page(page); + qc->curbytes += qc->sect_size; qc->cursg_ofs += qc->sect_size;