summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@openbsd.org>2013-03-10 15:56:23 +0100
committerMark Kettenis <kettenis@openbsd.org>2013-03-10 15:56:23 +0100
commit6c72e5081a474f55f569591415336cf91f88c3a0 (patch)
treea5c0d4fabbb8f428b6d138094c6ded477dc291c8 /sys/dev
parent098330ce3b0d632c91d1090795a9bdd550ba533e (diff)
move inteldrm_purge_obj to i915_gem.c and rename to i915_gem_object_truncate
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/drm/i915_drv.c25
-rw-r--r--sys/dev/pci/drm/i915_gem.c23
2 files changed, 18 insertions, 30 deletions
diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c
index 113d5f755b1..89a6b71776e 100644
--- a/sys/dev/pci/drm/i915_drv.c
+++ b/sys/dev/pci/drm/i915_drv.c
@@ -1496,31 +1496,6 @@ done:
return (ret);
}
-void
-inteldrm_purge_obj(struct drm_obj *obj)
-{
- struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
-
- DRM_ASSERT_HELD(obj);
- /*
- * may sleep. We free here instead of deactivate (which
- * the madvise() syscall would do) because in this case
- * (userland bo cache and GL_APPLE_object_purgeable objects in
- * OpenGL) the pages are defined to be freed if they were cleared
- * so kill them and free up the memory
- */
- simple_lock(&obj->uao->vmobjlock);
- obj->uao->pgops->pgo_flush(obj->uao, 0, obj->size,
- PGO_ALLPAGES | PGO_FREE);
- simple_unlock(&obj->uao->vmobjlock);
-
- /*
- * If flush failed, it may have halfway through, so just
- * always mark as purged
- */
- obj_priv->madv = __I915_MADV_PURGED;
-}
-
struct drm_obj *
i915_gem_find_inactive_object(struct inteldrm_softc *dev_priv,
size_t min_size)
diff --git a/sys/dev/pci/drm/i915_gem.c b/sys/dev/pci/drm/i915_gem.c
index ff19049fa48..2c385f61bca 100644
--- a/sys/dev/pci/drm/i915_gem.c
+++ b/sys/dev/pci/drm/i915_gem.c
@@ -74,6 +74,7 @@ void i915_gem_object_flush_gtt_write_domain(struct drm_i915_gem_object *);
void i915_gem_request_remove_from_client(struct drm_i915_gem_request *);
int i915_gem_object_flush_active(struct drm_i915_gem_object *);
int i915_gem_check_olr(struct intel_ring_buffer *, u32);
+void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
extern int ticks;
@@ -872,7 +873,20 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
return (i915_gem_mmap_gtt(file, dev, args->handle, &args->offset));
}
-// i915_gem_object_truncate
+/* Immediately discard the backing storage */
+void
+i915_gem_object_truncate(struct drm_i915_gem_object *obj)
+{
+ DRM_ASSERT_HELD(&obj->base);
+
+ 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;
+}
+
// i915_gem_object_is_purgeable
// i915_gem_object_put_pages_gtt
// i915_gem_object_put_pages
@@ -1434,7 +1448,7 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)
atomic_sub(obj->base.size, &dev->gtt_memory);
if (i915_gem_object_is_purgeable(obj))
- inteldrm_purge_obj(&obj->base);
+ i915_gem_object_truncate(obj);
return (0);
}
@@ -2515,9 +2529,8 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
obj->madv = args->madv;
/* if the object is no longer bound, discard its backing storage */
- if (i915_gem_object_is_purgeable(obj) &&
- obj->dmamap == NULL)
- inteldrm_purge_obj(&obj->base);
+ if (i915_gem_object_is_purgeable(obj) && obj->dmamap == NULL)
+ i915_gem_object_truncate(obj);
args->retained = obj->madv != __I915_MADV_PURGED;