dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Dave Airlie <airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 4/5] amdgpu/cs: split out fence dependency checking
Date: Thu,  1 Jun 2017 11:06:42 +1000	[thread overview]
Message-ID: <20170601010643.28616-5-airlied@gmail.com> (raw)
In-Reply-To: <20170601010643.28616-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

From: Dave Airlie <airlied@redhat.com>

This just splits out the fence depenency checking into it's
own function to make it easier to add semaphore dependencies.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 85 +++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 4e6b950..30225d7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -995,56 +995,65 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
 	return 0;
 }
 
-static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
-				  struct amdgpu_cs_parser *p)
+static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p,
+				       struct amdgpu_cs_chunk *chunk)
 {
 	struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
-	int i, j, r;
-
-	for (i = 0; i < p->nchunks; ++i) {
-		struct drm_amdgpu_cs_chunk_dep *deps;
-		struct amdgpu_cs_chunk *chunk;
-		unsigned num_deps;
+	unsigned num_deps;
+	int i, r;
+	struct drm_amdgpu_cs_chunk_dep *deps;
 
-		chunk = &p->chunks[i];
+	deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata;
+	num_deps = chunk->length_dw * 4 /
+		sizeof(struct drm_amdgpu_cs_chunk_dep);
 
-		if (chunk->chunk_id != AMDGPU_CHUNK_ID_DEPENDENCIES)
-			continue;
+	for (i = 0; i < num_deps; ++i) {
+		struct amdgpu_ring *ring;
+		struct amdgpu_ctx *ctx;
+		struct dma_fence *fence;
 
-		deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata;
-		num_deps = chunk->length_dw * 4 /
-			sizeof(struct drm_amdgpu_cs_chunk_dep);
+		r = amdgpu_cs_get_ring(p->adev, deps[i].ip_type,
+				       deps[i].ip_instance,
+				       deps[i].ring, &ring);
+		if (r)
+			return r;
 
-		for (j = 0; j < num_deps; ++j) {
-			struct amdgpu_ring *ring;
-			struct amdgpu_ctx *ctx;
-			struct dma_fence *fence;
+		ctx = amdgpu_ctx_get(fpriv, deps[i].ctx_id);
+		if (ctx == NULL)
+			return -EINVAL;
 
-			r = amdgpu_cs_get_ring(adev, deps[j].ip_type,
-					       deps[j].ip_instance,
-					       deps[j].ring, &ring);
+		fence = amdgpu_ctx_get_fence(ctx, ring,
+					     deps[i].handle);
+		if (IS_ERR(fence)) {
+			r = PTR_ERR(fence);
+			amdgpu_ctx_put(ctx);
+			return r;
+		} else if (fence) {
+			r = amdgpu_sync_fence(p->adev, &p->job->sync,
+					      fence);
+			dma_fence_put(fence);
+			amdgpu_ctx_put(ctx);
 			if (r)
 				return r;
+		}
+	}
+	return 0;
+}
 
-			ctx = amdgpu_ctx_get(fpriv, deps[j].ctx_id);
-			if (ctx == NULL)
-				return -EINVAL;
+static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
+				  struct amdgpu_cs_parser *p)
+{
+	int i, r;
 
-			fence = amdgpu_ctx_get_fence(ctx, ring,
-						     deps[j].handle);
-			if (IS_ERR(fence)) {
-				r = PTR_ERR(fence);
-				amdgpu_ctx_put(ctx);
-				return r;
+	for (i = 0; i < p->nchunks; ++i) {
+		struct amdgpu_cs_chunk *chunk;
 
-			} else if (fence) {
-				r = amdgpu_sync_fence(adev, &p->job->sync,
-						      fence);
-				dma_fence_put(fence);
-				amdgpu_ctx_put(ctx);
-				if (r)
-					return r;
-			}
+		chunk = &p->chunks[i];
+
+		if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES) {
+			r = amdgpu_cs_process_fence_dep(p, chunk);
+			if (r)
+				return r;
 		}
 	}
 
-- 
2.9.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-06-01  1:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01  1:06 drm syncobjs - running out of tag lines Dave Airlie
     [not found] ` <20170601010643.28616-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-01  1:06   ` [PATCH 1/5] drm: introduce sync objects (v4) Dave Airlie
     [not found]     ` <20170601010643.28616-2-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-01 10:25       ` Chris Wilson
2017-06-01  1:06   ` [PATCH 2/5] drm/syncobj: add sync obj wait interface. (v4) Dave Airlie
2017-06-01 10:57     ` Chris Wilson
2017-06-01  1:06   ` Dave Airlie [this message]
2017-06-01  1:06   ` [PATCH 5/5] amdgpu: use drm sync objects for shared semaphores (v5) Dave Airlie
2017-06-15  3:59     ` Dave Airlie
     [not found]       ` <CAPM=9twtavgA+D+vgZYz7UagnjxX6pGFBBUycCs2ofGjhOcBrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-16  8:28         ` Christian König
     [not found]           ` <e8021851-d630-3cbd-40e2-58f83a366a29-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-06-17  1:23             ` Dave Airlie
2017-06-01  1:06 ` [PATCH 3/5] drm/syncobj: add sync_file interaction. (v1.2) Dave Airlie
     [not found]   ` <20170601010643.28616-4-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-01 10:58     ` Chris Wilson
  -- strict thread matches above, loose matches on Subject: below --
2017-05-29  7:30 drm-syncobj - mostly wait changes Dave Airlie
     [not found] ` <20170529073033.10903-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-29  7:30   ` [PATCH 4/5] amdgpu/cs: split out fence dependency checking Dave Airlie
2017-05-24  7:06 drm syncobj - final posting I hope Dave Airlie
     [not found] ` <20170524070615.1634-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-24  7:06   ` [PATCH 4/5] amdgpu/cs: split out fence dependency checking Dave Airlie
2017-05-12  0:34 drm syncobj - can we get some r-b/a-bs? Dave Airlie
     [not found] ` <20170512003457.24936-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-12  0:34   ` [PATCH 4/5] amdgpu/cs: split out fence dependency checking Dave Airlie
2017-04-26  3:28 [rfc] drm sync objects (search for spock) Dave Airlie
     [not found] ` <20170426032833.1455-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-26  3:28   ` [PATCH 4/5] amdgpu/cs: split out fence dependency checking Dave Airlie
     [not found]     ` <20170426032833.1455-5-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-26  6:53       ` zhoucm1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170601010643.28616-5-airlied@gmail.com \
    --to=airlied-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).