blob: bf0a740122bf815cd3fbc9a7ed3710cb98af6848 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
Dave Airlieb5e89ed2005-09-25 14:28:13 +10002 * \file drm_fops.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * File operations for DRM
Dave Airlieb5e89ed2005-09-25 14:28:13 +10004 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 * \author Daryll Strauss <daryll@valinux.com>
7 * \author Gareth Hughes <gareth@valinux.com>
8 */
9
10/*
11 * Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
12 *
13 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
14 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
15 * All Rights Reserved.
16 *
17 * Permission is hereby granted, free of charge, to any person obtaining a
18 * copy of this software and associated documentation files (the "Software"),
19 * to deal in the Software without restriction, including without limitation
20 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
21 * and/or sell copies of the Software, and to permit persons to whom the
22 * Software is furnished to do so, subject to the following conditions:
23 *
24 * The above copyright notice and this permission notice (including the next
25 * paragraph) shall be included in all copies or substantial portions of the
26 * Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
31 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
32 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
33 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34 * OTHER DEALINGS IN THE SOFTWARE.
35 */
36
37#include "drmP.h"
38#include <linux/poll.h>
39
Dave Airlieb5e89ed2005-09-25 14:28:13 +100040static int drm_open_helper(struct inode *inode, struct file *filp,
41 drm_device_t * dev);
Dave Airliec94f7022005-07-07 21:03:38 +100042
Dave Airlieb5e89ed2005-09-25 14:28:13 +100043static int drm_setup(drm_device_t * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
45 int i;
46 int ret;
47
Dave Airlieb5e89ed2005-09-25 14:28:13 +100048 if (dev->driver->presetup) {
49 ret = dev->driver->presetup(dev);
50 if (ret != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 return ret;
52 }
53
Dave Airlieb5e89ed2005-09-25 14:28:13 +100054 atomic_set(&dev->ioctl_count, 0);
55 atomic_set(&dev->vma_count, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 dev->buf_use = 0;
Dave Airlieb5e89ed2005-09-25 14:28:13 +100057 atomic_set(&dev->buf_alloc, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Dave Airlieb5e89ed2005-09-25 14:28:13 +100059 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) {
60 i = drm_dma_setup(dev);
61 if (i < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 return i;
63 }
64
Dave Airlieb5e89ed2005-09-25 14:28:13 +100065 for (i = 0; i < DRM_ARRAY_SIZE(dev->counts); i++)
66 atomic_set(&dev->counts[i], 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Dave Airlieb5e89ed2005-09-25 14:28:13 +100068 for (i = 0; i < DRM_HASH_SIZE; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 dev->magiclist[i].head = NULL;
70 dev->magiclist[i].tail = NULL;
71 }
72
Dave Airlieb5e89ed2005-09-25 14:28:13 +100073 dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST);
74 if (dev->ctxlist == NULL)
75 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 memset(dev->ctxlist, 0, sizeof(*dev->ctxlist));
77 INIT_LIST_HEAD(&dev->ctxlist->head);
78
79 dev->vmalist = NULL;
80 dev->sigdata.lock = dev->lock.hw_lock = NULL;
Dave Airlieb5e89ed2005-09-25 14:28:13 +100081 init_waitqueue_head(&dev->lock.lock_queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 dev->queue_count = 0;
83 dev->queue_reserved = 0;
84 dev->queue_slots = 0;
85 dev->queuelist = NULL;
86 dev->irq_enabled = 0;
87 dev->context_flag = 0;
88 dev->interrupt_flag = 0;
89 dev->dma_flag = 0;
90 dev->last_context = 0;
91 dev->last_switch = 0;
92 dev->last_checked = 0;
Dave Airlieb5e89ed2005-09-25 14:28:13 +100093 init_waitqueue_head(&dev->context_wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 dev->if_version = 0;
95
96 dev->ctx_start = 0;
97 dev->lck_start = 0;
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 dev->buf_async = NULL;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000100 init_waitqueue_head(&dev->buf_readers);
101 init_waitqueue_head(&dev->buf_writers);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000103 DRM_DEBUG("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 /*
106 * The kernel's context could be created here, but is now created
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000107 * in drm_dma_enqueue. This is more resource-efficient for
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 * hardware that does not do DMA, but may mean that
109 * drm_select_queue fails between the time the interrupt is
110 * initialized and the time the queues are initialized.
111 */
112 if (dev->driver->postsetup)
113 dev->driver->postsetup(dev);
114
115 return 0;
116}
117
118/**
119 * Open file.
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000120 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 * \param inode device inode
122 * \param filp file pointer.
123 * \return zero on success or a negative number on failure.
124 *
125 * Searches the DRM device with the same minor number, calls open_helper(), and
126 * increments the device open count. If the open count was previous at zero,
127 * i.e., it's the first that the device is open, then calls setup().
128 */
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000129int drm_open(struct inode *inode, struct file *filp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130{
131 drm_device_t *dev = NULL;
132 int minor = iminor(inode);
133 int retcode = 0;
134
135 if (!((minor >= 0) && (minor < drm_cards_limit)))
136 return -ENODEV;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 if (!drm_heads[minor])
139 return -ENODEV;
140
141 if (!(dev = drm_heads[minor]->dev))
142 return -ENODEV;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000143
144 retcode = drm_open_helper(inode, filp, dev);
145 if (!retcode) {
146 atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
147 spin_lock(&dev->count_lock);
148 if (!dev->open_count++) {
149 spin_unlock(&dev->count_lock);
150 return drm_setup(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000152 spin_unlock(&dev->count_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 }
154
155 return retcode;
156}
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158EXPORT_SYMBOL(drm_open);
159
160/**
161 * Release file.
162 *
163 * \param inode device inode
164 * \param filp file pointer.
165 * \return zero on success or a negative number on failure.
166 *
167 * If the hardware lock is held then free it, and take it again for the kernel
168 * context since it's necessary to reclaim buffers. Unlink the file private
169 * data from its list and free it. Decreases the open count and if it reaches
170 * zero calls takedown().
171 */
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000172int drm_release(struct inode *inode, struct file *filp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173{
174 drm_file_t *priv = filp->private_data;
175 drm_device_t *dev;
176 int retcode = 0;
177
178 lock_kernel();
179 dev = priv->head->dev;
180
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000181 DRM_DEBUG("open_count = %d\n", dev->open_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 if (dev->driver->prerelease)
184 dev->driver->prerelease(dev, filp);
185
186 /* ========================================================
187 * Begin inline drm_release
188 */
189
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000190 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
191 current->pid, (long)old_encode_dev(priv->head->device),
192 dev->open_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000194 if (priv->lock_count && dev->lock.hw_lock &&
195 _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
196 dev->lock.filp == filp) {
197 DRM_DEBUG("File %p released, freeing lock for context %d\n",
198 filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
199
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 if (dev->driver->release)
201 dev->driver->release(dev, filp);
202
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000203 drm_lock_free(dev, &dev->lock.hw_lock->lock,
204 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000206 /* FIXME: may require heavy-handed reset of
207 hardware at this point, possibly
208 processed via a callback to the X
209 server. */
210 } else if (dev->driver->release && priv->lock_count
211 && dev->lock.hw_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 /* The lock is required to reclaim buffers */
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000213 DECLARE_WAITQUEUE(entry, current);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000215 add_wait_queue(&dev->lock.lock_queue, &entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 for (;;) {
217 __set_current_state(TASK_INTERRUPTIBLE);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000218 if (!dev->lock.hw_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 /* Device has been unregistered */
220 retcode = -EINTR;
221 break;
222 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000223 if (drm_lock_take(&dev->lock.hw_lock->lock,
224 DRM_KERNEL_CONTEXT)) {
225 dev->lock.filp = filp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 dev->lock.lock_time = jiffies;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000227 atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 break; /* Got lock */
229 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000230 /* Contention */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 schedule();
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000232 if (signal_pending(current)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 retcode = -ERESTARTSYS;
234 break;
235 }
236 }
237 __set_current_state(TASK_RUNNING);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000238 remove_wait_queue(&dev->lock.lock_queue, &entry);
239 if (!retcode) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 if (dev->driver->release)
241 dev->driver->release(dev, filp);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000242 drm_lock_free(dev, &dev->lock.hw_lock->lock,
243 DRM_KERNEL_CONTEXT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 }
245 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000246
247 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)
248 && !dev->driver->release) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 dev->driver->reclaim_buffers(dev, filp);
250 }
251
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000252 drm_fasync(-1, filp, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000254 down(&dev->ctxlist_sem);
255 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 drm_ctx_list_t *pos, *n;
257
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000258 list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) {
259 if (pos->tag == priv &&
260 pos->handle != DRM_KERNEL_CONTEXT) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 if (dev->driver->context_dtor)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000262 dev->driver->context_dtor(dev,
263 pos->handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000265 drm_ctxbitmap_free(dev, pos->handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000267 list_del(&pos->head);
268 drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 --dev->ctx_count;
270 }
271 }
272 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000273 up(&dev->ctxlist_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000275 down(&dev->struct_sem);
276 if (priv->remove_auth_on_close == 1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 drm_file_t *temp = dev->file_first;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000278 while (temp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 temp->authenticated = 0;
280 temp = temp->next;
281 }
282 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000283 if (priv->prev) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 priv->prev->next = priv->next;
285 } else {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000286 dev->file_first = priv->next;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000288 if (priv->next) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 priv->next->prev = priv->prev;
290 } else {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000291 dev->file_last = priv->prev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000293 up(&dev->struct_sem);
294
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 if (dev->driver->free_filp_priv)
296 dev->driver->free_filp_priv(dev, priv);
297
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000298 drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
300 /* ========================================================
301 * End inline drm_release
302 */
303
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000304 atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
305 spin_lock(&dev->count_lock);
306 if (!--dev->open_count) {
307 if (atomic_read(&dev->ioctl_count) || dev->blocked) {
308 DRM_ERROR("Device busy: %d %d\n",
309 atomic_read(&dev->ioctl_count), dev->blocked);
310 spin_unlock(&dev->count_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 unlock_kernel();
312 return -EBUSY;
313 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000314 spin_unlock(&dev->count_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 unlock_kernel();
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000316 return drm_takedown(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000318 spin_unlock(&dev->count_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320 unlock_kernel();
321
322 return retcode;
323}
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000324
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325EXPORT_SYMBOL(drm_release);
326
327/**
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000328 * Called whenever a process opens /dev/drm.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 *
330 * \param inode device inode.
331 * \param filp file pointer.
332 * \param dev device.
333 * \return zero on success or a negative number on failure.
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000334 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 * Creates and initializes a drm_file structure for the file private data in \p
336 * filp and add it into the double linked list in \p dev.
337 */
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000338static int drm_open_helper(struct inode *inode, struct file *filp,
339 drm_device_t * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340{
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000341 int minor = iminor(inode);
342 drm_file_t *priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 int ret;
344
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000345 if (filp->f_flags & O_EXCL)
346 return -EBUSY; /* No exclusive opens */
347 if (!drm_cpu_valid())
348 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
350 DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);
351
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000352 priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
353 if (!priv)
354 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356 memset(priv, 0, sizeof(*priv));
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000357 filp->private_data = priv;
358 priv->uid = current->euid;
359 priv->pid = current->pid;
360 priv->minor = minor;
361 priv->head = drm_heads[minor];
362 priv->ioctl_count = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 priv->authenticated = capable(CAP_SYS_ADMIN);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000364 priv->lock_count = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366 if (dev->driver->open_helper) {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000367 ret = dev->driver->open_helper(dev, priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 if (ret < 0)
369 goto out_free;
370 }
371
372 down(&dev->struct_sem);
373 if (!dev->file_last) {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000374 priv->next = NULL;
375 priv->prev = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 dev->file_first = priv;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000377 dev->file_last = priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 } else {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000379 priv->next = NULL;
380 priv->prev = dev->file_last;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 dev->file_last->next = priv;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000382 dev->file_last = priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 }
384 up(&dev->struct_sem);
385
386#ifdef __alpha__
387 /*
388 * Default the hose
389 */
390 if (!dev->hose) {
391 struct pci_dev *pci_dev;
392 pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
393 if (pci_dev) {
394 dev->hose = pci_dev->sysdata;
395 pci_dev_put(pci_dev);
396 }
397 if (!dev->hose) {
398 struct pci_bus *b = pci_bus_b(pci_root_buses.next);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000399 if (b)
400 dev->hose = b->sysdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 }
402 }
403#endif
404
405 return 0;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000406 out_free:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000408 filp->private_data = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 return ret;
410}
411
412/** No-op. */
413int drm_flush(struct file *filp)
414{
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000415 drm_file_t *priv = filp->private_data;
416 drm_device_t *dev = priv->head->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
418 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000419 current->pid, (long)old_encode_dev(priv->head->device),
420 dev->open_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 return 0;
422}
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424EXPORT_SYMBOL(drm_flush);
425
426/** No-op. */
427int drm_fasync(int fd, struct file *filp, int on)
428{
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000429 drm_file_t *priv = filp->private_data;
430 drm_device_t *dev = priv->head->dev;
431 int retcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000433 DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
434 (long)old_encode_dev(priv->head->device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 retcode = fasync_helper(fd, filp, on, &dev->buf_async);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000436 if (retcode < 0)
437 return retcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 return 0;
439}
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000440
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441EXPORT_SYMBOL(drm_fasync);
442
443/** No-op. */
444unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
445{
446 return 0;
447}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000449EXPORT_SYMBOL(drm_poll);