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