PATCH: EDAC atomic scrub operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Alan

Signed-off-by: Alan Cox <[email protected]>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/drivers/md/kcopyd.c linux-2.6.14-rc2-mm1/drivers/md/kcopyd.c
--- linux.vanilla-2.6.14-rc2-mm1/drivers/md/kcopyd.c	2005-09-22 15:21:40.000000000 +0100
+++ linux-2.6.14-rc2-mm1/drivers/md/kcopyd.c	2005-10-14 18:54:22.000000000 +0100
@@ -8,6 +8,7 @@
  * completion notification.
  */
 
+#include <asm/types.h>
 #include <asm/atomic.h>
 
 #include <linux/blkdev.h>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/drivers/w1/matrox_w1.c linux-2.6.14-rc2-mm1/drivers/w1/matrox_w1.c
--- linux.vanilla-2.6.14-rc2-mm1/drivers/w1/matrox_w1.c	2005-09-22 15:21:55.000000000 +0100
+++ linux-2.6.14-rc2-mm1/drivers/w1/matrox_w1.c	2005-10-14 19:04:55.000000000 +0100
@@ -19,8 +19,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#include <asm/atomic.h>
 #include <asm/types.h>
+#include <asm/atomic.h>
 #include <asm/io.h>
 
 #include <linux/delay.h>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/fs/nfsctl.c linux-2.6.14-rc2-mm1/fs/nfsctl.c
--- linux.vanilla-2.6.14-rc2-mm1/fs/nfsctl.c	2005-09-22 15:22:00.000000000 +0100
+++ linux-2.6.14-rc2-mm1/fs/nfsctl.c	2005-10-14 18:39:22.000000000 +0100
@@ -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>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/include/asm-i386/atomic.h linux-2.6.14-rc2-mm1/include/asm-i386/atomic.h
--- linux.vanilla-2.6.14-rc2-mm1/include/asm-i386/atomic.h	2005-09-22 15:22:55.000000000 +0100
+++ linux-2.6.14-rc2-mm1/include/asm-i386/atomic.h	2005-10-14 18:30:03.000000000 +0100
@@ -237,4 +237,15 @@
 #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));
+}
 #endif
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/include/asm-x86_64/atomic.h linux-2.6.14-rc2-mm1/include/asm-x86_64/atomic.h
--- linux.vanilla-2.6.14-rc2-mm1/include/asm-x86_64/atomic.h	2005-09-22 15:22:11.000000000 +0100
+++ linux-2.6.14-rc2-mm1/include/asm-x86_64/atomic.h	2005-10-14 18:29:47.000000000 +0100
@@ -378,4 +378,16 @@
 #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));
+}
+
 #endif
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/kernel/audit.c linux-2.6.14-rc2-mm1/kernel/audit.c
--- linux.vanilla-2.6.14-rc2-mm1/kernel/audit.c	2005-09-22 15:22:45.000000000 +0100
+++ linux-2.6.14-rc2-mm1/kernel/audit.c	2005-10-14 18:31:38.000000000 +0100
@@ -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>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/kernel/auditsc.c linux-2.6.14-rc2-mm1/kernel/auditsc.c
--- linux.vanilla-2.6.14-rc2-mm1/kernel/auditsc.c	2005-09-22 15:22:45.000000000 +0100
+++ linux-2.6.14-rc2-mm1/kernel/auditsc.c	2005-10-14 18:31:51.000000000 +0100
@@ -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>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.14-rc2-mm1/net/ipv4/raw.c linux-2.6.14-rc2-mm1/net/ipv4/raw.c
--- linux.vanilla-2.6.14-rc2-mm1/net/ipv4/raw.c	2005-09-22 15:22:45.000000000 +0100
+++ linux-2.6.14-rc2-mm1/net/ipv4/raw.c	2005-10-14 19:09:41.000000000 +0100
@@ -40,12 +40,12 @@
  */
  
 #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>




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux