Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef ASM_EDAC_H
0003 #define ASM_EDAC_H
0004 
0005 #include <asm/compiler.h>
0006 
0007 /* ECC atomic, DMA, SMP and interrupt safe scrub function */
0008 
0009 static inline void edac_atomic_scrub(void *va, u32 size)
0010 {
0011     unsigned long *virt_addr = va;
0012     unsigned long temp;
0013     u32 i;
0014 
0015     for (i = 0; i < size / sizeof(unsigned long); i++) {
0016         /*
0017          * Very carefully read and write to memory atomically
0018          * so we are interrupt, DMA and SMP safe.
0019          *
0020          * Intel: asm("lock; addl $0, %0"::"m"(*virt_addr));
0021          */
0022 
0023         __asm__ __volatile__ (
0024         "   .set    push                    \n"
0025         "   .set    mips2                   \n"
0026         "1: ll  %0, %1      # edac_atomic_scrub \n"
0027         "   addu    %0, $0                  \n"
0028         "   sc  %0, %1                  \n"
0029         "   beqz    %0, 1b                  \n"
0030         "   .set    pop                 \n"
0031         : "=&r" (temp), "=" GCC_OFF_SMALL_ASM() (*virt_addr)
0032         : GCC_OFF_SMALL_ASM() (*virt_addr));
0033 
0034         virt_addr++;
0035     }
0036 }
0037 
0038 #endif