2 * Copyright 2011 Calxeda, Inc.
3 * Based on PPC version Copyright 2007 MontaVista Software, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * ECC atomic, DMA, SMP and interrupt safe scrub function.
21 * Implements the per arch atomic_scrub() that EDAC use for software
22 * ECC scrubbing. It reads memory and then writes back the original
23 * value, allowing the hardware to detect and correct memory errors.
25 static inline void atomic_scrub(void *va
, u32 size
)
27 #if __LINUX_ARM_ARCH__ >= 6
28 unsigned int *virt_addr
= va
;
29 unsigned int temp
, temp2
;
32 for (i
= 0; i
< size
/ sizeof(*virt_addr
); i
++, virt_addr
++) {
33 /* Very carefully read and write to memory atomically
34 * so we are interrupt, DMA and SMP safe.
36 __asm__
__volatile__("\n"
38 " strex %1, %0, [%2]\n"
41 : "=&r"(temp
), "=&r"(temp2
)