2 * \author Rickard E. (Rik) Faith <faith@valinux.com>
3 * \author Daryll Strauss <daryll@valinux.com>
4 * \author Gareth Hughes <gareth@valinux.com>
8 * Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * All Rights Reserved.
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:
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
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.
34 #include <sys/types.h>
35 #include <sys/uio.h> /* must come first to avoid kfree() macros issues */
37 #include <linux/poll.h>
38 #include <linux/slab.h>
39 #include <linux/module.h>
41 #include <drm/drm_file.h>
44 #include "drm_legacy.h"
45 #include "drm_internal.h"
46 #include "drm_crtc_internal.h"
48 static void drm_events_release(struct drm_file *file_priv);
50 /* from BKL pushdown */
51 DEFINE_MUTEX(drm_global_mutex);
54 * DOC: file operations
56 * Drivers must define the file operations structure that forms the DRM
57 * userspace API entry point, even though most of those operations are
58 * implemented in the DRM core. The resulting &struct file_operations must be
59 * stored in the &drm_driver.fops field. The mandatory functions are drm_open(),
60 * drm_read(), drm_ioctl() and drm_compat_ioctl() if CONFIG_COMPAT is enabled
61 * Note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n, so there's no
62 * need to sprinkle #ifdef into the code. Drivers which implement private ioctls
63 * that require 32/64 bit compatibility support must provide their own
64 * &file_operations.compat_ioctl handler that processes private ioctls and calls
65 * drm_compat_ioctl() for core ioctls.
67 * In addition drm_read() and drm_poll() provide support for DRM events. DRM
68 * events are a generic and extensible means to send asynchronous events to
69 * userspace through the file descriptor. They are used to send vblank event and
70 * page flip completions by the KMS API. But drivers can also use it for their
71 * own needs, e.g. to signal completion of rendering.
73 * For the driver-side event interface see drm_event_reserve_init() and
74 * drm_send_event() as the main starting points.
76 * The memory mapping implementation will vary depending on how the driver
77 * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
78 * function, modern drivers should use one of the provided memory-manager
79 * specific implementations. For GEM-based drivers this is drm_gem_mmap(), and
80 * for drivers which use the CMA GEM helpers it's drm_gem_cma_mmap().
82 * No other file operations are supported by the DRM userspace API. Overall the
83 * following is an example &file_operations structure::
85 * static const example_drm_fops = {
86 * .owner = THIS_MODULE,
88 * .release = drm_release,
89 * .unlocked_ioctl = drm_ioctl,
90 * .compat_ioctl = drm_compat_ioctl, // NULL if CONFIG_COMPAT=n
93 * .llseek = no_llseek,
94 * .mmap = drm_gem_mmap,
97 * For plain GEM based drivers there is the DEFINE_DRM_GEM_FOPS() macro, and for
98 * CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make this
101 * The driver's &file_operations must be stored in &drm_driver.fops.
103 * For driver-private IOCTL handling see the more detailed discussion in
104 * :ref:`IOCTL support in the userland interfaces chapter<drm_driver_ioctl>`.
107 static int drm_open_helper(struct cdev *kdev, int flags,
108 struct file *filp, struct drm_minor *minor);
110 static int drm_setup(struct drm_device * dev)
114 if (dev->driver->firstopen &&
115 drm_core_check_feature(dev, DRIVER_LEGACY)) {
116 ret = dev->driver->firstopen(dev);
121 ret = drm_legacy_dma_setup(dev);
131 * drm_open - open method for DRM file
132 * @inode: device inode
133 * @filp: file pointer.
135 * This function must be used by drivers as their &file_operations.open method.
136 * It looks up the correct DRM device and instantiates all the per-file
137 * resources for it. It also calls the &drm_driver.open driver callback.
141 * 0 on success or negative errno value on falure.
143 // drm_open() is a file_operations function, not a dev_ops function
144 // int drm_open(struct inode *inode, struct file *filp)
145 int drm_open(struct dev_open_args *ap)
148 struct file *filp = ap->a_fpp ? *ap->a_fpp : NULL;
149 struct inode *inode = filp->f_data; /* A Linux inode is a Unix vnode */
150 struct cdev *kdev = ap->a_head.a_dev;
151 int flags = ap->a_oflags;
153 struct drm_device *dev;
154 struct drm_minor *minor;
158 minor = drm_minor_acquire(iminor(inode));
160 return PTR_ERR(minor);
163 if (!dev->open_count++)
166 /* share address_space across all char-devs of a single device */
168 filp->f_mapping = dev->anon_inode->i_mapping;
172 retcode = drm_open_helper(kdev, flags, filp, minor);
174 retcode = drm_open_helper(kdev, flags, ap->a_fp, minor);
179 retcode = drm_setup(dev);
184 device_busy(dev->dev->bsddev);
190 drm_minor_release(minor);
193 EXPORT_SYMBOL(drm_open);
199 drm_close(struct dev_close_args *ap)
202 struct file *filp = ap->a_fp;
203 struct inode *inode = filp->f_data; /* A Linux inode is a Unix vnode */
205 struct drm_file *file_priv = filp->private_data;
206 struct drm_minor *minor = drm_minor_acquire(iminor(inode));
207 struct drm_device *dev = minor->dev;
209 mutex_lock(&drm_global_mutex);
211 DRM_DEBUG("open_count = %d\n", dev->open_count);
213 mutex_lock(&dev->filelist_mutex);
214 list_del(&file_priv->lhead);
215 mutex_unlock(&dev->filelist_mutex);
217 if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
218 dev->driver->preclose)
219 dev->driver->preclose(dev, file_priv);
221 /* ========================================================
222 * Begin inline drm_release
225 DRM_DEBUG("pid = %d, device = 0x%p, open_count = %d\n",
230 if (drm_core_check_feature(dev, DRIVER_LEGACY))
231 drm_legacy_lock_release(dev, filp);
233 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
234 drm_legacy_reclaim_buffers(dev, file_priv);
236 drm_events_release(file_priv);
238 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
239 drm_fb_release(file_priv);
240 drm_property_destroy_user_blobs(dev, file_priv);
243 if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
244 drm_syncobj_release(file_priv);
246 if (drm_core_check_feature(dev, DRIVER_GEM))
247 drm_gem_release(dev, file_priv);
249 drm_legacy_ctxbitmap_flush(dev, file_priv);
251 if (drm_is_primary_client(file_priv))
252 drm_master_release(file_priv);
254 if (dev->driver->postclose)
255 dev->driver->postclose(dev, file_priv);
257 if (drm_core_check_feature(dev, DRIVER_PRIME))
258 drm_prime_destroy_file_private(&file_priv->prime);
260 WARN_ON(!list_empty(&file_priv->event_list));
262 put_pid(file_priv->pid);
265 /* ========================================================
266 * End inline drm_release
269 if (!--dev->open_count) {
271 #if 0 /* XXX: drm_put_dev() not implemented */
272 if (drm_dev_is_unplugged(dev))
276 mutex_unlock(&drm_global_mutex);
278 drm_minor_release(minor);
282 EXPORT_SYMBOL(drm_close);
285 * Check whether DRI will run on this CPU.
287 * \return non-zero if the DRI will run on this CPU, or zero otherwise.
289 static int drm_cpu_valid(void)
291 #if defined(__sparc__) && !defined(__sparc_v9__)
292 return 0; /* No cmpxchg before v9 sparc. */
298 * Called whenever a process opens /dev/drm.
300 * \param filp file pointer.
301 * \param minor acquired minor-object.
302 * \return zero on success or a negative number on failure.
304 * Creates and initializes a drm_file structure for the file private data in \p
305 * filp and add it into the double linked list in \p dev.
307 static int drm_open_helper(struct cdev *kdev, int flags,
308 struct file *filp, struct drm_minor *minor)
310 struct drm_device *dev = minor->dev;
311 struct drm_file *priv;
315 return -EBUSY; /* No exclusive opens */
316 if (!drm_cpu_valid())
319 DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, minor->index);
321 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
325 filp->private_data = priv;
327 priv->pid = curproc->p_pid;
331 /* for compatibility root is always authenticated */
332 priv->authenticated = capable(CAP_SYS_ADMIN);
333 priv->lock_count = 0;
335 INIT_LIST_HEAD(&priv->lhead);
336 INIT_LIST_HEAD(&priv->fbs);
337 lockinit(&priv->fbs_lock, "dpfl", 0, LK_CANRECURSE);
338 INIT_LIST_HEAD(&priv->blobs);
339 INIT_LIST_HEAD(&priv->pending_event_list);
340 INIT_LIST_HEAD(&priv->event_list);
341 init_waitqueue_head(&priv->event_wait);
342 priv->event_space = 4096; /* set aside 4k for event buffer */
344 lockinit(&priv->event_read_lock, "dperl", 0, LK_CANRECURSE);
346 if (drm_core_check_feature(dev, DRIVER_GEM))
347 drm_gem_open(dev, priv);
349 if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
350 drm_syncobj_open(priv);
352 if (drm_core_check_feature(dev, DRIVER_PRIME))
353 drm_prime_init_file_private(&priv->prime);
355 if (dev->driver->open) {
356 /* shared code returns -errno */
357 ret = -dev->driver->open(dev, priv);
359 goto out_prime_destroy;
366 if (drm_is_primary_client(priv)) {
367 ret = drm_master_open(priv);
372 mutex_lock(&dev->filelist_mutex);
373 list_add(&priv->lhead, &dev->filelist);
374 mutex_unlock(&dev->filelist_mutex);
381 struct pci_dev *pci_dev;
382 pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
384 dev->hose = pci_dev->sysdata;
385 pci_dev_put(pci_dev);
388 struct pci_bus *b = list_entry(pci_root_buses.next,
389 struct pci_bus, node);
391 dev->hose = b->sysdata;
399 if (dev->driver->postclose)
400 dev->driver->postclose(dev, priv);
402 if (drm_core_check_feature(dev, DRIVER_PRIME))
403 drm_prime_destroy_file_private(&priv->prime);
404 if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
405 drm_syncobj_release(priv);
406 if (drm_core_check_feature(dev, DRIVER_GEM))
407 drm_gem_release(dev, priv);
410 filp->private_data = NULL;
414 static void drm_events_release(struct drm_file *file_priv)
416 struct drm_device *dev = file_priv->minor->dev;
417 struct drm_pending_event *e, *et;
420 spin_lock_irqsave(&dev->event_lock, flags);
422 /* Unlink pending events */
423 list_for_each_entry_safe(e, et, &file_priv->pending_event_list,
425 list_del(&e->pending_link);
429 /* Remove unconsumed events */
430 list_for_each_entry_safe(e, et, &file_priv->event_list, link) {
435 spin_unlock_irqrestore(&dev->event_lock, flags);
438 static void drm_legacy_dev_reinit(struct drm_device *dev)
440 if (dev->irq_enabled)
441 drm_irq_uninstall(dev);
443 mutex_lock(&dev->struct_mutex);
445 drm_legacy_agp_clear(dev);
447 drm_legacy_sg_cleanup(dev);
448 drm_legacy_vma_flush(dev);
449 drm_legacy_dma_takedown(dev);
451 mutex_unlock(&dev->struct_mutex);
453 dev->sigdata.lock = NULL;
455 dev->context_flag = 0;
456 dev->last_context = 0;
459 DRM_DEBUG("lastclose completed\n");
462 void drm_lastclose(struct drm_device * dev)
466 if (dev->driver->lastclose)
467 dev->driver->lastclose(dev);
468 DRM_DEBUG("driver lastclose completed\n");
470 if (drm_core_check_feature(dev, DRIVER_LEGACY))
471 drm_legacy_dev_reinit(dev);
475 * drm_release - release method for DRM file
476 * @inode: device inode
477 * @filp: file pointer.
479 * This function must be used by drivers as their &file_operations.release
480 * method. It frees any resources associated with the open file, and calls the
481 * &drm_driver.postclose driver callback. If this is the last open file for the
482 * DRM device also proceeds to call the &drm_driver.lastclose driver callback.
486 * Always succeeds and returns 0.
488 int drm_release(struct inode *inode, struct file *filp)
490 struct drm_file *file_priv = filp->private_data;
491 struct drm_minor *minor = file_priv->minor;
492 struct drm_device *dev = minor->dev;
495 /* dev is not correctly set yet */
499 mutex_lock(&drm_global_mutex);
501 DRM_DEBUG("open_count = %d\n", dev->open_count);
503 mutex_lock(&dev->filelist_mutex);
504 list_del(&file_priv->lhead);
505 mutex_unlock(&dev->filelist_mutex);
507 if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
508 dev->driver->preclose)
509 dev->driver->preclose(dev, file_priv);
511 /* ========================================================
512 * Begin inline drm_release
515 DRM_DEBUG("pid = %d, device = 0x%p, open_count = %d\n",
520 if (drm_core_check_feature(dev, DRIVER_LEGACY))
521 drm_legacy_lock_release(dev, filp);
523 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
524 drm_legacy_reclaim_buffers(dev, file_priv);
526 drm_events_release(file_priv);
528 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
529 drm_fb_release(file_priv);
530 drm_property_destroy_user_blobs(dev, file_priv);
533 if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
534 drm_syncobj_release(file_priv);
536 if (drm_core_check_feature(dev, DRIVER_GEM))
537 drm_gem_release(dev, file_priv);
539 drm_legacy_ctxbitmap_flush(dev, file_priv);
541 if (drm_is_primary_client(file_priv))
542 drm_master_release(file_priv);
544 if (dev->driver->postclose)
545 dev->driver->postclose(dev, file_priv);
547 if (drm_core_check_feature(dev, DRIVER_PRIME))
548 drm_prime_destroy_file_private(&file_priv->prime);
550 WARN_ON(!list_empty(&file_priv->event_list));
552 put_pid(file_priv->pid);
555 /* ========================================================
556 * End inline drm_release
559 if (!--dev->open_count) {
561 #if 0 /* XXX: drm_put_dev() not implemented */
562 if (drm_dev_is_unplugged(dev))
566 mutex_unlock(&drm_global_mutex);
568 drm_minor_release(minor);
572 EXPORT_SYMBOL(drm_release);
575 * drm_read - read method for DRM file
576 * @filp: file pointer
577 * @buffer: userspace destination pointer for the read
578 * @count: count in bytes to read
579 * @offset: offset to read
581 * This function must be used by drivers as their &file_operations.read
582 * method iff they use DRM events for asynchronous signalling to userspace.
583 * Since events are used by the KMS API for vblank and page flip completion this
584 * means all modern display drivers must use it.
586 * @offset is ignored, DRM events are read like a pipe. Therefore drivers also
587 * must set the &file_operation.llseek to no_llseek(). Polling support is
588 * provided by drm_poll().
590 * This function will only ever read a full event. Therefore userspace must
591 * supply a big enough buffer to fit any event to ensure forward progress. Since
592 * the maximum event space is currently 4K it's recommended to just use that for
597 * Number of bytes read (always aligned to full events, and can be 0) or a
598 * negative error code on failure.
601 ssize_t drm_read(struct file *filp, char __user *buffer,
602 size_t count, loff_t *offset)
604 int drm_read(struct dev_read_args *ap)
606 struct file *filp = ap->a_fp;
607 struct uio *uio = ap->a_uio;
608 size_t count = uio->uio_resid;
609 struct drm_file *file_priv = filp->private_data;
610 struct drm_device *dev = file_priv->minor->dev;
611 int ret = 0; /* drm_read() returns int in DragonFly */
613 ret = mutex_lock_interruptible(&file_priv->event_read_lock);
618 struct drm_pending_event *e = NULL;
620 spin_lock_irq(&dev->event_lock);
621 if (!list_empty(&file_priv->event_list)) {
622 e = list_first_entry(&file_priv->event_list,
623 struct drm_pending_event, link);
624 file_priv->event_space += e->event->length;
627 spin_unlock_irq(&dev->event_lock);
631 ret = 0; /* DragonFly expects a zero return value on success */
635 if (filp->f_flag & O_NONBLOCK) {
640 mutex_unlock(&file_priv->event_read_lock);
641 ret = wait_event_interruptible(file_priv->event_wait,
642 !list_empty(&file_priv->event_list));
644 ret = mutex_lock_interruptible(&file_priv->event_read_lock);
648 unsigned length = e->event->length;
650 if (length > count - ret) {
652 spin_lock_irq(&dev->event_lock);
653 file_priv->event_space -= length;
654 list_add(&e->link, &file_priv->event_list);
655 spin_unlock_irq(&dev->event_lock);
659 if (uiomove((caddr_t)e->event, length, uio)) {
669 mutex_unlock(&file_priv->event_read_lock);
673 EXPORT_SYMBOL(drm_read);
676 * drm_poll - poll method for DRM file
677 * @filp: file pointer
678 * @wait: poll waiter table
680 * This function must be used by drivers as their &file_operations.read method
681 * iff they use DRM events for asynchronous signalling to userspace. Since
682 * events are used by the KMS API for vblank and page flip completion this means
683 * all modern display drivers must use it.
685 * See also drm_read().
689 * Mask of POLL flags indicating the current status of the file.
692 drmfilt(struct knote *kn, long hint)
694 struct drm_file *file_priv = (struct drm_file *)kn->kn_hook;
697 // poll_wait(filp, &file_priv->event_wait, wait);
699 if (!list_empty(&file_priv->event_list))
706 drmfilt_detach(struct knote *kn)
708 struct drm_file *file_priv;
711 file_priv = (struct drm_file *)kn->kn_hook;
713 klist = &file_priv->dkq.ki_note;
714 knote_remove(klist, kn);
717 static struct filterops drmfiltops =
718 { FILTEROP_MPSAFE | FILTEROP_ISFD, NULL, drmfilt_detach, drmfilt };
721 drm_kqfilter(struct dev_kqfilter_args *ap)
723 struct file *filp = ap->a_fp;
724 struct drm_file *file_priv = filp->private_data;
725 struct knote *kn = ap->a_kn;
730 switch (kn->kn_filter) {
733 kn->kn_fop = &drmfiltops;
734 kn->kn_hook = (caddr_t)file_priv;
737 ap->a_result = EOPNOTSUPP;
741 klist = &file_priv->dkq.ki_note;
742 knote_insert(klist, kn);
748 * drm_event_reserve_init_locked - init a DRM event and reserve space for it
750 * @file_priv: DRM file private data
751 * @p: tracking structure for the pending event
752 * @e: actual event data to deliver to userspace
754 * This function prepares the passed in event for eventual delivery. If the event
755 * doesn't get delivered (because the IOCTL fails later on, before queuing up
756 * anything) then the even must be cancelled and freed using
757 * drm_event_cancel_free(). Successfully initialized events should be sent out
758 * using drm_send_event() or drm_send_event_locked() to signal completion of the
759 * asynchronous event to userspace.
761 * If callers embedded @p into a larger structure it must be allocated with
762 * kmalloc and @p must be the first member element.
764 * This is the locked version of drm_event_reserve_init() for callers which
765 * already hold &drm_device.event_lock.
769 * 0 on success or a negative error code on failure.
771 int drm_event_reserve_init_locked(struct drm_device *dev,
772 struct drm_file *file_priv,
773 struct drm_pending_event *p,
776 if (file_priv->event_space < e->length)
779 file_priv->event_space -= e->length;
782 list_add(&p->pending_link, &file_priv->pending_event_list);
783 p->file_priv = file_priv;
787 EXPORT_SYMBOL(drm_event_reserve_init_locked);
790 * drm_event_reserve_init - init a DRM event and reserve space for it
792 * @file_priv: DRM file private data
793 * @p: tracking structure for the pending event
794 * @e: actual event data to deliver to userspace
796 * This function prepares the passed in event for eventual delivery. If the event
797 * doesn't get delivered (because the IOCTL fails later on, before queuing up
798 * anything) then the even must be cancelled and freed using
799 * drm_event_cancel_free(). Successfully initialized events should be sent out
800 * using drm_send_event() or drm_send_event_locked() to signal completion of the
801 * asynchronous event to userspace.
803 * If callers embedded @p into a larger structure it must be allocated with
804 * kmalloc and @p must be the first member element.
806 * Callers which already hold &drm_device.event_lock should use
807 * drm_event_reserve_init_locked() instead.
811 * 0 on success or a negative error code on failure.
813 int drm_event_reserve_init(struct drm_device *dev,
814 struct drm_file *file_priv,
815 struct drm_pending_event *p,
821 spin_lock_irqsave(&dev->event_lock, flags);
822 ret = drm_event_reserve_init_locked(dev, file_priv, p, e);
823 spin_unlock_irqrestore(&dev->event_lock, flags);
827 EXPORT_SYMBOL(drm_event_reserve_init);
830 * drm_event_cancel_free - free a DRM event and release it's space
832 * @p: tracking structure for the pending event
834 * This function frees the event @p initialized with drm_event_reserve_init()
835 * and releases any allocated space. It is used to cancel an event when the
836 * nonblocking operation could not be submitted and needed to be aborted.
838 void drm_event_cancel_free(struct drm_device *dev,
839 struct drm_pending_event *p)
842 spin_lock_irqsave(&dev->event_lock, flags);
844 p->file_priv->event_space += p->event->length;
845 list_del(&p->pending_link);
847 spin_unlock_irqrestore(&dev->event_lock, flags);
850 dma_fence_put(p->fence);
854 EXPORT_SYMBOL(drm_event_cancel_free);
857 * drm_send_event_locked - send DRM event to file descriptor
859 * @e: DRM event to deliver
861 * This function sends the event @e, initialized with drm_event_reserve_init(),
862 * to its associated userspace DRM file. Callers must already hold
863 * &drm_device.event_lock, see drm_send_event() for the unlocked version.
865 * Note that the core will take care of unlinking and disarming events when the
866 * corresponding DRM file is closed. Drivers need not worry about whether the
867 * DRM file for this event still exists and can call this function upon
868 * completion of the asynchronous work unconditionally.
870 void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
872 assert_spin_locked(&dev->event_lock);
875 complete_all(e->completion);
876 e->completion_release(e->completion);
877 e->completion = NULL;
881 dma_fence_signal(e->fence);
882 dma_fence_put(e->fence);
890 list_del(&e->pending_link);
891 list_add_tail(&e->link,
892 &e->file_priv->event_list);
893 wake_up_interruptible(&e->file_priv->event_wait);
895 KNOTE(&e->file_priv->dkq.ki_note, 0);
898 EXPORT_SYMBOL(drm_send_event_locked);
901 * drm_send_event - send DRM event to file descriptor
903 * @e: DRM event to deliver
905 * This function sends the event @e, initialized with drm_event_reserve_init(),
906 * to its associated userspace DRM file. This function acquires
907 * &drm_device.event_lock, see drm_send_event_locked() for callers which already
910 * Note that the core will take care of unlinking and disarming events when the
911 * corresponding DRM file is closed. Drivers need not worry about whether the
912 * DRM file for this event still exists and can call this function upon
913 * completion of the asynchronous work unconditionally.
915 void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
917 unsigned long irqflags;
919 spin_lock_irqsave(&dev->event_lock, irqflags);
920 drm_send_event_locked(dev, e);
921 spin_unlock_irqrestore(&dev->event_lock, irqflags);
923 EXPORT_SYMBOL(drm_send_event);