diff options
author | Rob Clark <robdclark@chromium.org> | 2022-08-02 18:51:40 +0300 |
---|---|---|
committer | Rob Clark <robdclark@chromium.org> | 2022-08-27 19:32:44 +0300 |
commit | 9fd5ff7f284a8554f9fa585ce45585deacfd7761 (patch) | |
tree | df6e8f9227743993f5cca0d736dc22cb436c8dcb /drivers/gpu/drm/msm/msm_gem.c | |
parent | e7cd5ee9aa77d9639566c721ad6dda8c25673235 (diff) | |
download | linux-9fd5ff7f284a8554f9fa585ce45585deacfd7761.tar.xz |
drm/msm/gem: Consolidate pin/unpin paths
Avoid having multiple spots where we increment/decrement pin_count (and
associated LRU updating)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/496130/
Link: https://lore.kernel.org/r/20220802155152.1727594-8-robdclark@gmail.com
Diffstat (limited to 'drivers/gpu/drm/msm/msm_gem.c')
-rw-r--r-- | drivers/gpu/drm/msm/msm_gem.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 3da64c7f65a2..407b18a24dc4 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -190,7 +190,7 @@ static struct page **msm_gem_pin_pages_locked(struct drm_gem_object *obj) p = get_pages(obj); if (!IS_ERR(p)) { - msm_obj->pin_count++; + to_msm_bo(obj)->pin_count++; update_lru(obj); } @@ -213,9 +213,7 @@ void msm_gem_unpin_pages(struct drm_gem_object *obj) struct msm_gem_object *msm_obj = to_msm_bo(obj); msm_gem_lock(obj); - msm_obj->pin_count--; - GEM_WARN_ON(msm_obj->pin_count < 0); - update_lru(obj); + msm_gem_unpin_locked(obj); msm_gem_unlock(obj); } @@ -436,14 +434,13 @@ int msm_gem_pin_vma_locked(struct drm_gem_object *obj, struct msm_gem_vma *vma) if (GEM_WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED)) return -EBUSY; - pages = get_pages(obj); + pages = msm_gem_pin_pages_locked(obj); if (IS_ERR(pages)) return PTR_ERR(pages); ret = msm_gem_map_vma(vma->aspace, vma, prot, msm_obj->sgt, obj->size); - - if (!ret) - msm_obj->pin_count++; + if (ret) + msm_gem_unpin_locked(obj); return ret; } |