Commit 16dad99d authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Patrik Jakobsson

drm/gma500: Acquire reservation lock for GEM objects

Protect concurrent access to struct psb_gem_object by acquiring
the GEM object's reservation lock; as it's supposed to be. The
use of the GTT mutex can now be moved into GTT code.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: default avatarPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220308195222.13471-3-tzimmermann@suse.de
parent de2d1822
...@@ -31,6 +31,10 @@ int psb_gem_pin(struct psb_gem_object *pobj) ...@@ -31,6 +31,10 @@ int psb_gem_pin(struct psb_gem_object *pobj)
unsigned int npages; unsigned int npages;
int ret; int ret;
ret = dma_resv_lock(obj->resv, NULL);
if (drm_WARN_ONCE(dev, ret, "dma_resv_lock() failed, ret=%d\n", ret))
return ret;
mutex_lock(&dev_priv->gtt_mutex); mutex_lock(&dev_priv->gtt_mutex);
if (pobj->in_gart || pobj->stolen) if (pobj->in_gart || pobj->stolen)
...@@ -56,11 +60,13 @@ int psb_gem_pin(struct psb_gem_object *pobj) ...@@ -56,11 +60,13 @@ int psb_gem_pin(struct psb_gem_object *pobj)
out: out:
++pobj->in_gart; ++pobj->in_gart;
mutex_unlock(&dev_priv->gtt_mutex); mutex_unlock(&dev_priv->gtt_mutex);
dma_resv_unlock(obj->resv);
return 0; return 0;
err_mutex_unlock: err_mutex_unlock:
mutex_unlock(&dev_priv->gtt_mutex); mutex_unlock(&dev_priv->gtt_mutex);
dma_resv_unlock(obj->resv);
return ret; return ret;
} }
...@@ -71,6 +77,11 @@ void psb_gem_unpin(struct psb_gem_object *pobj) ...@@ -71,6 +77,11 @@ void psb_gem_unpin(struct psb_gem_object *pobj)
struct drm_psb_private *dev_priv = to_drm_psb_private(dev); struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
u32 gpu_base = dev_priv->gtt.gatt_start; u32 gpu_base = dev_priv->gtt.gatt_start;
unsigned long npages; unsigned long npages;
int ret;
ret = dma_resv_lock(obj->resv, NULL);
if (drm_WARN_ONCE(dev, ret, "dma_resv_lock() failed, ret=%d\n", ret))
return;
mutex_lock(&dev_priv->gtt_mutex); mutex_lock(&dev_priv->gtt_mutex);
...@@ -95,6 +106,7 @@ void psb_gem_unpin(struct psb_gem_object *pobj) ...@@ -95,6 +106,7 @@ void psb_gem_unpin(struct psb_gem_object *pobj)
out: out:
mutex_unlock(&dev_priv->gtt_mutex); mutex_unlock(&dev_priv->gtt_mutex);
dma_resv_unlock(obj->resv);
} }
static vm_fault_t psb_gem_fault(struct vm_fault *vmf); static vm_fault_t psb_gem_fault(struct vm_fault *vmf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment