drm/amdgpu: Create csa per ctx
Subsystems (2)
PATCH 1/3 drm/amdgpu: Create csa per ctx
create csa for gfx/sdma engine to save the middle command buffer when gpu preemption triggered.
Signed-off-by Rex Zhu <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 12 ++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 48 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 5 ++++ 3 files changed, 59 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9 -3
@@ -824,8 +824,9 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)struct amdgpu_device *adev = p->adev;struct amdgpu_vm *vm = &fpriv->vm;struct amdgpu_bo_list_entry *e; -struct amdgpu_bo_va *bo_va; +struct amdgpu_bo_va *bo_va =NULL ;struct amdgpu_bo *bo; +struct amdgpu_ctx *ctx = p->ctx;int r;/* Only for UVD/VCE VM emulation */
@@ -907,10 +908,15 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)return r;if (amdgpu_sriov_vf (adev)) { -struct dma_fence *f; - bo_va = fpriv->csa_va;BUG_ON (!bo_va); + }else if (adev->gpu_preemption) { + bo_va = ctx->csa_va; +BUG_ON (!bo_va); + } +if (bo_va) { +struct dma_fence *f; + r =amdgpu_vm_bo_update (adev, bo_va, false);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +45 -3
86 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +5 -0
@@ -38,6 +38,10 @@ struct amdgpu_ctx_entity {struct amdgpu_ctx {struct kref refcount;struct amdgpu_device *adev; +struct amdgpu_ctx_mgr *ctx_mgr; +struct amdgpu_bo *csa_bo; +struct amdgpu_bo_va *csa_va; +uint64_t csa_mc_addr;unsigned reset_counter;unsigned reset_counter_query;
@@ -50,6 +54,7 @@ struct amdgpu_ctx {enum drm_sched_priority override_priority;struct mutex lock;atomic_t guilty; +u32 resv_space_id; };struct amdgpu_ctx_mgr {
Signature · 6 lines
1.9.1 _______________________________________________ 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): 1540395651-900-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
PATCH 2/3 drm/amdgpu: Add csa mc address into job structure
save csa mc address in the job, so can patch the address to pm4 when emit_ib even the ctx was freed.
suggested by Christian.
Signed-off-by Rex Zhu <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -230,6 +230,8 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs goto free_all_kdata; } + p->job->csa_mc_addr = p->ctx->csa_mc_addr; +if (p->uf_entry.tv.bo) p->job->uf_addr = uf_offset;kfree (chunk_array);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2 -1
@@ -56,10 +56,11 @@ struct amdgpu_job {uint32_t oa_base, oa_size;uint32_t vram_lost_counter; +/* csa buffer mc address */ +uint64_t csa_mc_addr;/* user fence handling */ uint64_t uf_addr;uint64_t uf_sequence; - }; int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdgpu: Patch csa mc address to sdma IB packet
In reply to a message not in the archivethe csa buffer is used by sdma engine to do context save when preemption happens. if the mc address is zero, mean the preemtpion feature(MCBP) is disabled.
Signed-off-by Rex Zhu <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 11 ++++++++--- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 11 +++++++++-- 4 files changed, 20 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2 -0
@@ -33,7 +33,9 @@#define to_amdgpu_job (sched_job) \ container_of((sched_job), struct amdgpu_job, base) +#define AMDGPU_JOB_GET_VMID (job) ((job) ? (job)->vmid : 0) +#define AMDGPU_JOB_GET_CSA_MC_ADDR (job) ((job) ? (job)->csa_mc_addr : 0)struct amdgpu_fence ;
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1 -0
@@ -26,6 +26,7 @@/* max number of IP instances */ #define AMDGPU_MAX_SDMA_INSTANCES 2 +#define AMDGPU_SDMA_CSA_SIZE (1024)enum amdgpu_sdma_irq {AMDGPU_SDMA_IRQ_TRAP0 =0 ,
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +8 -3
@@ -424,6 +424,12 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring, bool ctx_switch) {unsigned vmid =AMDGPU_JOB_GET_VMID (job); +uint64_t csa_mc_addr =AMDGPU_JOB_GET_CSA_MC_ADDR (job); + +if (csa_mc_addr ==0 || vmid ==0 ) + csa_mc_addr =0 ; +else + csa_mc_addr += ring->idx *AMDGPU_SDMA_CSA_SIZE ;/* IB packet must end on a 8 DW boundary */ sdma_v3_0_ring_insert_nop (ring, (10 - (lower_32_bits (ring->wptr) &7 )) %8 );
@@ -434,9 +440,8 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); - +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr)); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr)); }/**
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +9 -2
@@ -506,7 +506,14 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,struct amdgpu_ib *ib, bool ctx_switch) { + unsigned vmid = AMDGPU_JOB_GET_VMID(job); +uint64_t csa_mc_addr =AMDGPU_JOB_GET_CSA_MC_ADDR (job); + +if (csa_mc_addr ==0 || vmid ==0 ) + csa_mc_addr =0 ; +else + csa_mc_addr += ring->idx *AMDGPU_SDMA_CSA_SIZE ;/* IB packet must end on a 8 DW boundary */ sdma_v4_0_ring_insert_nop (ring, (10 - (lower_32_bits (ring->wptr) &7 )) %8 );
@@ -517,8 +524,8 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr)); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr)); }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx