Commit ca35ab2a authored by Rob Clark's avatar Rob Clark

drm/msm/gem: Split out inuse helper

Prep for a following patch, where it gets a bit more complicated.
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220411215849.297838-5-robdclark@gmail.comSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 8e30fa32
...@@ -937,7 +937,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, ...@@ -937,7 +937,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m,
name, comm ? ":" : "", comm ? comm : "", name, comm ? ":" : "", comm ? comm : "",
vma->aspace, vma->iova, vma->aspace, vma->iova,
vma->mapped ? "mapped" : "unmapped", vma->mapped ? "mapped" : "unmapped",
vma->inuse); msm_gem_vma_inuse(vma));
kfree(comm); kfree(comm);
} }
......
...@@ -61,6 +61,7 @@ struct msm_gem_vma { ...@@ -61,6 +61,7 @@ struct msm_gem_vma {
int msm_gem_init_vma(struct msm_gem_address_space *aspace, int msm_gem_init_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma, int npages, struct msm_gem_vma *vma, int npages,
u64 range_start, u64 range_end); u64 range_start, u64 range_end);
bool msm_gem_vma_inuse(struct msm_gem_vma *vma);
void msm_gem_purge_vma(struct msm_gem_address_space *aspace, void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma); struct msm_gem_vma *vma);
void msm_gem_unmap_vma(struct msm_gem_address_space *aspace, void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
......
...@@ -37,6 +37,11 @@ msm_gem_address_space_get(struct msm_gem_address_space *aspace) ...@@ -37,6 +37,11 @@ msm_gem_address_space_get(struct msm_gem_address_space *aspace)
return aspace; return aspace;
} }
bool msm_gem_vma_inuse(struct msm_gem_vma *vma)
{
return !!vma->inuse;
}
/* Actually unmap memory for the vma */ /* Actually unmap memory for the vma */
void msm_gem_purge_vma(struct msm_gem_address_space *aspace, void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma) struct msm_gem_vma *vma)
...@@ -44,7 +49,7 @@ void msm_gem_purge_vma(struct msm_gem_address_space *aspace, ...@@ -44,7 +49,7 @@ void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
unsigned size = vma->node.size << PAGE_SHIFT; unsigned size = vma->node.size << PAGE_SHIFT;
/* Print a message if we try to purge a vma in use */ /* Print a message if we try to purge a vma in use */
if (GEM_WARN_ON(vma->inuse > 0)) if (GEM_WARN_ON(msm_gem_vma_inuse(vma)))
return; return;
/* Don't do anything if the memory isn't mapped */ /* Don't do anything if the memory isn't mapped */
...@@ -100,7 +105,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace, ...@@ -100,7 +105,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace,
void msm_gem_close_vma(struct msm_gem_address_space *aspace, void msm_gem_close_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma) struct msm_gem_vma *vma)
{ {
if (GEM_WARN_ON(vma->inuse > 0 || vma->mapped)) if (GEM_WARN_ON(msm_gem_vma_inuse(vma) || vma->mapped))
return; return;
spin_lock(&aspace->lock); spin_lock(&aspace->lock);
......
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