summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/drmP.h36
-rw-r--r--sys/dev/pci/drm/drm_drv.c137
-rw-r--r--sys/dev/pci/drm/i915/i915_gem.c37
-rw-r--r--sys/dev/pci/drm/i915/i915_gem_tiling.c17
-rw-r--r--sys/dev/pci/drm/i915/intel_fb.c4
5 files changed, 20 insertions, 211 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index ff7ed042b33..80702aba32d 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.162 2014/01/22 22:17:34 jsg Exp $ */
+/* $OpenBSD: drmP.h,v 1.163 2014/01/30 15:10:47 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -1054,14 +1054,6 @@ int drm_gem_object_init(struct drm_device *dev,
void drm_unref(struct uvm_object *);
void drm_ref(struct uvm_object *);
-void drm_unref_locked(struct uvm_object *);
-void drm_ref_locked(struct uvm_object *);
-void drm_hold_object_locked(struct drm_gem_object *);
-void drm_hold_object(struct drm_gem_object *);
-void drm_unhold_object_locked(struct drm_gem_object *);
-void drm_unhold_object(struct drm_gem_object *);
-int drm_try_hold_object(struct drm_gem_object *);
-void drm_unhold_and_unref(struct drm_gem_object *);
int drm_gem_handle_create(struct drm_file *file_priv,
struct drm_gem_object *obj,
@@ -1100,38 +1092,12 @@ drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
DRM_UNLOCK();
}
-static __inline void
-drm_lock_obj(struct drm_gem_object *obj)
-{
- simple_lock(&obj->uobj);
-}
-
-static __inline void
-drm_unlock_obj(struct drm_gem_object *obj)
-{
- simple_unlock(&obj->uobj);
-}
-
static __inline__ int drm_core_check_feature(struct drm_device *dev,
int feature)
{
return ((dev->driver->flags & feature) ? 1 : 0);
}
-#ifdef DRMLOCKDEBUG
-
-#define DRM_ASSERT_HELD(obj) \
- KASSERT(obj->do_flags & DRM_BUSY && obj->holding_proc == curproc)
-#define DRM_OBJ_ASSERT_LOCKED(obj) /* XXX mutexes */
-#define DRM_ASSERT_LOCKED(lock) MUTEX_ASSERT_LOCKED(lock)
-#else
-
-#define DRM_ASSERT_HELD(obj)
-#define DRM_OBJ_ASSERT_LOCKED(obj)
-#define DRM_ASSERT_LOCKED(lock)
-
-#endif
-
#define DRM_PCIE_SPEED_25 1
#define DRM_PCIE_SPEED_50 2
#define DRM_PCIE_SPEED_80 4
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index 48a04caeb81..c9c088d9630 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_drv.c,v 1.121 2014/01/20 09:20:49 deraadt Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.122 2014/01/30 15:10:47 kettenis Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
@@ -1282,123 +1282,24 @@ struct uvm_pagerops drm_pgops = {
drm_flush,
};
-
-void
-drm_hold_object_locked(struct drm_gem_object *obj)
-{
- while (obj->do_flags & DRM_BUSY) {
- atomic_setbits_int(&obj->do_flags, DRM_WANTED);
- simple_unlock(&uobj->vmobjlock);
-#ifdef DRMLOCKDEBUG
- {
- int ret = 0;
- ret = tsleep(obj, PVM, "drm_hold", 3 * hz); /* XXX msleep */
- if (ret)
- printf("still waiting for obj %p, owned by %p\n",
- obj, obj->holding_proc);
- }
-#else
- tsleep(obj, PVM, "drm_hold", 0); /* XXX msleep */
-#endif
- simple_lock(&uobj->vmobjlock);
- }
-#ifdef DRMLOCKDEBUG
- obj->holding_proc = curproc;
-#endif
- atomic_setbits_int(&obj->do_flags, DRM_BUSY);
-}
-
-void
-drm_hold_object(struct drm_gem_object *obj)
-{
- simple_lock(&obj->uobj->vmobjlock);
- drm_hold_object_locked(obj);
- simple_unlock(&obj->uobj->vmobjlock);
-}
-
-int
-drm_try_hold_object(struct drm_gem_object *obj)
-{
- simple_lock(&obj->uobj->vmobjlock);
- /* if the object is free, grab it */
- if (obj->do_flags & (DRM_BUSY | DRM_WANTED))
- return (0);
- atomic_setbits_int(&obj->do_flags, DRM_BUSY);
-#ifdef DRMLOCKDEBUG
- obj->holding_proc = curproc;
-#endif
- simple_unlock(&obj->uobj->vmobjlock);
- return (1);
-}
-
-
-void
-drm_unhold_object_locked(struct drm_gem_object *obj)
-{
- if (obj->do_flags & DRM_WANTED)
- wakeup(obj);
-#ifdef DRMLOCKDEBUG
- obj->holding_proc = NULL;
-#endif
- atomic_clearbits_int(&obj->do_flags, DRM_WANTED | DRM_BUSY);
-}
-
-void
-drm_unhold_object(struct drm_gem_object *obj)
-{
- simple_lock(&obj->uobj->vmobjlock);
- drm_unhold_object_locked(obj);
- simple_unlock(&obj->uobj->vmobjlock);
-}
-
-void
-drm_ref_locked(struct uvm_object *uobj)
-{
- uobj->uo_refs++;
-}
-
void
drm_ref(struct uvm_object *uobj)
{
- simple_lock(&uobj->vmobjlock);
- drm_ref_locked(uobj);
- simple_unlock(&uobj->vmobjlock);
+ uobj->uo_refs++;
}
void
drm_unref(struct uvm_object *uobj)
{
- simple_lock(&uobj->vmobjlock);
- drm_unref_locked(uobj);
-}
-
-void
-drm_unref_locked(struct uvm_object *uobj)
-{
- struct drm_gem_object *obj = (struct drm_gem_object *)uobj;
- struct drm_device *dev = obj->dev;
+ struct drm_gem_object *obj = (struct drm_gem_object *)uobj;
+ struct drm_device *dev = obj->dev;
-again:
if (uobj->uo_refs > 1) {
uobj->uo_refs--;
- simple_unlock(&uobj->vmobjlock);
return;
}
- /* inlined version of drm_hold because we want to trylock then sleep */
- if (obj->do_flags & DRM_BUSY) {
- atomic_setbits_int(&obj->do_flags, DRM_WANTED);
- simple_unlock(&uobj->vmobjlock);
- tsleep(obj, PVM, "drm_unref", 0); /* XXX msleep */
- simple_lock(&uobj->vmobjlock);
- goto again;
- }
-#ifdef DRMLOCKDEBUG
- obj->holding_proc = curproc;
-#endif
- atomic_setbits_int(&obj->do_flags, DRM_BUSY);
- simple_unlock(&obj->vmobjlock);
- /* We own this thing now. it is on no queues, though it may still
+ /* We own this thing now. It is on no queues, though it may still
* be bound to the aperture (and on the inactive list, in which case
* idling the buffer is what triggered the free. Since we know no one
* else can grab it now, we can nuke with impunity.
@@ -1407,25 +1308,12 @@ again:
dev->driver->gem_free_object(obj);
}
-/*
- * convenience function to unreference and unhold an object.
- */
-void
-drm_unhold_and_unref(struct drm_gem_object *obj)
-{
- drm_lock_obj(obj);
- drm_unhold_object_locked(obj);
- drm_unref_locked(&obj->uobj);
-}
-
-
boolean_t
drm_flush(struct uvm_object *uobj, voff_t start, voff_t stop, int flags)
{
return (TRUE);
}
-
int
drm_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, vm_page_t *pps,
int npages, int centeridx, vm_fault_t fault_type,
@@ -1832,7 +1720,6 @@ udv_attach_drm(void *arg, vm_prot_t accessprot, voff_t off, vsize_t size)
if (dev->driver->mmap)
return dev->driver->mmap(dev, off, size);
-again:
DRM_LOCK();
TAILQ_FOREACH(map, &dev->maplist, link) {
if (off >= map->ext && off + size <= map->ext + map->size)
@@ -1845,21 +1732,7 @@ again:
}
obj = (struct drm_gem_object *)map->handle;
- simple_lock(&uobj->vmobjlock);
- if (obj->do_flags & DRM_BUSY) {
- atomic_setbits_int(&obj->do_flags, DRM_WANTED);
- simple_unlock(&uobj->vmobjlock);
- DRM_UNLOCK();
- tsleep(obj, PVM, "udv_drm", 0); /* XXX msleep */
- goto again;
- }
-#ifdef DRMLOCKDEBUG
- obj->holding_proc = curproc;
-#endif
- atomic_setbits_int(&obj->do_flags, DRM_BUSY);
- simple_unlock(&obj->vmobjlock);
drm_ref(&obj->uobj);
- drm_unhold_object(obj);
DRM_UNLOCK();
return &obj->uobj;
}
diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c
index baa7f56795e..7dec0527011 100644
--- a/sys/dev/pci/drm/i915/i915_gem.c
+++ b/sys/dev/pci/drm/i915/i915_gem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem.c,v 1.66 2014/01/21 08:57:22 kettenis Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.67 2014/01/30 15:10:47 kettenis Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -1473,21 +1473,12 @@ i915_gem_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
uvmfault_unlockall(ufi, NULL, &obj->base.uobj, NULL);
DRM_LOCK();
locked = uvmfault_relock(ufi);
- if (locked)
- drm_lock_obj(&obj->base);
}
- if (locked)
- drm_hold_object_locked(&obj->base);
- else { /* obj already unlocked */
+ if (!locked) {
dev_priv->entries--;
return (VM_PAGER_REFAULT);
}
- /* we have a hold set on the object now, we can unlock so that we can
- * sleep in binding and flushing.
- */
- drm_unlock_obj(&obj->base);
-
/* Now bind it into the GTT if needed */
ret = i915_gem_object_pin(obj, 0, true, false);
if (ret)
@@ -1526,7 +1517,6 @@ i915_gem_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
if (pmap_enter(ufi->orig_map->pmap, vaddr, paddr,
mapprot, PMAP_CANFAIL | mapprot) != 0) {
i915_gem_object_unpin(obj);
- drm_unhold_object(&obj->base);
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap,
NULL, NULL);
DRM_UNLOCK();
@@ -1538,7 +1528,6 @@ i915_gem_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
unpin:
i915_gem_object_unpin(obj);
unlock:
- drm_unhold_object(&obj->base);
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, NULL, NULL);
DRM_UNLOCK();
dev_priv->entries--;
@@ -1785,14 +1774,10 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
static void
i915_gem_object_truncate(struct drm_i915_gem_object *obj)
{
- DRM_ASSERT_HELD(&obj->base);
-
i915_gem_object_free_mmap_offset(obj);
- simple_lock(&obj->base.uao->vmobjlock);
obj->base.uao->pgops->pgo_flush(obj->base.uao, 0, obj->base.size,
PGO_ALLPAGES | PGO_FREE);
- simple_unlock(&obj->base.uao->vmobjlock);
obj->madv = __I915_MADV_PURGED;
}
@@ -3280,8 +3265,6 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
uint32_t old_write_domain, old_read_domains;
int ret;
- DRM_ASSERT_HELD(&obj->base);
-
/* Not valid to be called on unbound objects. */
if (obj->gtt_space == NULL)
return -EINVAL;
@@ -3548,8 +3531,6 @@ i915_gem_object_set_to_cpu_domain(struct drm_i915_gem_object *obj, bool write)
uint32_t old_write_domain, old_read_domains;
int ret;
- DRM_ASSERT_HELD(obj);
-
if (obj->base.write_domain == I915_GEM_DOMAIN_CPU)
return 0;
@@ -3714,8 +3695,6 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
goto unlock;
}
- drm_hold_object(&obj->base);
-
if (obj->madv != I915_MADV_WILLNEED) {
DRM_ERROR("Attempting to pin a purgeable buffer\n");
ret = -EINVAL;
@@ -3744,7 +3723,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
i915_gem_object_flush_cpu_write_domain(obj);
args->offset = obj->gtt_offset;
out:
- drm_unhold_and_unref(&obj->base);
+ drm_gem_object_unreference(&obj->base);
unlock:
DRM_UNLOCK();
return ret;
@@ -3768,8 +3747,6 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
goto unlock;
}
- drm_hold_object(&obj->base);
-
if (obj->pin_filp != file) {
DRM_ERROR("Not pinned by caller in i915_gem_pin_ioctl(): %d\n",
args->handle);
@@ -3783,7 +3760,7 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
}
out:
- drm_unhold_and_unref(&obj->base);
+ drm_gem_object_unreference(&obj->base);
unlock:
DRM_UNLOCK();
return ret;
@@ -3861,8 +3838,6 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
goto unlock;
}
- drm_hold_object(&obj->base);
-
if (obj->pin_count) {
ret = -EINVAL;
goto out;
@@ -3878,7 +3853,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
args->retained = obj->madv != __I915_MADV_PURGED;
out:
- drm_unhold_and_unref(&obj->base);
+ drm_gem_object_unreference(&obj->base);
unlock:
DRM_UNLOCK();
return ret;
@@ -3959,8 +3934,6 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
struct drm_device *dev = obj->base.dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- DRM_ASSERT_HELD(&obj->base);
-
if (obj->phys_obj)
i915_gem_detach_phys_object(dev, obj);
diff --git a/sys/dev/pci/drm/i915/i915_gem_tiling.c b/sys/dev/pci/drm/i915/i915_gem_tiling.c
index bc84a9e7f7e..569d310fbe2 100644
--- a/sys/dev/pci/drm/i915/i915_gem_tiling.c
+++ b/sys/dev/pci/drm/i915/i915_gem_tiling.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem_tiling.c,v 1.13 2014/01/21 08:57:22 kettenis Exp $ */
+/* $OpenBSD: i915_gem_tiling.c,v 1.14 2014/01/30 15:10:48 kettenis Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -329,17 +329,16 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
if (&obj->base == NULL)
return -ENOENT;
- drm_hold_object(&obj->base);
if (!i915_tiling_ok(dev,
args->stride, obj->base.size, args->tiling_mode)) {
- ret = -EINVAL;
- goto out;
+ drm_gem_object_unreference_unlocked(&obj->base);
+ return -EINVAL;
}
if (obj->pin_count) {
- ret = -EBUSY;
- goto out;
+ drm_gem_object_unreference_unlocked(&obj->base);
+ return -EBUSY;
}
if (args->tiling_mode == I915_TILING_NONE) {
@@ -417,9 +416,8 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
/* we have to maintain this existing ABI... */
args->stride = obj->stride;
args->tiling_mode = obj->tiling_mode;
+ drm_gem_object_unreference(&obj->base);
DRM_UNLOCK();
-out:
- drm_unhold_and_unref(&obj->base);
return ret;
}
@@ -438,7 +436,6 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
if (&obj->base == NULL)
return -ENOENT;
- drm_hold_object(&obj->base);
DRM_LOCK();
@@ -463,8 +460,8 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
+ drm_gem_object_unreference(&obj->base);
DRM_UNLOCK();
- drm_unhold_and_unref(&obj->base);
return 0;
}
diff --git a/sys/dev/pci/drm/i915/intel_fb.c b/sys/dev/pci/drm/i915/intel_fb.c
index 2c27c357af1..c2ff357db63 100644
--- a/sys/dev/pci/drm/i915/intel_fb.c
+++ b/sys/dev/pci/drm/i915/intel_fb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_fb.c,v 1.9 2014/01/24 04:05:06 jsg Exp $ */
+/* $OpenBSD: intel_fb.c,v 1.10 2014/01/30 15:10:48 kettenis Exp $ */
/*
* Copyright © 2007 David Airlie
*
@@ -237,7 +237,7 @@ static void intel_fbdev_destroy(struct drm_device *dev,
drm_framebuffer_cleanup(&ifb->base);
if (ifb->obj) {
- drm_gem_object_unreference(&ifb->obj->base);
+ drm_gem_object_unreference_unlocked(&ifb->obj->base);
ifb->obj = NULL;
}
}