18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_EDAC_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_EDAC_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/* ECC atomic, DMA, SMP and interrupt safe scrub function */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cistatic inline void edac_atomic_scrub(void *va, u32 size)
88c2ecf20Sopenharmony_ci{
98c2ecf20Sopenharmony_ci	u32 i, *virt_addr = va;
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci	/*
128c2ecf20Sopenharmony_ci	 * Very carefully read and write to memory atomically so we
138c2ecf20Sopenharmony_ci	 * are interrupt, DMA and SMP safe.
148c2ecf20Sopenharmony_ci	 */
158c2ecf20Sopenharmony_ci	for (i = 0; i < size / 4; i++, virt_addr++)
168c2ecf20Sopenharmony_ci		asm volatile("lock; addl $0, %0"::"m" (*virt_addr));
178c2ecf20Sopenharmony_ci}
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#endif /* _ASM_X86_EDAC_H */
20