Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/include/linux linux/kref: Fix memory b...



details:   https://anonhg.NetBSD.org/src/rev/e607b36f3507
branches:  trunk
changeset: 365159:e607b36f3507
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 09 23:43:39 2022 +0000

description:
linux/kref: Fix memory barriers and use membar_release/acquire.

diffstat:

 sys/external/bsd/drm2/include/linux/kref.h |  25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diffs (88 lines):

diff -r 18f99e56ca51 -r e607b36f3507 sys/external/bsd/drm2/include/linux/kref.h
--- a/sys/external/bsd/drm2/include/linux/kref.h        Sat Apr 09 23:43:30 2022 +0000
+++ b/sys/external/bsd/drm2/include/linux/kref.h        Sat Apr 09 23:43:39 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kref.h,v 1.12 2021/12/19 11:45:01 riastradh Exp $      */
+/*     $NetBSD: kref.h,v 1.13 2022/04/09 23:43:39 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -58,10 +58,6 @@
            atomic_inc_uint_nv(&kref->kr_count);
 
        KASSERTMSG((count > 1), "getting released kref");
-
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
-       membar_enter();
-#endif
 }
 
 static inline bool
@@ -76,10 +72,6 @@
        } while (atomic_cas_uint(&kref->kr_count, count, (count + 1)) !=
            count);
 
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
-       membar_enter();
-#endif
-
        return true;
 }
 
@@ -89,7 +81,7 @@
        unsigned int old, new;
 
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-       membar_exit();
+       membar_release();
 #endif
 
        do {
@@ -100,6 +92,9 @@
        } 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;
        }
@@ -114,7 +109,7 @@
        unsigned int old, new;
 
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-       membar_exit();
+       membar_release();
 #endif
 
        do {
@@ -123,6 +118,9 @@
                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;
                        }
@@ -149,7 +147,7 @@
        unsigned int old, new;
 
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-       membar_exit();
+       membar_release();
 #endif
 
        do {
@@ -158,6 +156,9 @@
                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;
                        }



Home | Main Index | Thread Index | Old Index