]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] EDAC: atomic scrub operations
authorAlan Cox <alan@lxorguk.ukuu.org.uk>
Thu, 19 Jan 2006 01:44:07 +0000 (17:44 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 19 Jan 2006 03:20:30 +0000 (19:20 -0800)
EDAC requires a way to scrub memory if an ECC error is found and the chipset
does not do the work automatically.  That means rewriting memory locations
atomically with respect to all CPUs _and_ bus masters.  That means we can't
use atomic_add(foo, 0) as it gets optimised for non-SMP

This adds a function to include/asm-foo/atomic.h for the platforms currently
supported which implements a scrub of a mapped block.

It also adjusts a few other files include order where atomic.h is included
before types.h as this now causes an error as atomic_scrub uses u32.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/md/kcopyd.c
fs/nfsctl.c
include/asm-i386/atomic.h
include/asm-x86_64/atomic.h
kernel/audit.c
kernel/auditsc.c
net/ipv4/raw.c

index ca99979c868acbc38d752f83ee37a5553f12e2e6..8b3515f394a6ef93c115f00073bea02c071707ac 100644 (file)
@@ -8,6 +8,7 @@
  * completion notification.
  */
 
+#include <asm/types.h>
 #include <asm/atomic.h>
 
 #include <linux/blkdev.h>
index 0b14938b5b627ceac85590762fb50ec68f1c872f..0d4cf948606866f71d1807883da0afbf35968668 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 #include <linux/config.h>
+#include <linux/types.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/sunrpc/svc.h>
index de649d3aa2d45d630874634c11f732e5e4819491..e2c00c95a5e130b5bc16249a76c8e82d82ff0cb6 100644 (file)
@@ -255,5 +255,17 @@ __asm__ __volatile__(LOCK "orl %0,%1" \
 #define smp_mb__before_atomic_inc()    barrier()
 #define smp_mb__after_atomic_inc()     barrier()
 
+/* ECC atomic, DMA, SMP and interrupt safe scrub function */
+
+static __inline__ void atomic_scrub(unsigned long *virt_addr, u32 size)
+{
+       u32 i;
+       for (i = 0; i < size / 4; i++, virt_addr++)
+               /* Very carefully read and write to memory atomically
+                * so we are interrupt, DMA and SMP safe.
+                */
+               __asm__ __volatile__("lock; addl $0, %0"::"m"(*virt_addr));
+}
+
 #include <asm-generic/atomic.h>
 #endif
index 4b5cd553e772637d157b0af95edbd89d7e12eb1a..4048508c4f407fbd7bdd5129974a101014d24265 100644 (file)
@@ -426,5 +426,17 @@ __asm__ __volatile__(LOCK "orl %0,%1" \
 #define smp_mb__before_atomic_inc()    barrier()
 #define smp_mb__after_atomic_inc()     barrier()
 
+/* ECC atomic, DMA, SMP and interrupt safe scrub function */
+
+static __inline__ void atomic_scrub(u32 *virt_addr, u32 size)
+{
+       u32 i;
+       for (i = 0; i < size / 4; i++, virt_addr++)
+               /* Very carefully read and write to memory atomically
+                * so we are interrupt, DMA and SMP safe.
+                */
+               __asm__ __volatile__("lock; addl $0, %0"::"m"(*virt_addr));
+}
+
 #include <asm-generic/atomic.h>
 #endif
index d13ab7d2d8994f38fb9bf422d873152fd4417057..0a813d2883e58089563bd0d266a99e5c029ece3b 100644 (file)
@@ -42,8 +42,8 @@
  */
 
 #include <linux/init.h>
-#include <asm/atomic.h>
 #include <asm/types.h>
+#include <asm/atomic.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/err.h>
index d8a68509e7299df13233c98134c9431e994faa41..685c25175d96374a601d33460dae6e7a35ff0f07 100644 (file)
@@ -30,8 +30,8 @@
  */
 
 #include <linux/init.h>
-#include <asm/atomic.h>
 #include <asm/types.h>
+#include <asm/atomic.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/mount.h>
index 165a4d81efa4a75663e72e12d3cfa12eddb9f969..f29a12da5109d91a9a9dfebd318c2b1aa5a63b94 100644 (file)
  */
  
 #include <linux/config.h> 
+#include <linux/types.h>
 #include <asm/atomic.h>
 #include <asm/byteorder.h>
 #include <asm/current.h>
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
-#include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/slab.h>
 #include <linux/errno.h>