[Intel-gfx] [PATCH 06/29] drm/i915: Protect private gem objects from truncate (such as imported dmabuf)
Chris Wilson
chris at chris-wilson.co.uk
Sat Aug 11 16:41:05 CEST 2012
If the object has no backing shmemfs filp, then we obviously cannot
perform a truncation operation upon it.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b16b5ff..2f4a113 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1385,6 +1385,11 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
{
struct inode *inode;
+ i915_gem_object_free_mmap_offset(obj);
+
+ if (obj->base.filp == NULL)
+ return;
+
/* Our goal here is to return as much of the memory as
* is possible back to the system as we are called from OOM.
* To do this we must instruct the shmfs to drop all of its
@@ -1393,8 +1398,6 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
inode = obj->base.filp->f_path.dentry->d_inode;
shmem_truncate_range(inode, 0, (loff_t)-1);
- i915_gem_object_free_mmap_offset(obj);
-
obj->madv = __I915_MADV_PURGED;
}
--
1.7.10.4
More information about the Intel-gfx
mailing list