From dda20596b57c71620d3bc72eab55cb4c35118cdd Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 31 Mar 2022 02:17:23 +0000 Subject: [PATCH 28/49] linux/ratelimit: Convert to membar_acquire and atomic_store_release. Simplify while here: atomic_swap is enough, no need for atomic_cas. (Maybe drm'll run faster on sparcv8 this way...!) --- sys/external/bsd/drm2/include/linux/ratelimit.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/external/bsd/drm2/include/linux/ratelimit.h b/sys/external/bsd/drm2/include/linux/ratelimit.h index 4628f71ec472..cd9a617d9310 100644 --- a/sys/external/bsd/drm2/include/linux/ratelimit.h +++ b/sys/external/bsd/drm2/include/linux/ratelimit.h @@ -86,14 +86,13 @@ __ratelimit(struct ratelimit_state *r) { int ok; - if (atomic_cas_uint(&r->rl_lock, 0, 1)) { + if (atomic_swap_uint(&r->rl_lock, 1)) { ok = false; goto out; } - membar_enter(); + membar_acquire(); ok = ppsratecheck(&r->rl_lasttime, &r->rl_curpps, r->rl_maxpps); - membar_exit(); - r->rl_lock = 0; + atomic_store_release(&r->rl_lock, 0); out: if (!ok) atomic_store_relaxed(&r->missed, 1);