Commit 6f0308eb authored by Dave Airlie's avatar Dave Airlie Committed by Alex Deucher

amdgpu/cs: split out fence dependency checking (v2)

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

v2: rebase onto other changes.

v1-Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 64dab074
...@@ -923,59 +923,68 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ...@@ -923,59 +923,68 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
return 0; return 0;
} }
static int amdgpu_cs_dependencies(struct amdgpu_device *adev, static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p,
struct amdgpu_cs_parser *p) struct amdgpu_cs_chunk *chunk)
{ {
struct amdgpu_fpriv *fpriv = p->filp->driver_priv; struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
int i, j, r; unsigned num_deps;
int i, r;
struct drm_amdgpu_cs_chunk_dep *deps;
for (i = 0; i < p->nchunks; ++i) { deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata;
struct drm_amdgpu_cs_chunk_dep *deps; num_deps = chunk->length_dw * 4 /
struct amdgpu_cs_chunk *chunk; sizeof(struct drm_amdgpu_cs_chunk_dep);
unsigned num_deps;
chunk = &p->chunks[i]; for (i = 0; i < num_deps; ++i) {
struct amdgpu_ring *ring;
struct amdgpu_ctx *ctx;
struct dma_fence *fence;
if (chunk->chunk_id != AMDGPU_CHUNK_ID_DEPENDENCIES) ctx = amdgpu_ctx_get(fpriv, deps[i].ctx_id);
continue; if (ctx == NULL)
return -EINVAL;
deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata; r = amdgpu_queue_mgr_map(p->adev, &ctx->queue_mgr,
num_deps = chunk->length_dw * 4 / deps[i].ip_type,
sizeof(struct drm_amdgpu_cs_chunk_dep); deps[i].ip_instance,
deps[i].ring, &ring);
if (r) {
amdgpu_ctx_put(ctx);
return r;
}
for (j = 0; j < num_deps; ++j) { fence = amdgpu_ctx_get_fence(ctx, ring,
struct amdgpu_ring *ring; deps[i].handle);
struct amdgpu_ctx *ctx; if (IS_ERR(fence)) {
struct dma_fence *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); static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
if (ctx == NULL) struct amdgpu_cs_parser *p)
return -EINVAL; {
int i, r;
r = amdgpu_queue_mgr_map(adev, &ctx->queue_mgr, for (i = 0; i < p->nchunks; ++i) {
deps[j].ip_type, struct amdgpu_cs_chunk *chunk;
deps[j].ip_instance,
deps[j].ring, &ring);
if (r) {
amdgpu_ctx_put(ctx);
return r;
}
fence = amdgpu_ctx_get_fence(ctx, ring, chunk = &p->chunks[i];
deps[j].handle);
if (IS_ERR(fence)) {
r = PTR_ERR(fence);
amdgpu_ctx_put(ctx);
return r;
} else if (fence) { if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES) {
r = amdgpu_sync_fence(adev, &p->job->sync, r = amdgpu_cs_process_fence_dep(p, chunk);
fence); if (r)
dma_fence_put(fence); return r;
amdgpu_ctx_put(ctx);
if (r)
return r;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment