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 Implement dma_resv_locking_ctx m...



details:   https://anonhg.NetBSD.org/src/rev/75f833004f06
branches:  trunk
changeset: 1028323:75f833004f06
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 10:38:14 2021 +0000

description:
Implement dma_resv_locking_ctx more carefully.

diffstat:

 sys/external/bsd/drm2/include/linux/dma-resv.h |  11 +++------
 sys/external/bsd/drm2/include/linux/ww_mutex.h |   6 ++++-
 sys/external/bsd/drm2/linux/linux_dma_resv.c   |  18 ++++++++++++++-
 sys/external/bsd/drm2/linux/linux_ww_mutex.c   |  28 ++++++++++++++++++++++++-
 4 files changed, 51 insertions(+), 12 deletions(-)

diffs (147 lines):

diff -r ea2b1ce5ab9e -r 75f833004f06 sys/external/bsd/drm2/include/linux/dma-resv.h
--- a/sys/external/bsd/drm2/include/linux/dma-resv.h    Sun Dec 19 10:38:05 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/dma-resv.h    Sun Dec 19 10:38:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dma-resv.h,v 1.8 2021/12/19 10:37:56 riastradh Exp $   */
+/*     $NetBSD: dma-resv.h,v 1.9 2021/12/19 10:38:14 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -79,6 +79,7 @@
 #define        dma_resv_lock_interruptible     linux_dma_resv_lock_interruptible
 #define        dma_resv_lock_slow              linux_dma_resv_lock_slow
 #define        dma_resv_lock_slow_interruptible linux_dma_resv_lock_slow_interruptible
+#define        dma_resv_locking_ctx            linux_dma_resv_locking_ctx
 #define        dma_resv_reserve_shared         linux_dma_resv_reserve_shared
 #define        dma_resv_test_signaled_rcu      linux_dma_resv_test_signaled_rcu
 #define        dma_resv_trylock                linux_dma_resv_trylock
@@ -101,6 +102,8 @@
 int    dma_resv_lock_slow_interruptible(struct dma_resv *,
            struct ww_acquire_ctx *);
 bool   dma_resv_trylock(struct dma_resv *) __must_check;
+struct ww_acquire_ctx *
+       dma_resv_locking_ctx(struct dma_resv *);
 void   dma_resv_unlock(struct dma_resv *);
 bool   dma_resv_held(struct dma_resv *);
 void   dma_resv_assert_held(struct dma_resv *);
@@ -141,10 +144,4 @@
        return robj->fence_excl != NULL;
 }
 
-static inline struct ww_acquire_ctx *
-dma_resv_locking_ctx(struct dma_resv *robj)
-{
-       return robj->lock.wwm_u.ctx;
-}
-
 #endif /* _LINUX_DMA_RESV_H_ */
diff -r ea2b1ce5ab9e -r 75f833004f06 sys/external/bsd/drm2/include/linux/ww_mutex.h
--- a/sys/external/bsd/drm2/include/linux/ww_mutex.h    Sun Dec 19 10:38:05 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/ww_mutex.h    Sun Dec 19 10:38:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ww_mutex.h,v 1.13 2018/08/27 15:11:32 riastradh Exp $  */
+/*     $NetBSD: ww_mutex.h,v 1.14 2021/12/19 10:38:14 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -93,6 +93,7 @@
 #define        ww_mutex_lock_interruptible linux_ww_mutex_lock_interruptible
 #define        ww_mutex_lock_slow      linux_ww_mutex_lock_slow
 #define        ww_mutex_lock_slow_interruptible linux_ww_mutex_lock_slow_interruptible
+#define        ww_mutex_locking_ctx    linux_ww_mutex_locking_ctx
 #define        ww_mutex_trylock        linux_ww_mutex_trylock
 #define        ww_mutex_unlock         linux_ww_mutex_unlock
 
@@ -119,4 +120,7 @@
 int    ww_mutex_trylock(struct ww_mutex *);
 void   ww_mutex_unlock(struct ww_mutex *);
 
+struct ww_acquire_ctx *
+       ww_mutex_locking_ctx(struct ww_mutex *);
+
 #endif  /* _ASM_WW_MUTEX_H_ */
diff -r ea2b1ce5ab9e -r 75f833004f06 sys/external/bsd/drm2/linux/linux_dma_resv.c
--- a/sys/external/bsd/drm2/linux/linux_dma_resv.c      Sun Dec 19 10:38:05 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_dma_resv.c      Sun Dec 19 10:38:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_dma_resv.c,v 1.3 2021/12/19 10:37:47 riastradh Exp $     */
+/*     $NetBSD: linux_dma_resv.c,v 1.4 2021/12/19 10:38:14 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.3 2021/12/19 10:37:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.4 2021/12/19 10:38:14 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/poll.h>
@@ -199,6 +199,20 @@
 }
 
 /*
+ * dma_resv_locking_ctx(robj)
+ *
+ *     Return a pointer to the ww_acquire_ctx used by the owner of
+ *     the reservation object's lock, or NULL if it is either not
+ *     owned or if it is locked without context.
+ */
+struct ww_acquire_ctx *
+dma_resv_locking_ctx(struct dma_resv *robj)
+{
+
+       return ww_mutex_locking_ctx(&robj->lock);
+}
+
+/*
  * dma_resv_unlock(robj)
  *
  *     Release a reservation object's lock.
diff -r ea2b1ce5ab9e -r 75f833004f06 sys/external/bsd/drm2/linux/linux_ww_mutex.c
--- a/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Sun Dec 19 10:38:05 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Sun Dec 19 10:38:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_ww_mutex.c,v 1.7 2019/05/09 05:00:31 ozaki-r Exp $       */
+/*     $NetBSD: linux_ww_mutex.c,v 1.8 2021/12/19 10:38:14 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.7 2019/05/09 05:00:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.8 2021/12/19 10:38:14 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -832,3 +832,27 @@
        cv_broadcast(&mutex->wwm_cv);
        mutex_exit(&mutex->wwm_lock);
 }
+
+struct ww_acquire_ctx *
+ww_mutex_locking_ctx(struct ww_mutex *mutex)
+{
+       struct ww_acquire_ctx *ctx;
+
+       mutex_enter(&mutex->wwm_lock);
+       switch (mutex->wwm_state) {
+       case WW_UNLOCKED:
+       case WW_OWNED:
+               ctx = NULL;
+               break;
+       case WW_CTX:
+       case WW_WANTOWN:
+               ctx = mutex->wwm_u.ctx;
+               break;
+       default:
+               panic("wait/wound mutex %p in bad state: %d",
+                   mutex, (int)mutex->wwm_state);
+       }
+       mutex_exit(&mutex->wwm_lock);
+
+       return ctx;
+}



Home | Main Index | Thread Index | Old Index