]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/drm_file.c
83e8c96ec4abeb17e5048ada5aed763098e43edc
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / drm_file.c
1 /*
2 * \author Rickard E. (Rik) Faith <faith@valinux.com>
3 * \author Daryll Strauss <daryll@valinux.com>
4 * \author Gareth Hughes <gareth@valinux.com>
5 */
6
7 /*
8 * Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
9 *
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * All Rights Reserved.
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice (including the next
22 * paragraph) shall be included in all copies or substantial portions of the
23 * Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31 * OTHER DEALINGS IN THE SOFTWARE.
32 */
33
34 #include <drm/drmP.h>
35 #include <linux/poll.h>
36 #include <linux/slab.h>
37 #include <linux/module.h>
38 #include "drm_legacy.h"
39 #include "drm_internal.h"
40 #include "drm_crtc_internal.h"
41
42 /* from BKL pushdown */
43 DEFINE_MUTEX(drm_global_mutex);
44
45 /**
46 * DOC: file operations
47 *
48 * Drivers must define the file operations structure that forms the DRM
49 * userspace API entry point, even though most of those operations are
50 * implemented in the DRM core. The mandatory functions are drm_open(),
51 * drm_read(), drm_ioctl() and drm_compat_ioctl() if CONFIG_COMPAT is enabled
52 * (note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n). Drivers which
53 * implement private ioctls that require 32/64 bit compatibility support must
54 * provide their own .compat_ioctl() handler that processes private ioctls and
55 * calls drm_compat_ioctl() for core ioctls.
56 *
57 * In addition drm_read() and drm_poll() provide support for DRM events. DRM
58 * events are a generic and extensible means to send asynchronous events to
59 * userspace through the file descriptor. They are used to send vblank event and
60 * page flip completions by the KMS API. But drivers can also use it for their
61 * own needs, e.g. to signal completion of rendering.
62 *
63 * The memory mapping implementation will vary depending on how the driver
64 * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
65 * function, modern drivers should use one of the provided memory-manager
66 * specific implementations. For GEM-based drivers this is drm_gem_mmap().
67 *
68 * No other file operations are supported by the DRM userspace API. Overall the
69 * following is an example #file_operations structure::
70 *
71 * static const example_drm_fops = {
72 * .owner = THIS_MODULE,
73 * .open = drm_open,
74 * .release = drm_release,
75 * .unlocked_ioctl = drm_ioctl,
76 * .compat_ioctl = drm_compat_ioctl, // NULL if CONFIG_COMPAT=n
77 * .poll = drm_poll,
78 * .read = drm_read,
79 * .llseek = no_llseek,
80 * .mmap = drm_gem_mmap,
81 * };
82 */
83
84 static int drm_open_helper(struct file *filp, struct drm_minor *minor);
85
86 static int drm_setup(struct drm_device * dev)
87 {
88 int ret;
89
90 if (dev->driver->firstopen &&
91 drm_core_check_feature(dev, DRIVER_LEGACY)) {
92 ret = dev->driver->firstopen(dev);
93 if (ret != 0)
94 return ret;
95 }
96
97 ret = drm_legacy_dma_setup(dev);
98 if (ret < 0)
99 return ret;
100
101
102 DRM_DEBUG("\n");
103 return 0;
104 }
105
106 /**
107 * drm_open - open method for DRM file
108 * @inode: device inode
109 * @filp: file pointer.
110 *
111 * This function must be used by drivers as their .open() #file_operations
112 * method. It looks up the correct DRM device and instantiates all the per-file
113 * resources for it.
114 *
115 * RETURNS:
116 *
117 * 0 on success or negative errno value on falure.
118 */
119 int drm_open(struct inode *inode, struct file *filp)
120 {
121 struct drm_device *dev;
122 struct drm_minor *minor;
123 int retcode;
124 int need_setup = 0;
125
126 minor = drm_minor_acquire(iminor(inode));
127 if (IS_ERR(minor))
128 return PTR_ERR(minor);
129
130 dev = minor->dev;
131 if (!dev->open_count++)
132 need_setup = 1;
133
134 /* share address_space across all char-devs of a single device */
135 filp->f_mapping = dev->anon_inode->i_mapping;
136
137 retcode = drm_open_helper(filp, minor);
138 if (retcode)
139 goto err_undo;
140 if (need_setup) {
141 retcode = drm_setup(dev);
142 if (retcode)
143 goto err_undo;
144 }
145 return 0;
146
147 err_undo:
148 dev->open_count--;
149 drm_minor_release(minor);
150 return retcode;
151 }
152 EXPORT_SYMBOL(drm_open);
153
154 /*
155 * Check whether DRI will run on this CPU.
156 *
157 * \return non-zero if the DRI will run on this CPU, or zero otherwise.
158 */
159 static int drm_cpu_valid(void)
160 {
161 #if defined(__sparc__) && !defined(__sparc_v9__)
162 return 0; /* No cmpxchg before v9 sparc. */
163 #endif
164 return 1;
165 }
166
167 /*
168 * Called whenever a process opens /dev/drm.
169 *
170 * \param filp file pointer.
171 * \param minor acquired minor-object.
172 * \return zero on success or a negative number on failure.
173 *
174 * Creates and initializes a drm_file structure for the file private data in \p
175 * filp and add it into the double linked list in \p dev.
176 */
177 static int drm_open_helper(struct file *filp, struct drm_minor *minor)
178 {
179 struct drm_device *dev = minor->dev;
180 struct drm_file *priv;
181 int ret;
182
183 if (filp->f_flags & O_EXCL)
184 return -EBUSY; /* No exclusive opens */
185 if (!drm_cpu_valid())
186 return -EINVAL;
187 if (dev->switch_power_state != DRM_SWITCH_POWER_ON && dev->switch_power_state != DRM_SWITCH_POWER_DYNAMIC_OFF)
188 return -EINVAL;
189
190 DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor->index);
191
192 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
193 if (!priv)
194 return -ENOMEM;
195
196 filp->private_data = priv;
197 priv->filp = filp;
198 priv->pid = get_pid(task_pid(current));
199 priv->minor = minor;
200
201 /* for compatibility root is always authenticated */
202 priv->authenticated = capable(CAP_SYS_ADMIN);
203 priv->lock_count = 0;
204
205 INIT_LIST_HEAD(&priv->lhead);
206 INIT_LIST_HEAD(&priv->fbs);
207 mutex_init(&priv->fbs_lock);
208 INIT_LIST_HEAD(&priv->blobs);
209 INIT_LIST_HEAD(&priv->pending_event_list);
210 INIT_LIST_HEAD(&priv->event_list);
211 init_waitqueue_head(&priv->event_wait);
212 priv->event_space = 4096; /* set aside 4k for event buffer */
213
214 mutex_init(&priv->event_read_lock);
215
216 if (drm_core_check_feature(dev, DRIVER_GEM))
217 drm_gem_open(dev, priv);
218
219 if (drm_core_check_feature(dev, DRIVER_PRIME))
220 drm_prime_init_file_private(&priv->prime);
221
222 if (dev->driver->open) {
223 ret = dev->driver->open(dev, priv);
224 if (ret < 0)
225 goto out_prime_destroy;
226 }
227
228 if (drm_is_primary_client(priv)) {
229 ret = drm_master_open(priv);
230 if (ret)
231 goto out_close;
232 }
233
234 mutex_lock(&dev->filelist_mutex);
235 list_add(&priv->lhead, &dev->filelist);
236 mutex_unlock(&dev->filelist_mutex);
237
238 #ifdef __alpha__
239 /*
240 * Default the hose
241 */
242 if (!dev->hose) {
243 struct pci_dev *pci_dev;
244 pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
245 if (pci_dev) {
246 dev->hose = pci_dev->sysdata;
247 pci_dev_put(pci_dev);
248 }
249 if (!dev->hose) {
250 struct pci_bus *b = list_entry(pci_root_buses.next,
251 struct pci_bus, node);
252 if (b)
253 dev->hose = b->sysdata;
254 }
255 }
256 #endif
257
258 return 0;
259
260 out_close:
261 if (dev->driver->postclose)
262 dev->driver->postclose(dev, priv);
263 out_prime_destroy:
264 if (drm_core_check_feature(dev, DRIVER_PRIME))
265 drm_prime_destroy_file_private(&priv->prime);
266 if (drm_core_check_feature(dev, DRIVER_GEM))
267 drm_gem_release(dev, priv);
268 put_pid(priv->pid);
269 kfree(priv);
270 filp->private_data = NULL;
271 return ret;
272 }
273
274 static void drm_events_release(struct drm_file *file_priv)
275 {
276 struct drm_device *dev = file_priv->minor->dev;
277 struct drm_pending_event *e, *et;
278 unsigned long flags;
279
280 spin_lock_irqsave(&dev->event_lock, flags);
281
282 /* Unlink pending events */
283 list_for_each_entry_safe(e, et, &file_priv->pending_event_list,
284 pending_link) {
285 list_del(&e->pending_link);
286 e->file_priv = NULL;
287 }
288
289 /* Remove unconsumed events */
290 list_for_each_entry_safe(e, et, &file_priv->event_list, link) {
291 list_del(&e->link);
292 kfree(e);
293 }
294
295 spin_unlock_irqrestore(&dev->event_lock, flags);
296 }
297
298 /*
299 * drm_legacy_dev_reinit
300 *
301 * Reinitializes a legacy/ums drm device in it's lastclose function.
302 */
303 static void drm_legacy_dev_reinit(struct drm_device *dev)
304 {
305 if (dev->irq_enabled)
306 drm_irq_uninstall(dev);
307
308 mutex_lock(&dev->struct_mutex);
309
310 drm_legacy_agp_clear(dev);
311
312 drm_legacy_sg_cleanup(dev);
313 drm_legacy_vma_flush(dev);
314 drm_legacy_dma_takedown(dev);
315
316 mutex_unlock(&dev->struct_mutex);
317
318 dev->sigdata.lock = NULL;
319
320 dev->context_flag = 0;
321 dev->last_context = 0;
322 dev->if_version = 0;
323
324 DRM_DEBUG("lastclose completed\n");
325 }
326
327 /*
328 * Take down the DRM device.
329 *
330 * \param dev DRM device structure.
331 *
332 * Frees every resource in \p dev.
333 *
334 * \sa drm_device
335 */
336 void drm_lastclose(struct drm_device * dev)
337 {
338 DRM_DEBUG("\n");
339
340 if (dev->driver->lastclose)
341 dev->driver->lastclose(dev);
342 DRM_DEBUG("driver lastclose completed\n");
343
344 if (drm_core_check_feature(dev, DRIVER_LEGACY))
345 drm_legacy_dev_reinit(dev);
346 }
347
348 /**
349 * drm_release - release method for DRM file
350 * @inode: device inode
351 * @filp: file pointer.
352 *
353 * This function must be used by drivers as their .release() #file_operations
354 * method. It frees any resources associated with the open file, and if this is
355 * the last open file for the DRM device also proceeds to call drm_lastclose().
356 *
357 * RETURNS:
358 *
359 * Always succeeds and returns 0.
360 */
361 int drm_release(struct inode *inode, struct file *filp)
362 {
363 struct drm_file *file_priv = filp->private_data;
364 struct drm_minor *minor = file_priv->minor;
365 struct drm_device *dev = minor->dev;
366
367 mutex_lock(&drm_global_mutex);
368
369 DRM_DEBUG("open_count = %d\n", dev->open_count);
370
371 mutex_lock(&dev->filelist_mutex);
372 list_del(&file_priv->lhead);
373 mutex_unlock(&dev->filelist_mutex);
374
375 if (dev->driver->preclose)
376 dev->driver->preclose(dev, file_priv);
377
378 /* ========================================================
379 * Begin inline drm_release
380 */
381
382 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
383 task_pid_nr(current),
384 (long)old_encode_dev(file_priv->minor->kdev->devt),
385 dev->open_count);
386
387 if (drm_core_check_feature(dev, DRIVER_LEGACY))
388 drm_legacy_lock_release(dev, filp);
389
390 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
391 drm_legacy_reclaim_buffers(dev, file_priv);
392
393 drm_events_release(file_priv);
394
395 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
396 drm_fb_release(file_priv);
397 drm_property_destroy_user_blobs(dev, file_priv);
398 }
399
400 if (drm_core_check_feature(dev, DRIVER_GEM))
401 drm_gem_release(dev, file_priv);
402
403 drm_legacy_ctxbitmap_flush(dev, file_priv);
404
405 if (drm_is_primary_client(file_priv))
406 drm_master_release(file_priv);
407
408 if (dev->driver->postclose)
409 dev->driver->postclose(dev, file_priv);
410
411 if (drm_core_check_feature(dev, DRIVER_PRIME))
412 drm_prime_destroy_file_private(&file_priv->prime);
413
414 WARN_ON(!list_empty(&file_priv->event_list));
415
416 put_pid(file_priv->pid);
417 kfree(file_priv);
418
419 /* ========================================================
420 * End inline drm_release
421 */
422
423 if (!--dev->open_count) {
424 drm_lastclose(dev);
425 if (drm_device_is_unplugged(dev))
426 drm_put_dev(dev);
427 }
428 mutex_unlock(&drm_global_mutex);
429
430 drm_minor_release(minor);
431
432 return 0;
433 }
434 EXPORT_SYMBOL(drm_release);
435
436 /**
437 * drm_read - read method for DRM file
438 * @filp: file pointer
439 * @buffer: userspace destination pointer for the read
440 * @count: count in bytes to read
441 * @offset: offset to read
442 *
443 * This function must be used by drivers as their .read() #file_operations
444 * method iff they use DRM events for asynchronous signalling to userspace.
445 * Since events are used by the KMS API for vblank and page flip completion this
446 * means all modern display drivers must use it.
447 *
448 * @offset is ignore, DRM events are read like a pipe. Therefore drivers also
449 * must set the .llseek() #file_operation to no_llseek(). Polling support is
450 * provided by drm_poll().
451 *
452 * This function will only ever read a full event. Therefore userspace must
453 * supply a big enough buffer to fit any event to ensure forward progress. Since
454 * the maximum event space is currently 4K it's recommended to just use that for
455 * safety.
456 *
457 * RETURNS:
458 *
459 * Number of bytes read (always aligned to full events, and can be 0) or a
460 * negative error code on failure.
461 */
462 ssize_t drm_read(struct file *filp, char __user *buffer,
463 size_t count, loff_t *offset)
464 {
465 struct drm_file *file_priv = filp->private_data;
466 struct drm_device *dev = file_priv->minor->dev;
467 ssize_t ret;
468
469 if (!access_ok(VERIFY_WRITE, buffer, count))
470 return -EFAULT;
471
472 ret = mutex_lock_interruptible(&file_priv->event_read_lock);
473 if (ret)
474 return ret;
475
476 for (;;) {
477 struct drm_pending_event *e = NULL;
478
479 spin_lock_irq(&dev->event_lock);
480 if (!list_empty(&file_priv->event_list)) {
481 e = list_first_entry(&file_priv->event_list,
482 struct drm_pending_event, link);
483 file_priv->event_space += e->event->length;
484 list_del(&e->link);
485 }
486 spin_unlock_irq(&dev->event_lock);
487
488 if (e == NULL) {
489 if (ret)
490 break;
491
492 if (filp->f_flags & O_NONBLOCK) {
493 ret = -EAGAIN;
494 break;
495 }
496
497 mutex_unlock(&file_priv->event_read_lock);
498 ret = wait_event_interruptible(file_priv->event_wait,
499 !list_empty(&file_priv->event_list));
500 if (ret >= 0)
501 ret = mutex_lock_interruptible(&file_priv->event_read_lock);
502 if (ret)
503 return ret;
504 } else {
505 unsigned length = e->event->length;
506
507 if (length > count - ret) {
508 put_back_event:
509 spin_lock_irq(&dev->event_lock);
510 file_priv->event_space -= length;
511 list_add(&e->link, &file_priv->event_list);
512 spin_unlock_irq(&dev->event_lock);
513 break;
514 }
515
516 if (copy_to_user(buffer + ret, e->event, length)) {
517 if (ret == 0)
518 ret = -EFAULT;
519 goto put_back_event;
520 }
521
522 ret += length;
523 kfree(e);
524 }
525 }
526 mutex_unlock(&file_priv->event_read_lock);
527
528 return ret;
529 }
530 EXPORT_SYMBOL(drm_read);
531
532 /**
533 * drm_poll - poll method for DRM file
534 * @filp: file pointer
535 * @wait: poll waiter table
536 *
537 * This function must be used by drivers as their .read() #file_operations
538 * method iff they use DRM events for asynchronous signalling to userspace.
539 * Since events are used by the KMS API for vblank and page flip completion this
540 * means all modern display drivers must use it.
541 *
542 * See also drm_read().
543 *
544 * RETURNS:
545 *
546 * Mask of POLL flags indicating the current status of the file.
547 */
548 unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
549 {
550 struct drm_file *file_priv = filp->private_data;
551 unsigned int mask = 0;
552
553 poll_wait(filp, &file_priv->event_wait, wait);
554
555 if (!list_empty(&file_priv->event_list))
556 mask |= POLLIN | POLLRDNORM;
557
558 return mask;
559 }
560 EXPORT_SYMBOL(drm_poll);
561
562 /**
563 * drm_event_reserve_init_locked - init a DRM event and reserve space for it
564 * @dev: DRM device
565 * @file_priv: DRM file private data
566 * @p: tracking structure for the pending event
567 * @e: actual event data to deliver to userspace
568 *
569 * This function prepares the passed in event for eventual delivery. If the event
570 * doesn't get delivered (because the IOCTL fails later on, before queuing up
571 * anything) then the even must be cancelled and freed using
572 * drm_event_cancel_free(). Successfully initialized events should be sent out
573 * using drm_send_event() or drm_send_event_locked() to signal completion of the
574 * asynchronous event to userspace.
575 *
576 * If callers embedded @p into a larger structure it must be allocated with
577 * kmalloc and @p must be the first member element.
578 *
579 * This is the locked version of drm_event_reserve_init() for callers which
580 * already hold &drm_device.event_lock.
581 *
582 * RETURNS:
583 *
584 * 0 on success or a negative error code on failure.
585 */
586 int drm_event_reserve_init_locked(struct drm_device *dev,
587 struct drm_file *file_priv,
588 struct drm_pending_event *p,
589 struct drm_event *e)
590 {
591 if (file_priv->event_space < e->length)
592 return -ENOMEM;
593
594 file_priv->event_space -= e->length;
595
596 p->event = e;
597 list_add(&p->pending_link, &file_priv->pending_event_list);
598 p->file_priv = file_priv;
599
600 return 0;
601 }
602 EXPORT_SYMBOL(drm_event_reserve_init_locked);
603
604 /**
605 * drm_event_reserve_init - init a DRM event and reserve space for it
606 * @dev: DRM device
607 * @file_priv: DRM file private data
608 * @p: tracking structure for the pending event
609 * @e: actual event data to deliver to userspace
610 *
611 * This function prepares the passed in event for eventual delivery. If the event
612 * doesn't get delivered (because the IOCTL fails later on, before queuing up
613 * anything) then the even must be cancelled and freed using
614 * drm_event_cancel_free(). Successfully initialized events should be sent out
615 * using drm_send_event() or drm_send_event_locked() to signal completion of the
616 * asynchronous event to userspace.
617 *
618 * If callers embedded @p into a larger structure it must be allocated with
619 * kmalloc and @p must be the first member element.
620 *
621 * Callers which already hold &drm_device.event_lock should use
622 * drm_event_reserve_init_locked() instead.
623 *
624 * RETURNS:
625 *
626 * 0 on success or a negative error code on failure.
627 */
628 int drm_event_reserve_init(struct drm_device *dev,
629 struct drm_file *file_priv,
630 struct drm_pending_event *p,
631 struct drm_event *e)
632 {
633 unsigned long flags;
634 int ret;
635
636 spin_lock_irqsave(&dev->event_lock, flags);
637 ret = drm_event_reserve_init_locked(dev, file_priv, p, e);
638 spin_unlock_irqrestore(&dev->event_lock, flags);
639
640 return ret;
641 }
642 EXPORT_SYMBOL(drm_event_reserve_init);
643
644 /**
645 * drm_event_cancel_free - free a DRM event and release it's space
646 * @dev: DRM device
647 * @p: tracking structure for the pending event
648 *
649 * This function frees the event @p initialized with drm_event_reserve_init()
650 * and releases any allocated space.
651 */
652 void drm_event_cancel_free(struct drm_device *dev,
653 struct drm_pending_event *p)
654 {
655 unsigned long flags;
656 spin_lock_irqsave(&dev->event_lock, flags);
657 if (p->file_priv) {
658 p->file_priv->event_space += p->event->length;
659 list_del(&p->pending_link);
660 }
661 spin_unlock_irqrestore(&dev->event_lock, flags);
662
663 if (p->fence)
664 dma_fence_put(p->fence);
665
666 kfree(p);
667 }
668 EXPORT_SYMBOL(drm_event_cancel_free);
669
670 /**
671 * drm_send_event_locked - send DRM event to file descriptor
672 * @dev: DRM device
673 * @e: DRM event to deliver
674 *
675 * This function sends the event @e, initialized with drm_event_reserve_init(),
676 * to its associated userspace DRM file. Callers must already hold
677 * &drm_device.event_lock, see drm_send_event() for the unlocked version.
678 *
679 * Note that the core will take care of unlinking and disarming events when the
680 * corresponding DRM file is closed. Drivers need not worry about whether the
681 * DRM file for this event still exists and can call this function upon
682 * completion of the asynchronous work unconditionally.
683 */
684 void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
685 {
686 assert_spin_locked(&dev->event_lock);
687
688 if (e->completion) {
689 complete_all(e->completion);
690 e->completion_release(e->completion);
691 e->completion = NULL;
692 }
693
694 if (e->fence) {
695 dma_fence_signal(e->fence);
696 dma_fence_put(e->fence);
697 }
698
699 if (!e->file_priv) {
700 kfree(e);
701 return;
702 }
703
704 list_del(&e->pending_link);
705 list_add_tail(&e->link,
706 &e->file_priv->event_list);
707 wake_up_interruptible(&e->file_priv->event_wait);
708 }
709 EXPORT_SYMBOL(drm_send_event_locked);
710
711 /**
712 * drm_send_event - send DRM event to file descriptor
713 * @dev: DRM device
714 * @e: DRM event to deliver
715 *
716 * This function sends the event @e, initialized with drm_event_reserve_init(),
717 * to its associated userspace DRM file. This function acquires
718 * &drm_device.event_lock, see drm_send_event_locked() for callers which already
719 * hold this lock.
720 *
721 * Note that the core will take care of unlinking and disarming events when the
722 * corresponding DRM file is closed. Drivers need not worry about whether the
723 * DRM file for this event still exists and can call this function upon
724 * completion of the asynchronous work unconditionally.
725 */
726 void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
727 {
728 unsigned long irqflags;
729
730 spin_lock_irqsave(&dev->event_lock, irqflags);
731 drm_send_event_locked(dev, e);
732 spin_unlock_irqrestore(&dev->event_lock, irqflags);
733 }
734 EXPORT_SYMBOL(drm_send_event);