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>
This commit is contained in:
parent
86a1ee26bb
commit
4d6294bf77
1 changed files with 5 additions and 2 deletions
|
@ -1385,6 +1385,11 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
|
||||||
{
|
{
|
||||||
struct inode *inode;
|
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
|
/* Our goal here is to return as much of the memory as
|
||||||
* is possible back to the system as we are called from OOM.
|
* 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
|
* 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;
|
inode = obj->base.filp->f_path.dentry->d_inode;
|
||||||
shmem_truncate_range(inode, 0, (loff_t)-1);
|
shmem_truncate_range(inode, 0, (loff_t)-1);
|
||||||
|
|
||||||
i915_gem_object_free_mmap_offset(obj);
|
|
||||||
|
|
||||||
obj->madv = __I915_MADV_PURGED;
|
obj->madv = __I915_MADV_PURGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue