* PATCH: EDAC atomic scrub operations
@ 2005-10-15 18:55 Alan Cox
2005-10-15 19:05 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2005-10-15 18:55 UTC (permalink / raw)
To: akpm, linux-kernel
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 <alan@redhat.com>
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: EDAC atomic scrub operations
2005-10-15 18:55 PATCH: EDAC atomic scrub operations Alan Cox
@ 2005-10-15 19:05 ` Avi Kivity
2005-10-15 19:44 ` Alan Cox
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2005-10-15 19:05 UTC (permalink / raw)
To: Alan Cox; +Cc: akpm, linux-kernel
Alan Cox wrote:
>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++)
>
>
(size+7) / 8? or increment virt_addr by 0.5? :)
>+ /* 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));
>
>
shouldn't that be addq?
>+}
>+
> #endif
>
>
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: EDAC atomic scrub operations
2005-10-15 19:05 ` Avi Kivity
@ 2005-10-15 19:44 ` Alan Cox
0 siblings, 0 replies; 3+ messages in thread
From: Alan Cox @ 2005-10-15 19:44 UTC (permalink / raw)
To: Avi Kivity; +Cc: akpm, linux-kernel
On Sad, 2005-10-15 at 21:05 +0200, Avi Kivity wrote:
> >+static __inline__ void atomic_scrub(unsigned long *virt_addr, u32 size)
> >+{
> >+ u32 i;
> >+ for (i = 0; i < size / 4; i++, virt_addr++)
> >
> >
> (size+7) / 8? or increment virt_addr by 0.5? :)
>
> >+ /* 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));
> >
> >
> shouldn't that be addq?
Should be u32 * for the address used. Well spotted.
Alan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-10-15 19:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-15 18:55 PATCH: EDAC atomic scrub operations Alan Cox
2005-10-15 19:05 ` Avi Kivity
2005-10-15 19:44 ` Alan Cox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.