summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/panfrost/panfrost_job.c
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@collabora.com>2019-11-29 16:59:08 +0300
committerRob Herring <robh@kernel.org>2020-02-03 14:23:21 +0300
commit7e0cf7e9936c4358b0863357b90aa12afe6489da (patch)
treedcc48a883e1e10ddef9ba7f8791d2894a66d7bf9 /drivers/gpu/drm/panfrost/panfrost_job.c
parent8ccb5bf7619c6523e7a4384a84b72e7be804298c (diff)
downloadlinux-7e0cf7e9936c4358b0863357b90aa12afe6489da.tar.xz
drm/panfrost: Make sure the shrinker does not reclaim referenced BOs
Userspace might tag a BO purgeable while it's still referenced by GPU jobs. We need to make sure the shrinker does not purge such BOs until all jobs referencing it are finished. Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support") Cc: <stable@vger.kernel.org> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Steven Price <steven.price@arm.com> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20191129135908.2439529-9-boris.brezillon@collabora.com
Diffstat (limited to 'drivers/gpu/drm/panfrost/panfrost_job.c')
-rw-r--r--drivers/gpu/drm/panfrost/panfrost_job.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index e364ee00f3d0..4d383831c1fc 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -269,8 +269,13 @@ static void panfrost_job_cleanup(struct kref *ref)
dma_fence_put(job->render_done_fence);
if (job->mappings) {
- for (i = 0; i < job->bo_count; i++)
+ for (i = 0; i < job->bo_count; i++) {
+ if (!job->mappings[i])
+ break;
+
+ atomic_dec(&job->mappings[i]->obj->gpu_usecount);
panfrost_gem_mapping_put(job->mappings[i]);
+ }
kvfree(job->mappings);
}