mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 02:26:52 +07:00
drm/i915: Make i915_gem_object_phys_attach() use obj->mm.lock more appropriately
Actually transferring from shmemfs to the physically contiguous set of pages should be wholly guarded by its obj->mm.lock! v2: Remember to free the old pages. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20170726160038.29487-2-chris@chris-wilson.co.uk Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
fd70075f82
commit
6ea1d55d31
@ -565,7 +565,8 @@ int
|
|||||||
i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
|
i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
|
||||||
int align)
|
int align)
|
||||||
{
|
{
|
||||||
int ret;
|
struct sg_table *pages;
|
||||||
|
int err;
|
||||||
|
|
||||||
if (align > obj->base.size)
|
if (align > obj->base.size)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -573,32 +574,51 @@ i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
|
|||||||
if (obj->ops == &i915_gem_phys_ops)
|
if (obj->ops == &i915_gem_phys_ops)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (obj->mm.madv != I915_MADV_WILLNEED)
|
if (obj->ops != &i915_gem_object_ops)
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (obj->base.filp == NULL)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ret = i915_gem_object_unbind(obj);
|
err = i915_gem_object_unbind(obj);
|
||||||
if (ret)
|
if (err)
|
||||||
return ret;
|
return err;
|
||||||
|
|
||||||
__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
|
mutex_lock(&obj->mm.lock);
|
||||||
if (obj->mm.pages)
|
|
||||||
return -EBUSY;
|
|
||||||
|
|
||||||
GEM_BUG_ON(obj->ops != &i915_gem_object_ops);
|
if (obj->mm.madv != I915_MADV_WILLNEED) {
|
||||||
|
err = -EFAULT;
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj->mm.quirked) {
|
||||||
|
err = -EFAULT;
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj->mm.mapping) {
|
||||||
|
err = -EBUSY;
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
pages = obj->mm.pages;
|
||||||
obj->ops = &i915_gem_phys_ops;
|
obj->ops = &i915_gem_phys_ops;
|
||||||
|
|
||||||
ret = i915_gem_object_pin_pages(obj);
|
err = __i915_gem_object_get_pages(obj);
|
||||||
if (ret)
|
if (err)
|
||||||
goto err_xfer;
|
goto err_xfer;
|
||||||
|
|
||||||
|
/* Perma-pin (until release) the physical set of pages */
|
||||||
|
__i915_gem_object_pin_pages(obj);
|
||||||
|
|
||||||
|
if (!IS_ERR_OR_NULL(pages))
|
||||||
|
i915_gem_object_ops.put_pages(obj, pages);
|
||||||
|
mutex_unlock(&obj->mm.lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_xfer:
|
err_xfer:
|
||||||
obj->ops = &i915_gem_object_ops;
|
obj->ops = &i915_gem_object_ops;
|
||||||
return ret;
|
obj->mm.pages = pages;
|
||||||
|
err_unlock:
|
||||||
|
mutex_unlock(&obj->mm.lock);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user