Linux Audio

Check our new training course

Loading...
v6.2
  1/*
  2 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  4 * Copyright (c) 2009-2010, Code Aurora Forum.
  5 * All rights reserved.
  6 *
  7 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  8 * Author: Gareth Hughes <gareth@valinux.com>
  9 *
 10 * Permission is hereby granted, free of charge, to any person obtaining a
 11 * copy of this software and associated documentation files (the "Software"),
 12 * to deal in the Software without restriction, including without limitation
 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14 * and/or sell copies of the Software, and to permit persons to whom the
 15 * Software is furnished to do so, subject to the following conditions:
 16 *
 17 * The above copyright notice and this permission notice (including the next
 18 * paragraph) shall be included in all copies or substantial portions of the
 19 * Software.
 20 *
 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 27 * OTHER DEALINGS IN THE SOFTWARE.
 28 */
 29
 30#ifndef _DRM_FILE_H_
 31#define _DRM_FILE_H_
 32
 33#include <linux/types.h>
 34#include <linux/completion.h>
 35#include <linux/idr.h>
 36
 37#include <uapi/drm/drm.h>
 38
 39#include <drm/drm_prime.h>
 40
 41struct dma_fence;
 42struct drm_file;
 43struct drm_device;
 
 44struct device;
 45struct file;
 46
 47/*
 48 * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
 49 * header include loops we need it here for now.
 50 */
 51
 52/* Note that the order of this enum is ABI (it determines
 53 * /dev/dri/renderD* numbers).
 54 *
 55 * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
 56 * be implemented before we hit any future
 57 */
 58enum drm_minor_type {
 59	DRM_MINOR_PRIMARY,
 60	DRM_MINOR_CONTROL,
 61	DRM_MINOR_RENDER,
 62	DRM_MINOR_ACCEL = 32,
 63};
 64
 65/**
 66 * struct drm_minor - DRM device minor structure
 67 *
 68 * This structure represents a DRM minor number for device nodes in /dev.
 69 * Entirely opaque to drivers and should never be inspected directly by drivers.
 70 * Drivers instead should only interact with &struct drm_file and of course
 71 * &struct drm_device, which is also where driver-private data and resources can
 72 * be attached to.
 73 */
 74struct drm_minor {
 75	/* private: */
 76	int index;			/* Minor device number */
 77	int type;                       /* Control or render or accel */
 78	struct device *kdev;		/* Linux device */
 79	struct drm_device *dev;
 80
 
 81	struct dentry *debugfs_root;
 82
 83	struct list_head debugfs_list;
 84	struct mutex debugfs_lock; /* Protects debugfs_list. */
 85};
 86
 87/**
 88 * struct drm_pending_event - Event queued up for userspace to read
 89 *
 90 * This represents a DRM event. Drivers can use this as a generic completion
 91 * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
 92 * and also the DRM-specific &struct drm_event delivery mechanism.
 93 */
 94struct drm_pending_event {
 95	/**
 96	 * @completion:
 97	 *
 98	 * Optional pointer to a kernel internal completion signalled when
 99	 * drm_send_event() is called, useful to internally synchronize with
100	 * nonblocking operations.
101	 */
102	struct completion *completion;
103
104	/**
105	 * @completion_release:
106	 *
107	 * Optional callback currently only used by the atomic modeset helpers
108	 * to clean up the reference count for the structure @completion is
109	 * stored in.
110	 */
111	void (*completion_release)(struct completion *completion);
112
113	/**
114	 * @event:
115	 *
116	 * Pointer to the actual event that should be sent to userspace to be
117	 * read using drm_read(). Can be optional, since nowadays events are
118	 * also used to signal kernel internal threads with @completion or DMA
119	 * transactions using @fence.
120	 */
121	struct drm_event *event;
122
123	/**
124	 * @fence:
125	 *
126	 * Optional DMA fence to unblock other hardware transactions which
127	 * depend upon the nonblocking DRM operation this event represents.
128	 */
129	struct dma_fence *fence;
130
131	/**
132	 * @file_priv:
133	 *
134	 * &struct drm_file where @event should be delivered to. Only set when
135	 * @event is set.
136	 */
137	struct drm_file *file_priv;
138
139	/**
140	 * @link:
141	 *
142	 * Double-linked list to keep track of this event. Can be used by the
143	 * driver up to the point when it calls drm_send_event(), after that
144	 * this list entry is owned by the core for its own book-keeping.
145	 */
146	struct list_head link;
147
148	/**
149	 * @pending_link:
150	 *
151	 * Entry on &drm_file.pending_event_list, to keep track of all pending
152	 * events for @file_priv, to allow correct unwinding of them when
153	 * userspace closes the file before the event is delivered.
154	 */
155	struct list_head pending_link;
156};
157
158/**
159 * struct drm_file - DRM file private data
160 *
161 * This structure tracks DRM state per open file descriptor.
162 */
163struct drm_file {
164	/**
165	 * @authenticated:
166	 *
167	 * Whether the client is allowed to submit rendering, which for legacy
168	 * nodes means it must be authenticated.
169	 *
170	 * See also the :ref:`section on primary nodes and authentication
171	 * <drm_primary_node>`.
172	 */
173	bool authenticated;
174
175	/**
176	 * @stereo_allowed:
177	 *
178	 * True when the client has asked us to expose stereo 3D mode flags.
179	 */
180	bool stereo_allowed;
181
182	/**
183	 * @universal_planes:
184	 *
185	 * True if client understands CRTC primary planes and cursor planes
186	 * in the plane list. Automatically set when @atomic is set.
187	 */
188	bool universal_planes;
189
190	/** @atomic: True if client understands atomic properties. */
191	bool atomic;
192
193	/**
194	 * @aspect_ratio_allowed:
195	 *
196	 * True, if client can handle picture aspect ratios, and has requested
197	 * to pass this information along with the mode.
198	 */
199	bool aspect_ratio_allowed;
200
201	/**
202	 * @writeback_connectors:
203	 *
204	 * True if client understands writeback connectors
205	 */
206	bool writeback_connectors;
207
208	/**
209	 * @was_master:
210	 *
211	 * This client has or had, master capability. Protected by struct
212	 * &drm_device.master_mutex.
213	 *
214	 * This is used to ensure that CAP_SYS_ADMIN is not enforced, if the
215	 * client is or was master in the past.
216	 */
217	bool was_master;
218
219	/**
220	 * @is_master:
221	 *
222	 * This client is the creator of @master. Protected by struct
223	 * &drm_device.master_mutex.
224	 *
225	 * See also the :ref:`section on primary nodes and authentication
226	 * <drm_primary_node>`.
227	 */
228	bool is_master;
229
230	/**
 
 
 
 
 
 
 
 
 
 
 
 
231	 * @master:
232	 *
233	 * Master this node is currently associated with. Protected by struct
234	 * &drm_device.master_mutex, and serialized by @master_lookup_lock.
235	 *
236	 * Only relevant if drm_is_primary_client() returns true. Note that
237	 * this only matches &drm_device.master if the master is the currently
238	 * active one.
239	 *
240	 * To update @master, both &drm_device.master_mutex and
241	 * @master_lookup_lock need to be held, therefore holding either of
242	 * them is safe and enough for the read side.
243	 *
244	 * When dereferencing this pointer, either hold struct
245	 * &drm_device.master_mutex for the duration of the pointer's use, or
246	 * use drm_file_get_master() if struct &drm_device.master_mutex is not
247	 * currently held and there is no other need to hold it. This prevents
248	 * @master from being freed during use.
249	 *
250	 * See also @authentication and @is_master and the :ref:`section on
251	 * primary nodes and authentication <drm_primary_node>`.
252	 */
253	struct drm_master *master;
254
255	/** @master_lookup_lock: Serializes @master. */
256	spinlock_t master_lookup_lock;
257
258	/** @pid: Process that opened this file. */
259	struct pid *pid;
 
 
 
 
 
 
 
 
 
 
260
261	/** @magic: Authentication magic, see @authenticated. */
262	drm_magic_t magic;
263
264	/**
265	 * @lhead:
266	 *
267	 * List of all open files of a DRM device, linked into
268	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
269	 */
270	struct list_head lhead;
271
272	/** @minor: &struct drm_minor for this file. */
273	struct drm_minor *minor;
274
275	/**
276	 * @object_idr:
277	 *
278	 * Mapping of mm object handles to object pointers. Used by the GEM
279	 * subsystem. Protected by @table_lock.
280	 */
281	struct idr object_idr;
282
283	/** @table_lock: Protects @object_idr. */
284	spinlock_t table_lock;
285
286	/** @syncobj_idr: Mapping of sync object handles to object pointers. */
287	struct idr syncobj_idr;
288	/** @syncobj_table_lock: Protects @syncobj_idr. */
289	spinlock_t syncobj_table_lock;
290
291	/** @filp: Pointer to the core file structure. */
292	struct file *filp;
293
294	/**
295	 * @driver_priv:
296	 *
297	 * Optional pointer for driver private data. Can be allocated in
298	 * &drm_driver.open and should be freed in &drm_driver.postclose.
299	 */
300	void *driver_priv;
301
302	/**
303	 * @fbs:
304	 *
305	 * List of &struct drm_framebuffer associated with this file, using the
306	 * &drm_framebuffer.filp_head entry.
307	 *
308	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
309	 * the framebuffer object to prevent it from untimely disappearing.
310	 */
311	struct list_head fbs;
312
313	/** @fbs_lock: Protects @fbs. */
314	struct mutex fbs_lock;
315
316	/**
317	 * @blobs:
318	 *
319	 * User-created blob properties; this retains a reference on the
320	 * property.
321	 *
322	 * Protected by @drm_mode_config.blob_lock;
323	 */
324	struct list_head blobs;
325
326	/** @event_wait: Waitqueue for new events added to @event_list. */
327	wait_queue_head_t event_wait;
328
329	/**
330	 * @pending_event_list:
331	 *
332	 * List of pending &struct drm_pending_event, used to clean up pending
333	 * events in case this file gets closed before the event is signalled.
334	 * Uses the &drm_pending_event.pending_link entry.
335	 *
336	 * Protect by &drm_device.event_lock.
337	 */
338	struct list_head pending_event_list;
339
340	/**
341	 * @event_list:
342	 *
343	 * List of &struct drm_pending_event, ready for delivery to userspace
344	 * through drm_read(). Uses the &drm_pending_event.link entry.
345	 *
346	 * Protect by &drm_device.event_lock.
347	 */
348	struct list_head event_list;
349
350	/**
351	 * @event_space:
352	 *
353	 * Available event space to prevent userspace from
354	 * exhausting kernel memory. Currently limited to the fairly arbitrary
355	 * value of 4KB.
356	 */
357	int event_space;
358
359	/** @event_read_lock: Serializes drm_read(). */
360	struct mutex event_read_lock;
361
362	/**
363	 * @prime:
364	 *
365	 * Per-file buffer caches used by the PRIME buffer sharing code.
366	 */
367	struct drm_prime_file_private prime;
368
369	/* private: */
370#if IS_ENABLED(CONFIG_DRM_LEGACY)
371	unsigned long lock_count; /* DRI1 legacy lock count */
372#endif
373};
374
375/**
376 * drm_is_primary_client - is this an open file of the primary node
377 * @file_priv: DRM file
378 *
379 * Returns true if this is an open file of the primary node, i.e.
380 * &drm_file.minor of @file_priv is a primary minor.
381 *
382 * See also the :ref:`section on primary nodes and authentication
383 * <drm_primary_node>`.
384 */
385static inline bool drm_is_primary_client(const struct drm_file *file_priv)
386{
387	return file_priv->minor->type == DRM_MINOR_PRIMARY;
388}
389
390/**
391 * drm_is_render_client - is this an open file of the render node
392 * @file_priv: DRM file
393 *
394 * Returns true if this is an open file of the render node, i.e.
395 * &drm_file.minor of @file_priv is a render minor.
396 *
397 * See also the :ref:`section on render nodes <drm_render_node>`.
398 */
399static inline bool drm_is_render_client(const struct drm_file *file_priv)
400{
401	return file_priv->minor->type == DRM_MINOR_RENDER;
402}
403
404/**
405 * drm_is_accel_client - is this an open file of the compute acceleration node
406 * @file_priv: DRM file
407 *
408 * Returns true if this is an open file of the compute acceleration node, i.e.
409 * &drm_file.minor of @file_priv is a accel minor.
410 *
411 * See also the :ref:`section on accel nodes <drm_accel_node>`.
 
412 */
413static inline bool drm_is_accel_client(const struct drm_file *file_priv)
414{
415	return file_priv->minor->type == DRM_MINOR_ACCEL;
416}
417
 
 
418int drm_open(struct inode *inode, struct file *filp);
419int drm_open_helper(struct file *filp, struct drm_minor *minor);
420ssize_t drm_read(struct file *filp, char __user *buffer,
421		 size_t count, loff_t *offset);
422int drm_release(struct inode *inode, struct file *filp);
423int drm_release_noglobal(struct inode *inode, struct file *filp);
424__poll_t drm_poll(struct file *filp, struct poll_table_struct *wait);
425int drm_event_reserve_init_locked(struct drm_device *dev,
426				  struct drm_file *file_priv,
427				  struct drm_pending_event *p,
428				  struct drm_event *e);
429int drm_event_reserve_init(struct drm_device *dev,
430			   struct drm_file *file_priv,
431			   struct drm_pending_event *p,
432			   struct drm_event *e);
433void drm_event_cancel_free(struct drm_device *dev,
434			   struct drm_pending_event *p);
435void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
436void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
437void drm_send_event_timestamp_locked(struct drm_device *dev,
438				     struct drm_pending_event *e,
439				     ktime_t timestamp);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
441struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags);
442
443#endif /* _DRM_FILE_H_ */
v6.8
  1/*
  2 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  4 * Copyright (c) 2009-2010, Code Aurora Forum.
  5 * All rights reserved.
  6 *
  7 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  8 * Author: Gareth Hughes <gareth@valinux.com>
  9 *
 10 * Permission is hereby granted, free of charge, to any person obtaining a
 11 * copy of this software and associated documentation files (the "Software"),
 12 * to deal in the Software without restriction, including without limitation
 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14 * and/or sell copies of the Software, and to permit persons to whom the
 15 * Software is furnished to do so, subject to the following conditions:
 16 *
 17 * The above copyright notice and this permission notice (including the next
 18 * paragraph) shall be included in all copies or substantial portions of the
 19 * Software.
 20 *
 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 27 * OTHER DEALINGS IN THE SOFTWARE.
 28 */
 29
 30#ifndef _DRM_FILE_H_
 31#define _DRM_FILE_H_
 32
 33#include <linux/types.h>
 34#include <linux/completion.h>
 35#include <linux/idr.h>
 36
 37#include <uapi/drm/drm.h>
 38
 39#include <drm/drm_prime.h>
 40
 41struct dma_fence;
 42struct drm_file;
 43struct drm_device;
 44struct drm_printer;
 45struct device;
 46struct file;
 47
 48/*
 49 * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
 50 * header include loops we need it here for now.
 51 */
 52
 53/* Note that the values of this enum are ABI (it determines
 54 * /dev/dri/renderD* numbers).
 55 *
 56 * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
 57 * be implemented before we hit any future
 58 */
 59enum drm_minor_type {
 60	DRM_MINOR_PRIMARY = 0,
 61	DRM_MINOR_CONTROL = 1,
 62	DRM_MINOR_RENDER = 2,
 63	DRM_MINOR_ACCEL = 32,
 64};
 65
 66/**
 67 * struct drm_minor - DRM device minor structure
 68 *
 69 * This structure represents a DRM minor number for device nodes in /dev.
 70 * Entirely opaque to drivers and should never be inspected directly by drivers.
 71 * Drivers instead should only interact with &struct drm_file and of course
 72 * &struct drm_device, which is also where driver-private data and resources can
 73 * be attached to.
 74 */
 75struct drm_minor {
 76	/* private: */
 77	int index;			/* Minor device number */
 78	int type;                       /* Control or render or accel */
 79	struct device *kdev;		/* Linux device */
 80	struct drm_device *dev;
 81
 82	struct dentry *debugfs_symlink;
 83	struct dentry *debugfs_root;
 
 
 
 84};
 85
 86/**
 87 * struct drm_pending_event - Event queued up for userspace to read
 88 *
 89 * This represents a DRM event. Drivers can use this as a generic completion
 90 * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
 91 * and also the DRM-specific &struct drm_event delivery mechanism.
 92 */
 93struct drm_pending_event {
 94	/**
 95	 * @completion:
 96	 *
 97	 * Optional pointer to a kernel internal completion signalled when
 98	 * drm_send_event() is called, useful to internally synchronize with
 99	 * nonblocking operations.
100	 */
101	struct completion *completion;
102
103	/**
104	 * @completion_release:
105	 *
106	 * Optional callback currently only used by the atomic modeset helpers
107	 * to clean up the reference count for the structure @completion is
108	 * stored in.
109	 */
110	void (*completion_release)(struct completion *completion);
111
112	/**
113	 * @event:
114	 *
115	 * Pointer to the actual event that should be sent to userspace to be
116	 * read using drm_read(). Can be optional, since nowadays events are
117	 * also used to signal kernel internal threads with @completion or DMA
118	 * transactions using @fence.
119	 */
120	struct drm_event *event;
121
122	/**
123	 * @fence:
124	 *
125	 * Optional DMA fence to unblock other hardware transactions which
126	 * depend upon the nonblocking DRM operation this event represents.
127	 */
128	struct dma_fence *fence;
129
130	/**
131	 * @file_priv:
132	 *
133	 * &struct drm_file where @event should be delivered to. Only set when
134	 * @event is set.
135	 */
136	struct drm_file *file_priv;
137
138	/**
139	 * @link:
140	 *
141	 * Double-linked list to keep track of this event. Can be used by the
142	 * driver up to the point when it calls drm_send_event(), after that
143	 * this list entry is owned by the core for its own book-keeping.
144	 */
145	struct list_head link;
146
147	/**
148	 * @pending_link:
149	 *
150	 * Entry on &drm_file.pending_event_list, to keep track of all pending
151	 * events for @file_priv, to allow correct unwinding of them when
152	 * userspace closes the file before the event is delivered.
153	 */
154	struct list_head pending_link;
155};
156
157/**
158 * struct drm_file - DRM file private data
159 *
160 * This structure tracks DRM state per open file descriptor.
161 */
162struct drm_file {
163	/**
164	 * @authenticated:
165	 *
166	 * Whether the client is allowed to submit rendering, which for legacy
167	 * nodes means it must be authenticated.
168	 *
169	 * See also the :ref:`section on primary nodes and authentication
170	 * <drm_primary_node>`.
171	 */
172	bool authenticated;
173
174	/**
175	 * @stereo_allowed:
176	 *
177	 * True when the client has asked us to expose stereo 3D mode flags.
178	 */
179	bool stereo_allowed;
180
181	/**
182	 * @universal_planes:
183	 *
184	 * True if client understands CRTC primary planes and cursor planes
185	 * in the plane list. Automatically set when @atomic is set.
186	 */
187	bool universal_planes;
188
189	/** @atomic: True if client understands atomic properties. */
190	bool atomic;
191
192	/**
193	 * @aspect_ratio_allowed:
194	 *
195	 * True, if client can handle picture aspect ratios, and has requested
196	 * to pass this information along with the mode.
197	 */
198	bool aspect_ratio_allowed;
199
200	/**
201	 * @writeback_connectors:
202	 *
203	 * True if client understands writeback connectors
204	 */
205	bool writeback_connectors;
206
207	/**
208	 * @was_master:
209	 *
210	 * This client has or had, master capability. Protected by struct
211	 * &drm_device.master_mutex.
212	 *
213	 * This is used to ensure that CAP_SYS_ADMIN is not enforced, if the
214	 * client is or was master in the past.
215	 */
216	bool was_master;
217
218	/**
219	 * @is_master:
220	 *
221	 * This client is the creator of @master. Protected by struct
222	 * &drm_device.master_mutex.
223	 *
224	 * See also the :ref:`section on primary nodes and authentication
225	 * <drm_primary_node>`.
226	 */
227	bool is_master;
228
229	/**
230	 * @supports_virtualized_cursor_plane:
231	 *
232	 * This client is capable of handling the cursor plane with the
233	 * restrictions imposed on it by the virtualized drivers.
234	 *
235	 * This implies that the cursor plane has to behave like a cursor
236	 * i.e. track cursor movement. It also requires setting of the
237	 * hotspot properties by the client on the cursor plane.
238	 */
239	bool supports_virtualized_cursor_plane;
240
241	/**
242	 * @master:
243	 *
244	 * Master this node is currently associated with. Protected by struct
245	 * &drm_device.master_mutex, and serialized by @master_lookup_lock.
246	 *
247	 * Only relevant if drm_is_primary_client() returns true. Note that
248	 * this only matches &drm_device.master if the master is the currently
249	 * active one.
250	 *
251	 * To update @master, both &drm_device.master_mutex and
252	 * @master_lookup_lock need to be held, therefore holding either of
253	 * them is safe and enough for the read side.
254	 *
255	 * When dereferencing this pointer, either hold struct
256	 * &drm_device.master_mutex for the duration of the pointer's use, or
257	 * use drm_file_get_master() if struct &drm_device.master_mutex is not
258	 * currently held and there is no other need to hold it. This prevents
259	 * @master from being freed during use.
260	 *
261	 * See also @authentication and @is_master and the :ref:`section on
262	 * primary nodes and authentication <drm_primary_node>`.
263	 */
264	struct drm_master *master;
265
266	/** @master_lookup_lock: Serializes @master. */
267	spinlock_t master_lookup_lock;
268
269	/**
270	 * @pid: Process that is using this file.
271	 *
272	 * Must only be dereferenced under a rcu_read_lock or equivalent.
273	 *
274	 * Updates are guarded with dev->filelist_mutex and reference must be
275	 * dropped after a RCU grace period to accommodate lockless readers.
276	 */
277	struct pid __rcu *pid;
278
279	/** @client_id: A unique id for fdinfo */
280	u64 client_id;
281
282	/** @magic: Authentication magic, see @authenticated. */
283	drm_magic_t magic;
284
285	/**
286	 * @lhead:
287	 *
288	 * List of all open files of a DRM device, linked into
289	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
290	 */
291	struct list_head lhead;
292
293	/** @minor: &struct drm_minor for this file. */
294	struct drm_minor *minor;
295
296	/**
297	 * @object_idr:
298	 *
299	 * Mapping of mm object handles to object pointers. Used by the GEM
300	 * subsystem. Protected by @table_lock.
301	 */
302	struct idr object_idr;
303
304	/** @table_lock: Protects @object_idr. */
305	spinlock_t table_lock;
306
307	/** @syncobj_idr: Mapping of sync object handles to object pointers. */
308	struct idr syncobj_idr;
309	/** @syncobj_table_lock: Protects @syncobj_idr. */
310	spinlock_t syncobj_table_lock;
311
312	/** @filp: Pointer to the core file structure. */
313	struct file *filp;
314
315	/**
316	 * @driver_priv:
317	 *
318	 * Optional pointer for driver private data. Can be allocated in
319	 * &drm_driver.open and should be freed in &drm_driver.postclose.
320	 */
321	void *driver_priv;
322
323	/**
324	 * @fbs:
325	 *
326	 * List of &struct drm_framebuffer associated with this file, using the
327	 * &drm_framebuffer.filp_head entry.
328	 *
329	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
330	 * the framebuffer object to prevent it from untimely disappearing.
331	 */
332	struct list_head fbs;
333
334	/** @fbs_lock: Protects @fbs. */
335	struct mutex fbs_lock;
336
337	/**
338	 * @blobs:
339	 *
340	 * User-created blob properties; this retains a reference on the
341	 * property.
342	 *
343	 * Protected by @drm_mode_config.blob_lock;
344	 */
345	struct list_head blobs;
346
347	/** @event_wait: Waitqueue for new events added to @event_list. */
348	wait_queue_head_t event_wait;
349
350	/**
351	 * @pending_event_list:
352	 *
353	 * List of pending &struct drm_pending_event, used to clean up pending
354	 * events in case this file gets closed before the event is signalled.
355	 * Uses the &drm_pending_event.pending_link entry.
356	 *
357	 * Protect by &drm_device.event_lock.
358	 */
359	struct list_head pending_event_list;
360
361	/**
362	 * @event_list:
363	 *
364	 * List of &struct drm_pending_event, ready for delivery to userspace
365	 * through drm_read(). Uses the &drm_pending_event.link entry.
366	 *
367	 * Protect by &drm_device.event_lock.
368	 */
369	struct list_head event_list;
370
371	/**
372	 * @event_space:
373	 *
374	 * Available event space to prevent userspace from
375	 * exhausting kernel memory. Currently limited to the fairly arbitrary
376	 * value of 4KB.
377	 */
378	int event_space;
379
380	/** @event_read_lock: Serializes drm_read(). */
381	struct mutex event_read_lock;
382
383	/**
384	 * @prime:
385	 *
386	 * Per-file buffer caches used by the PRIME buffer sharing code.
387	 */
388	struct drm_prime_file_private prime;
 
 
 
 
 
389};
390
391/**
392 * drm_is_primary_client - is this an open file of the primary node
393 * @file_priv: DRM file
394 *
395 * Returns true if this is an open file of the primary node, i.e.
396 * &drm_file.minor of @file_priv is a primary minor.
397 *
398 * See also the :ref:`section on primary nodes and authentication
399 * <drm_primary_node>`.
400 */
401static inline bool drm_is_primary_client(const struct drm_file *file_priv)
402{
403	return file_priv->minor->type == DRM_MINOR_PRIMARY;
404}
405
406/**
407 * drm_is_render_client - is this an open file of the render node
408 * @file_priv: DRM file
409 *
410 * Returns true if this is an open file of the render node, i.e.
411 * &drm_file.minor of @file_priv is a render minor.
412 *
413 * See also the :ref:`section on render nodes <drm_render_node>`.
414 */
415static inline bool drm_is_render_client(const struct drm_file *file_priv)
416{
417	return file_priv->minor->type == DRM_MINOR_RENDER;
418}
419
420/**
421 * drm_is_accel_client - is this an open file of the compute acceleration node
422 * @file_priv: DRM file
423 *
424 * Returns true if this is an open file of the compute acceleration node, i.e.
425 * &drm_file.minor of @file_priv is a accel minor.
426 *
427 * See also :doc:`Introduction to compute accelerators subsystem
428 * </accel/introduction>`.
429 */
430static inline bool drm_is_accel_client(const struct drm_file *file_priv)
431{
432	return file_priv->minor->type == DRM_MINOR_ACCEL;
433}
434
435void drm_file_update_pid(struct drm_file *);
436
437int drm_open(struct inode *inode, struct file *filp);
438int drm_open_helper(struct file *filp, struct drm_minor *minor);
439ssize_t drm_read(struct file *filp, char __user *buffer,
440		 size_t count, loff_t *offset);
441int drm_release(struct inode *inode, struct file *filp);
442int drm_release_noglobal(struct inode *inode, struct file *filp);
443__poll_t drm_poll(struct file *filp, struct poll_table_struct *wait);
444int drm_event_reserve_init_locked(struct drm_device *dev,
445				  struct drm_file *file_priv,
446				  struct drm_pending_event *p,
447				  struct drm_event *e);
448int drm_event_reserve_init(struct drm_device *dev,
449			   struct drm_file *file_priv,
450			   struct drm_pending_event *p,
451			   struct drm_event *e);
452void drm_event_cancel_free(struct drm_device *dev,
453			   struct drm_pending_event *p);
454void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
455void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
456void drm_send_event_timestamp_locked(struct drm_device *dev,
457				     struct drm_pending_event *e,
458				     ktime_t timestamp);
459
460/**
461 * struct drm_memory_stats - GEM object stats associated
462 * @shared: Total size of GEM objects shared between processes
463 * @private: Total size of GEM objects
464 * @resident: Total size of GEM objects backing pages
465 * @purgeable: Total size of GEM objects that can be purged (resident and not active)
466 * @active: Total size of GEM objects active on one or more engines
467 *
468 * Used by drm_print_memory_stats()
469 */
470struct drm_memory_stats {
471	u64 shared;
472	u64 private;
473	u64 resident;
474	u64 purgeable;
475	u64 active;
476};
477
478enum drm_gem_object_status;
479
480void drm_print_memory_stats(struct drm_printer *p,
481			    const struct drm_memory_stats *stats,
482			    enum drm_gem_object_status supported_status,
483			    const char *region);
484
485void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file);
486void drm_show_fdinfo(struct seq_file *m, struct file *f);
487
488struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags);
489
490#endif /* _DRM_FILE_H_ */