drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Discussed on tech-kern: https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html
This commit is contained in:
parent
0d6840a179
commit
68de6bb2f1
|
@ -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_ */
|
||||
|
|
|
@ -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_struct *tasklet)
|
|||
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 *tasklet)
|
|||
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 *tasklet)
|
|||
* 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 tasklet_struct *tasklet)
|
|||
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 tasklet_struct *tasklet)
|
|||
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 *tasklet)
|
|||
* 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);
|
||||
|
|
|
@ -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 count, void (*release)(struct kref *))
|
|||
{
|
||||
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 count, void (*release)(struct kref *))
|
|||
} 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 (*release)(struct kref *),
|
|||
{
|
||||
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 (*release)(struct kref *),
|
|||
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 (*release)(struct kref *),
|
|||
{
|
||||
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 (*release)(struct kref *),
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue