From 37f48d5abae83362d0df5c6ccbd6076e4d470b8d Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 21 Dec 2017 23:39:00 +0000 Subject: [PATCH] Fix mips build after introduction of MD definitions of atomic_load_64 and atomic_store_64. The MD definitions are provided for LP64 only, while mips also uses them for 32bit and n32. Only define mips variants for 32bit and n32 and change the syntax to match common definitions. Note that this commit does not fix 32bit asm implementation to follow new KBI, this will be fixed later. The functions are only used for 8 byte ddb accesses so the known bug does not prevent normal kernel operations. Sponsored by: The FreeBSD Foundation --- sys/mips/include/atomic.h | 17 +++++++++-------- sys/mips/mips/db_interface.c | 12 ++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/sys/mips/include/atomic.h b/sys/mips/include/atomic.h index 668d311d24a..9838a6953ac 100644 --- a/sys/mips/include/atomic.h +++ b/sys/mips/include/atomic.h @@ -342,20 +342,21 @@ atomic_store_rel_##WIDTH(__volatile uint##WIDTH##_t *p, uint##WIDTH##_t v)\ ATOMIC_STORE_LOAD(32) ATOMIC_STORE_LOAD(64) #if !defined(__mips_n64) && !defined(__mips_n32) -void atomic_store_64(__volatile uint64_t *, uint64_t *); -void atomic_load_64(__volatile uint64_t *, uint64_t *); -#else +void atomic_store_64(__volatile uint64_t *, uint64_t); +uint64_t atomic_load_64(__volatile uint64_t *); +#elif defined (__mips_n32) static __inline void -atomic_store_64(__volatile uint64_t *p, uint64_t *v) +atomic_store_64(__volatile uint64_t *p, uint64_t v) { - *p = *v; + *p = v; } -static __inline void -atomic_load_64(__volatile uint64_t *p, uint64_t *v) +static __inline uint64_t +atomic_load_64(__volatile uint64_t *p) { - *v = *p; + return (*p); } +/* #else atomic_common.h definitions of atomic_load/store_64 are used */ #endif #undef ATOMIC_STORE_LOAD diff --git a/sys/mips/mips/db_interface.c b/sys/mips/mips/db_interface.c index 9a7f346d95f..3426bf48a00 100644 --- a/sys/mips/mips/db_interface.c +++ b/sys/mips/mips/db_interface.c @@ -164,9 +164,9 @@ db_read_bytes(vm_offset_t addr, size_t size, char *data) *(uint32_t *)data = *(uint32_t *)addr; break; case 8: - atomic_load_64((volatile u_int64_t *)addr, - (u_int64_t *)data); - break; + *(uint64_t *)data = atomic_load_64( + (void *)addr); + break; } } else { char *src; @@ -207,9 +207,9 @@ db_write_bytes(vm_offset_t addr, size_t size, char *data) *(uint32_t *)addr = *(uint32_t *)data; break; case 8: - atomic_store_64((volatile u_int64_t *)addr, - (u_int64_t *)data); - break; + atomic_store_64((uint64_t *)addr, + *(uint64_t *)data); + break; } } else { char *dst;