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