Skip to content

Commit

Permalink
drm/msm/gem: Split out inuse helper
Browse files Browse the repository at this point in the history
Prep for a following patch, where it gets a bit more complicated.

Signed-off-by: Rob Clark <[email protected]>
Reviewed-by: Dmitry Baryshkov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Rob Clark <[email protected]>
  • Loading branch information
robclark committed Apr 21, 2022
1 parent 8e30fa3 commit ca35ab2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/msm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m,
name, comm ? ":" : "", comm ? comm : "",
vma->aspace, vma->iova,
vma->mapped ? "mapped" : "unmapped",
vma->inuse);
msm_gem_vma_inuse(vma));
kfree(comm);
}

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/msm/msm_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct msm_gem_vma {
int msm_gem_init_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma, int npages,
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,
struct msm_gem_vma *vma);
void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
Expand Down
9 changes: 7 additions & 2 deletions drivers/gpu/drm/msm/msm_gem_vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ msm_gem_address_space_get(struct msm_gem_address_space *aspace)
return aspace;
}

bool msm_gem_vma_inuse(struct msm_gem_vma *vma)
{
return !!vma->inuse;
}

/* Actually unmap memory for the vma */
void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma)
{
unsigned size = vma->node.size << PAGE_SHIFT;

/* 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;

/* Don't do anything if the memory isn't mapped */
Expand Down Expand Up @@ -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,
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;

spin_lock(&aspace->lock);
Expand Down

0 comments on commit ca35ab2

Please sign in to comment.