drm/amdgpu: use new scheduler load balancing for VMs
Subsystems (2)
PATCH 1/7 drm/amdgpu: use new scheduler load balancing for VMs
Instead of the fixed round robin use let the scheduler balance the load of page table updates.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 7 +++---- drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/si_dma.c | 12 +++++++----- 8 files changed, 41 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2335,7 +2335,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->mman.buffer_funcs =NULL ; adev->mman.buffer_funcs_ring =NULL ; adev->vm_manager.vm_pte_funcs =NULL ; - adev->vm_manager.vm_pte_num_rings =0 ; + adev->vm_manager.vm_pte_num_rqs =0 ; adev->gmc.gmc_funcs =NULL ; adev->fence_context =dma_fence_context_alloc (AMDGPU_MAX_RINGS );bitmap_zero (adev->gfx.pipe_reserve_bitmap,AMDGPU_MAX_COMPUTE_QUEUES );
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -10
@@ -2568,9 +2568,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,struct amdgpu_bo *root;const unsigned align =min (AMDGPU_VM_PTB_ALIGN_SIZE ,AMDGPU_VM_PTE_COUNT (adev) *8 ); -unsigned ring_instance; -struct amdgpu_ring *ring; -struct drm_sched_rq *rq;unsigned long size;uint64_t flags;int r, i;
@@ -2586,12 +2583,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,INIT_LIST_HEAD (&vm->freed);/* create scheduler entity for page table updates */ - - ring_instance =atomic_inc_return (&adev->vm_manager.vm_pte_next_ring); - ring_instance %= adev->vm_manager.vm_pte_num_rings; - ring = adev->vm_manager.vm_pte_rings[ring_instance]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; - r =drm_sched_entity_init (&vm->entity, &rq,1 ,NULL ); + r =drm_sched_entity_init (&vm->entity, adev->vm_manager.vm_pte_rqs, + adev->vm_manager.vm_pte_num_rqs,NULL );if (r)return r;
@@ -2898,7 +2891,6 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) adev->vm_manager.seqno[i] =0 ; -atomic_set (&adev->vm_manager.vm_pte_next_ring,0 );spin_lock_init (&adev->vm_manager.prt_lock);atomic_set (&adev->vm_manager.num_prt_users,0 );
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3 -4
@@ -244,10 +244,9 @@ struct amdgpu_vm_manager {/* vram base address for page table entry */ u64 vram_base_offset;/* vm pte handling */ -const struct amdgpu_vm_pte_funcs *vm_pte_funcs; -struct amdgpu_ring *vm_pte_rings[AMDGPU_MAX_RINGS ]; -unsigned vm_pte_num_rings; -atomic_t vm_pte_next_ring; +const struct amdgpu_vm_pte_funcs *vm_pte_funcs; +struct drm_sched_rq *vm_pte_rqs[AMDGPU_MAX_RINGS ]; +unsigned vm_pte_num_rqs;/* partial resident texture handling */ spinlock_t prt_lock;
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +7 -5
@@ -1386,15 +1386,17 @@ static const struct amdgpu_vm_pte_funcs cik_sdma_vm_pte_funcs = {static void cik_sdma_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &cik_sdma_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +7 -5
@@ -1312,15 +1312,17 @@ static const struct amdgpu_vm_pte_funcs sdma_v2_4_vm_pte_funcs = {static void sdma_v2_4_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &sdma_v2_4_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +7 -5
@@ -1752,15 +1752,17 @@ static const struct amdgpu_vm_pte_funcs sdma_v3_0_vm_pte_funcs = {static void sdma_v3_0_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &sdma_v3_0_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +7 -5
@@ -1750,15 +1750,17 @@ static const struct amdgpu_vm_pte_funcs sdma_v4_0_vm_pte_funcs = {static void sdma_v4_0_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &sdma_v4_0_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }
drivers/gpu/drm/amd/amdgpu/si_dma.c +7 -5
@@ -879,15 +879,17 @@ static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = {static void si_dma_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &si_dma_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }
Signature · 6 lines
2.14.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): 20180801113116.1994-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/7 drm/amdgpu: use scheduler load balancing for SDMA CS
Start to use the scheduler load balancing for userspace SDMA command submissions.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +21 -4
@@ -48,7 +48,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,struct drm_file *filp, struct amdgpu_ctx *ctx) { - unsigned i, j; + struct drm_sched_rq *sdma_rqs[AMDGPU_MAX_RINGS]; +unsigned i, j, num_sdma_rqs;int r;if (priority <0 || priority >=DRM_SCHED_PRIORITY_MAX )
@@ -80,18 +81,34 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->init_priority = priority; ctx->override_priority =DRM_SCHED_PRIORITY_UNSET ; -/* create context entity for each ring */ + num_sdma_rqs =0 ;for (i =0 ; i < adev->num_rings; i++) {struct amdgpu_ring *ring = adev->rings[i];struct drm_sched_rq *rq; rq = &ring->sched.sched_rq[priority]; +if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) + sdma_rqs[num_sdma_rqs++] = rq; + } + +/* create context entity for each ring */ +for (i =0 ; i < adev->num_rings; i++) { +struct amdgpu_ring *ring = adev->rings[i];if (ring == &adev->gfx.kiq.ring)continue ; - r =drm_sched_entity_init (&ctx->rings[i].entity, - &rq,1 , &ctx->guilty); +if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) { + r =drm_sched_entity_init (&ctx->rings[i].entity, + sdma_rqs, num_sdma_rqs, + &ctx->guilty); + }else { +struct drm_sched_rq *rq; + + rq = &ring->sched.sched_rq[priority]; + r =drm_sched_entity_init (&ctx->rings[i].entity, + &rq,1 , &ctx->guilty); + }if (r) goto failed; }
Signature · 6 lines
2.14.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): 20180801113116.1994-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/7] drm/amdgpu: use scheduler load balancing for SDMA CS
Quoted 3 lines · Christian König
Start to use the scheduler load balancing for userspace SDMA command submissions.
In this case, each SDMA could load all SDMA(instances) rqs, and UMD will not specify a ring id.
If so, we may abstract a set of rings for each type of IP, associated with such kind of IP instances' rq. Accordingly libdrm needs to update as well, but it may be more user-friendly, regardless of ring id when submits command.
And will it interfere ctx->ring's settings, like sequence?
e.g. submit a command to SDMA0, but SDMA0 is busy and SDMA1 is idle,
So the command will be pushed to SDMA1 rq, but update sequence for ctx->ring[SDMA0] actually.
Regards,
Jerry
Quoted 48 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +14
-4@@ -48,7 +48,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,struct drm_file *filp, struct amdgpu_ctx *ctx) { - unsigned i, j; + struct drm_sched_rq *sdma_rqs[AMDGPU_MAX_RINGS]; +unsigned i, j, num_sdma_rqs;int r;if (priority <0 || priority >=DRM_SCHED_PRIORITY_MAX )@@ -80,18 +81,34 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->init_priority = priority; ctx->override_priority =DRM_SCHED_PRIORITY_UNSET ; -/* create context entity for each ring */ + num_sdma_rqs =0 ;for (i =0 ; i < adev->num_rings; i++) {struct amdgpu_ring *ring = adev->rings[i];struct drm_sched_rq *rq; rq = &ring->sched.sched_rq[priority]; +if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) + sdma_rqs[num_sdma_rqs++] = rq; + } + +/* create context entity for each ring */ +for (i =0 ; i < adev->num_rings; i++) { +struct amdgpu_ring *ring = adev->rings[i];if (ring == &adev->gfx.kiq.ring)continue ; - r =drm_sched_entity_init (&ctx->rings[i].entity, - &rq,1 , &ctx->guilty); +if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) { + r =drm_sched_entity_init (&ctx->rings[i].entity, + sdma_rqs, num_sdma_rqs, + &ctx->guilty);
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c static int amdgpu_ctx_init(struct amdgpu_device *adev, · line 114
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +7
-0+ }else { +struct drm_sched_rq *rq; + + rq = &ring->sched.sched_rq[priority]; + r =drm_sched_entity_init (&ctx->rings[i].entity, + &rq,1 , &ctx->guilty); + }if (r) goto failed; }
_______________________________________________
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): [email protected]
Re: [PATCH 2/7] drm/amdgpu: use scheduler load balancing for SDMA CS
Am 02.08.2018 um 07:50 schrieb Zhang, Jerry (Junwei):
Quoted 7 lines · Christian König
Quoted 3 lines
Start to use the scheduler load balancing for userspace SDMA command submissions.
In this case, each SDMA could load all SDMA(instances) rqs, and UMD will not specify a ring id. If so, we may abstract a set of rings for each type of IP, associated with such kind of IP instances' rq.
That's what my follow up patch set does.
Quoted 1 line
Accordingly libdrm needs to update as well, but it may be more user-friendly, regardless of ring id when submits command.
No, libdrm and userspace should and must stay as they are. Userspace should not notice that we move jobs to another ring in the kernel.
Quoted 2 lines
And will it interfere ctx->ring's settings, like sequence?
No, take a look at the patch. There is no ctx->ring any more.
Regards,
Christian.
Quoted 58 lines
e.g. submit a command to SDMA0, but SDMA0 is busy and SDMA1 is idle,
So the command will be pushed to SDMA1 rq, but update sequence for ctx->ring[SDMA0] actually.Regards,
JerryQuoted 51 lines
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c| 25 +++++++++++++++++++++----1 file changed, 21 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +17
-4@@ -48,7 +48,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct drm_file *filp, struct amdgpu_ctx *ctx) { - unsigned i, j; + struct drm_sched_rq *sdma_rqs[AMDGPU_MAX_RINGS]; + unsigned i, j, num_sdma_rqs; int r; if (priority < 0 || priority >= DRM_SCHED_PRIORITY_MAX)@@ -80,18 +81,34 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->init_priority = priority; ctx->override_priority = DRM_SCHED_PRIORITY_UNSET; - /* create context entity for each ring */ + num_sdma_rqs = 0; for (i = 0; i < adev->num_rings; i++) { struct amdgpu_ring *ring = adev->rings[i]; struct drm_sched_rq *rq; rq = &ring->sched.sched_rq[priority]; + if (ring->funcs->type == AMDGPU_RING_TYPE_SDMA) + sdma_rqs[num_sdma_rqs++] = rq; + } + + /* create context entity for each ring */ + for (i = 0; i < adev->num_rings; i++) { + struct amdgpu_ring *ring = adev->rings[i]; if (ring == &adev->gfx.kiq.ring) continue; - r = drm_sched_entity_init(&ctx->rings[i].entity, - &rq, 1, &ctx->guilty); + if (ring->funcs->type == AMDGPU_RING_TYPE_SDMA) { + r = drm_sched_entity_init(&ctx->rings[i].entity, + sdma_rqs, num_sdma_rqs, + &ctx->guilty); + } else { + struct drm_sched_rq *rq; +
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4
-0+ rq = &ring->sched.sched_rq[priority]; + r = drm_sched_entity_init(&ctx->rings[i].entity, + &rq, 1, &ctx->guilty); + } if (r) goto failed;}
_______________________________________________
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): a7d63f7f-a110-5897-2726-c59c425e42a1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Zhang, Jerry (Junwei)
Reviewed-by Junwei ZhangRe: [PATCH 2/7] drm/amdgpu: use scheduler load balancing for SDMA CS
Quoted 10 lines · Christian König
Am 02.08.2018 um 07:50 schrieb Zhang, Jerry (Junwei):
Quoted 7 lines · Christian König
Quoted 3 lines
Start to use the scheduler load balancing for userspace SDMA command submissions.
In this case, each SDMA could load all SDMA(instances) rqs, and UMD will not specify a ring id. If so, we may abstract a set of rings for each type of IP, associated with such kind of IP instances' rq.
That's what my follow up patch set does.
I missed patch 7, that answer my concerns
(it's in another mail inbox...)
command will be sent to the expected entity, scheduler would decide which ring is actually used.
Feel free to add
Quoted 4 lines
Quoted 2 lines
Accordingly libdrm needs to update as well, but it may be more user-friendly, regardless of ring id when submits command.
No, libdrm and userspace should and must stay as they are. Userspace should not notice that we move jobs to another ring in the kernel.
libdrm test uses instance for ring id, that confuses me a bit.
Regards,
Jerry
Quoted 66 lines
Quoted 3 lines
And will it interfere ctx->ring's settings, like sequence?
No, take a look at the patch. There is no
ctx->ringany more.Regards,
Christian.Quoted 57 lines
e.g. submit a command to SDMA0, but SDMA0 is busy and SDMA1 is idle,
So the command will be pushed to SDMA1 rq, but update sequence for ctx->ring[SDMA0] actually.Regards,
JerryQuoted 50 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +17
-4@@ -48,7 +48,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,struct drm_file *filp, struct amdgpu_ctx *ctx) { - unsigned i, j; + struct drm_sched_rq *sdma_rqs[AMDGPU_MAX_RINGS]; +unsigned i, j, num_sdma_rqs;int r;if (priority <0 || priority >=DRM_SCHED_PRIORITY_MAX )@@ -80,18 +81,34 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->init_priority = priority; ctx->override_priority =DRM_SCHED_PRIORITY_UNSET ; -/* create context entity for each ring */ + num_sdma_rqs =0 ;for (i =0 ; i < adev->num_rings; i++) {struct amdgpu_ring *ring = adev->rings[i];struct drm_sched_rq *rq; rq = &ring->sched.sched_rq[priority]; +if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) + sdma_rqs[num_sdma_rqs++] = rq; + } + +/* create context entity for each ring */ +for (i =0 ; i < adev->num_rings; i++) { +struct amdgpu_ring *ring = adev->rings[i];if (ring == &adev->gfx.kiq.ring)continue ; - r =drm_sched_entity_init (&ctx->rings[i].entity, - &rq,1 , &ctx->guilty); +if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) { + r =drm_sched_entity_init (&ctx->rings[i].entity, + sdma_rqs, num_sdma_rqs, + &ctx->guilty); + }else { +struct drm_sched_rq *rq; +
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c static int amdgpu_ctx_init(struct amdgpu_device *adev, · line 114
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4
-0+ rq = &ring->sched.sched_rq[priority]; + r =drm_sched_entity_init (&ctx->rings[i].entity, + &rq,1 , &ctx->guilty); + }if (r) goto failed; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/7 drm/amdgpu: use scheduler load balancing for compute CS
In reply to a message not in the archiveStart to use the scheduler load balancing for userspace compute command submissions.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +9 -1
@@ -49,7 +49,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx) {struct drm_sched_rq *sdma_rqs[AMDGPU_MAX_RINGS ]; -unsigned i, j, num_sdma_rqs; +struct drm_sched_rq *comp_rqs[AMDGPU_MAX_RINGS ]; +unsigned i, j, num_sdma_rqs, num_comp_rqs;int r;if (priority <0 || priority >=DRM_SCHED_PRIORITY_MAX )
@@ -82,6 +83,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->override_priority =DRM_SCHED_PRIORITY_UNSET ; num_sdma_rqs =0 ; + num_comp_rqs =0 ;for (i =0 ; i < adev->num_rings; i++) {struct amdgpu_ring *ring = adev->rings[i];struct drm_sched_rq *rq;
@@ -89,6 +91,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, rq = &ring->sched.sched_rq[priority];if (ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) sdma_rqs[num_sdma_rqs++] = rq; +else if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) + comp_rqs[num_comp_rqs++] = rq; }/* create context entity for each ring */
@@ -102,6 +106,10 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, r =drm_sched_entity_init (&ctx->rings[i].entity, sdma_rqs, num_sdma_rqs, &ctx->guilty); + }else if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { + r =drm_sched_entity_init (&ctx->rings[i].entity, + comp_rqs, num_comp_rqs, + &ctx->guilty); }else {struct drm_sched_rq *rq;
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/7 drm/amdgpu: remove the queue manager
In reply to a message not in the archiveNot needed any more since that is now done by the scheduler.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 27 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 22 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 67 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c | 316 -------------------------- 5 files changed, 75 insertions(+), 360 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c
drivers/gpu/drm/amd/amdgpu/Makefile +1 -2
@@ -51,8 +51,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ - amdgpu_queue_mgr.o amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o \ - amdgpu_ids.o + amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -24
@@ -599,29 +599,6 @@ struct amdgpu_ib {extern const struct drm_sched_backend_ops amdgpu_sched_ops; -/* -* Queue manager -*/ -struct amdgpu_queue_mapper { -int hw_ip; -struct mutex lock; -/* protected by lock */ -struct amdgpu_ring *queue_map[AMDGPU_MAX_RINGS ]; -}; - -struct amdgpu_queue_mgr { -struct amdgpu_queue_mapper mapper[AMDGPU_MAX_IP_NUM ]; -}; - -int amdgpu_queue_mgr_init (struct amdgpu_device *adev, -struct amdgpu_queue_mgr *mgr); -int amdgpu_queue_mgr_fini (struct amdgpu_device *adev, -struct amdgpu_queue_mgr *mgr); -int amdgpu_queue_mgr_map (struct amdgpu_device *adev, -struct amdgpu_queue_mgr *mgr, -u32 hw_ip,u32 instance,u32 ring, -struct amdgpu_ring **out_ring); -/* * context related structures */
@@ -635,7 +612,6 @@ struct amdgpu_ctx_ring {struct amdgpu_ctx {struct kref refcount;struct amdgpu_device *adev; -struct amdgpu_queue_mgr queue_mgr;unsigned reset_counter;unsigned reset_counter_query;uint32_t vram_lost_counter;
@@ -659,6 +635,9 @@ struct amdgpu_ctx_mgr {struct amdgpu_ctx *amdgpu_ctx_get (struct amdgpu_fpriv *fpriv,uint32_t id);int amdgpu_ctx_put (struct amdgpu_ctx *ctx); +int amdgpu_ctx_get_ring (struct amdgpu_ctx *ctx, +u32 hw_ip,u32 instance,u32 ring, +struct amdgpu_ring **out_ring);int amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx,struct amdgpu_ring *ring,struct dma_fence *fence,uint64_t *seq); struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +10 -12
@@ -1007,8 +1007,9 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,return -EINVAL ; } - r =amdgpu_queue_mgr_map (adev, &parser->ctx->queue_mgr, chunk_ib->ip_type, - chunk_ib->ip_instance, chunk_ib->ring, &ring); + r =amdgpu_ctx_get_ring (parser->ctx, chunk_ib->ip_type, + chunk_ib->ip_instance, chunk_ib->ring, + &ring);if (r)return r;
@@ -1070,10 +1071,9 @@ static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p,if (ctx ==NULL )return -EINVAL ; - r =amdgpu_queue_mgr_map (p->adev, &ctx->queue_mgr, - deps[i].ip_type, - deps[i].ip_instance, - deps[i].ring, &ring); + r =amdgpu_ctx_get_ring (ctx, deps[i].ip_type, + deps[i].ip_instance, + deps[i].ring, &ring);if (r) {amdgpu_ctx_put (ctx);return r;
@@ -1328,7 +1328,6 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) {union drm_amdgpu_wait_cs *wait = data; -struct amdgpu_device *adev = dev->dev_private;unsigned long timeout =amdgpu_gem_timeout (wait->in.timeout);struct amdgpu_ring *ring =NULL ;struct amdgpu_ctx *ctx;
@@ -1339,9 +1338,8 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data,if (ctx ==NULL )return -EINVAL ; - r =amdgpu_queue_mgr_map (adev, &ctx->queue_mgr, - wait->in.ip_type, wait->in.ip_instance, - wait->in.ring, &ring); + r =amdgpu_ctx_get_ring (ctx, wait->in.ip_type, wait->in.ip_instance, + wait->in.ring, &ring);if (r) {amdgpu_ctx_put (ctx);return r;
@@ -1388,8 +1386,8 @@ static struct dma_fence *amdgpu_cs_get_fence(struct amdgpu_device *adev,if (ctx ==NULL )return ERR_PTR (-EINVAL ); - r =amdgpu_queue_mgr_map (adev, &ctx->queue_mgr, user->ip_type, - user->ip_instance, user->ring, &ring); + r =amdgpu_ctx_get_ring (ctx, user->ip_type, user->ip_instance, + user->ring, &ring);if (r) {amdgpu_ctx_put (ctx);return ERR_PTR (r);
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +61 -6
84 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c deleted +0 -316
316 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/7 drm/amdgpu: remove ring lru handling
In reply to a message not in the archiveNot needed any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 98 -------------------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 5 -- 2 files changed, 103 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -98
@@ -135,9 +135,6 @@ void amdgpu_ring_commit(struct amdgpu_ring *ring)if (ring->funcs->end_use) ring->funcs->end_use (ring); - -if (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ ) -amdgpu_ring_lru_touch (ring->adev, ring); }/**
@@ -320,8 +317,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, ring->max_dw = max_dw; ring->priority =DRM_SCHED_PRIORITY_NORMAL ;mutex_init (&ring->priority_mutex); -INIT_LIST_HEAD (&ring->lru_list); -amdgpu_ring_lru_touch (adev, ring);for (i =0 ; i <DRM_SCHED_PRIORITY_MAX ; ++i)atomic_set (&ring->num_jobs[i],0 );
@@ -368,99 +363,6 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) ring->adev->rings[ring->idx] =NULL ; } -static void amdgpu_ring_lru_touch_locked (struct amdgpu_device *adev, -struct amdgpu_ring *ring) -{ -/* list_move_tail handles the case where ring isn't part of the list */ -list_move_tail (&ring->lru_list, &adev->ring_lru_list); -} - -static bool amdgpu_ring_is_blacklisted (struct amdgpu_ring *ring, -int *blacklist,int num_blacklist) -{ -int i; - -for (i =0 ; i < num_blacklist; i++) { -if (ring->idx == blacklist[i]) -return true; - } - -return false; -} - -/** -* amdgpu_ring_lru_get - get the least recently used ring for a HW IP block -* -* @adev: amdgpu_device pointer -* @type: amdgpu_ring_type enum -* @blacklist: blacklisted ring ids array -* @num_blacklist: number of entries in @blacklist -* @lru_pipe_order: find a ring from the least recently used pipe -* @ring: output ring -* -* Retrieve the amdgpu_ring structure for the least recently used ring of -* a specific IP block (all asics). -* Returns 0 on success, error on failure. -*/ -int amdgpu_ring_lru_get (struct amdgpu_device *adev,int type, -int *blacklist,int num_blacklist, -bool lru_pipe_order,struct amdgpu_ring **ring) -{ -struct amdgpu_ring *entry; - -/* List is sorted in LRU order, find first entry corresponding -* to the desired HW IP */ - *ring =NULL ; -spin_lock (&adev->ring_lru_list_lock); -list_for_each_entry (entry, &adev->ring_lru_list, lru_list) { -if (entry->funcs->type != type) -continue ; - -if (amdgpu_ring_is_blacklisted (entry, blacklist, num_blacklist)) -continue ; - -if (!*ring) { - *ring = entry; - -/* We are done for ring LRU */ -if (!lru_pipe_order) -break ; - } - -/* Move all rings on the same pipe to the end of the list */ -if (entry->pipe == (*ring)->pipe) -amdgpu_ring_lru_touch_locked (adev, entry); - } - -/* Move the ring we found to the end of the list */ -if (*ring) -amdgpu_ring_lru_touch_locked (adev, *ring); - -spin_unlock (&adev->ring_lru_list_lock); - -if (!*ring) { -DRM_ERROR ("Ring LRU contains no entries for ring type:%d\n" , type); -return -EINVAL ; - } - -return 0 ; -} - -/** -* amdgpu_ring_lru_touch - mark a ring as recently being used -* -* @adev: amdgpu_device pointer -* @ring: ring to touch -* -* Move @ring to the tail of the lru list -*/ -void amdgpu_ring_lru_touch (struct amdgpu_device *adev,struct amdgpu_ring *ring) -{ -spin_lock (&adev->ring_lru_list_lock); -amdgpu_ring_lru_touch_locked (adev, ring); -spin_unlock (&adev->ring_lru_list_lock); -} -/** * amdgpu_ring_emit_reg_write_reg_wait_helper - ring helper *
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -5
@@ -175,7 +175,6 @@ struct amdgpu_ring {const struct amdgpu_ring_funcs *funcs;struct amdgpu_fence_driver fence_drv;struct drm_gpu_scheduler sched; -struct list_head lru_list;struct amdgpu_bo *ring_obj;volatile uint32_t *ring;
@@ -234,10 +233,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned ring_size, struct amdgpu_irq_src *irq_src, unsigned irq_type);void amdgpu_ring_fini (struct amdgpu_ring *ring); -int amdgpu_ring_lru_get (struct amdgpu_device *adev,int type, -int *blacklist,int num_blacklist, -bool lru_pipe_order,struct amdgpu_ring **ring); -void amdgpu_ring_lru_touch (struct amdgpu_device *adev,struct amdgpu_ring *ring);void amdgpu_ring_emit_reg_write_reg_wait_helper (struct amdgpu_ring *ring,uint32_t reg0,uint32_t val0,uint32_t reg1,uint32_t val1);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/7 drm/amdgpu: move context related stuff to amdgpu_ctx.h
In reply to a message not in the archiveFurther unmangle amdgpu.h.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 59 +---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 84 +++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 57 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -57
@@ -28,6 +28,8 @@#ifndef __AMDGPU_H__#define __AMDGPU_H__ +#include "amdgpu_ctx.h" +#include <linux/atomic.h> #include <linux/wait.h> #include <linux/list.h>
@@ -599,63 +601,6 @@ struct amdgpu_ib {extern const struct drm_sched_backend_ops amdgpu_sched_ops; -/* -* context related structures -*/ - -struct amdgpu_ctx_ring { -uint64_t sequence; -struct dma_fence **fences; -struct drm_sched_entity entity; -}; - -struct amdgpu_ctx { -struct kref refcount; -struct amdgpu_device *adev; -unsigned reset_counter; -unsigned reset_counter_query; -uint32_t vram_lost_counter; -spinlock_t ring_lock; -struct dma_fence **fences; -struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS ]; -bool preamble_presented; -enum drm_sched_priority init_priority; -enum drm_sched_priority override_priority; -struct mutex lock; -atomic_t guilty; -}; - -struct amdgpu_ctx_mgr { -struct amdgpu_device *adev; -struct mutex lock; -/* protected by lock */ -struct idr ctx_handles; -}; - -struct amdgpu_ctx *amdgpu_ctx_get (struct amdgpu_fpriv *fpriv,uint32_t id); -int amdgpu_ctx_put (struct amdgpu_ctx *ctx); - -int amdgpu_ctx_get_ring (struct amdgpu_ctx *ctx, -u32 hw_ip,u32 instance,u32 ring, -struct amdgpu_ring **out_ring); -int amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx,struct amdgpu_ring *ring, -struct dma_fence *fence,uint64_t *seq); -struct dma_fence *amdgpu_ctx_get_fence (struct amdgpu_ctx *ctx, -struct amdgpu_ring *ring,uint64_t seq); -void amdgpu_ctx_priority_override (struct amdgpu_ctx *ctx, -enum drm_sched_priority priority); - -int amdgpu_ctx_ioctl (struct drm_device *dev,void *data, -struct drm_file *filp); - -int amdgpu_ctx_wait_prev_fence (struct amdgpu_ctx *ctx,unsigned ring_id); - -void amdgpu_ctx_mgr_init (struct amdgpu_ctx_mgr *mgr); -void amdgpu_ctx_mgr_entity_fini (struct amdgpu_ctx_mgr *mgr); -void amdgpu_ctx_mgr_entity_flush (struct amdgpu_ctx_mgr *mgr); -void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); - -/* * file private structure */
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h new file +84 -0
84 lines not on this page · raw message
Signature · 6 lines
2.14.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): 20180801113116.1994-6-christian.koenig-5C7GfCeVMHo@public.gmane.org
Huang Rui
Reviewed-byRe: [PATCH 6/7] drm/amdgpu: move context related stuff to amdgpu_ctx.h
Quoted 3 lines · Christian König
Further unmangle
amdgpu.h.Signed-off-by Christian König <[email protected]>
Quoted 180 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 59 +---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 84 +++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 57 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.hdrivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-57@@ -28,6 +28,8 @@#ifndef __AMDGPU_H__#define __AMDGPU_H__ +#include "amdgpu_ctx.h" +#include <linux/atomic.h> #include <linux/wait.h> #include <linux/list.h> @@ -599,63 +601,6 @@ struct amdgpu_ib {extern const struct drm_sched_backend_ops amdgpu_sched_ops; -/* -* context related structures -*/ - -struct amdgpu_ctx_ring { -uint64_t sequence; -struct dma_fence **fences; -struct drm_sched_entity entity; -}; - -struct amdgpu_ctx { -struct kref refcount; -struct amdgpu_device *adev; -unsigned reset_counter; -unsigned reset_counter_query; -uint32_t vram_lost_counter; -spinlock_t ring_lock; -struct dma_fence **fences; -struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS ]; -bool preamble_presented; -enum drm_sched_priority init_priority; -enum drm_sched_priority override_priority; -struct mutex lock; -atomic_t guilty; -}; - -struct amdgpu_ctx_mgr { -struct amdgpu_device *adev; -struct mutex lock; -/* protected by lock */ -struct idr ctx_handles; -}; - -struct amdgpu_ctx *amdgpu_ctx_get (struct amdgpu_fpriv *fpriv,uint32_t id); -int amdgpu_ctx_put (struct amdgpu_ctx *ctx); - -int amdgpu_ctx_get_ring (struct amdgpu_ctx *ctx, -u32 hw_ip,u32 instance,u32 ring, -struct amdgpu_ring **out_ring); -int amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx,struct amdgpu_ring *ring, -struct dma_fence *fence,uint64_t *seq); -struct dma_fence *amdgpu_ctx_get_fence (struct amdgpu_ctx *ctx, -struct amdgpu_ring *ring,uint64_t seq); -void amdgpu_ctx_priority_override (struct amdgpu_ctx *ctx, -enum drm_sched_priority priority); - -int amdgpu_ctx_ioctl (struct drm_device *dev,void *data, -struct drm_file *filp); - -int amdgpu_ctx_wait_prev_fence (struct amdgpu_ctx *ctx,unsigned ring_id); - -void amdgpu_ctx_mgr_init (struct amdgpu_ctx_mgr *mgr); -void amdgpu_ctx_mgr_entity_fini (struct amdgpu_ctx_mgr *mgr); -void amdgpu_ctx_mgr_entity_flush (struct amdgpu_ctx_mgr *mgr); -void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); - -/* * file private structure */ drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h new file +84
-0@@ -0,0 +1,84 @@ +/* +* Copyright 2018 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __AMDGPU_CTX_H__ +#define __AMDGPU_CTX_H__ + +#include "amdgpu_ring.h" + +struct drm_device ; +struct drm_file ; +struct amdgpu_fpriv ; + +struct amdgpu_ctx_ring { +uint64_t sequence; +struct dma_fence **fences; +struct drm_sched_entity entity; +}; + +struct amdgpu_ctx { +struct kref refcount; +struct amdgpu_device *adev; +unsigned reset_counter; +unsigned reset_counter_query; +uint32_t vram_lost_counter; +spinlock_t ring_lock; +struct dma_fence **fences; +struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS ]; +bool preamble_presented; +enum drm_sched_priority init_priority; +enum drm_sched_priority override_priority; +struct mutex lock; +atomic_t guilty; +}; + +struct amdgpu_ctx_mgr { +struct amdgpu_device *adev; +struct mutex lock; +/* protected by lock */ +struct idr ctx_handles; +}; + +struct amdgpu_ctx *amdgpu_ctx_get (struct amdgpu_fpriv *fpriv,uint32_t id); +int amdgpu_ctx_put (struct amdgpu_ctx *ctx); + +int amdgpu_ctx_get_ring (struct amdgpu_ctx *ctx, +u32 hw_ip,u32 instance,u32 ring, +struct amdgpu_ring **out_ring); +int amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx,struct amdgpu_ring *ring, +struct dma_fence *fence,uint64_t *seq); +struct dma_fence *amdgpu_ctx_get_fence (struct amdgpu_ctx *ctx, +struct amdgpu_ring *ring,uint64_t seq); +void amdgpu_ctx_priority_override (struct amdgpu_ctx *ctx, +enum drm_sched_priority priority); + +int amdgpu_ctx_ioctl (struct drm_device *dev,void *data, +struct drm_file *filp); + +int amdgpu_ctx_wait_prev_fence (struct amdgpu_ctx *ctx,unsigned ring_id); + +void amdgpu_ctx_mgr_init (struct amdgpu_ctx_mgr *mgr); +void amdgpu_ctx_mgr_entity_fini (struct amdgpu_ctx_mgr *mgr); +void amdgpu_ctx_mgr_entity_flush (struct amdgpu_ctx_mgr *mgr); +void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); + +#endif Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/7 drm/amdgpu: use entity instead of ring for CS
In reply to a message not in the archiveFurther demangle ring from entity handling.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 66 ++++++++++++++++--------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 53 ++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 16 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 4 +- drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 3 +- 6 files changed, 78 insertions(+), 66 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -910,7 +910,7 @@ struct amdgpu_cs_parser {/* scheduler job object */ struct amdgpu_job *job; -struct amdgpu_ring *ring; +struct drm_sched_entity *entity;/* buffer objects */ struct ww_acquire_ctx ticket;
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +34 -32
184 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +30 -23
137 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +9 -7
@@ -61,20 +61,22 @@ struct amdgpu_ctx_mgr {struct amdgpu_ctx *amdgpu_ctx_get (struct amdgpu_fpriv *fpriv,uint32_t id);int amdgpu_ctx_put (struct amdgpu_ctx *ctx); -int amdgpu_ctx_get_ring (struct amdgpu_ctx *ctx, -u32 hw_ip,u32 instance,u32 ring, -struct amdgpu_ring **out_ring); -int amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx,struct amdgpu_ring *ring, -struct dma_fence *fence,uint64_t *seq); +int amdgpu_ctx_get_entity (struct amdgpu_ctx *ctx,u32 hw_ip,u32 instance, +u32 ring,struct drm_sched_entity **entity); +int amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx, +struct drm_sched_entity *entity, +struct dma_fence *fence,uint64_t *seq);struct dma_fence *amdgpu_ctx_get_fence (struct amdgpu_ctx *ctx, -struct amdgpu_ring *ring,uint64_t seq); +struct drm_sched_entity *entity, +uint64_t seq);void amdgpu_ctx_priority_override (struct amdgpu_ctx *ctx,enum drm_sched_priority priority);int amdgpu_ctx_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); -int amdgpu_ctx_wait_prev_fence (struct amdgpu_ctx *ctx,unsigned ring_id); +int amdgpu_ctx_wait_prev_fence (struct amdgpu_ctx *ctx, +struct drm_sched_entity *entity);void amdgpu_ctx_mgr_init (struct amdgpu_ctx_mgr *mgr);void amdgpu_ctx_mgr_entity_fini (struct amdgpu_ctx_mgr *mgr);
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -2
@@ -150,10 +150,10 @@ TRACE_EVENT(amdgpu_cs,TP_fast_assign ( __entry->bo_list = p->bo_list; - __entry->ring = p->ring->idx; + __entry->ring =to_amdgpu_ring (p->entity->rq->sched)->idx; __entry->dw = p->job->ibs[i].length_dw; __entry->fences =amdgpu_fence_count_emitted ( - p->ring); +to_amdgpu_ring (p->entity->rq->sched)); ), TP_printk("bo_list=%p, ring=%u, dw=%u, fences=%u", __entry->bo_list, __entry->ring, __entry->dw,
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +2 -1
@@ -1259,11 +1259,12 @@ static int uvd_v7_0_ring_test_ring(struct amdgpu_ring *ring)static int uvd_v7_0_ring_patch_cs_in_place (struct amdgpu_cs_parser *p,uint32_t ib_idx) { +struct amdgpu_ring *ring =to_amdgpu_ring (p->entity->rq->sched);struct amdgpu_ib *ib = &p->job->ibs[ib_idx];unsigned i;/* No patching necessary for the first instance */ -if (!p->ring->me) +if (!ring->me)return 0 ;for (i =0 ; i < ib->length_dw; i +=2 ) {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
zhoucm1
Reviewed-by Chunming ZhouThanks,
David Zhou
Quoted 208 lines · Christian König
Instead of the fixed round robin use let the scheduler balance the load of page table updates.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 7 +++---- drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/si_dma.c | 12 +++++++----- 8 files changed, 41 insertions(+), 40 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -2335,7 +2335,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->mman.buffer_funcs =NULL ; adev->mman.buffer_funcs_ring =NULL ; adev->vm_manager.vm_pte_funcs =NULL ; - adev->vm_manager.vm_pte_num_rings =0 ; + adev->vm_manager.vm_pte_num_rqs =0 ; adev->gmc.gmc_funcs =NULL ; adev->fence_context =dma_fence_context_alloc (AMDGPU_MAX_RINGS );bitmap_zero (adev->gfx.pipe_reserve_bitmap,AMDGPU_MAX_COMPUTE_QUEUES );drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-10@@ -2568,9 +2568,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,struct amdgpu_bo *root;const unsigned align =min (AMDGPU_VM_PTB_ALIGN_SIZE ,AMDGPU_VM_PTE_COUNT (adev) *8 ); -unsigned ring_instance; -struct amdgpu_ring *ring; -struct drm_sched_rq *rq;unsigned long size;uint64_t flags;int r, i;@@ -2586,12 +2583,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,INIT_LIST_HEAD (&vm->freed);/* create scheduler entity for page table updates */ - - ring_instance =atomic_inc_return (&adev->vm_manager.vm_pte_next_ring); - ring_instance %= adev->vm_manager.vm_pte_num_rings; - ring = adev->vm_manager.vm_pte_rings[ring_instance]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; - r =drm_sched_entity_init (&vm->entity, &rq,1 ,NULL ); + r =drm_sched_entity_init (&vm->entity, adev->vm_manager.vm_pte_rqs, + adev->vm_manager.vm_pte_num_rqs,NULL );if (r)return r;@@ -2898,7 +2891,6 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) adev->vm_manager.seqno[i] =0 ; -atomic_set (&adev->vm_manager.vm_pte_next_ring,0 );spin_lock_init (&adev->vm_manager.prt_lock);atomic_set (&adev->vm_manager.num_prt_users,0 );drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3
-4@@ -244,10 +244,9 @@ struct amdgpu_vm_manager {/* vram base address for page table entry */ u64 vram_base_offset;/* vm pte handling */ -const struct amdgpu_vm_pte_funcs *vm_pte_funcs; -struct amdgpu_ring *vm_pte_rings[AMDGPU_MAX_RINGS ]; -unsigned vm_pte_num_rings; -atomic_t vm_pte_next_ring; +const struct amdgpu_vm_pte_funcs *vm_pte_funcs; +struct drm_sched_rq *vm_pte_rqs[AMDGPU_MAX_RINGS ]; +unsigned vm_pte_num_rqs;/* partial resident texture handling */ spinlock_t prt_lock;drivers/gpu/drm/amd/amdgpu/cik_sdma.c +7
-5@@ -1386,15 +1386,17 @@ static const struct amdgpu_vm_pte_funcs cik_sdma_vm_pte_funcs = {static void cik_sdma_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &cik_sdma_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +7
-5@@ -1312,15 +1312,17 @@ static const struct amdgpu_vm_pte_funcs sdma_v2_4_vm_pte_funcs = {static void sdma_v2_4_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &sdma_v2_4_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +7
-5@@ -1752,15 +1752,17 @@ static const struct amdgpu_vm_pte_funcs sdma_v3_0_vm_pte_funcs = {static void sdma_v3_0_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &sdma_v3_0_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +7
-5@@ -1750,15 +1750,17 @@ static const struct amdgpu_vm_pte_funcs sdma_v4_0_vm_pte_funcs = {static void sdma_v4_0_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &sdma_v4_0_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; - - adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }drivers/gpu/drm/amd/amdgpu/si_dma.c +1
-4@@ -879,15 +879,17 @@ static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = {static void si_dma_set_vm_pte_funcs (struct amdgpu_device *adev) { +struct drm_gpu_scheduler *sched;unsigned i;if (adev->vm_manager.vm_pte_funcs ==NULL ) { adev->vm_manager.vm_pte_funcs = &si_dma_vm_pte_funcs; -for (i =0 ; i < adev->sdma.num_instances; i++) - adev->vm_manager.vm_pte_rings[i] = - &adev->sdma.instance[i].ring; -
drivers/gpu/drm/amd/amdgpu/si_dma.c static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = { · line 895
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/si_dma.c +6
-1- adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; +for (i =0 ; i < adev->sdma.num_instances; i++) { + sched = &adev->sdma.instance[i].ring.sched; + adev->vm_manager.vm_pte_rqs[i] = + &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; + } + adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; } }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx