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/linux Linux API wants seqcount exposed...



details:   https://anonhg.NetBSD.org/src/rev/cc3a43f701cd
branches:  trunk
changeset: 1027958:cc3a43f701cd
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:21:37 2021 +0000

description:
Linux API wants seqcount exposed in reservation object, so do that.

diffstat:

 sys/external/bsd/drm2/include/linux/reservation.h |   5 +++--
 sys/external/bsd/drm2/linux/linux_reservation.c   |  23 ++++++++---------------
 2 files changed, 11 insertions(+), 17 deletions(-)

diffs (111 lines):

diff -r 1db4e75c35c6 -r cc3a43f701cd sys/external/bsd/drm2/include/linux/reservation.h
--- a/sys/external/bsd/drm2/include/linux/reservation.h Sun Dec 19 01:21:30 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/reservation.h Sun Dec 19 01:21:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reservation.h,v 1.12 2021/12/19 01:20:53 riastradh Exp $       */
+/*     $NetBSD: reservation.h,v 1.13 2021/12/19 01:21:37 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,12 +34,13 @@
 
 #include <linux/dma-fence.h>
 #include <linux/rcupdate.h>
+#include <linux/seqlock.h>
 #include <linux/ww_mutex.h>
 
 struct reservation_object {
        struct ww_mutex         lock;
+       struct seqcount         count;
 
-       unsigned                                robj_version;
        struct dma_fence __rcu                  *robj_fence;
        struct reservation_object_list __rcu    *robj_list;
        struct reservation_object_list __rcu    *robj_prealloc;
diff -r 1db4e75c35c6 -r cc3a43f701cd sys/external/bsd/drm2/linux/linux_reservation.c
--- a/sys/external/bsd/drm2/linux/linux_reservation.c   Sun Dec 19 01:21:30 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_reservation.c   Sun Dec 19 01:21:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_reservation.c,v 1.17 2021/12/19 01:20:30 riastradh Exp $ */
+/*     $NetBSD: linux_reservation.c,v 1.18 2021/12/19 01:21:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.17 2021/12/19 01:20:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.18 2021/12/19 01:21:38 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/poll.h>
@@ -38,6 +38,7 @@
 
 #include <linux/dma-fence.h>
 #include <linux/reservation.h>
+#include <linux/seqlock.h>
 #include <linux/ww_mutex.h>
 
 DEFINE_WW_CLASS(reservation_ww_class __cacheline_aligned);
@@ -90,7 +91,7 @@
 {
 
        ww_mutex_init(&robj->lock, &reservation_ww_class);
-       robj->robj_version = 0;
+       seqcount_init(&robj->count);
        robj->robj_fence = NULL;
        robj->robj_list = NULL;
        robj->robj_prealloc = NULL;
@@ -289,7 +290,6 @@
 }
 
 struct reservation_object_write_ticket {
-       unsigned version;
 };
 
 /*
@@ -308,8 +308,7 @@
 
        KASSERT(reservation_object_held(robj));
 
-       ticket->version = robj->robj_version |= 1;
-       membar_producer();
+       write_seqcount_begin(&robj->count);
 }
 
 /*
@@ -326,11 +325,8 @@
 {
 
        KASSERT(reservation_object_held(robj));
-       KASSERT(ticket->version == robj->robj_version);
-       KASSERT((ticket->version & 1) == 1);
 
-       membar_producer();
-       robj->robj_version = ticket->version + 1;
+       write_seqcount_end(&robj->count);
 }
 
 struct reservation_object_read_ticket {
@@ -349,9 +345,7 @@
     struct reservation_object_read_ticket *ticket)
 {
 
-       while ((ticket->version = robj->robj_version) & 1)
-               SPINLOCK_BACKOFF_HOOK;
-       membar_consumer();
+       ticket->version = read_seqcount_begin(&robj->count);
 }
 
 /*
@@ -366,8 +360,7 @@
     struct reservation_object_read_ticket *ticket)
 {
 
-       membar_consumer();
-       return ticket->version == robj->robj_version;
+       return !read_seqcount_retry(&robj->count, ticket->version);
 }
 
 /*



Home | Main Index | Thread Index | Old Index