1 1.4 riastrad /* $NetBSD: drm_auth.h,v 1.4 2021/12/19 01:54:28 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad #ifndef _DRM_AUTH_H_ 4 1.1 riastrad #define _DRM_AUTH_H_ 5 1.1 riastrad 6 1.1 riastrad /* 7 1.1 riastrad * Internal Header for the Direct Rendering Manager 8 1.1 riastrad * 9 1.1 riastrad * Copyright 2016 Intel Corporation 10 1.1 riastrad * 11 1.1 riastrad * Author: Daniel Vetter <daniel.vetter (at) ffwll.ch> 12 1.1 riastrad * 13 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 14 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 15 1.1 riastrad * to deal in the Software without restriction, including without limitation 16 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 18 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 19 1.1 riastrad * 20 1.1 riastrad * The above copyright notice and this permission notice (including the next 21 1.1 riastrad * paragraph) shall be included in all copies or substantial portions of the 22 1.1 riastrad * Software. 23 1.1 riastrad * 24 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 1.1 riastrad * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 28 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 29 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 30 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 31 1.1 riastrad */ 32 1.1 riastrad 33 1.1 riastrad #include <linux/idr.h> 34 1.1 riastrad #include <linux/kref.h> 35 1.1 riastrad #include <linux/wait.h> 36 1.1 riastrad 37 1.1 riastrad struct drm_file; 38 1.1 riastrad struct drm_hw_lock; 39 1.1 riastrad 40 1.3 riastrad #include <linux/idr.h> 41 1.3 riastrad #include <linux/kref.h> 42 1.3 riastrad #include <linux/list.h> 43 1.3 riastrad #include <linux/spinlock.h> 44 1.3 riastrad #include <linux/types.h> 45 1.3 riastrad 46 1.3 riastrad #ifdef __NetBSD__ 47 1.3 riastrad #include <drm/drm_wait_netbsd.h> 48 1.3 riastrad #endif 49 1.3 riastrad 50 1.3 riastrad struct drm_device; 51 1.3 riastrad struct drm_file; 52 1.3 riastrad struct drm_hw_lock; 53 1.3 riastrad struct drm_master; 54 1.3 riastrad 55 1.1 riastrad /* 56 1.1 riastrad * Legacy DRI1 locking data structure. Only here instead of in drm_legacy.h for 57 1.1 riastrad * include ordering reasons. 58 1.1 riastrad * 59 1.1 riastrad * DO NOT USE. 60 1.1 riastrad */ 61 1.1 riastrad struct drm_lock_data { 62 1.1 riastrad struct drm_hw_lock *hw_lock; 63 1.1 riastrad struct drm_file *file_priv; 64 1.4 riastrad #ifdef __NetBSD__ 65 1.4 riastrad drm_waitqueue_t lock_queue; /**< Queue of blocked processes */ 66 1.4 riastrad #else 67 1.1 riastrad wait_queue_head_t lock_queue; 68 1.4 riastrad #endif 69 1.1 riastrad unsigned long lock_time; 70 1.1 riastrad spinlock_t spinlock; 71 1.1 riastrad uint32_t kernel_waiters; 72 1.1 riastrad uint32_t user_waiters; 73 1.1 riastrad int idle_has_lock; 74 1.1 riastrad }; 75 1.1 riastrad 76 1.1 riastrad /** 77 1.1 riastrad * struct drm_master - drm master structure 78 1.1 riastrad * 79 1.1 riastrad * @refcount: Refcount for this master object. 80 1.1 riastrad * @dev: Link back to the DRM device 81 1.1 riastrad * @driver_priv: Pointer to driver-private information. 82 1.1 riastrad * @lessor: Lease holder 83 1.1 riastrad * @lessee_id: id for lessees. Owners always have id 0 84 1.1 riastrad * @lessee_list: other lessees of the same master 85 1.1 riastrad * @lessees: drm_masters leasing from this one 86 1.1 riastrad * @leases: Objects leased to this drm_master. 87 1.1 riastrad * @lessee_idr: All lessees under this owner (only used where lessor == NULL) 88 1.1 riastrad * 89 1.1 riastrad * Note that master structures are only relevant for the legacy/primary device 90 1.1 riastrad * nodes, hence there can only be one per device, not one per drm_minor. 91 1.1 riastrad */ 92 1.1 riastrad struct drm_master { 93 1.1 riastrad struct kref refcount; 94 1.1 riastrad struct drm_device *dev; 95 1.1 riastrad /** 96 1.1 riastrad * @unique: Unique identifier: e.g. busid. Protected by 97 1.1 riastrad * &drm_device.master_mutex. 98 1.1 riastrad */ 99 1.1 riastrad char *unique; 100 1.1 riastrad /** 101 1.1 riastrad * @unique_len: Length of unique field. Protected by 102 1.1 riastrad * &drm_device.master_mutex. 103 1.1 riastrad */ 104 1.1 riastrad int unique_len; 105 1.1 riastrad /** 106 1.1 riastrad * @magic_map: Map of used authentication tokens. Protected by 107 1.1 riastrad * &drm_device.master_mutex. 108 1.1 riastrad */ 109 1.1 riastrad struct idr magic_map; 110 1.1 riastrad void *driver_priv; 111 1.1 riastrad 112 1.1 riastrad /* Tree of display resource leases, each of which is a drm_master struct 113 1.1 riastrad * All of these get activated simultaneously, so drm_device master points 114 1.1 riastrad * at the top of the tree (for which lessor is NULL). Protected by 115 1.1 riastrad * &drm_device.mode_config.idr_mutex. 116 1.1 riastrad */ 117 1.1 riastrad 118 1.1 riastrad struct drm_master *lessor; 119 1.1 riastrad int lessee_id; 120 1.1 riastrad struct list_head lessee_list; 121 1.1 riastrad struct list_head lessees; 122 1.1 riastrad struct idr leases; 123 1.1 riastrad struct idr lessee_idr; 124 1.1 riastrad /* private: */ 125 1.1 riastrad #if IS_ENABLED(CONFIG_DRM_LEGACY) 126 1.1 riastrad struct drm_lock_data lock; 127 1.1 riastrad #endif 128 1.1 riastrad }; 129 1.1 riastrad 130 1.1 riastrad struct drm_master *drm_master_get(struct drm_master *master); 131 1.1 riastrad void drm_master_put(struct drm_master **master); 132 1.1 riastrad bool drm_is_current_master(struct drm_file *fpriv); 133 1.1 riastrad 134 1.1 riastrad struct drm_master *drm_master_create(struct drm_device *dev); 135 1.1 riastrad 136 1.1 riastrad #endif 137