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 Insert membars needed fo...



details:   https://anonhg.NetBSD.org/src/rev/ae54919d86ea
branches:  trunk
changeset: 992889:ae54919d86ea
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 13:44:41 2018 +0000

description:
Insert membars needed for non-x86.

XXX We should really define membar_enter_postatomic and
membar_exit_preatomic to avoid relying on not typoing
__HAVE_ATOMIC_AS_MEMBAR.

diffstat:

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

diffs (61 lines):

diff -r 5cac1ac4bf05 -r ae54919d86ea sys/external/bsd/drm2/include/linux/kref.h
--- a/sys/external/bsd/drm2/include/linux/kref.h        Mon Aug 27 13:44:29 2018 +0000
+++ b/sys/external/bsd/drm2/include/linux/kref.h        Mon Aug 27 13:44:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kref.h,v 1.6 2018/08/27 06:51:52 riastradh Exp $       */
+/*     $NetBSD: kref.h,v 1.7 2018/08/27 13:44:41 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
 #include <sys/atomic.h>
 #include <sys/systm.h>
 
+#include <linux/atomic.h>
 #include <linux/mutex.h>
 
 struct kref {
@@ -55,6 +56,10 @@
            atomic_inc_uint_nv(&kref->kr_count);
 
        KASSERTMSG((count > 1), "getting released kref");
+
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+       membar_enter();
+#endif
 }
 
 static inline bool
@@ -69,6 +74,10 @@
        } while (atomic_cas_uint(&kref->kr_count, count, (count + 1)) !=
            count);
 
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+       membar_enter();
+#endif
+
        return true;
 }
 
@@ -77,6 +86,10 @@
 {
        unsigned int old, new;
 
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+       membar_exit();
+#endif
+
        do {
                old = kref->kr_count;
                KASSERTMSG((count <= old), "overreleasing kref: %u - %u",
@@ -105,6 +118,10 @@
 {
        unsigned int old, new;
 
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+       membar_exit();
+#endif
+
        do {
                old = kref->kr_count;
                KASSERT(old > 0);



Home | Main Index | Thread Index | Old Index