]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
39c29657 DT |
2 | #ifndef ASM_EDAC_H |
3 | #define ASM_EDAC_H | |
4 | ||
b0984c43 MR |
5 | #include <asm/compiler.h> |
6 | ||
39c29657 DT |
7 | /* ECC atomic, DMA, SMP and interrupt safe scrub function */ |
8 | ||
b01aec9b | 9 | static inline void edac_atomic_scrub(void *va, u32 size) |
39c29657 DT |
10 | { |
11 | unsigned long *virt_addr = va; | |
12 | unsigned long temp; | |
13 | u32 i; | |
14 | ||
1bfa771e | 15 | for (i = 0; i < size / sizeof(unsigned long); i++) { |
39c29657 DT |
16 | /* |
17 | * Very carefully read and write to memory atomically | |
18 | * so we are interrupt, DMA and SMP safe. | |
19 | * | |
20 | * Intel: asm("lock; addl $0, %0"::"m"(*virt_addr)); | |
21 | */ | |
22 | ||
23 | __asm__ __volatile__ ( | |
378ed6f0 | 24 | " .set push \n" |
1bfa771e | 25 | " .set mips2 \n" |
b01aec9b | 26 | "1: ll %0, %1 # edac_atomic_scrub \n" |
1bfa771e RB |
27 | " addu %0, $0 \n" |
28 | " sc %0, %1 \n" | |
29 | " beqz %0, 1b \n" | |
378ed6f0 | 30 | " .set pop \n" |
94bfb75a MC |
31 | : "=&r" (temp), "=" GCC_OFF_SMALL_ASM() (*virt_addr) |
32 | : GCC_OFF_SMALL_ASM() (*virt_addr)); | |
39c29657 | 33 | |
1bfa771e | 34 | virt_addr++; |
39c29657 DT |
35 | } |
36 | } | |
37 | ||
38 | #endif |