linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/2] fix and improvement of flush(_kernel)_dcache_page()
@ 2012-10-07 11:29 Simon Baatz
  2012-10-07 11:29 ` [PATCH V2 1/2] ARM: remove unnecessary flush of anon pages in flush_dcache_page() Simon Baatz
  2012-10-07 11:29 ` [PATCH V3 2/2] ARM: Handle user space mapped pages in flush_kernel_dcache_page Simon Baatz
  0 siblings, 2 replies; 35+ messages in thread
From: Simon Baatz @ 2012-10-07 11:29 UTC (permalink / raw)
  To: linux-arm-kernel

The first patch optimizes flush_dcache_page() for non-aliasing VIPT
caches.  On these the flush of the kernel mapping for the anon case is
actually not needed.  It may be needed to ensure I/D coherency, but
this can be handled by __sync_icache_dcache() later and more
effectively (similar to arm64, see [3]).  Thus, we should be lazy as
well here and just clear the PG_dcache_clean bit.

The second patch is another attempt to fix the regression caused by
patch f8b63c1 "ARM: 6382/1" in 2.6.37 (see [2]).  The problem occurs
on VIVT (and probably VIPT aliasing) cache architectures for drivers
that use flush_kernel_dcache_page().  For example, 3.6 (as any
kernel beginning with 2.6.37) on kirkwood using mv_cesa produces data
corruption when using direct I/O:

~# cryptsetup luksOpen /dev/sda2 c_sda2
Enter passphrase for /dev/sda2: 
~# dd if=/dev/mapper/c_sda2 iflag=direct bs=4k count=16 2>/dev/null | sha1sum 
9ae4997ec85ad9b7ab4b10341e42ace80f0ea5d6  -
~# dd if=/dev/mapper/c_sda2 bs=4k count=16 2>/dev/null | sha1sum
ca39c5d4950b3704eff952c48e383bf1db20532e  -

(The mv_cesa driver uses the scatterlist memory iterator, which uses
flush_kernel_dcache_page() before kunmap()).

As described in [1], both flush_dcache_page() and
flush_kernel_dcache_page() need to handle the following cases:
- page cache pages with no user space mapping
- page cache pages with user space mapping(s)
- flush the kernel mapping of anonymous pages

The last one is contradictory to documentation for flush_dcache_page(),
but many uses in the kernel require it (drivers use it to flush
modifications via the kernel mapping).

In the proposed patch the implementation of flush_kernel_dcache_page()
follows the one of flush_dcache_page(), but only flushes the kernel
mapping, not the alias user mapping(s).

I could only test this on kirkwood (ARMv5, VIVT) and raspberry pi
BCM2835 (ARMv6, PIPT / VIPT nonaliasing data cache).  More testing
would probably be a good thing...  Especially, I could not test the
non-aliasing cache case with a real driver using
flush_kernel_dcache_page() (mv_cesa on dove could be a test case for
this).


Changes:

in V2:
- Followed Catalin's suggestion to reverse the order of the patches
- Clarified comment for flush_dcache_page()


- Simon

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2012-August/113908.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2012-May/101795.html
[3] https://lkml.org/lkml/2012/9/12/121



Simon Baatz (2):
  ARM: remove unnecessary flush of anon pages in flush_dcache_page()
  ARM: Handle user space mapped pages in flush_kernel_dcache_page

 arch/arm/include/asm/cacheflush.h |    4 ++
 arch/arm/mm/flush.c               |   87 +++++++++++++++++++++++++++++--------
 2 files changed, 72 insertions(+), 19 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2013-05-13  3:12 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-07 11:29 [PATCH V2 0/2] fix and improvement of flush(_kernel)_dcache_page() Simon Baatz
2012-10-07 11:29 ` [PATCH V2 1/2] ARM: remove unnecessary flush of anon pages in flush_dcache_page() Simon Baatz
2012-10-08 11:36   ` Catalin Marinas
2012-10-08 17:38     ` Simon Baatz
2012-10-08 17:43       ` Catalin Marinas
2012-10-07 11:29 ` [PATCH V3 2/2] ARM: Handle user space mapped pages in flush_kernel_dcache_page Simon Baatz
2012-10-08 17:44   ` Catalin Marinas
2012-10-08 20:02     ` Simon Baatz
2012-10-08 20:20       ` Russell King - ARM Linux
2012-10-08 23:07         ` Simon Baatz
2012-11-18 21:10           ` Jason Cooper
2013-04-18 11:16             ` Jason Cooper
2013-04-18 11:22               ` Russell King - ARM Linux
2013-04-18 11:40                 ` Jason Cooper
2013-04-18 13:51                   ` Catalin Marinas
2013-04-21 22:06                     ` Simon Baatz
2013-04-30 11:22                       ` Catalin Marinas
2013-04-30 21:04                         ` Simon Baatz
2013-05-01 14:22                           ` Catalin Marinas
2013-05-01 19:04                             ` Simon Baatz
2013-05-02  9:54                               ` Catalin Marinas
2013-05-02 19:38                                 ` Simon Baatz
2013-05-03 10:02                                   ` Catalin Marinas
2013-05-04  8:21                                     ` Ming Lei
2013-05-08 15:08                                       ` Catalin Marinas
2013-05-08 18:43                                         ` Russell King - ARM Linux
2013-05-08 19:31                                           ` Simon Baatz
2013-05-08 21:13                                             ` Catalin Marinas
2013-05-09  1:52                                         ` Ming Lei
2013-05-11  6:27                                       ` Simon Baatz
2013-05-13  3:12                                         ` Ming Lei
2013-05-05 22:26                                     ` Simon Baatz
2013-05-08 15:28                                       ` Catalin Marinas
2013-04-18 19:39                   ` Simon Baatz
2013-04-18 19:00                 ` Simon Baatz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).