diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-11 10:41:05 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-08-23 20:04:31 -0400 |
commit | 4d6294bf77834276d41b51154a18663b0a8f2063 (patch) | |
tree | 05d5ade15309741955af9dbced1af353abbae3c0 /drivers/gpu | |
parent | 86a1ee26bb60e1ab8984e92f0e9186c354670aed (diff) |
drm/i915: Protect private gem objects from truncate (such as imported dmabuf)
If the object has no backing shmemfs filp, then we obviously cannot
perform a truncation operation upon it.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 1ec5f7ef2cc2..eb54a6d81517 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) | |||
1385 | { | 1385 | { |
1386 | struct inode *inode; | 1386 | struct inode *inode; |
1387 | 1387 | ||
1388 | i915_gem_object_free_mmap_offset(obj); | ||
1389 | |||
1390 | if (obj->base.filp == NULL) | ||
1391 | return; | ||
1392 | |||
1388 | /* Our goal here is to return as much of the memory as | 1393 | /* Our goal here is to return as much of the memory as |
1389 | * is possible back to the system as we are called from OOM. | 1394 | * is possible back to the system as we are called from OOM. |
1390 | * To do this we must instruct the shmfs to drop all of its | 1395 | * 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) | |||
1393 | inode = obj->base.filp->f_path.dentry->d_inode; | 1398 | inode = obj->base.filp->f_path.dentry->d_inode; |
1394 | shmem_truncate_range(inode, 0, (loff_t)-1); | 1399 | shmem_truncate_range(inode, 0, (loff_t)-1); |
1395 | 1400 | ||
1396 | i915_gem_object_free_mmap_offset(obj); | ||
1397 | |||
1398 | obj->madv = __I915_MADV_PURGED; | 1401 | obj->madv = __I915_MADV_PURGED; |
1399 | } | 1402 | } |
1400 | 1403 | ||