/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright 2011 Calxeda, Inc.3* Based on PPC version Copyright 2007 MontaVista Software, Inc.4*/5#ifndef ASM_EDAC_H6#define ASM_EDAC_H7/*8* ECC atomic, DMA, SMP and interrupt safe scrub function.9* Implements the per arch edac_atomic_scrub() that EDAC use for software10* ECC scrubbing. It reads memory and then writes back the original11* value, allowing the hardware to detect and correct memory errors.12*/1314static inline void edac_atomic_scrub(void *va, u32 size)15{16#if __LINUX_ARM_ARCH__ >= 617unsigned int *virt_addr = va;18unsigned int temp, temp2;19unsigned int i;2021for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {22/* Very carefully read and write to memory atomically23* so we are interrupt, DMA and SMP safe.24*/25__asm__ __volatile__("\n"26"1: ldrex %0, [%2]\n"27" strex %1, %0, [%2]\n"28" teq %1, #0\n"29" bne 1b\n"30: "=&r"(temp), "=&r"(temp2)31: "r"(virt_addr)32: "cc");33}34#endif35}3637#endif383940