diff options
author | Alan Hourihane <alanh@fairlite.demon.co.uk> | 2007-05-18 13:48:56 +0100 |
---|---|---|
committer | Alan Hourihane <alanh@fairlite.demon.co.uk> | 2007-05-18 13:48:56 +0100 |
commit | 315cf14af814da60285adb95238181de430c6f68 (patch) | |
tree | 0474fc6591ffb1d4c76c3feb1f34df9ab6286eac /linux-core/drm_drv.c | |
parent | 95945bbf226610ba4f41381fd0436722082397ec (diff) | |
parent | ea98d7e79657469545b865a353784d79fc8cff9d (diff) |
Merge branch 'master' of git+ssh://git.freedesktop.org/git/mesa/drm into modesetting-101
Conflicts:
shared-core/i915_dma.c
Diffstat (limited to 'linux-core/drm_drv.c')
-rw-r--r-- | linux-core/drm_drv.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index dc52f302..76fb90c9 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -632,3 +632,45 @@ err_i1: return retcode; } EXPORT_SYMBOL(drm_ioctl); + +int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, int timeout, + int (*fn)(drm_device_t *dev, void *priv), void *priv) +{ + DECLARE_WAITQUEUE(entry, current); + unsigned long end = jiffies + (timeout); + int ret = 0; + add_wait_queue(queue, &entry); + + for (;;) { + __set_current_state(TASK_INTERRUPTIBLE); + if ((*fn)(dev, priv)) + break; + if (time_after_eq(jiffies, end)) { + ret = -EBUSY; + break; + } + schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); + if (signal_pending(current)) { + ret = -EINTR; + break; + } + } + __set_current_state(TASK_RUNNING); + remove_wait_queue(queue, &entry); + return ret; +} +EXPORT_SYMBOL(drm_wait_on); + +drm_local_map_t *drm_getsarea(struct drm_device *dev) +{ + drm_map_list_t *entry; + + list_for_each_entry(entry, &dev->maplist->head, head) { + if (entry->map && entry->map->type == _DRM_SHM && + (entry->map->flags & _DRM_CONTAINS_LOCK)) { + return entry->map; + } + } + return NULL; +} +EXPORT_SYMBOL(drm_getsarea); |