diff options
author | Rob Clark <robdclark@gmail.com> | 2016-05-27 11:16:28 -0400 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2016-07-16 10:09:07 -0400 |
commit | e1e9db2ca79575b8d6b4b5891194bb29c630c42d (patch) | |
tree | 645b6ec8caf75d2a26d6e62836eb514a5f78ad90 /drivers/gpu/drm/msm/msm_gem.c | |
parent | 18f23049f640e2590930c34009418c66e6ebf7b6 (diff) | |
download | op-kernel-dev-e1e9db2ca79575b8d6b4b5891194bb29c630c42d.zip op-kernel-dev-e1e9db2ca79575b8d6b4b5891194bb29c630c42d.tar.gz |
drm/msm: wire up vmap shrinker
Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/msm/msm_gem.c')
-rw-r--r-- | drivers/gpu/drm/msm/msm_gem.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index c05fc1d..886cfe0 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -421,6 +421,7 @@ void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj) if (msm_obj->vaddr == NULL) return ERR_PTR(-ENOMEM); } + msm_obj->vmap_count++; return msm_obj->vaddr; } @@ -435,13 +436,17 @@ void *msm_gem_get_vaddr(struct drm_gem_object *obj) void msm_gem_put_vaddr_locked(struct drm_gem_object *obj) { + struct msm_gem_object *msm_obj = to_msm_bo(obj); WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); - /* no-op for now */ + WARN_ON(msm_obj->vmap_count < 1); + msm_obj->vmap_count--; } void msm_gem_put_vaddr(struct drm_gem_object *obj) { - /* no-op for now */ + mutex_lock(&obj->dev->struct_mutex); + msm_gem_put_vaddr_locked(obj); + mutex_unlock(&obj->dev->struct_mutex); } /* Update madvise status, returns true if not purged, else @@ -470,8 +475,7 @@ void msm_gem_purge(struct drm_gem_object *obj) put_iova(obj); - vunmap(msm_obj->vaddr); - msm_obj->vaddr = NULL; + msm_gem_vunmap(obj); put_pages(obj); @@ -491,6 +495,17 @@ void msm_gem_purge(struct drm_gem_object *obj) 0, (loff_t)-1); } +void msm_gem_vunmap(struct drm_gem_object *obj) +{ + struct msm_gem_object *msm_obj = to_msm_bo(obj); + + if (!msm_obj->vaddr || WARN_ON(!is_vunmapable(msm_obj))) + return; + + vunmap(msm_obj->vaddr); + msm_obj->vaddr = NULL; +} + /* must be called before _move_to_active().. */ int msm_gem_sync_object(struct drm_gem_object *obj, struct msm_fence_context *fctx, bool exclusive) @@ -694,7 +709,7 @@ void msm_gem_free_object(struct drm_gem_object *obj) drm_prime_gem_destroy(obj, msm_obj->sgt); } else { - vunmap(msm_obj->vaddr); + msm_gem_vunmap(obj); put_pages(obj); } |