[Freedreno] [PATCH 05/13] drm/msm: rearrange submit buffer objects clean up
Sharat Masetty
smasetty at codeaurora.org
Mon Oct 1 12:31:37 UTC 2018
The submit path in msm_gpu_submit() takes a reference to the buffer
object and the iova. This should not be needed with a little bit of
code rearrangement. We still keep the same semantic of a valid GPU
submission holding a reference to the base object and the iova until
retirement.
Signed-off-by: Sharat Masetty <smasetty at codeaurora.org>
---
drivers/gpu/drm/msm/msm_gem_submit.c | 20 ++++++++++++++++++--
drivers/gpu/drm/msm/msm_gpu.c | 8 --------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index fd28ace..a7c8cbc 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -68,9 +68,21 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
void msm_gem_submit_free(struct msm_gem_submit *submit)
{
+ int i;
+
idr_remove(&submit->ring->fence_idr, submit->out_fence_id);
dma_fence_put(submit->hw_fence);
+
+ for (i = 0; i < submit->nr_bos; i++) {
+ struct msm_gem_object *msm_obj = submit->bos[i].obj;
+
+ if (submit->bos[i].flags & BO_PINNED)
+ msm_gem_put_iova(&msm_obj->base, submit->gpu->aspace);
+
+ drm_gem_object_put(&msm_obj->base);
+ }
+
list_del(&submit->node);
put_pid(submit->pid);
msm_submitqueue_put(submit->queue);
@@ -398,9 +410,13 @@ static void submit_cleanup(struct msm_gem_submit *submit)
for (i = 0; i < submit->nr_bos; i++) {
struct msm_gem_object *msm_obj = submit->bos[i].obj;
- submit_unlock_unpin_bo(submit, i, false);
+
+ if (submit->bos[i].flags & BO_LOCKED) {
+ ww_mutex_unlock(&msm_obj->resv->lock);
+ submit->bos[i].flags &= ~BO_LOCKED;
+ }
+
list_del_init(&msm_obj->submit_entry);
- drm_gem_object_unreference(&msm_obj->base);
}
ww_acquire_fini(&submit->ticket);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 449cc23..cd5fe49 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -551,8 +551,6 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
struct msm_gem_object *msm_obj = submit->bos[i].obj;
/* move to inactive: */
msm_gem_move_to_inactive(&msm_obj->base);
- msm_gem_put_iova(&msm_obj->base, gpu->aspace);
- drm_gem_object_put(&msm_obj->base);
}
pm_runtime_mark_last_busy(&gpu->pdev->dev);
@@ -630,18 +628,12 @@ struct dma_fence *msm_gpu_submit(struct msm_gem_submit *submit)
for (i = 0; i < submit->nr_bos; i++) {
struct msm_gem_object *msm_obj = submit->bos[i].obj;
- uint64_t iova;
/* can't happen yet.. but when we add 2d support we'll have
* to deal w/ cross-ring synchronization:
*/
WARN_ON(is_active(msm_obj) && (msm_obj->gpu != gpu));
- /* submit takes a reference to the bo and iova until retired: */
- drm_gem_object_get(&msm_obj->base);
- msm_gem_get_iova(&msm_obj->base,
- submit->gpu->aspace, &iova);
-
if (submit->bos[i].flags & MSM_SUBMIT_BO_WRITE)
msm_gem_move_to_active(&msm_obj->base, gpu, true, submit->hw_fence);
else if (submit->bos[i].flags & MSM_SUBMIT_BO_READ)
--
1.9.1
More information about the Freedreno
mailing list