[PATCH 2/2] drm/amdgpu: call amdgpu_cs_parser_fini at most once per parser.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Thu Aug 20 13:51:52 PDT 2015


Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 16 +++++++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 454d4e2..207d963 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1247,6 +1247,7 @@ struct amdgpu_cs_parser {
 	/* relocations */
 	struct amdgpu_bo_list_entry	*vm_bos;
 	struct list_head	validated;
+	bool			bos_reserved;
 
 	struct amdgpu_ib	*ibs;
 	uint32_t		num_ibs;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 2c49dd4..10ba301 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -369,6 +369,7 @@ int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p)
 	if (unlikely(r != 0)) {
 		return r;
 	}
+	p->bos_reserved = true;
 
 	list_for_each_entry(lobj, &p->validated, tv.head) {
 		bo = lobj->robj;
@@ -469,7 +470,7 @@ static int cmp_size_smaller_first(void *priv, struct list_head *a,
 	return (int)la->robj->tbo.num_pages - (int)lb->robj->tbo.num_pages;
 }
 
-static void amdgpu_cs_parser_fini_early(struct amdgpu_cs_parser *parser, int error, bool backoff)
+static void amdgpu_cs_parser_fini_early(struct amdgpu_cs_parser *parser, int error)
 {
 	if (!error) {
 		/* Sort the buffer list from the smallest to largest buffer,
@@ -487,7 +488,7 @@ static void amdgpu_cs_parser_fini_early(struct amdgpu_cs_parser *parser, int err
 		ttm_eu_fence_buffer_objects(&parser->ticket,
 				&parser->validated,
 				&parser->ibs[parser->num_ibs-1].fence->base);
-	} else if (backoff) {
+	} else if (parser->bos_reserved) {
 		ttm_eu_backoff_reservation(&parser->ticket,
 					   &parser->validated);
 	}
@@ -527,9 +528,9 @@ static void amdgpu_cs_parser_fini_late(struct amdgpu_cs_parser *parser)
  * If error is set than unvalidate buffer, otherwise just free memory
  * used by parsing context.
  **/
-static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bool backoff)
+static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error)
 {
-       amdgpu_cs_parser_fini_early(parser, error, backoff);
+       amdgpu_cs_parser_fini_early(parser, error);
        amdgpu_cs_parser_fini_late(parser);
 }
 
@@ -816,7 +817,6 @@ static int amdgpu_cs_parser_prepare_job(struct amdgpu_cs_parser *sched_job)
 	int r, i;
 	struct amdgpu_cs_parser *parser = sched_job;
 	struct amdgpu_device *adev = sched_job->adev;
-	bool reserved_buffers = false;
 
 	r = amdgpu_cs_parser_relocs(parser);
 	if (r) {
@@ -829,7 +829,6 @@ static int amdgpu_cs_parser_prepare_job(struct amdgpu_cs_parser *sched_job)
 	}
 
 	if (!r) {
-		reserved_buffers = true;
 		r = amdgpu_cs_ib_fill(adev, parser);
 	}
 	if (!r) {
@@ -838,7 +837,6 @@ static int amdgpu_cs_parser_prepare_job(struct amdgpu_cs_parser *sched_job)
 			DRM_ERROR("Failed in the dependencies handling %d!\n", r);
 	}
 	if (r) {
-		amdgpu_cs_parser_fini(parser, r, reserved_buffers);
 		return r;
 	}
 
@@ -894,7 +892,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 	r = amdgpu_cs_parser_init(parser, data);
 	if (r) {
 		DRM_ERROR("Failed to initialize parser !\n");
-		amdgpu_cs_parser_fini(parser, r, false);
+		amdgpu_cs_parser_fini(parser, r);
 		up_read(&adev->exclusive_lock);
 		r = amdgpu_cs_handle_lockup(adev, r);
 		return r;
@@ -937,7 +935,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 
 	cs->out.handle = parser->ibs[parser->num_ibs - 1].sequence;
 out:
-	amdgpu_cs_parser_fini(parser, r, true);
+	amdgpu_cs_parser_fini(parser, r);
 	up_read(&adev->exclusive_lock);
 	r = amdgpu_cs_handle_lockup(adev, r);
 	return r;
-- 
2.5.0



More information about the dri-devel mailing list