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 Rename reservation_object -> dma...



details:   https://anonhg.NetBSD.org/src/rev/34a0f652e06f
branches:  trunk
changeset: 1028278:34a0f652e06f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 10:19:53 2021 +0000

description:
Rename reservation_object -> dma_resv.

diffstat:

 sys/external/bsd/drm2/include/linux/dma-buf.h     |    14 +-
 sys/external/bsd/drm2/include/linux/dma-resv.h    |   399 +----
 sys/external/bsd/drm2/include/linux/reservation.h |   138 --
 sys/external/bsd/drm2/linux/files.drmkms_linux    |     4 +-
 sys/external/bsd/drm2/linux/linux_dma_buf.c       |    22 +-
 sys/external/bsd/drm2/linux/linux_dma_resv.c      |  1335 +++++++++++++++++++++
 sys/external/bsd/drm2/linux/linux_reservation.c   |  1335 ---------------------
 7 files changed, 1476 insertions(+), 1771 deletions(-)

diffs (truncated from 3395 to 300 lines):

diff -r 703cd5c6c03e -r 34a0f652e06f sys/external/bsd/drm2/include/linux/dma-buf.h
--- a/sys/external/bsd/drm2/include/linux/dma-buf.h     Sun Dec 19 10:17:00 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/dma-buf.h     Sun Dec 19 10:19:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dma-buf.h,v 1.7 2021/12/19 09:50:57 riastradh Exp $    */
+/*     $NetBSD: dma-buf.h,v 1.8 2021/12/19 10:19:53 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #include <sys/mutex.h>
 
 #include <linux/err.h>
-#include <linux/reservation.h>
+#include <linux/dma-resv.h>
 
 struct device;
 struct dma_buf;
@@ -46,7 +46,7 @@
 struct dma_buf_ops;
 struct file;
 struct module;
-struct reservation_object;
+struct dma_resv;
 struct sg_table;
 struct uvm_object;
 
@@ -80,12 +80,12 @@
        void                            *priv;
        const struct dma_buf_ops        *ops;
        size_t                          size;
-       struct reservation_object       *resv;
+       struct dma_resv                 *resv;
 
        kmutex_t                        db_lock;
        volatile unsigned               db_refcnt;
-       struct reservation_poll         db_resv_poll;
-       struct reservation_object       db_resv_int[];
+       struct dma_resv_poll            db_resv_poll;
+       struct dma_resv                 db_resv_int[];
 };
 
 struct dma_buf_attachment {
@@ -102,7 +102,7 @@
        const struct dma_buf_ops        *ops;
        size_t                          size;
        int                             flags;
-       struct reservation_object       *resv;
+       struct dma_resv                 *resv;
        void                            *priv;
 };
 
diff -r 703cd5c6c03e -r 34a0f652e06f sys/external/bsd/drm2/include/linux/dma-resv.h
--- a/sys/external/bsd/drm2/include/linux/dma-resv.h    Sun Dec 19 10:17:00 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/dma-resv.h    Sun Dec 19 10:19:53 2021 +0000
@@ -1,295 +1,138 @@
-/*
- * Header file for reservations for dma-buf and ttm
- *
- * Copyright(C) 2011 Linaro Limited. All rights reserved.
- * Copyright (C) 2012-2013 Canonical Ltd
- * Copyright (C) 2012 Texas Instruments
+/*     $NetBSD: dma-resv.h,v 1.5 2021/12/19 10:19:53 riastradh Exp $   */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
  *
- * Authors:
- * Rob Clark <robdclark%gmail.com@localhost>
- * Maarten Lankhorst <maarten.lankhorst%canonical.com@localhost>
- * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
- *
- * Based on bo.c which bears the following copyright notice,
- * but is dual licensed:
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
  *
- * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef _LINUX_RESERVATION_H
-#define _LINUX_RESERVATION_H
 
-#include <linux/ww_mutex.h>
+#ifndef        _LINUX_DMA_RESV_H_
+#define        _LINUX_DMA_RESV_H_
+
 #include <linux/dma-fence.h>
-#include <linux/slab.h>
-#include <linux/seqlock.h>
 #include <linux/rcupdate.h>
+#include <linux/seqlock.h>
+#include <linux/ww_mutex.h>
 
-extern struct ww_class reservation_ww_class;
-extern struct lock_class_key reservation_seqcount_class;
-extern const char reservation_seqcount_string[];
+struct dma_resv {
+       struct ww_mutex                         lock;
+       struct seqcount                         seq;
+       struct dma_fence __rcu                  *fence_excl;
+       struct dma_resv_list __rcu              *fence;
+
+       struct dma_resv_list __rcu              *robj_prealloc;
+};
 
-/**
- * struct dma_resv_list - a list of shared fences
- * @rcu: for internal use
- * @shared_count: table of shared fences
- * @shared_max: for growing shared fence table
- * @shared: shared fence table
- */
 struct dma_resv_list {
-       struct rcu_head rcu;
-       u32 shared_count, shared_max;
-       struct dma_fence __rcu *shared[];
+       struct rcu_head         rol_rcu;
+
+       uint32_t                shared_count;
+       uint32_t                shared_max;
+       struct dma_fence __rcu  *shared[];
+};
+
+/* NetBSD addition */
+struct dma_resv_poll {
+       kmutex_t                rp_lock;
+       struct selinfo          rp_selq;
+       struct dma_fence_cb             rp_fcb;
+       bool                    rp_claimed;
 };
 
-/**
- * struct dma_resv - a reservation object manages fences for a buffer
- * @lock: update side lock
- * @seq: sequence count for managing RCU read-side synchronization
- * @fence_excl: the exclusive fence, if there is one currently
- * @fence: list of current shared fences
- */
-struct dma_resv {
-       struct ww_mutex lock;
-       seqcount_t seq;
-
-       struct dma_fence __rcu *fence_excl;
-       struct dma_resv_list __rcu *fence;
-};
+#define        dma_resv_add_excl_fence         linux_dma_resv_add_excl_fence
+#define        dma_resv_add_shared_fence       linux_dma_resv_add_shared_fence
+#define        dma_resv_assert_held            linux_dma_resv_assert_held
+#define        dma_resv_copy_fences            linux_dma_resv_copy_fences
+#define        dma_resv_do_poll                linux_dma_resv_do_poll
+#define        dma_resv_fini                   linux_dma_resv_fini
+#define        dma_resv_get_excl               linux_dma_resv_get_excl
+#define        dma_resv_get_excl_rcu           linux_dma_resv_get_excl_rcu
+#define        dma_resv_get_fences_rcu         linux_dma_resv_get_fences_rcu
+#define        dma_resv_get_list               linux_dma_resv_get_list
+#define        dma_resv_held                   linux_dma_resv_held
+#define        dma_resv_init                   linux_dma_resv_init
+#define        dma_resv_kqfilter               linux_dma_resv_kqfilter
+#define        dma_resv_lock                   linux_dma_resv_lock
+#define        dma_resv_lock_interruptible     linux_dma_resv_lock_interruptible
+#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
+#define        dma_resv_unlock                 linux_dma_resv_unlock
+#define        dma_resv_wait_timeout_rcu       linux_dma_resv_wait_timeout_rcu
+#define        dma_resv_poll_fini              linux_dma_resv_poll_fini
+#define        dma_resv_poll_init              linux_dma_resv_poll_init
+#define        reservation_ww_class            linux_reservation_ww_class
 
-#define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base)
-#define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base)
-
-/**
- * dma_resv_get_list - get the reservation object's
- * shared fence list, with update-side lock held
- * @obj: the reservation object
- *
- * Returns the shared fence list.  Does NOT take references to
- * the fence.  The obj->lock must be held.
- */
-static inline struct dma_resv_list *dma_resv_get_list(struct dma_resv *obj)
-{
-       return rcu_dereference_protected(obj->fence,
-                                        dma_resv_held(obj));
-}
+extern struct ww_class reservation_ww_class;
 
-/**
- * dma_resv_lock - lock the reservation object
- * @obj: the reservation object
- * @ctx: the locking context
- *
- * Locks the reservation object for exclusive access and modification. Note,
- * that the lock is only against other writers, readers will run concurrently
- * with a writer under RCU. The seqlock is used to notify readers if they
- * overlap with a writer.
- *
- * As the reservation object may be locked by multiple parties in an
- * undefined order, a #ww_acquire_ctx is passed to unwind if a cycle
- * is detected. See ww_mutex_lock() and ww_acquire_init(). A reservation
- * object may be locked by itself by passing NULL as @ctx.
- */
-static inline int dma_resv_lock(struct dma_resv *obj,
-                               struct ww_acquire_ctx *ctx)
+void   dma_resv_init(struct dma_resv *);
+void   dma_resv_fini(struct dma_resv *);
+int    dma_resv_lock(struct dma_resv *,
+           struct ww_acquire_ctx *);
+int    dma_resv_lock_interruptible(struct dma_resv *,
+           struct ww_acquire_ctx *);
+bool   dma_resv_trylock(struct dma_resv *) __must_check;
+void   dma_resv_unlock(struct dma_resv *);
+bool   dma_resv_held(struct dma_resv *);
+void   dma_resv_assert_held(struct dma_resv *);
+struct dma_fence *
+       dma_resv_get_excl(struct dma_resv *);
+struct dma_resv_list *
+       dma_resv_get_list(struct dma_resv *);
+int    dma_resv_reserve_shared(struct dma_resv *);
+void   dma_resv_add_excl_fence(struct dma_resv *,
+           struct dma_fence *);
+void   dma_resv_add_shared_fence(struct dma_resv *,
+           struct dma_fence *);
+
+struct dma_fence *
+       dma_resv_get_excl_rcu(const struct dma_resv *);
+int    dma_resv_get_fences_rcu(const struct dma_resv *,
+           struct dma_fence **, unsigned *, struct dma_fence ***);
+
+int    dma_resv_copy_fences(struct dma_resv *,
+           const struct dma_resv *);
+
+bool   dma_resv_test_signaled_rcu(const struct dma_resv *,
+           bool);
+long   dma_resv_wait_timeout_rcu(const struct dma_resv *,
+           bool, bool, unsigned long);
+
+/* NetBSD additions */
+void   dma_resv_poll_init(struct dma_resv_poll *);
+void   dma_resv_poll_fini(struct dma_resv_poll *);
+int    dma_resv_do_poll(const struct dma_resv *, int,
+           struct dma_resv_poll *);
+int    dma_resv_kqfilter(const struct dma_resv *,
+           struct knote *, struct dma_resv_poll *);
+
+static inline bool
+dma_resv_has_excl_fence(const struct dma_resv *robj)
 {
-       return ww_mutex_lock(&obj->lock, ctx);
-}
-
-/**
- * dma_resv_lock_interruptible - lock the reservation object
- * @obj: the reservation object
- * @ctx: the locking context
- *
- * Locks the reservation object interruptible for exclusive access and
- * modification. Note, that the lock is only against other writers, readers
- * will run concurrently with a writer under RCU. The seqlock is used to



Home | Main Index | Thread Index | Old Index