amdgpu/cs: split out fence dependency checking (v2)
Subsystems (3)
PATCH 1/2 amdgpu/cs: split out fence dependency checking (v2)
From: Dave Airlie <[email protected]>
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 93 +++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 42 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +51 -42
@@ -923,59 +923,68 @@ 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; +unsigned num_deps; +int i, r; +struct drm_amdgpu_cs_chunk_dep *deps; -for (i =0 ; i < p->nchunks; ++i) { -struct drm_amdgpu_cs_chunk_dep *deps; -struct amdgpu_cs_chunk *chunk; -unsigned num_deps; + deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata; + num_deps = chunk->length_dw *4 / +sizeof (struct drm_amdgpu_cs_chunk_dep ); - 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 ) -continue ; + ctx =amdgpu_ctx_get (fpriv, deps[i].ctx_id); +if (ctx ==NULL ) +return -EINVAL ; - deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata; - num_deps = chunk->length_dw *4 / -sizeof (struct drm_amdgpu_cs_chunk_dep ); + r =amdgpu_queue_mgr_map (p->adev, &ctx->queue_mgr, + deps[i].ip_type, + deps[i].ip_instance, + deps[i].ring, &ring); +if (r) { +amdgpu_ctx_put (ctx); +return r; + } -for (j =0 ; j < num_deps; ++j) { -struct amdgpu_ring *ring; -struct amdgpu_ctx *ctx; -struct dma_fence *fence; + 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; - r =amdgpu_queue_mgr_map (adev, &ctx->queue_mgr, - deps[j].ip_type, - deps[j].ip_instance, - deps[j].ring, &ring); -if (r) { -amdgpu_ctx_put (ctx); -return r; - } +for (i =0 ; i < p->nchunks; ++i) { +struct amdgpu_cs_chunk *chunk; - fence =amdgpu_ctx_get_fence (ctx, ring, - deps[j].handle); -if (IS_ERR (fence)) { - r =PTR_ERR (fence); -amdgpu_ctx_put (ctx); -return r; + chunk = &p->chunks[i]; - }else if (fence) { - r =amdgpu_sync_fence (adev, &p->job->sync, - fence); -dma_fence_put (fence); -amdgpu_ctx_put (ctx); -if (r) -return r; - } +if (chunk->chunk_id ==AMDGPU_CHUNK_ID_DEPENDENCIES ) { + r =amdgpu_cs_process_fence_dep (p, chunk); +if (r) +return r; } }
Signature · 6 lines
2.9.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170616035250.4300-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/2 amdgpu: use drm sync objects for shared semaphores (v5)
From: Dave Airlie <[email protected]>
This creates a new command submission chunk for amdgpu to add in and out sync objects around the submission.
Sync objects are managed via the drm syncobj ioctls.
The command submission interface is enhanced with two new chunks, one for syncobj pre submission dependencies, and one for post submission sync obj signalling, and just takes a list of handles for each.
This is based on work originally done by David Zhou at AMD, with input from Christian Konig on what things should look like.
In theory VkFences could be backed with sync objects and just get passed into the cs as syncobj handles as well.
NOTE: this interface addition needs a version bump to expose it to userspace.
TODO: update to dep_sync when rebasing onto amdgpu master. (with this - r-b from Christian)
v1.1: keep file reference on import.
v2: move to using syncobjs
v2.1: change some APIs to just use p pointer.
v3: make more robust against CS failures, we now add the wait sems but only remove them once the CS job has been submitted.
v4: rewrite names of API and base on new syncobj code.
v5: move post deps earlier, rename some apis
v6: lookup post deps earlier, and just replace fences in post deps stage (Christian)
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 88 ++++++++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- include/uapi/drm/amdgpu_drm.h | 6 +++ 4 files changed, 97 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -1159,6 +1159,9 @@ struct amdgpu_cs_parser {/* user fence */ struct amdgpu_bo_list_entry uf_entry; + +unsigned num_post_dep_syncobjs; +struct drm_syncobj **post_dep_syncobjs; };#define AMDGPU_PREAMBLE_IB_PRESENT (1 << 0)/* bit set means command submit involves a preamble IB */
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +87 -1
136 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -782,7 +782,7 @@ static struct drm_driver kms_driver = { .driver_features =DRIVER_USE_AGP |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED |DRIVER_GEM | - DRIVER_PRIME | DRIVER_RENDER | DRIVER_MODESET, + DRIVER_PRIME | DRIVER_RENDER | DRIVER_MODESET | DRIVER_SYNCOBJ, .load = amdgpu_driver_load_kms, .open = amdgpu_driver_open_kms, .postclose = amdgpu_driver_postclose_kms,
include/uapi/drm/amdgpu_drm.h +6 -0
@@ -440,6 +440,8 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_IB 0x01#define AMDGPU_CHUNK_ID_FENCE 0x02#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 +#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04 +#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05struct drm_amdgpu_cs_chunk {__u32 chunk_id;
@@ -507,6 +509,10 @@ struct drm_amdgpu_cs_chunk_fence {__u32 offset; }; +struct drm_amdgpu_cs_chunk_sem { +__u32 handle; +}; +struct drm_amdgpu_cs_chunk_data {union {struct drm_amdgpu_cs_chunk_ib ib_data;
Signature · 6 lines
2.9.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx