drm/scheduler: rework entity creation
Subsystems (8)
PATCH 1/4 drm/scheduler: rework entity creation
Entity currently keeps a copy of run_queue list and modify it in drm_sched_entity_set_priority(). Entities shouldn't modify run_queue list. Use drm_gpu_scheduler list instead of drm_sched_rq list in drm_sched_entity struct. In this way we can select a runqueue based on entity/ctx's priority for a drm scheduler.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 7 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 7 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 7 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++-- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 7 ++- drivers/gpu/drm/lima/lima_sched.c | 5 +- drivers/gpu/drm/panfrost/panfrost_job.c | 8 ++- drivers/gpu/drm/scheduler/sched_entity.c | 74 ++++++++++-------------- drivers/gpu/drm/v3d/v3d_drv.c | 8 ++- include/drm/gpu_scheduler.h | 8 ++- 11 files changed, 78 insertions(+), 75 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -3
@@ -122,7 +122,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,for (i =0 ; i <AMDGPU_HW_IP_NUM ; ++i) {struct amdgpu_ring *rings[AMDGPU_MAX_RINGS ]; -struct drm_sched_rq *rqs[AMDGPU_MAX_RINGS ]; +struct drm_gpu_scheduler *sched_list[AMDGPU_MAX_RINGS ];unsigned num_rings =0 ;unsigned num_rqs =0 ;
@@ -181,12 +181,13 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,if (!rings[j]->adev)continue ; - rqs[num_rqs++] = &rings[j]->sched.sched_rq[priority]; + sched_list[num_rqs++] = &rings[j]->sched; }for (j =0 ; j < amdgpu_ctx_num_entities[i]; ++j) r =drm_sched_entity_init (&ctx->entities[i][j].entity, - rqs, num_rqs, &ctx->guilty); + priority, sched_list, + num_rqs, &ctx->guilty);if (r) goto error_cleanup_entities; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -3
@@ -1957,11 +1957,13 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)if (enable) {struct amdgpu_ring *ring; -struct drm_sched_rq *rq; +struct drm_gpu_scheduler *sched; ring = adev->mman.buffer_funcs_ring; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_KERNEL ]; - r =drm_sched_entity_init (&adev->mman.entity, &rq,1 ,NULL ); + sched = &ring->sched; + r =drm_sched_entity_init (&adev->mman.entity, +DRM_SCHED_PRIORITY_KERNEL , &sched, +1 ,NULL );if (r) {DRM_ERROR ("Failed setting up TTM BO move entity (%d)\n" , r);
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4 -3
@@ -330,12 +330,13 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)int amdgpu_uvd_entity_init (struct amdgpu_device *adev) {struct amdgpu_ring *ring; -struct drm_sched_rq *rq; +struct drm_gpu_scheduler *sched;int r; ring = &adev->uvd.inst[0 ].ring; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.entity, &rq,1 ,NULL ); + sched = &ring->sched; + r =drm_sched_entity_init (&adev->uvd.entity,DRM_SCHED_PRIORITY_NORMAL , + &sched,1 ,NULL );if (r) {DRM_ERROR ("Failed setting up UVD kernel entity.\n" );return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +4 -3
@@ -240,12 +240,13 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev)int amdgpu_vce_entity_init (struct amdgpu_device *adev) {struct amdgpu_ring *ring; -struct drm_sched_rq *rq; +struct drm_gpu_scheduler *sched;int r; ring = &adev->vce.ring[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->vce.entity, &rq,1 ,NULL ); + sched = &ring->sched; + r =drm_sched_entity_init (&adev->vce.entity,DRM_SCHED_PRIORITY_NORMAL , + &sched,1 ,NULL );if (r !=0 ) {DRM_ERROR ("Failed setting up VCE run queue.\n" );return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -4
@@ -2687,6 +2687,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, {struct amdgpu_bo_param bp;struct amdgpu_bo *root; +struct drm_gpu_scheduler *sched_list[AMDGPU_MAX_RINGS ];int r, i; vm->va =RB_ROOT_CACHED ;
@@ -2700,14 +2701,19 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,spin_lock_init (&vm->invalidated_lock);INIT_LIST_HEAD (&vm->freed); +for (i =0 ; i < adev->vm_manager.vm_pte_num_rqs; i++) + sched_list[i] = adev->vm_manager.vm_pte_rqs[i]->sched; +/* create scheduler entities for page table updates */ - r =drm_sched_entity_init (&vm->direct, adev->vm_manager.vm_pte_rqs, - adev->vm_manager.vm_pte_num_rqs,NULL ); + r =drm_sched_entity_init (&vm->direct,DRM_SCHED_PRIORITY_NORMAL , + sched_list, adev->vm_manager.vm_pte_num_rqs, +NULL );if (r)return r; - r =drm_sched_entity_init (&vm->delayed, adev->vm_manager.vm_pte_rqs, - adev->vm_manager.vm_pte_num_rqs,NULL ); + r =drm_sched_entity_init (&vm->delayed,DRM_SCHED_PRIORITY_NORMAL , + sched_list, adev->vm_manager.vm_pte_num_rqs, +NULL );if (r) goto error_free_direct;
drivers/gpu/drm/etnaviv/etnaviv_drv.c +4 -3
@@ -65,12 +65,13 @@ static int etnaviv_open(struct drm_device *dev, struct drm_file *file)for (i =0 ; i <ETNA_MAX_PIPES ; i++) {struct etnaviv_gpu *gpu = priv->gpu[i]; -struct drm_sched_rq *rq; +struct drm_gpu_scheduler *sched;if (gpu) { - rq = &gpu->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; + sched = &gpu->sched;drm_sched_entity_init (&ctx->sched_entity[i], - &rq,1 ,NULL ); +DRM_SCHED_PRIORITY_NORMAL , &sched, +1 ,NULL ); } }
drivers/gpu/drm/lima/lima_sched.c +3 -2
@@ -159,9 +159,10 @@ int lima_sched_context_init(struct lima_sched_pipe *pipe,struct lima_sched_context *context, atomic_t *guilty) { - struct drm_sched_rq *rq = pipe->base.sched_rq + DRM_SCHED_PRIORITY_NORMAL; + struct drm_gpu_scheduler *sched = &pipe->base; -return drm_sched_entity_init (&context->base, &rq,1 , guilty); +return drm_sched_entity_init (&context->base,DRM_SCHED_PRIORITY_NORMAL , + &sched,1 , guilty); } void lima_sched_context_fini(struct lima_sched_pipe *pipe,
drivers/gpu/drm/panfrost/panfrost_job.c +5 -3
@@ -542,12 +542,14 @@ int panfrost_job_open(struct panfrost_file_priv *panfrost_priv) {struct panfrost_device *pfdev = panfrost_priv->pfdev;struct panfrost_job_slot *js = pfdev->js; -struct drm_sched_rq *rq; +struct drm_gpu_scheduler *sched;int ret, i;for (i =0 ; i <NUM_JOB_SLOTS ; i++) { - rq = &js->queue[i].sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - ret =drm_sched_entity_init (&panfrost_priv->sched_entity[i], &rq,1 ,NULL ); + sched = &js->queue[i].sched; + ret =drm_sched_entity_init (&panfrost_priv->sched_entity[i], +DRM_SCHED_PRIORITY_NORMAL , &sched, +1 ,NULL ,DRM_SCHED_PRIORITY_NORMAL );if (WARN_ON (ret))return ret; }
drivers/gpu/drm/scheduler/sched_entity.c +29 -45
148 lines not on this page · raw message
drivers/gpu/drm/v3d/v3d_drv.c +5 -3
@@ -140,7 +140,7 @@ v3d_open(struct drm_device *dev, struct drm_file *file) {struct v3d_dev *v3d =to_v3d_dev (dev);struct v3d_file_priv *v3d_priv; -struct drm_sched_rq *rq; +struct drm_gpu_scheduler *sched;int i; v3d_priv =kzalloc (sizeof (*v3d_priv),GFP_KERNEL );
@@ -150,8 +150,10 @@ v3d_open(struct drm_device *dev, struct drm_file *file) v3d_priv->v3d = v3d;for (i =0 ; i <V3D_MAX_QUEUES ; i++) { - rq = &v3d->queue[i].sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; -drm_sched_entity_init (&v3d_priv->sched_entity[i], &rq,1 ,NULL ); + sched = &v3d->queue[i].sched; +drm_sched_entity_init (&v3d_priv->sched_entity[i], +DRM_SCHED_PRIORITY_NORMAL , &sched, +1 ,NULL ); } file->driver_priv = v3d_priv;
include/drm/gpu_scheduler.h +5 -3
@@ -81,8 +81,9 @@ enum drm_sched_priority {struct drm_sched_entity {struct list_head list;struct drm_sched_rq *rq; -struct drm_sched_rq **rq_list; -unsigned int num_rq_list; +unsigned int num_sched_list; +struct drm_gpu_scheduler **sched_list; +enum drm_sched_priority priority;spinlock_t rq_lock;struct spsc_queue job_queue;
@@ -312,7 +313,8 @@ void drm_sched_rq_remove_entity(struct drm_sched_rq *rq, struct drm_sched_entity *entity);int drm_sched_entity_init (struct drm_sched_entity *entity, -struct drm_sched_rq **rq_list, +enum drm_sched_priority priority, +struct drm_gpu_scheduler **sched_list,unsigned int num_rq_list,atomic_t *guilty);long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout);
Signature · 6 lines
2.24.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 3/4 amd/amdgpu: add sched array to IPs with multiple run-queues
This sched array can be passed on to entity creation routine instead of manually creating such sched array on every context creation.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 113 +++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 9 +- 7 files changed, 89 insertions(+), 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +69 -44
@@ -74,7 +74,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx) {unsigned num_entities =amdgpu_ctx_total_num_entities (); -unsigned i, j, k; +unsigned i, j;int r;if (priority <0 || priority >=DRM_SCHED_PRIORITY_MAX )
@@ -121,73 +121,56 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->override_priority =DRM_SCHED_PRIORITY_UNSET ;for (i =0 ; i <AMDGPU_HW_IP_NUM ; ++i) { -struct amdgpu_ring *rings[AMDGPU_MAX_RINGS ]; -struct drm_gpu_scheduler *sched_list[AMDGPU_MAX_RINGS ]; -unsigned num_rings =0 ; -unsigned num_rqs =0 ; +struct drm_gpu_scheduler **scheds; +struct drm_gpu_scheduler *sched; +unsigned num_scheds =0 ;switch (i) {case AMDGPU_HW_IP_GFX : - rings[0 ] = &adev->gfx.gfx_ring[0 ]; - num_rings =1 ; + scheds = adev->gfx.gfx_sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_COMPUTE : -for (j =0 ; j < adev->gfx.num_compute_rings; ++j) - rings[j] = &adev->gfx.compute_ring[j]; - num_rings = adev->gfx.num_compute_rings; + scheds = adev->gfx.compute_sched; + num_scheds = adev->gfx.num_compute_sched;break ;case AMDGPU_HW_IP_DMA : -for (j =0 ; j < adev->sdma.num_instances; ++j) - rings[j] = &adev->sdma.instance[j].ring; - num_rings = adev->sdma.num_instances; + scheds = adev->sdma.sdma_sched; + num_scheds = adev->sdma.num_sdma_sched;break ;case AMDGPU_HW_IP_UVD : - rings[0 ] = &adev->uvd.inst[0 ].ring; - num_rings =1 ; + sched = &adev->uvd.inst[0 ].ring.sched; + scheds = &sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_VCE : - rings[0 ] = &adev->vce.ring[0 ]; - num_rings =1 ; + sched = &adev->vce.ring[0 ].sched; + scheds = &sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_UVD_ENC : - rings[0 ] = &adev->uvd.inst[0 ].ring_enc[0 ]; - num_rings =1 ; + sched = &adev->uvd.inst[0 ].ring_enc[0 ].sched; + scheds = &sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_VCN_DEC : -for (j =0 ; j < adev->vcn.num_vcn_inst; ++j) { -if (adev->vcn.harvest_config & (1 << j)) -continue ; - rings[num_rings++] = &adev->vcn.inst[j].ring_dec; - } + scheds = adev->vcn.vcn_dec_sched; + num_scheds = adev->vcn.num_vcn_dec_sched;break ;case AMDGPU_HW_IP_VCN_ENC : -for (j =0 ; j < adev->vcn.num_vcn_inst; ++j) { -if (adev->vcn.harvest_config & (1 << j)) -continue ; -for (k =0 ; k < adev->vcn.num_enc_rings; ++k) - rings[num_rings++] = &adev->vcn.inst[j].ring_enc[k]; - } + scheds = adev->vcn.vcn_enc_sched; + num_scheds = adev->vcn.num_vcn_enc_sched;break ;case AMDGPU_HW_IP_VCN_JPEG : -for (j =0 ; j < adev->jpeg.num_jpeg_inst; ++j) { -if (adev->vcn.harvest_config & (1 << j)) -continue ; - rings[num_rings++] = &adev->jpeg.inst[j].ring_dec; - } + scheds = adev->jpeg.jpeg_sched; + num_scheds = adev->jpeg.num_jpeg_sched;break ; } -for (j =0 ; j < num_rings; ++j) { -if (!rings[j]->adev) -continue ; - - sched_list[num_rqs++] = &rings[j]->sched; - } -for (j =0 ; j < amdgpu_ctx_num_entities[i]; ++j) r =drm_sched_entity_init (&ctx->entities[i][j].entity, - priority, sched_list, - num_rqs, &ctx->guilty); + priority, scheds, + num_scheds, &ctx->guilty);if (r) goto error_cleanup_entities; }
@@ -631,3 +614,45 @@ void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr)idr_destroy (&mgr->ctx_handles);mutex_destroy (&mgr->lock); } + +void amdgpu_ctx_init_sched (struct amdgpu_device *adev) +{ +int i, j; + +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + adev->gfx.gfx_sched[i] = &adev->gfx.gfx_ring[i].sched; + adev->gfx.num_gfx_sched++; + } + +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + adev->gfx.compute_sched[i] = &adev->gfx.compute_ring[i].sched; + adev->gfx.num_compute_sched++; + } + +for (i =0 ; i < adev->sdma.num_instances; i++) { + adev->sdma.sdma_sched[i] = &adev->sdma.instance[i].ring.sched; + adev->sdma.num_sdma_sched++; + } + +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + adev->vcn.vcn_dec_sched[adev->vcn.num_vcn_dec_sched++] = + &adev->vcn.inst[i].ring_dec.sched; + } + +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) + adev->vcn.vcn_enc_sched[adev->vcn.num_vcn_enc_sched++] = + &adev->vcn.inst[i].ring_enc[j].sched; + } + +for (i =0 ; i < adev->jpeg.num_jpeg_inst; ++i) { +if (adev->jpeg.harvest_config & (1 << i)) +continue ; + adev->jpeg.jpeg_sched[adev->jpeg.num_jpeg_sched++] = + &adev->jpeg.inst[i].ring_dec.sched; + } +}
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +3 -0
@@ -87,4 +87,7 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr);long amdgpu_ctx_mgr_entity_flush (struct amdgpu_ctx_mgr *mgr,long timeout);void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); +void amdgpu_ctx_init_sched (struct amdgpu_device *adev); + +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3024,6 +3024,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, goto failed; } +amdgpu_ctx_init_sched (adev); + adev->accel_working = true;amdgpu_vm_check_compute_bug (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +4 -0
@@ -269,8 +269,12 @@ struct amdgpu_gfx {bool me_fw_write_wait;bool cp_fw_write_wait;struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS ]; +struct drm_gpu_scheduler *gfx_sched[AMDGPU_MAX_GFX_RINGS ]; +uint32_t num_gfx_sched;unsigned num_gfx_rings;struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS ]; +struct drm_gpu_scheduler *compute_sched[AMDGPU_MAX_COMPUTE_RINGS ]; +uint32_t num_compute_sched;unsigned num_compute_rings;struct amdgpu_irq_src eop_irq;struct amdgpu_irq_src priv_reg_irq;
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h +2 -0
@@ -43,6 +43,8 @@ struct amdgpu_jpeg {uint8_t num_jpeg_inst;struct amdgpu_jpeg_inst inst[AMDGPU_MAX_JPEG_INSTANCES ];struct amdgpu_jpeg_reg internal; +struct drm_gpu_scheduler *jpeg_sched[AMDGPU_MAX_JPEG_INSTANCES ]; +uint32_t num_jpeg_sched;unsigned harvest_config;struct delayed_work idle_work;enum amd_powergating_state cur_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +2 -0
@@ -52,6 +52,8 @@ struct amdgpu_sdma_instance {struct amdgpu_sdma {struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES ]; +struct drm_gpu_scheduler *sdma_sched[AMDGPU_MAX_SDMA_INSTANCES ]; +uint32_t num_sdma_sched;struct amdgpu_irq_src trap_irq;struct amdgpu_irq_src illegal_inst_irq;struct amdgpu_irq_src ecc_irq;
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +7 -2
@@ -31,6 +31,7 @@#define AMDGPU_VCN_MAX_ENC_RINGS 3#define AMDGPU_MAX_VCN_INSTANCES 2 +#define AMDGPU_MAX_VCN_ENC_RINGS AMDGPU_VCN_MAX_ENC_RINGS * AMDGPU_MAX_VCN_INSTANCES#define AMDGPU_VCN_HARVEST_VCN0 (1 << 0)#define AMDGPU_VCN_HARVEST_VCN1 (1 << 1)
@@ -186,8 +187,12 @@ struct amdgpu_vcn {uint32_t *dpg_sram_curr_addr;uint8_t num_vcn_inst; -struct amdgpu_vcn_inst inst[AMDGPU_MAX_VCN_INSTANCES ]; -struct amdgpu_vcn_reg internal; +struct amdgpu_vcn_inst inst[AMDGPU_MAX_VCN_INSTANCES ]; +struct amdgpu_vcn_reg internal; +struct drm_gpu_scheduler *vcn_enc_sched[AMDGPU_MAX_VCN_ENC_RINGS ]; +struct drm_gpu_scheduler *vcn_dec_sched[AMDGPU_MAX_VCN_INSTANCES ]; +uint32_t num_vcn_enc_sched; +uint32_t num_vcn_dec_sched;unsigned harvest_config; int (*pause_dpg_mode)(struct amdgpu_device *adev,
--
2.24.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 3/4 v2] amd/amdgpu: add sched array to IPs with multiple run-queues
Am 10.12.19 um 13:52 schrieb Nirmoy Das:
Quoted 4 lines
This sched array can be passed on to entity creation routine instead of manually creating such sched array on every context creation.
Signed-off-by Nirmoy Das <[email protected]>
Quoted 265 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 113 +++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 9 +- 7 files changed, 89 insertions(+), 46 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +69
-44@@ -74,7 +74,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx) {unsigned num_entities =amdgpu_ctx_total_num_entities (); -unsigned i, j, k; +unsigned i, j;int r;if (priority <0 || priority >=DRM_SCHED_PRIORITY_MAX )@@ -121,73 +121,56 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, ctx->override_priority =DRM_SCHED_PRIORITY_UNSET ;for (i =0 ; i <AMDGPU_HW_IP_NUM ; ++i) { -struct amdgpu_ring *rings[AMDGPU_MAX_RINGS ]; -struct drm_gpu_scheduler *sched_list[AMDGPU_MAX_RINGS ]; -unsigned num_rings =0 ; -unsigned num_rqs =0 ; +struct drm_gpu_scheduler **scheds; +struct drm_gpu_scheduler *sched; +unsigned num_scheds =0 ;switch (i) {case AMDGPU_HW_IP_GFX : - rings[0 ] = &adev->gfx.gfx_ring[0 ]; - num_rings =1 ; + scheds = adev->gfx.gfx_sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_COMPUTE : -for (j =0 ; j < adev->gfx.num_compute_rings; ++j) - rings[j] = &adev->gfx.compute_ring[j]; - num_rings = adev->gfx.num_compute_rings; + scheds = adev->gfx.compute_sched; + num_scheds = adev->gfx.num_compute_sched;break ;case AMDGPU_HW_IP_DMA : -for (j =0 ; j < adev->sdma.num_instances; ++j) - rings[j] = &adev->sdma.instance[j].ring; - num_rings = adev->sdma.num_instances; + scheds = adev->sdma.sdma_sched; + num_scheds = adev->sdma.num_sdma_sched;break ;case AMDGPU_HW_IP_UVD : - rings[0 ] = &adev->uvd.inst[0 ].ring; - num_rings =1 ; + sched = &adev->uvd.inst[0 ].ring.sched; + scheds = &sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_VCE : - rings[0 ] = &adev->vce.ring[0 ]; - num_rings =1 ; + sched = &adev->vce.ring[0 ].sched; + scheds = &sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_UVD_ENC : - rings[0 ] = &adev->uvd.inst[0 ].ring_enc[0 ]; - num_rings =1 ; + sched = &adev->uvd.inst[0 ].ring_enc[0 ].sched; + scheds = &sched; + num_scheds =1 ;break ;case AMDGPU_HW_IP_VCN_DEC : -for (j =0 ; j < adev->vcn.num_vcn_inst; ++j) { -if (adev->vcn.harvest_config & (1 << j)) -continue ; - rings[num_rings++] = &adev->vcn.inst[j].ring_dec; - } + scheds = adev->vcn.vcn_dec_sched; + num_scheds = adev->vcn.num_vcn_dec_sched;break ;case AMDGPU_HW_IP_VCN_ENC : -for (j =0 ; j < adev->vcn.num_vcn_inst; ++j) { -if (adev->vcn.harvest_config & (1 << j)) -continue ; -for (k =0 ; k < adev->vcn.num_enc_rings; ++k) - rings[num_rings++] = &adev->vcn.inst[j].ring_enc[k]; - } + scheds = adev->vcn.vcn_enc_sched; + num_scheds = adev->vcn.num_vcn_enc_sched;break ;case AMDGPU_HW_IP_VCN_JPEG : -for (j =0 ; j < adev->jpeg.num_jpeg_inst; ++j) { -if (adev->vcn.harvest_config & (1 << j)) -continue ; - rings[num_rings++] = &adev->jpeg.inst[j].ring_dec; - } + scheds = adev->jpeg.jpeg_sched; + num_scheds = adev->jpeg.num_jpeg_sched;break ; } -for (j =0 ; j < num_rings; ++j) { -if (!rings[j]->adev) -continue ; - - sched_list[num_rqs++] = &rings[j]->sched; - } -for (j =0 ; j < amdgpu_ctx_num_entities[i]; ++j) r =drm_sched_entity_init (&ctx->entities[i][j].entity, - priority, sched_list, - num_rqs, &ctx->guilty); + priority, scheds, + num_scheds, &ctx->guilty);if (r) goto error_cleanup_entities; }@@ -631,3 +614,45 @@ void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr)idr_destroy (&mgr->ctx_handles);mutex_destroy (&mgr->lock); } + +void amdgpu_ctx_init_sched (struct amdgpu_device *adev) +{ +int i, j; + +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + adev->gfx.gfx_sched[i] = &adev->gfx.gfx_ring[i].sched; + adev->gfx.num_gfx_sched++; + } + +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + adev->gfx.compute_sched[i] = &adev->gfx.compute_ring[i].sched; + adev->gfx.num_compute_sched++; + } + +for (i =0 ; i < adev->sdma.num_instances; i++) { + adev->sdma.sdma_sched[i] = &adev->sdma.instance[i].ring.sched; + adev->sdma.num_sdma_sched++; + } + +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + adev->vcn.vcn_dec_sched[adev->vcn.num_vcn_dec_sched++] = + &adev->vcn.inst[i].ring_dec.sched; + } + +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) + adev->vcn.vcn_enc_sched[adev->vcn.num_vcn_enc_sched++] = + &adev->vcn.inst[i].ring_enc[j].sched; + } + +for (i =0 ; i < adev->jpeg.num_jpeg_inst; ++i) { +if (adev->jpeg.harvest_config & (1 << i)) +continue ; + adev->jpeg.jpeg_sched[adev->jpeg.num_jpeg_sched++] = + &adev->jpeg.inst[i].ring_dec.sched; + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +3
-0@@ -87,4 +87,7 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr);long amdgpu_ctx_mgr_entity_flush (struct amdgpu_ctx_mgr *mgr,long timeout);void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); +void amdgpu_ctx_init_sched (struct amdgpu_device *adev); + +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0@@ -3024,6 +3024,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, goto failed; } +amdgpu_ctx_init_sched (adev); + adev->accel_working = true;amdgpu_vm_check_compute_bug (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +4
-0@@ -269,8 +269,12 @@ struct amdgpu_gfx {bool me_fw_write_wait;bool cp_fw_write_wait;struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS ]; +struct drm_gpu_scheduler *gfx_sched[AMDGPU_MAX_GFX_RINGS ]; +uint32_t num_gfx_sched;unsigned num_gfx_rings;struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS ]; +struct drm_gpu_scheduler *compute_sched[AMDGPU_MAX_COMPUTE_RINGS ]; +uint32_t num_compute_sched;unsigned num_compute_rings;struct amdgpu_irq_src eop_irq;struct amdgpu_irq_src priv_reg_irq;drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h +2
-0@@ -43,6 +43,8 @@ struct amdgpu_jpeg {uint8_t num_jpeg_inst;struct amdgpu_jpeg_inst inst[AMDGPU_MAX_JPEG_INSTANCES ];struct amdgpu_jpeg_reg internal; +struct drm_gpu_scheduler *jpeg_sched[AMDGPU_MAX_JPEG_INSTANCES ]; +uint32_t num_jpeg_sched;unsigned harvest_config;struct delayed_work idle_work;enum amd_powergating_state cur_state;drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +2
-0@@ -52,6 +52,8 @@ struct amdgpu_sdma_instance {struct amdgpu_sdma {struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES ]; +struct drm_gpu_scheduler *sdma_sched[AMDGPU_MAX_SDMA_INSTANCES ]; +uint32_t num_sdma_sched;struct amdgpu_irq_src trap_irq;struct amdgpu_irq_src illegal_inst_irq;struct amdgpu_irq_src ecc_irq;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +7
-3@@ -31,6 +31,7 @@#define AMDGPU_VCN_MAX_ENC_RINGS 3#define AMDGPU_MAX_VCN_INSTANCES 2 +#define AMDGPU_MAX_VCN_ENC_RINGS AMDGPU_VCN_MAX_ENC_RINGS * AMDGPU_MAX_VCN_INSTANCES#define AMDGPU_VCN_HARVEST_VCN0 (1 << 0)#define AMDGPU_VCN_HARVEST_VCN1 (1 << 1)@@ -186,8 +187,12 @@ struct amdgpu_vcn {uint32_t *dpg_sram_curr_addr;uint8_t num_vcn_inst; -struct amdgpu_vcn_inst inst[AMDGPU_MAX_VCN_INSTANCES ]; -struct amdgpu_vcn_reg internal; +struct amdgpu_vcn_inst inst[AMDGPU_MAX_VCN_INSTANCES ]; +struct amdgpu_vcn_reg internal; +struct drm_gpu_scheduler *vcn_enc_sched[AMDGPU_MAX_VCN_ENC_RINGS ]; +struct drm_gpu_scheduler *vcn_dec_sched[AMDGPU_MAX_VCN_INSTANCES ]; +uint32_t num_vcn_enc_sched; +uint32_t num_vcn_dec_sched;unsigned harvest_config; int (*pause_dpg_mode)(struct amdgpu_device *adev, --
Quoted 2 lines
2.24.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 drm/amdgpu: replace vm_pte's run-queue list with drm gpu scheds list
In reply to Nirmoy Dasdrm_sched_entity_init() takes drm gpu scheduler list instead of drm_sched_rq list. This makes conversion of drm_sched_rq list to drm gpu scheduler list unnecessary
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 ++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 ++-- drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/si_dma.c | 8 +++----- 9 files changed, 24 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2779,7 +2779,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_rqs =0 ; + adev->vm_manager.vm_pte_num_scheds =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 +4 -7
@@ -2687,7 +2687,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, {struct amdgpu_bo_param bp;struct amdgpu_bo *root; -struct drm_gpu_scheduler *sched_list[AMDGPU_MAX_RINGS ];int r, i; vm->va =RB_ROOT_CACHED ;
@@ -2701,19 +2700,17 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,spin_lock_init (&vm->invalidated_lock);INIT_LIST_HEAD (&vm->freed); -for (i =0 ; i < adev->vm_manager.vm_pte_num_rqs; i++) - sched_list[i] = adev->vm_manager.vm_pte_rqs[i]->sched;/* create scheduler entities for page table updates */ r =drm_sched_entity_init (&vm->direct,DRM_SCHED_PRIORITY_NORMAL , - sched_list, adev->vm_manager.vm_pte_num_rqs, -NULL ); + adev->vm_manager.vm_pte_scheds, + adev->vm_manager.vm_pte_num_scheds,NULL );if (r)return r; r =drm_sched_entity_init (&vm->delayed,DRM_SCHED_PRIORITY_NORMAL , - sched_list, adev->vm_manager.vm_pte_num_rqs, -NULL ); + adev->vm_manager.vm_pte_scheds, + adev->vm_manager.vm_pte_num_scheds,NULL );if (r) goto error_free_direct;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -2
@@ -322,8 +322,8 @@ struct amdgpu_vm_manager {u64 vram_base_offset;/* vm pte handling */ const struct amdgpu_vm_pte_funcs *vm_pte_funcs; -struct drm_sched_rq *vm_pte_rqs[AMDGPU_MAX_RINGS ]; -unsigned vm_pte_num_rqs; +struct drm_gpu_scheduler *vm_pte_scheds[AMDGPU_MAX_RINGS ]; +unsigned vm_pte_num_scheds;struct amdgpu_ring *page_fault;/* partial resident texture handling */
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +3 -5
@@ -1373,16 +1373,14 @@ 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; adev->vm_manager.vm_pte_funcs = &cik_sdma_vm_pte_funcs;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_scheds[i] = + &adev->sdma.instance[i].ring.sched; } - adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; + adev->vm_manager.vm_pte_num_scheds = adev->sdma.num_instances; } const struct amdgpu_ip_block_version cik_sdma_ip_block =
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +3 -5
@@ -1261,16 +1261,14 @@ 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; adev->vm_manager.vm_pte_funcs = &sdma_v2_4_vm_pte_funcs;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_scheds[i] = + &adev->sdma.instance[i].ring.sched; } - adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; + adev->vm_manager.vm_pte_num_scheds = adev->sdma.num_instances; } const struct amdgpu_ip_block_version sdma_v2_4_ip_block =
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +3 -5
@@ -1699,16 +1699,14 @@ 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; adev->vm_manager.vm_pte_funcs = &sdma_v3_0_vm_pte_funcs;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_scheds[i] = + &adev->sdma.instance[i].ring.sched; } - adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; + adev->vm_manager.vm_pte_num_scheds = adev->sdma.num_instances; } const struct amdgpu_ip_block_version sdma_v3_0_ip_block =
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -3
@@ -2411,10 +2411,9 @@ static void sdma_v4_0_set_vm_pte_funcs(struct amdgpu_device *adev) sched = &adev->sdma.instance[i].page.sched; else 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_scheds[i] = sched; } - adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; + adev->vm_manager.vm_pte_num_scheds = adev->sdma.num_instances; }const struct amdgpu_ip_block_version sdma_v4_0_ip_block = {
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +3 -5
@@ -1723,17 +1723,15 @@ static const struct amdgpu_vm_pte_funcs sdma_v5_0_vm_pte_funcs = {static void sdma_v5_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_v5_0_vm_pte_funcs;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_scheds[i] = + &adev->sdma.instance[i].ring.sched; } - adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; + adev->vm_manager.vm_pte_num_scheds = adev->sdma.num_instances; } }
drivers/gpu/drm/amd/amdgpu/si_dma.c +3 -5
@@ -835,16 +835,14 @@ 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; adev->vm_manager.vm_pte_funcs = &si_dma_vm_pte_funcs;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_scheds[i] = + &adev->sdma.instance[i].ring.sched; } - adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; + adev->vm_manager.vm_pte_num_scheds = adev->sdma.num_instances; } const struct amdgpu_ip_block_version si_dma_ip_block =
Signature · 6 lines
2.24.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/scheduler: do not keep a copy of sched list
In reply to Nirmoy Dasentity should not keep copy and maintain sched list for itself.
--- drivers/gpu/drm/scheduler/sched_entity.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +1 -9
@@ -67,17 +67,10 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; - entity->sched_list =kcalloc (num_sched_list, -sizeof (struct drm_gpu_scheduler *),GFP_KERNEL ); + entity->sched_list = sched_list; -if (!entity->sched_list) -return -ENOMEM ;init_completion (&entity->entity_idle); - -for (i =0 ; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; -if (num_sched_list) entity->rq = &entity->sched_list[0 ]->sched_rq[entity->priority];
@@ -312,7 +305,6 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity)dma_fence_put (entity->last_scheduled); entity->last_scheduled =NULL ; -kfree (entity->sched_list); }EXPORT_SYMBOL (drm_sched_entity_fini);
Signature · 6 lines
2.24.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
Am 10.12.19 um 13:53 schrieb Nirmoy Das:
Quoted 13 lines
entity should not keep copy and maintain sched list for itself.
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +0
-0
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 70
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -67,17 +67,10 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; - entity->sched_list =kcalloc (num_sched_list, -sizeof (struct drm_gpu_scheduler *),GFP_KERNEL ); + entity->sched_list = sched_list;
Maybe make this "num_sched_list > 1 ? sched_list : NULL" to avoid accidentally dereferencing a stale pointer to the stack.
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 74
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-6-if (!entity->sched_list) -return -ENOMEM ;init_completion (&entity->entity_idle); - -for (i =0 ; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; -if (num_sched_list)
That check can actually be dropped as well. We return -EINVAL when the num_sched_list is zero.
Regards,
Christian.
drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_fini(struct drm_sched_entity *entity) · line 310
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-1entity->rq = &entity->sched_list[0 ]->sched_rq[entity->priority];@@ -312,7 +305,6 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity)dma_fence_put (entity->last_scheduled); entity->last_scheduled =NULL ; -kfree (entity->sched_list); }EXPORT_SYMBOL (drm_sched_entity_fini);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
reviewerRe: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
Am 10.12.19 um 14:00 schrieb Christian König:
Quoted 35 lines
Am 10.12.19 um 13:53 schrieb Nirmoy Das:
Quoted 13 lines
entity should not keep copy and maintain sched list for itself.
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/scheduler/sched_entity.c| 10 +---------1 file changed, 1 insertion(+), 9 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +0
-0drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity · line 71
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -67,17 +67,10 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; - entity->sched_list = kcalloc(num_sched_list, - sizeof(struct drm_gpu_scheduler *), GFP_KERNEL); + entity->sched_list = sched_list;Maybe make this "
num_sched_list> 1 ?sched_list: NULL" to avoid accidentally dereferencing a stale pointer to the stack.drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 74
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-5- if(!entity->sched_list) - return -ENOMEM; init_completion(&entity->entity_idle); - - for (i = 0; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; - if (num_sched_list)That check can actually be dropped as well. We return
-EINVALwhen thenum_sched_listis zero.
Quoted 4 lines
Regards,
Christian.Quoted 1 line
drivers/gpu/drm/scheduler/sched_entity.c +0
-0entity->rq = &entity->sched_list[0]->sched_rq[entity->priority];
Forgot to note that this should then probably use "sched_list[0]->sched_rq[entity->priority]" directly when we change the assignment above.
Christian.
Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0@@ -312,7 +305,6 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity)
dma_fence_put(entity->last_scheduled);
entity->last_scheduled= NULL;
-kfree(entity->sched_list);
}
EXPORT_SYMBOL(drm_sched_entity_fini);_______________________________________________
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
Re: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
In reply to Christian KönigQuoted 9 lines · Christian König
Am 10.12.19 um 13:53 schrieb Nirmoy Das:
Quoted 8 lines
entity should not keep copy and maintain sched list for itself.
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/scheduler/sched_entity.c| 10 +---------1 file changed, 1 insertion(+), 9 deletions(-)
Quoted 14 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity · line 71
Quoted 12 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -67,17 +67,10 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; - entity->sched_list = kcalloc(num_sched_list, - sizeof(struct drm_gpu_scheduler *), GFP_KERNEL); + entity->sched_list = sched_list;Maybe make this "
num_sched_list> 1 ?sched_list: NULL" to avoid accidentally dereferencing a stale pointer to the stack.
Do you mean "num_sched_list >= 1 ? sched_list : NULL"
Quoted 11 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 74
Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-5- if(!entity->sched_list) - return -ENOMEM; init_completion(&entity->entity_idle); - - for (i = 0; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; - if (num_sched_list)That check can actually be dropped as well. We return
-EINVALwhen thenum_sched_listis zero.
This one took me some time to understand. So we don't really return -EINVAL if num_sched_list == 0
if (!(entity && sched_list && (num_sched_list == 0 || sched_list[0]))) return -EINVAL;
This is coming from below patch. Are we suppose to tolerate IPs with uninitialized sched so that ctx creation dosn't return error ?
commit 1decbf6bb0b4dc56c9da6c5e57b994ebfc2be3aa
Author: Bas Nieuwenhuizen <[email protected]> Date: Wed Jan 30 02:53:19 2019 +0100
drm/sched: Fix entities with 0 rqs.
Some blocks in amdgpu can have 0 rqs.
Job creation already fails with -ENOENT when entity->rq is NULL, so jobs cannot be pushed. Without a rq there is no scheduler to pop jobs, and rq selection already does the right thing with a list of length 0.
So the operations we need to fix are:
- Creation, do not set rq to rq_list[0] if the list can have length 0.
- Do not flush any jobs when there is no rq.
- On entity destruction handle the rq = NULL case.
- on set_priority, do not try to change the rq if it is NULL.
Quoted 12 lines
Regards,
Christian.Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0entity->rq = &entity->sched_list[0]->sched_rq[entity->priority]; @@ -312,7 +305,6 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity)
dma_fence_put(entity->last_scheduled);
entity->last_scheduled= NULL;
-kfree(entity->sched_list);
}
EXPORT_SYMBOL(drm_sched_entity_fini);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
I think amdgpu_ctx_init() should check for num_scheds and not call drm_sched_entity_init()
if its zero.
Quoted 59 lines · Nirmoy
Quoted 9 lines · Christian König
Am 10.12.19 um 13:53 schrieb Nirmoy Das:
Quoted 8 lines
entity should not keep copy and maintain sched list for itself.
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/scheduler/sched_entity.c| 10 +---------1 file changed, 1 insertion(+), 9 deletions(-)Quoted 14 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct · line 71
Quoted 12 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -67,17 +67,10 @@ int drm_sched_entity_init(structdrm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; - entity->sched_list = kcalloc(num_sched_list, - sizeof(struct drm_gpu_scheduler *), GFP_KERNEL); + entity->sched_list = sched_list;Maybe make this "
num_sched_list> 1 ?sched_list: NULL" to avoid accidentally dereferencing a stale pointer to the stack.Do you mean "
num_sched_list>= 1 ?sched_list: NULL"Quoted 11 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 74
Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-5- if(!entity->sched_list) - return -ENOMEM; init_completion(&entity->entity_idle); - - for (i = 0; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; - if (num_sched_list)That check can actually be dropped as well. We return
-EINVALwhen thenum_sched_listis zero.This one took me some time to understand. So we don't really return
-EINVALifnum_sched_list== 0if (!(entity &&
sched_list&& (num_sched_list== 0 || sched_list[0]))) return-EINVAL;This is coming from below patch. Are we suppose to tolerate IPs with uninitialized sched so that ctx creation dosn't return error ?
commit
1decbf6bb0b4dc56c9da6c5e57b994ebfc2be3aa
Author: Bas Nieuwenhuizen <[email protected]> Date: Wed Jan 30 02:53:19 2019 +0100drm/sched: Fix entities with 0 rqs.
Some blocks in amdgpu can have 0 rqs.
Job creation already fails with
-ENOENTwhenentity->rqis NULL, so jobs cannot be pushed. Without a rq there is no scheduler to pop jobs, and rq selection already does the right thing with a list of length 0.
Quoted 18 lines
So the operations we need to fix are:
- Creation, do not set rq to rq_list[0] if the list can have length 0.
- Do not flush any jobs when there is no rq.
- On entity destruction handle the rq = NULL case.
- onset_priority, do not try to change the rq if it is NULL.Quoted 12 lines
Regards,
Christian.Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0entity->rq = &entity->sched_list[0]->sched_rq[entity->priority]; @@ -312,7 +305,6 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity)
dma_fence_put(entity->last_scheduled);
entity->last_scheduled= NULL;
-kfree(entity->sched_list);
}
EXPORT_SYMBOL(drm_sched_entity_fini);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
Am 10.12.19 um 16:08 schrieb Nirmoy:
Quoted 3 lines
I think
amdgpu_ctx_init()should check fornum_schedsand not calldrm_sched_entity_init()if its zero.
Ah, that's where that came from. No that is intentionally this way, but see below.
Quoted 28 lines · Nirmoy
Quoted 26 lines · Christian König
Quoted 24 lines
Am 10.12.19 um 13:53 schrieb Nirmoy Das:
Quoted 13 lines
entity should not keep copy and maintain sched list for itself.
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/scheduler/sched_entity.c| 10 +---------1 file changed, 1 insertion(+), 9 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +0
-0drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct · line 72
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -67,17 +67,10 @@ int drm_sched_entity_init(structdrm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; - entity->sched_list = kcalloc(num_sched_list, - sizeof(struct drm_gpu_scheduler *), GFP_KERNEL); + entity->sched_list = sched_list;Maybe make this "
num_sched_list> 1 ?sched_list: NULL" to avoid accidentally dereferencing a stale pointer to the stack.
Quoted 1 line
Quoted 1 line
Do you mean "
num_sched_list>= 1 ?sched_list: NULL"
No, the entity->sched_list field should be NULL when num_sched_list==1.
When num_sched_list==1 the entity->sched_list shouldn't be used and we can use a dummy list on the stack as parameter. But we should set the pointer to NULL in this case just to make sure that nobody is dereferencing it.
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 74
Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-5- if(!entity->sched_list) - return -ENOMEM; init_completion(&entity->entity_idle); - - for (i = 0; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; - if (num_sched_list)That check can actually be dropped as well. We return
-EINVALwhen thenum_sched_listis zero.
Quoted 7 lines
Quoted 7 lines
This one took me some time to understand. So we don't really return
-EINVALifnum_sched_list== 0if (!(entity &&
sched_list&& (num_sched_list== 0 || sched_list[0]))) return-EINVAL;This is coming from below patch. Are we suppose to tolerate IPs with uninitialized sched so that ctx creation dosn't return error ?
Yes, exactly. That's intentionally this way.
GPU reset sometimes resulted in schedulers being disabled because we couldn't re-init them. In this case we had entities with an empty scheduler list.
That can't happen any more after you make the scheduler arrays constant, but I would stick with that behavior.
Regards,
Christian.
Quoted 24 lines
Quoted 24 lines
commit
1decbf6bb0b4dc56c9da6c5e57b994ebfc2be3aa
Author: Bas Nieuwenhuizen <[email protected]> Date: Wed Jan 30 02:53:19 2019 +0100drm/sched: Fix entities with 0 rqs.
Some blocks in amdgpu can have 0 rqs.
Job creation already fails with
-ENOENTwhenentity->rqis NULL, so jobs cannot be pushed. Without a rq there is no scheduler to pop jobs, and rq selection already does the right thing with a list of length 0.So the operations we need to fix are:
- Creation, do not set rq to rq_list[0] if the list can have length 0.
- Do not flush any jobs when there is no rq.
- On entity destruction handle the rq = NULL case.
- onset_priority, do not try to change the rq if it is NULL.Quoted 4 lines
Regards,
Christian.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0entity->rq = &entity->sched_list[0]->sched_rq[entity->priority];@@ -312,7 +305,6 @@ void
drm_sched_entity_fini(struct drm_sched_entity *entity)dma_fence_put(entity->last_scheduled);entity->last_scheduled= NULL;
-kfree(entity->sched_list);
}
EXPORT_SYMBOL(drm_sched_entity_fini);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
Quoted 7 lines · Christian König
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Maybe make this "
num_sched_list> 1 ?sched_list: NULL" to avoid accidentally dereferencing a stale pointer to the stack.Do you mean "
num_sched_list>= 1 ?sched_list: NULL"No, the
entity->sched_listfield should be NULL when num_sched_list==1.When num_sched_list==1 the
entity->sched_listshouldn't be used and we can use a dummy list on the stack as parameter. But we should set the pointer to NULL in this case just to make sure that nobody is dereferencing it.
Okay I understand now.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 12 lines
Quoted 10 lines
-
if(!entity->sched_list)
- return-ENOMEM;
init_completion(&entity->entity_idle);drivers/gpu/drm/scheduler/sched_entity.c +0
-4- - for (i = 0; i < num_sched_list; i++) - entity->sched_list[i] = sched_list[i]; -if (
num_sched_list)That check can actually be dropped as well. We return
-EINVALwhen thenum_sched_listis zero.This one took me some time to understand. So we don't really return
-EINVALifnum_sched_list== 0if (!(entity &&
sched_list&& (num_sched_list== 0 || sched_list[0]))) return-EINVAL;
Quoted 7 lines
Quoted 1 line
Quoted 1 line
This is coming from below patch. Are we suppose to tolerate IPs with uninitialized sched so that ctx creation dosn't return error ?
Yes, exactly. That's intentionally this way.
GPU reset sometimes resulted in schedulers being disabled because we couldn't re-init them. In this case we had entities with an empty scheduler list.
That can't happen any more after you make the scheduler arrays constant, but I would stick with that behavior.
So I will keep the check.
Quoted 5 lines
Regards,
Christian.
Regards,
Nirmoy
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx