edac.h 819 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ASM_EDAC_H
  3. #define ASM_EDAC_H
  4. #include <asm/compiler.h>
  5. /* ECC atomic, DMA, SMP and interrupt safe scrub function */
  6. static inline void edac_atomic_scrub(void *va, u32 size)
  7. {
  8. unsigned long *virt_addr = va;
  9. unsigned long temp;
  10. u32 i;
  11. for (i = 0; i < size / sizeof(unsigned long); i++) {
  12. /*
  13. * Very carefully read and write to memory atomically
  14. * so we are interrupt, DMA and SMP safe.
  15. *
  16. * Intel: asm("lock; addl $0, %0"::"m"(*virt_addr));
  17. */
  18. __asm__ __volatile__ (
  19. " .set mips2 \n"
  20. "1: ll %0, %1 # edac_atomic_scrub \n"
  21. " addu %0, $0 \n"
  22. " sc %0, %1 \n"
  23. " beqz %0, 1b \n"
  24. " .set mips0 \n"
  25. : "=&r" (temp), "=" GCC_OFF_SMALL_ASM() (*virt_addr)
  26. : GCC_OFF_SMALL_ASM() (*virt_addr));
  27. virt_addr++;
  28. }
  29. }
  30. #endif