Module Name: src Committed By: riastradh Date: Fri Feb 24 11:02:06 UTC 2023
Modified Files: src/sys/external/bsd/common/include/asm: barrier.h src/sys/external/bsd/common/linux: linux_tasklet.c src/sys/external/bsd/drm2/include/linux: kref.h Log Message: drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals. Discussed on tech-kern: https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/external/bsd/common/include/asm/barrier.h cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/common/linux/linux_tasklet.c cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/kref.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/common/include/asm/barrier.h diff -u src/sys/external/bsd/common/include/asm/barrier.h:1.19 src/sys/external/bsd/common/include/asm/barrier.h:1.20 --- src/sys/external/bsd/common/include/asm/barrier.h:1.19 Tue Jul 19 21:30:40 2022 +++ src/sys/external/bsd/common/include/asm/barrier.h Fri Feb 24 11:02:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: barrier.h,v 1.19 2022/07/19 21:30:40 riastradh Exp $ */ +/* $NetBSD: barrier.h,v 1.20 2023/02/24 11:02:05 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -100,18 +100,14 @@ # define smp_mb membar_sync # define smp_wmb membar_producer # define smp_rmb membar_consumer +# define smp_mb__before_atomic membar_release +# define smp_mb__after_atomic membar_acquire #else # define smp_mb() __insn_barrier() # define smp_wmb() __insn_barrier() # define smp_rmb() __insn_barrier() -#endif - -#if defined(MULTIPROCESSOR) && !defined(__HAVE_ATOMIC_AS_MEMBAR) -# define smp_mb__before_atomic() membar_release() -# define smp_mb__after_atomic() membar_acquire() -#else -# define smp_mb__before_atomic() __insn_barrier() -# define smp_mb__after_atomic() __insn_barrier() +# define smp_mb__before_atomic __nothing +# define smp_mb__after_atomic __nothing #endif #endif /* _ASM_BARRIER_H_ */ Index: src/sys/external/bsd/common/linux/linux_tasklet.c diff -u src/sys/external/bsd/common/linux/linux_tasklet.c:1.11 src/sys/external/bsd/common/linux/linux_tasklet.c:1.12 --- src/sys/external/bsd/common/linux/linux_tasklet.c:1.11 Sat Apr 9 23:43:31 2022 +++ src/sys/external/bsd/common/linux/linux_tasklet.c Fri Feb 24 11:02:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_tasklet.c,v 1.11 2022/04/09 23:43:31 riastradh Exp $ */ +/* $NetBSD: linux_tasklet.c,v 1.12 2023/02/24 11:02:05 riastradh Exp $ */ /*- * Copyright (c) 2018, 2020, 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_tasklet.c,v 1.11 2022/04/09 23:43:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_tasklet.c,v 1.12 2023/02/24 11:02:05 riastradh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -395,9 +395,7 @@ tasklet_disable_nosync(struct tasklet_st KASSERT(disablecount != 0); /* Pairs with membar_release in __tasklet_enable. */ -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_acquire(); -#endif } /* @@ -515,9 +513,7 @@ tasklet_trylock(struct tasklet_struct *t state | TASKLET_RUNNING) != state); /* Pairs with membar_release in tasklet_unlock. */ -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_acquire(); -#endif return true; } @@ -539,9 +535,7 @@ tasklet_unlock(struct tasklet_struct *ta * Pairs with membar_acquire in tasklet_trylock and with * atomic_load_acquire in tasklet_unlock_wait. */ -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_release(); -#endif atomic_and_uint(&tasklet->tl_state, ~TASKLET_RUNNING); } @@ -590,9 +584,7 @@ __tasklet_disable_sync_once(struct taskl KASSERT(disablecount != 0); /* Pairs with membar_release in __tasklet_enable_sync_once. */ -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_acquire(); -#endif /* * If it was zero, wait for it to finish running. If it was @@ -614,9 +606,7 @@ __tasklet_enable_sync_once(struct taskle unsigned int disablecount; /* Pairs with membar_acquire in __tasklet_disable_sync_once. */ -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_release(); -#endif /* Decrement the disable count. */ disablecount = atomic_dec_uint_nv(&tasklet->tl_disablecount); @@ -683,9 +673,7 @@ __tasklet_enable(struct tasklet_struct * * Pairs with atomic_load_acquire in tasklet_softintr and with * membar_acquire in tasklet_disable. */ -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_release(); -#endif /* Decrement the disable count. */ disablecount = atomic_dec_uint_nv(&tasklet->tl_disablecount); Index: src/sys/external/bsd/drm2/include/linux/kref.h diff -u src/sys/external/bsd/drm2/include/linux/kref.h:1.13 src/sys/external/bsd/drm2/include/linux/kref.h:1.14 --- src/sys/external/bsd/drm2/include/linux/kref.h:1.13 Sat Apr 9 23:43:39 2022 +++ src/sys/external/bsd/drm2/include/linux/kref.h Fri Feb 24 11:02:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kref.h,v 1.13 2022/04/09 23:43:39 riastradh Exp $ */ +/* $NetBSD: kref.h,v 1.14 2023/02/24 11:02:06 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -80,9 +80,7 @@ kref_sub(struct kref *kref, unsigned int { unsigned int old, new; -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_release(); -#endif do { old = atomic_load_relaxed(&kref->kr_count); @@ -92,9 +90,7 @@ kref_sub(struct kref *kref, unsigned int } while (atomic_cas_uint(&kref->kr_count, old, new) != old); if (new == 0) { -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_acquire(); -#endif (*release)(kref); return 1; } @@ -108,9 +104,7 @@ kref_put_lock(struct kref *kref, void (* { unsigned int old, new; -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_release(); -#endif do { old = atomic_load_relaxed(&kref->kr_count); @@ -118,9 +112,7 @@ kref_put_lock(struct kref *kref, void (* if (old == 1) { spin_lock(interlock); if (atomic_add_int_nv(&kref->kr_count, -1) == 0) { -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_acquire(); -#endif (*release)(kref); return 1; } @@ -146,9 +138,7 @@ kref_put_mutex(struct kref *kref, void ( { unsigned int old, new; -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_release(); -#endif do { old = atomic_load_relaxed(&kref->kr_count); @@ -156,9 +146,7 @@ kref_put_mutex(struct kref *kref, void ( if (old == 1) { mutex_lock(interlock); if (atomic_add_int_nv(&kref->kr_count, -1) == 0) { -#ifndef __HAVE_ATOMIC_AS_MEMBAR membar_acquire(); -#endif (*release)(kref); return 1; }