drm/sched dependency tracking and dma-resv fixes
Subsystems (15)
v4 cover drm/sched dependency tracking and dma-resv fixes
Hi all,
Quick new version since the previous one was a bit too broken:
- dropped the bug-on patch to avoid breaking amdgpu's gpu reset failure games
- another attempt at splitting job_init/arm, hopefully we're getting there.
Note that Christian has brought up a bikeshed on the new functions to add dependencies to drm_sched_jobs. I'm happy to repaint, if there's some kind of consensus on what it should be.
Testing and review very much welcome, as usual.
Cheers, Daniel
Daniel Vetter (18):
drm/sched: Split drm_sched_job_init
drm/sched: Barriers are needed for entity->last_scheduled drm/sched: Add dependency tracking
drm/sched: drop entity parameter from drm_sched_push_job drm/sched: improve docs around drm_sched_entity drm/panfrost: use scheduler dependency tracking
drm/lima: use scheduler dependency tracking
drm/v3d: Move drm_sched_job_init to v3d_job_init
drm/v3d: Use scheduler dependency handling
drm/etnaviv: Use scheduler dependency handling
drm/gem: Delete gem array fencing helpers
drm/sched: Don't store self-dependencies
drm/sched: Check locking in drm_sched_job_await_implicit drm/msm: Don't break exclusive fence ordering
drm/etnaviv: Don't break exclusive fence ordering drm/i915: delete exclude argument from i915_sw_fence_await_reservation drm/i915: Don't break exclusive fence ordering
dma-resv: Give the docs a do-over
Documentation/gpu/drm-mm.rst | 3 + drivers/dma-buf/dma-resv.c | 24 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 4 +- drivers/gpu/drm/drm_gem.c | 96 --------- drivers/gpu/drm/etnaviv/etnaviv_gem.h | 5 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 64 +++--- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 65 +----- drivers/gpu/drm/etnaviv/etnaviv_sched.h | 3 +- drivers/gpu/drm/i915/display/intel_display.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_clflush.c | 2 +- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 8 +- drivers/gpu/drm/i915/i915_sw_fence.c | 6 +- drivers/gpu/drm/i915/i915_sw_fence.h | 1 - drivers/gpu/drm/lima/lima_gem.c | 7 +- drivers/gpu/drm/lima/lima_sched.c | 28 +-- drivers/gpu/drm/lima/lima_sched.h | 6 +- drivers/gpu/drm/msm/msm_gem_submit.c | 3 +- drivers/gpu/drm/panfrost/panfrost_drv.c | 16 +- drivers/gpu/drm/panfrost/panfrost_job.c | 39 +--- drivers/gpu/drm/panfrost/panfrost_job.h | 5 +- drivers/gpu/drm/scheduler/sched_entity.c | 140 +++++++------ drivers/gpu/drm/scheduler/sched_fence.c | 19 +- drivers/gpu/drm/scheduler/sched_main.c | 181 +++++++++++++++-- drivers/gpu/drm/v3d/v3d_drv.h | 6 +- drivers/gpu/drm/v3d/v3d_gem.c | 115 +++++------ drivers/gpu/drm/v3d/v3d_sched.c | 44 +---- include/drm/drm_gem.h | 5 - include/drm/gpu_scheduler.h | 186 ++++++++++++++---- include/linux/dma-buf.h | 7 + include/linux/dma-resv.h | 104 +++++++++- 31 files changed, 672 insertions(+), 528 deletions(-)
Signature · 1 line
2.32.0
PATCH v4 1/18 drm/sched: Split drm_sched_job_init
This is a very confusingly named function, because not just does it init an object, it arms it and provides a point of no return for pushing a job into the scheduler. It would be nice if that's a bit clearer in the interface.
But the real reason is that I want to push the dependency tracking helpers into the scheduler code, and that means drm_sched_job_init must be called a lot earlier, without arming the job.
v2:
- don't change .gitignore (Steven)
- don't forget v3d (Emma)
v3: Emma noticed that I leak the memory allocated in drm_sched_job_init if we bail out before the point of no return in subsequent driver patches. To be able to fix this change drm_sched_job_cleanup() so it can handle being called both before and after drm_sched_job_arm().
Also improve the kerneldoc for this.
v4:
- Fix the drm_sched_job_cleanup logic, I inverted the booleans, as usual (Melissa)
- Christian pointed out that drm_sched_entity_select_rq() also needs to be moved into drm_sched_job_arm, which made me realize that the job->id definitely needs to be moved too.
Shuffle things to fit between job_init and job_arm.
v5:
Reshuffle the split between init/arm once more, amdgpu abuses drm_sched.ready to signal gpu reset failures. Also document this somewhat. (Christian)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 + drivers/gpu/drm/etnaviv/etnaviv_sched.c | 2 + drivers/gpu/drm/lima/lima_sched.c | 2 + drivers/gpu/drm/panfrost/panfrost_job.c | 2 + drivers/gpu/drm/scheduler/sched_entity.c | 6 +-- drivers/gpu/drm/scheduler/sched_fence.c | 19 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 69 ++++++++++++++++++++---- drivers/gpu/drm/v3d/v3d_gem.c | 2 + include/drm/gpu_scheduler.h | 7 ++- 10 files changed, 91 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -1226,6 +1226,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,if (r) goto error_unlock; +drm_sched_job_arm (&job->base); +/* No memory allocation is allowed while holding the notifier lock. * The lock is held until amdgpu_cs_submit is finished and fence is * added to BOs.
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
@@ -170,6 +170,8 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,if (r)return r; +drm_sched_job_arm (&job->base); + *f =dma_fence_get (&job->base.s_fence->finished);amdgpu_job_free_resources (job);drm_sched_entity_push_job (&job->base, entity);
drivers/gpu/drm/etnaviv/etnaviv_sched.c +2 -0
@@ -163,6 +163,8 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity,if (ret) goto out_unlock; +drm_sched_job_arm (&submit->sched_job); + submit->out_fence =dma_fence_get (&submit->sched_job.s_fence->finished); submit->out_fence_id = idr_alloc_cyclic(&submit->gpu->fence_idr, submit->out_fence, 0,
drivers/gpu/drm/lima/lima_sched.c +2 -0
@@ -129,6 +129,8 @@ int lima_sched_task_init(struct lima_sched_task *task,return err; } +drm_sched_job_arm (&task->base); + task->num_bos = num_bos; task->vm =lima_vm_get (vm);
drivers/gpu/drm/panfrost/panfrost_job.c +2 -0
@@ -288,6 +288,8 @@ int panfrost_job_push(struct panfrost_job *job) goto unlock; } +drm_sched_job_arm (&job->base); + job->render_done_fence =dma_fence_get (&job->base.s_fence->finished); ret = panfrost_acquire_object_fences(job->bos, job->bo_count,
drivers/gpu/drm/scheduler/sched_entity.c +3 -3
@@ -485,9 +485,9 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)* @sched_job: job to submit * @entity: scheduler entity * -* Note: To guarantee that the order of insertion to queue matches -* the job's fence sequence number this function should be -* called with drm_sched_job_init under common lock. +* Note: To guarantee that the order of insertion to queue matches the job's +* fence sequence number this function should be called with drm_sched_job_arm() +* under common lock. * * Returns 0 for success, negative error code otherwise. */
drivers/gpu/drm/scheduler/sched_fence.c +12 -7
@@ -90,7 +90,7 @@ static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f)* * Free up the fence memory after the RCU grace period. */ -static void drm_sched_fence_free (struct rcu_head *rcu) +void drm_sched_fence_free (struct rcu_head *rcu) { struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);struct drm_sched_fence *fence =to_drm_sched_fence (f);
@@ -152,27 +152,32 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f) }EXPORT_SYMBOL (to_drm_sched_fence); -struct drm_sched_fence *drm_sched_fence_create (struct drm_sched_entity *entity, -void *owner) +struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *entity, +void *owner) {struct drm_sched_fence *fence =NULL ; -unsigned seq; fence =kmem_cache_zalloc (sched_fence_slab,GFP_KERNEL );if (fence ==NULL )return NULL ; fence->owner = owner; - fence->sched = entity->rq->sched;spin_lock_init (&fence->lock); +return fence; +} + +void drm_sched_fence_init (struct drm_sched_fence *fence, +struct drm_sched_entity *entity) +{ +unsigned seq; + + fence->sched = entity->rq->sched; seq =atomic_inc_return (&entity->fence_seq);dma_fence_init (&fence->scheduled, &drm_sched_fence_ops_scheduled, &fence->lock, entity->fence_context, seq);dma_fence_init (&fence->finished, &drm_sched_fence_ops_finished, &fence->lock, entity->fence_context +1 , seq); - -return fence; }module_init (drm_sched_fence_slab_init);
drivers/gpu/drm/scheduler/sched_main.c +58 -11
114 lines not on this page · raw message
drivers/gpu/drm/v3d/v3d_gem.c +2 -0
@@ -475,6 +475,8 @@ v3d_push_job(struct v3d_file_priv *v3d_priv,if (ret)return ret; +drm_sched_job_arm (&job->base); + job->done_fence =dma_fence_get (&job->base.s_fence->finished);/* put by scheduler job completion */
include/drm/gpu_scheduler.h +6 -1
@@ -348,6 +348,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched);int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner); +void drm_sched_job_arm (struct drm_sched_job *job);void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list);
@@ -387,8 +388,12 @@ void drm_sched_entity_set_priority(struct drm_sched_entity *entity, enum drm_sched_priority priority);bool drm_sched_entity_is_ready (struct drm_sched_entity *entity); -struct drm_sched_fence *drm_sched_fence_create ( +struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *s_entity,void *owner); +void drm_sched_fence_init (struct drm_sched_fence *fence, +struct drm_sched_entity *entity); +void drm_sched_fence_free (struct rcu_head *rcu); +void drm_sched_fence_scheduled (struct drm_sched_fence *fence);void drm_sched_fence_finished (struct drm_sched_fence *fence);
Signature · 1 line
2.32.0
Re: [PATCH v4 01/18] drm/sched: Split drm_sched_job_init
Quoted 30 lines · Daniel Vetter
This is a very confusingly named function, because not just does it init an object, it arms it and provides a point of no return for pushing a job into the scheduler. It would be nice if that's a bit clearer in the interface.
But the real reason is that I want to push the dependency tracking helpers into the scheduler code, and that means
drm_sched_job_initmust be called a lot earlier, without arming the job.v2:
- don't change .gitignore (Steven)
- don't forget v3d (Emma)v3: Emma noticed that I leak the memory allocated in
drm_sched_job_initif we bail out before the point of no return in subsequent driver patches. To be able to fix this changedrm_sched_job_cleanup()so it can handle being called both before and afterdrm_sched_job_arm().Also improve the kerneldoc for this.
v4:
- Fix thedrm_sched_job_cleanuplogic, I inverted the booleans, as usual (Melissa)- Christian pointed out that
drm_sched_entity_select_rq()also needs to be moved intodrm_sched_job_arm, which made me realize that thejob->iddefinitely needs to be moved too.
Quoted 6 lines
Shuffle things to fit between
job_initandjob_arm.v5:
Reshuffle the split between init/arm once more, amdgpu abuses drm_sched.ready to signal gpu reset failures. Also document this somewhat. (Christian)
Ack from me for the changes I was Cced on.
Christian König
maintainerRe: [PATCH v4 01/18] drm/sched: Split drm_sched_job_init
In reply to Daniel VetterAm 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 21 lines
This is a very confusingly named function, because not just does it init an object, it arms it and provides a point of no return for pushing a job into the scheduler. It would be nice if that's a bit clearer in the interface.
But the real reason is that I want to push the dependency tracking helpers into the scheduler code, and that means
drm_sched_job_initmust be called a lot earlier, without arming the job.v2:
- don't change .gitignore (Steven)
- don't forget v3d (Emma)v3: Emma noticed that I leak the memory allocated in
drm_sched_job_initif we bail out before the point of no return in subsequent driver patches. To be able to fix this changedrm_sched_job_cleanup()so it can handle being called both before and afterdrm_sched_job_arm().Also improve the kerneldoc for this.
Quoted 7 lines
v4:
- Fix thedrm_sched_job_cleanuplogic, I inverted the booleans, as usual (Melissa)- Christian pointed out that
drm_sched_entity_select_rq()also needs to be moved intodrm_sched_job_arm, which made me realize that thejob->iddefinitely needs to be moved too.
As far as I can see you still have drm_sched_entity_select_rq() in drm_sched_job_init()?
Christian.
Quoted 359 lines
Shuffle things to fit between
job_initandjob_arm.v5:
Reshuffle the split between init/arm once more, amdgpu abuses drm_sched.ready to signal gpu reset failures. Also document this somewhat. (Christian)Cc Melissa Wen <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Lucas Stach <[email protected]>Cc Russell King <[email protected]>Cc Christian Gmeiner <[email protected]>Cc Qiang Yu <[email protected]>Cc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Sumit Semwal <[email protected]>Cc "Christian König" <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Kees Cook <[email protected]>Cc Adam Borowski <[email protected]>Cc Nick Terrell <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Paul Menzel <[email protected]>Cc Sami Tolvanen <[email protected]>Cc Viresh Kumar <[email protected]>Cc Alex Deucher <[email protected]>Cc Dave Airlie <[email protected]>Cc Nirmoy Das <[email protected]>Cc Deepak R Varma <[email protected]>Cc Lee Jones <[email protected]>Cc Kevin Wang <[email protected]>Cc Chen Li <[email protected]>Cc Luben Tuikov <[email protected]>Cc "Marek Olšák" <[email protected]>Cc Dennis Li <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Sonny Jiang <[email protected]>Cc Boris Brezillon <[email protected]>Cc Tian Tao <[email protected]>Cc Emma Anholt <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 + drivers/gpu/drm/etnaviv/etnaviv_sched.c | 2 + drivers/gpu/drm/lima/lima_sched.c | 2 + drivers/gpu/drm/panfrost/panfrost_job.c | 2 + drivers/gpu/drm/scheduler/sched_entity.c | 6 +-- drivers/gpu/drm/scheduler/sched_fence.c | 19 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 69 ++++++++++++++++++++---- drivers/gpu/drm/v3d/v3d_gem.c | 2 + include/drm/gpu_scheduler.h | 7 ++- 10 files changed, 91 insertions(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-0@@ -1226,6 +1226,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,if (r) goto error_unlock; +drm_sched_job_arm (&job->base); +/* No memory allocation is allowed while holding the notifier lock. * The lock is held until amdgpu_cs_submit is finished and fence is * added to BOs. drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-0@@ -170,6 +170,8 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,if (r)return r; +drm_sched_job_arm (&job->base); + *f =dma_fence_get (&job->base.s_fence->finished);amdgpu_job_free_resources (job);drm_sched_entity_push_job (&job->base, entity);drivers/gpu/drm/etnaviv/etnaviv_sched.c +2
-0@@ -163,6 +163,8 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity,if (ret) goto out_unlock; +drm_sched_job_arm (&submit->sched_job); + submit->out_fence =dma_fence_get (&submit->sched_job.s_fence->finished); submit->out_fence_id = idr_alloc_cyclic(&submit->gpu->fence_idr, submit->out_fence, 0,drivers/gpu/drm/lima/lima_sched.c +2
-0@@ -129,6 +129,8 @@ int lima_sched_task_init(struct lima_sched_task *task,return err; } +drm_sched_job_arm (&task->base); + task->num_bos = num_bos; task->vm =lima_vm_get (vm);drivers/gpu/drm/panfrost/panfrost_job.c +2
-0@@ -288,6 +288,8 @@ int panfrost_job_push(struct panfrost_job *job) goto unlock; } +drm_sched_job_arm (&job->base); + job->render_done_fence =dma_fence_get (&job->base.s_fence->finished); ret = panfrost_acquire_object_fences(job->bos, job->bo_count,drivers/gpu/drm/scheduler/sched_entity.c +3
-3@@ -485,9 +485,9 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)* @sched_job: job to submit * @entity: scheduler entity * -* Note: To guarantee that the order of insertion to queue matches -* the job's fence sequence number this function should be -* called with drm_sched_job_init under common lock. +* Note: To guarantee that the order of insertion to queue matches the job's +* fence sequence number this function should be called with drm_sched_job_arm() +* under common lock. * * Returns 0 for success, negative error code otherwise. */ drivers/gpu/drm/scheduler/sched_fence.c +12
-7@@ -90,7 +90,7 @@ static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f)* * Free up the fence memory after the RCU grace period. */ -static void drm_sched_fence_free (struct rcu_head *rcu) +void drm_sched_fence_free (struct rcu_head *rcu) { struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);struct drm_sched_fence *fence =to_drm_sched_fence (f);@@ -152,27 +152,32 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f) }EXPORT_SYMBOL (to_drm_sched_fence); -struct drm_sched_fence *drm_sched_fence_create (struct drm_sched_entity *entity, -void *owner) +struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *entity, +void *owner) {struct drm_sched_fence *fence =NULL ; -unsigned seq; fence =kmem_cache_zalloc (sched_fence_slab,GFP_KERNEL );if (fence ==NULL )return NULL ; fence->owner = owner; - fence->sched = entity->rq->sched;spin_lock_init (&fence->lock); +return fence; +} + +void drm_sched_fence_init (struct drm_sched_fence *fence, +struct drm_sched_entity *entity) +{ +unsigned seq; + + fence->sched = entity->rq->sched; seq =atomic_inc_return (&entity->fence_seq);dma_fence_init (&fence->scheduled, &drm_sched_fence_ops_scheduled, &fence->lock, entity->fence_context, seq);dma_fence_init (&fence->finished, &drm_sched_fence_ops_finished, &fence->lock, entity->fence_context +1 , seq); - -return fence; }module_init (drm_sched_fence_slab_init);drivers/gpu/drm/scheduler/sched_main.c +58
-11@@ -48,9 +48,11 @@#include <linux/wait.h> #include <linux/sched.h> #include <linux/completion.h> +#include <linux/dma-resv.h> #include <uapi/linux/sched/types.h> #include <drm/drm_print.h> +#include <drm/drm_gem.h> #include <drm/gpu_scheduler.h> #include <drm/spsc_queue.h> @@ -569,7 +571,6 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs_ext);/** * drm_sched_job_init - init a scheduler job -* * @job: scheduler job to init * @entity: scheduler entity to use * @owner: job owner for debugging @@ -577,27 +578,28 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs_ext);* Refer to drm_sched_entity_push_job() documentation * for locking considerations. * +* Drivers must make sure drm_sched_job_cleanup() if this function returns +* successfully, even when @job is aborted before drm_sched_job_arm() is called. +* +* WARNING: amdgpu abuses &drm_sched.ready to signal when the hardware +* has died, which can mean that there's no valid runqueue for a @entity. +* This function returns -ENOENT in this case (which probably should be -EIO as +* a more meanigful return value). +* * Returns 0 for success, negative error code otherwise. */ int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner) { -struct drm_gpu_scheduler *sched; -drm_sched_entity_select_rq (entity);if (!entity->rq)return -ENOENT ; - sched = entity->rq->sched; - - job->sched = sched; job->entity = entity; - job->s_priority = entity->rq - sched->sched_rq; - job->s_fence =drm_sched_fence_create (entity, owner); + job->s_fence =drm_sched_fence_alloc (entity, owner);if (!job->s_fence)return -ENOMEM ; - job->id =atomic64_inc_return (&sched->job_id_count);INIT_LIST_HEAD (&job->list);@@ -606,13 +608,58 @@ int drm_sched_job_init(struct drm_sched_job *job,EXPORT_SYMBOL (drm_sched_job_init);/** -* drm_sched_job_cleanup - clean up scheduler job resources +* drm_sched_job_arm - arm a scheduler job for execution +* @job: scheduler job to arm +* +* This arms a scheduler job for execution. Specifically it initializes the +* &drm_sched_job.s_fence of @job, so that it can be attached to struct dma_resv +* or other places that need to track the completion of this job. +* +* Refer to drm_sched_entity_push_job() documentation for locking +* considerations. * +* This can only be called if drm_sched_job_init() succeeded. +*/ +void drm_sched_job_arm (struct drm_sched_job *job) +{ +struct drm_gpu_scheduler *sched; +struct drm_sched_entity *entity = job->entity; + +BUG_ON (!entity); + + sched = entity->rq->sched; + + job->sched = sched; + job->s_priority = entity->rq - sched->sched_rq; + job->id =atomic64_inc_return (&sched->job_id_count); + +drm_sched_fence_init (job->s_fence, job->entity); +} +EXPORT_SYMBOL (drm_sched_job_arm); + +/** +* drm_sched_job_cleanup - clean up scheduler job resources * @job: scheduler job to clean up +* +* Cleans up the resources allocated with drm_sched_job_init(). +* +* Drivers should call this from their error unwind code if @job is aborted +* before drm_sched_job_arm() is called. +* +* After that point of no return @job is committed to be executed by the +* scheduler, and this function should be called from the +* &drm_sched_backend_ops.free_job callback. */ void drm_sched_job_cleanup (struct drm_sched_job *job) { -dma_fence_put (&job->s_fence->finished); +if (kref_read (&job->s_fence->finished.refcount)) { +/* drm_sched_job_arm() has been called */ +dma_fence_put (&job->s_fence->finished); + }else { +/* aborted job before committing to run it */ +drm_sched_fence_free (&job->s_fence->finished.rcu); + } + job->s_fence =NULL ; }EXPORT_SYMBOL (drm_sched_job_cleanup);drivers/gpu/drm/v3d/v3d_gem.c +2
-0@@ -475,6 +475,8 @@ v3d_push_job(struct v3d_file_priv *v3d_priv,if (ret)return ret; +drm_sched_job_arm (&job->base); + job->done_fence =dma_fence_get (&job->base.s_fence->finished);/* put by scheduler job completion */ include/drm/gpu_scheduler.h +6
-1@@ -348,6 +348,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched);int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner); +void drm_sched_job_arm (struct drm_sched_job *job);void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list);@@ -387,8 +388,12 @@ void drm_sched_entity_set_priority(struct drm_sched_entity *entity, enum drm_sched_priority priority);bool drm_sched_entity_is_ready (struct drm_sched_entity *entity); -struct drm_sched_fence *drm_sched_fence_create ( +struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *s_entity,void *owner); +void drm_sched_fence_init (struct drm_sched_fence *fence, +struct drm_sched_entity *entity); +void drm_sched_fence_free (struct rcu_head *rcu); +void drm_sched_fence_scheduled (struct drm_sched_fence *fence);void drm_sched_fence_finished (struct drm_sched_fence *fence);
Re: [PATCH v4 01/18] drm/sched: Split drm_sched_job_init
Quoted 27 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 25 lines
This is a very confusingly named function, because not just does it init an object, it arms it and provides a point of no return for pushing a job into the scheduler. It would be nice if that's a bit clearer in the interface.
But the real reason is that I want to push the dependency tracking helpers into the scheduler code, and that means
drm_sched_job_initmust be called a lot earlier, without arming the job.v2:
- don't change .gitignore (Steven)
- don't forget v3d (Emma)v3: Emma noticed that I leak the memory allocated in
drm_sched_job_initif we bail out before the point of no return in subsequent driver patches. To be able to fix this changedrm_sched_job_cleanup()so it can handle being called both before and afterdrm_sched_job_arm().Also improve the kerneldoc for this.
v4:
- Fix thedrm_sched_job_cleanuplogic, I inverted the booleans, as usual (Melissa)
Quoted 6 lines
Quoted 3 lines
- Christian pointed out that
drm_sched_entity_select_rq()also needs to be moved intodrm_sched_job_arm, which made me realize that thejob->iddefinitely needs to be moved too.As far as I can see you still have
drm_sched_entity_select_rq()indrm_sched_job_init()?
Yeah it's again in there, but everything else which changes entity->rq state isn't in there anymore, but in job_arm(). I also checked the cleanup code, and we only update entity state in there, not job state, so there's no additional complications for cleanup.
Of course this is quite a bit earlier, than if we do it in job_arm(), but also not fundamentally a new race window. Just a bigger one, so assuming the current code is correct, should be all fine. But also, very possible I missed something else again :-)
-Daniel
Quoted 362 lines
Christian.
Quoted 359 lines
Shuffle things to fit between
job_initandjob_arm.v5:
Reshuffle the split between init/arm once more, amdgpu abuses drm_sched.ready to signal gpu reset failures. Also document this somewhat. (Christian)Cc Melissa Wen <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Lucas Stach <[email protected]>Cc Russell King <[email protected]>Cc Christian Gmeiner <[email protected]>Cc Qiang Yu <[email protected]>Cc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Sumit Semwal <[email protected]>Cc "Christian König" <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Kees Cook <[email protected]>Cc Adam Borowski <[email protected]>Cc Nick Terrell <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Paul Menzel <[email protected]>Cc Sami Tolvanen <[email protected]>Cc Viresh Kumar <[email protected]>Cc Alex Deucher <[email protected]>Cc Dave Airlie <[email protected]>Cc Nirmoy Das <[email protected]>Cc Deepak R Varma <[email protected]>Cc Lee Jones <[email protected]>Cc Kevin Wang <[email protected]>Cc Chen Li <[email protected]>Cc Luben Tuikov <[email protected]>Cc "Marek Olšák" <[email protected]>Cc Dennis Li <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Sonny Jiang <[email protected]>Cc Boris Brezillon <[email protected]>Cc Tian Tao <[email protected]>Cc Emma Anholt <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 + drivers/gpu/drm/etnaviv/etnaviv_sched.c | 2 + drivers/gpu/drm/lima/lima_sched.c | 2 + drivers/gpu/drm/panfrost/panfrost_job.c | 2 + drivers/gpu/drm/scheduler/sched_entity.c | 6 +-- drivers/gpu/drm/scheduler/sched_fence.c | 19 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 69 ++++++++++++++++++++---- drivers/gpu/drm/v3d/v3d_gem.c | 2 + include/drm/gpu_scheduler.h | 7 ++- 10 files changed, 91 insertions(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-0@@ -1226,6 +1226,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,if (r) goto error_unlock; +drm_sched_job_arm (&job->base); +/* No memory allocation is allowed while holding the notifier lock. * The lock is held until amdgpu_cs_submit is finished and fence is * added to BOs. drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-0@@ -170,6 +170,8 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,if (r)return r; +drm_sched_job_arm (&job->base); + *f =dma_fence_get (&job->base.s_fence->finished);amdgpu_job_free_resources (job);drm_sched_entity_push_job (&job->base, entity);drivers/gpu/drm/etnaviv/etnaviv_sched.c +2
-0@@ -163,6 +163,8 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity,if (ret) goto out_unlock; +drm_sched_job_arm (&submit->sched_job); + submit->out_fence =dma_fence_get (&submit->sched_job.s_fence->finished); submit->out_fence_id = idr_alloc_cyclic(&submit->gpu->fence_idr, submit->out_fence, 0,drivers/gpu/drm/lima/lima_sched.c +2
-0@@ -129,6 +129,8 @@ int lima_sched_task_init(struct lima_sched_task *task,return err; } +drm_sched_job_arm (&task->base); + task->num_bos = num_bos; task->vm =lima_vm_get (vm);drivers/gpu/drm/panfrost/panfrost_job.c +2
-0@@ -288,6 +288,8 @@ int panfrost_job_push(struct panfrost_job *job) goto unlock; } +drm_sched_job_arm (&job->base); + job->render_done_fence =dma_fence_get (&job->base.s_fence->finished); ret = panfrost_acquire_object_fences(job->bos, job->bo_count,drivers/gpu/drm/scheduler/sched_entity.c +3
-3@@ -485,9 +485,9 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)* @sched_job: job to submit * @entity: scheduler entity * -* Note: To guarantee that the order of insertion to queue matches -* the job's fence sequence number this function should be -* called with drm_sched_job_init under common lock. +* Note: To guarantee that the order of insertion to queue matches the job's +* fence sequence number this function should be called with drm_sched_job_arm() +* under common lock. * * Returns 0 for success, negative error code otherwise. */ drivers/gpu/drm/scheduler/sched_fence.c +12
-7@@ -90,7 +90,7 @@ static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f)* * Free up the fence memory after the RCU grace period. */ -static void drm_sched_fence_free (struct rcu_head *rcu) +void drm_sched_fence_free (struct rcu_head *rcu) { struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);struct drm_sched_fence *fence =to_drm_sched_fence (f);@@ -152,27 +152,32 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f) }EXPORT_SYMBOL (to_drm_sched_fence); -struct drm_sched_fence *drm_sched_fence_create (struct drm_sched_entity *entity, -void *owner) +struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *entity, +void *owner) {struct drm_sched_fence *fence =NULL ; -unsigned seq; fence =kmem_cache_zalloc (sched_fence_slab,GFP_KERNEL );if (fence ==NULL )return NULL ; fence->owner = owner; - fence->sched = entity->rq->sched;spin_lock_init (&fence->lock); +return fence; +} + +void drm_sched_fence_init (struct drm_sched_fence *fence, +struct drm_sched_entity *entity) +{ +unsigned seq; + + fence->sched = entity->rq->sched; seq =atomic_inc_return (&entity->fence_seq);dma_fence_init (&fence->scheduled, &drm_sched_fence_ops_scheduled, &fence->lock, entity->fence_context, seq);dma_fence_init (&fence->finished, &drm_sched_fence_ops_finished, &fence->lock, entity->fence_context +1 , seq); - -return fence; }module_init (drm_sched_fence_slab_init);drivers/gpu/drm/scheduler/sched_main.c +58
-11@@ -48,9 +48,11 @@#include <linux/wait.h> #include <linux/sched.h> #include <linux/completion.h> +#include <linux/dma-resv.h> #include <uapi/linux/sched/types.h> #include <drm/drm_print.h> +#include <drm/drm_gem.h> #include <drm/gpu_scheduler.h> #include <drm/spsc_queue.h> @@ -569,7 +571,6 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs_ext);/** * drm_sched_job_init - init a scheduler job -* * @job: scheduler job to init * @entity: scheduler entity to use * @owner: job owner for debugging @@ -577,27 +578,28 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs_ext);* Refer to drm_sched_entity_push_job() documentation * for locking considerations. * +* Drivers must make sure drm_sched_job_cleanup() if this function returns +* successfully, even when @job is aborted before drm_sched_job_arm() is called. +* +* WARNING: amdgpu abuses &drm_sched.ready to signal when the hardware +* has died, which can mean that there's no valid runqueue for a @entity. +* This function returns -ENOENT in this case (which probably should be -EIO as +* a more meanigful return value). +* * Returns 0 for success, negative error code otherwise. */ int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner) { -struct drm_gpu_scheduler *sched; -drm_sched_entity_select_rq (entity);if (!entity->rq)return -ENOENT ; - sched = entity->rq->sched; - - job->sched = sched; job->entity = entity; - job->s_priority = entity->rq - sched->sched_rq; - job->s_fence =drm_sched_fence_create (entity, owner); + job->s_fence =drm_sched_fence_alloc (entity, owner);if (!job->s_fence)return -ENOMEM ; - job->id =atomic64_inc_return (&sched->job_id_count);INIT_LIST_HEAD (&job->list);@@ -606,13 +608,58 @@ int drm_sched_job_init(struct drm_sched_job *job,EXPORT_SYMBOL (drm_sched_job_init);/** -* drm_sched_job_cleanup - clean up scheduler job resources +* drm_sched_job_arm - arm a scheduler job for execution +* @job: scheduler job to arm +* +* This arms a scheduler job for execution. Specifically it initializes the +* &drm_sched_job.s_fence of @job, so that it can be attached to struct dma_resv +* or other places that need to track the completion of this job. +* +* Refer to drm_sched_entity_push_job() documentation for locking +* considerations. * +* This can only be called if drm_sched_job_init() succeeded. +*/ +void drm_sched_job_arm (struct drm_sched_job *job) +{ +struct drm_gpu_scheduler *sched; +struct drm_sched_entity *entity = job->entity; + +BUG_ON (!entity); + + sched = entity->rq->sched; + + job->sched = sched; + job->s_priority = entity->rq - sched->sched_rq; + job->id =atomic64_inc_return (&sched->job_id_count); + +drm_sched_fence_init (job->s_fence, job->entity); +} +EXPORT_SYMBOL (drm_sched_job_arm); + +/** +* drm_sched_job_cleanup - clean up scheduler job resources * @job: scheduler job to clean up +* +* Cleans up the resources allocated with drm_sched_job_init(). +* +* Drivers should call this from their error unwind code if @job is aborted +* before drm_sched_job_arm() is called. +* +* After that point of no return @job is committed to be executed by the +* scheduler, and this function should be called from the +* &drm_sched_backend_ops.free_job callback. */ void drm_sched_job_cleanup (struct drm_sched_job *job) { -dma_fence_put (&job->s_fence->finished); +if (kref_read (&job->s_fence->finished.refcount)) { +/* drm_sched_job_arm() has been called */ +dma_fence_put (&job->s_fence->finished); + }else { +/* aborted job before committing to run it */ +drm_sched_fence_free (&job->s_fence->finished.rcu); + } + job->s_fence =NULL ; }EXPORT_SYMBOL (drm_sched_job_cleanup);drivers/gpu/drm/v3d/v3d_gem.c +2
-0@@ -475,6 +475,8 @@ v3d_push_job(struct v3d_file_priv *v3d_priv,if (ret)return ret; +drm_sched_job_arm (&job->base); + job->done_fence =dma_fence_get (&job->base.s_fence->finished);/* put by scheduler job completion */ include/drm/gpu_scheduler.h +6
-1@@ -348,6 +348,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched);int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner); +void drm_sched_job_arm (struct drm_sched_job *job);void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list);@@ -387,8 +388,12 @@ void drm_sched_entity_set_priority(struct drm_sched_entity *entity, enum drm_sched_priority priority);bool drm_sched_entity_is_ready (struct drm_sched_entity *entity); -struct drm_sched_fence *drm_sched_fence_create ( +struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *s_entity,void *owner); +void drm_sched_fence_init (struct drm_sched_fence *fence, +struct drm_sched_entity *entity); +void drm_sched_fence_free (struct rcu_head *rcu); +void drm_sched_fence_scheduled (struct drm_sched_fence *fence);void drm_sched_fence_finished (struct drm_sched_fence *fence);
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH v4 2/18 drm/sched: Barriers are needed for entity->last_scheduled
In reply to Daniel VetterIt might be good enough on x86 with just READ_ONCE, but the write side should then at least be WRITE_ONCE because x86 has total store order.
It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each comment
Also pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put smp_rmp() in the right place and fix up comment (Andrey)
--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +25 -2
@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished); +/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +spsc_queue_pop (&entity->job_queue);return sched_job; }
@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ; - fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other +* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;
Signature · 1 line
2.32.0
Christian König
maintainerRe: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 40 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +0
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled);
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +8
-0+ entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished); +/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +
Again, conceptual those barriers should be part of the spsc_queue container and not externally.
Regards,
Christian.
Quoted 31 lines
drivers/gpu/drm/scheduler/sched_entity.c +17
-2spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ; - fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other +* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;
Re: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Quoted 45 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.
That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
- wake_up (i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace spsc_queue with an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.
This is similar to how atomic_t is by default completely unordered, and users need to add barriers as needed, with comments. I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
I'm definitely not going to hide all that by making the spsc_queue stuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go. -Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;
Quoted 16 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Christian König
maintainerRe: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.
Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.
My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Regards,
Christian.
Quoted 34 lines
-Daniel
Quoted 31 lines
Regards,
Christian.Quoted 28 lines
drivers/gpu/drm/scheduler/sched_entity.c +17
-2spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ; - fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other +* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */
Quoted 8 lines
Quoted 3 lines
drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 3 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Cchristian.koenig%40amd.com%7Ce06013b14cfc49e3e10f08d945ca8f73%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617558577952913%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yKAIrzyRRh1AoGM%2BQXyrwd4psTvyO%2Bcn8961PbcJmpQ%3D&reserved=0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Quoted 108 lines · Christian König
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.
Quoted 7 lines
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
This is the standard barriers that also wake-up queues have, it's just store-release+load-acquire.
Quoted 2 lines
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
This is very much non-standard for a queue. I guess you could make that part of the spsc_queue api between pop and is_empty (really we shouldn't expose the _count() function for this), but that's all very clever.
I think having explicit barriers in the code, with comments, is much more robust. Because it forces you to think about all this, and document it properly. Because there's also lockless stuff like drm_sched.ready, which doesn't look at all like it's ordered somehow.
E.g. there's also an rmb(); in drm_sched_entity_is_idle(), which
- probably should be an smp_rmb()
- really should document what it actually synchronizes against, and the lack of an smp_wmb() somewhere else indicates it's probably busted. You always need two barriers.
Quoted 2 lines
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Imo that's what we need to do. And the most important part for maintainability is to properly document thing with comments, and the most important part in that comment is pointing at the other side of a barrier (since a barrier on one side only orders nothing).
Also, on x86 almost nothing here matters, because both rmb() and wmb() are no-op. Aside from the compiler barrier, which tends to not be the biggest issue. Only mb() does anything, because x86 is only allowed to reorder reads ahead of writes.
So in practice it's not quite as big a disaster, imo the big thing here is maintainability of all these tricks just not being documented. -Daniel
Quoted 46 lines
Regards,
Christian.Quoted 42 lines
-Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Cchristian.koenig%40amd.com%7Ce06013b14cfc49e3e10f08d945ca8f73%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617558577952913%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yKAIrzyRRh1AoGM%2BQXyrwd4psTvyO%2Bcn8961PbcJmpQ%3D&reserved=0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Christian König
maintainerRe: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Am 13.07.21 um 11:10 schrieb Daniel Vetter:
Quoted 116 lines
Quoted 104 lines · Christian König
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.Quoted 7 lines
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
This is the standard barriers that also wake-up queues have, it's just store-release+load-acquire.
Quoted 6 lines
Quoted 2 lines
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
This is very much non-standard for a queue. I guess you could make that part of the
spsc_queueapi between pop andis_empty(really we shouldn't expose the_count()function for this), but that's all very clever.
Yeah, even having count is superfluous. You can much easier do this by checking if the pointer is NULL or not.
Quoted 5 lines
I think having explicit barriers in the code, with comments, is much more robust. Because it forces you to think about all this, and document it properly. Because there's also lockless stuff like drm_sched.ready, which doesn't look at all like it's ordered somehow.
But then you have to fix drm_sched_entity_fini() as well which also relies on the same behavior.
Regards,
Christian.
Quoted 14 lines
E.g. there's also an
rmb(); indrm_sched_entity_is_idle(), which
- probably should be ansmp_rmb()
- really should document what it actually synchronizes against, and the lack of ansmp_wmb()somewhere else indicates it's probably busted. You always need two barriers.Quoted 2 lines
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Imo that's what we need to do. And the most important part for maintainability is to properly document thing with comments, and the most important part in that comment is pointing at the other side of a barrier (since a barrier on one side only orders nothing).
Quoted 54 lines
Also, on x86 almost nothing here matters, because both
rmb()andwmb()are no-op. Aside from the compiler barrier, which tends to not be the biggest issue. Onlymb()does anything, because x86 is only allowed to reorder reads ahead of writes.So in practice it's not quite as big a disaster, imo the big thing here is maintainability of all these tricks just not being documented. -Daniel
Quoted 44 lines
Regards,
Christian.Quoted 41 lines
-Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Cchristian.koenig%40amd.com%7Ca29a8f0b7dea46d9be7608d945de0570%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617642150542001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Rv%2FY8LKVKz09FuqC2neEM3Ps0NMJq1SeZ4Y08wkUKBI%3D&reserved=0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
In reply to Daniel VetterQuoted 123 lines · Daniel Vetter
Quoted 104 lines · Christian König
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.Quoted 7 lines
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
This is the standard barriers that also wake-up queues have, it's just store-release+load-acquire.
Quoted 2 lines
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
This is very much non-standard for a queue. I guess you could make that part of the
spsc_queueapi between pop andis_empty(really we shouldn't expose the_count()function for this), but that's all very clever.
Quoted 4 lines
I think having explicit barriers in the code, with comments, is much more robust. Because it forces you to think about all this, and document it properly. Because there's also lockless stuff like drm_sched.ready, which doesn't look at all like it's ordered somehow.
At least for amdgpu, after drm_sched_fini is called (setting sched.ready = false) we call amdgpu_fence_wait_empty to ensure all in progress jobs are done. Seems to me at least, this should guarantee that all in flight consumers of sched.ready (those who still see sched.ready == true) are finished while all later consumers will see sched.ready == fakle and will bail out.
On second thought there is a gap between checking for sched.ready and inserting the HW fence for the new job so this might still be a bug... Looks like we need to check for sched.ready after inserting the HW fence and for this we will need barrier or locking.
Andrey
Quoted 14 lines
E.g. there's also an
rmb(); indrm_sched_entity_is_idle(), which
- probably should be ansmp_rmb()
- really should document what it actually synchronizes against, and the lack of ansmp_wmb()somewhere else indicates it's probably busted. You always need two barriers.Quoted 2 lines
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Imo that's what we need to do. And the most important part for maintainability is to properly document thing with comments, and the most important part in that comment is pointing at the other side of a barrier (since a barrier on one side only orders nothing).
Quoted 54 lines
Also, on x86 almost nothing here matters, because both
rmb()andwmb()are no-op. Aside from the compiler barrier, which tends to not be the biggest issue. Onlymb()does anything, because x86 is only allowed to reorder reads ahead of writes.So in practice it's not quite as big a disaster, imo the big thing here is maintainability of all these tricks just not being documented. -Daniel
Quoted 44 lines
Regards,
Christian.Quoted 41 lines
-Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Candrey.grodzovsky%40amd.com%7C24488ad1956a4a54b0ab08d945de0552%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617642160395692%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u%2Fpm%2BsmTT%2Bdb8NvEah%2BJHj22l8sRfhgo1gvO%2FnYLvhg%3D&reserved=0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Quoted 137 lines · Andrey Grodzovsky
Quoted 123 lines · Daniel Vetter
Quoted 104 lines · Christian König
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.Quoted 7 lines
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
This is the standard barriers that also wake-up queues have, it's just store-release+load-acquire.
Quoted 2 lines
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
This is very much non-standard for a queue. I guess you could make that part of the
spsc_queueapi between pop andis_empty(really we shouldn't expose the_count()function for this), but that's all very clever.Quoted 4 lines
I think having explicit barriers in the code, with comments, is much more robust. Because it forces you to think about all this, and document it properly. Because there's also lockless stuff like drm_sched.ready, which doesn't look at all like it's ordered somehow.
At least for amdgpu, after
drm_sched_finiis called (setting sched.ready = false)
we callamdgpu_fence_wait_emptyto ensure all in progress jobs are done. Seems to me at least, this should guarantee that all in flight consumers of sched.ready (those who still see sched.ready == true) are finished while all later consumers will see sched.ready == fakle and will bail out.
Quoted 6 lines
On second thought there is a gap between checking for sched.ready and inserting
the HW fence for the new job so this might still be a bug... Looks like we need to check for
sched.ready after inserting the HW fence and for this we will need barrier or locking.
Yeah, and at that point I think it's good to split up drm_sched.ready from a new thing for when the hw died, like drm_sched.wedged or .hw_death or similar, so that we can tell them apart. Trying to submit a job to a non-ready scheduler is a driver bug and should WARN, while submitting a job to a dead scheduler should probably result in -EIO being returned to userspace (instead of the current -ENOENT, assuming I haven't missed a errno remapping code somewhere in amdgpu).
Also, then you could do a drm_sched_die() or similar function which combines setting the hw_died with the right barriers and cleaning up all the jobs.
Wrt the fundamental race: I think that's not fixeable easily, so maybe the scheduler thread also needs to handle this and immediately fail these jobs by setting all fences to -EIO and completing them, without even calling into the driver. If you try to catch this synchronously I think it would require some kind of locking in push_job, plus failure handling, which would be a) slow and b) real ugly in the driver code. Just accepting that some jobs can slip through and letting the scheduler thread clean them up is I think cleaner.
If userspace then goes ahead and closes the ctx before all the jobs are cleaned up we can handle that with the normal drm_sched_entity cleanup logic. Which would be another reason to split normal cleanup from hw death.
-Daniel
Quoted 70 lines
Andrey
Quoted 68 lines
E.g. there's also an
rmb(); indrm_sched_entity_is_idle(), which
- probably should be ansmp_rmb()
- really should document what it actually synchronizes against, and the lack of ansmp_wmb()somewhere else indicates it's probably busted. You always need two barriers.Quoted 2 lines
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Imo that's what we need to do. And the most important part for maintainability is to properly document thing with comments, and the most important part in that comment is pointing at the other side of a barrier (since a barrier on one side only orders nothing).
Also, on x86 almost nothing here matters, because both
rmb()andwmb()are no-op. Aside from the compiler barrier, which tends to not be the biggest issue. Onlymb()does anything, because x86 is only allowed to reorder reads ahead of writes.So in practice it's not quite as big a disaster, imo the big thing here is maintainability of all these tricks just not being documented. -Daniel
Quoted 44 lines
Regards,
Christian.Quoted 41 lines
-Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Candrey.grodzovsky%40amd.com%7C24488ad1956a4a54b0ab08d945de0552%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617642160395692%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u%2Fpm%2BsmTT%2Bdb8NvEah%2BJHj22l8sRfhgo1gvO%2FnYLvhg%3D&reserved=0
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Quoted 156 lines · Daniel Vetter
Quoted 136 lines · Andrey Grodzovsky
Quoted 123 lines · Daniel Vetter
Quoted 104 lines · Christian König
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.Quoted 7 lines
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
This is the standard barriers that also wake-up queues have, it's just store-release+load-acquire.
Quoted 2 lines
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
This is very much non-standard for a queue. I guess you could make that part of the
spsc_queueapi between pop andis_empty(really we shouldn't expose the_count()function for this), but that's all very clever.Quoted 4 lines
I think having explicit barriers in the code, with comments, is much more robust. Because it forces you to think about all this, and document it properly. Because there's also lockless stuff like drm_sched.ready, which doesn't look at all like it's ordered somehow.
At least for amdgpu, after
drm_sched_finiis called (setting sched.ready = false)
we callamdgpu_fence_wait_emptyto ensure all in progress jobs are done. Seems to me at least, this should guarantee that all in flight consumers of sched.ready (those who still see sched.ready == true) are finished while all later consumers will see sched.ready == fakle and will bail out.Quoted 6 lines
On second thought there is a gap between checking for sched.ready and inserting
the HW fence for the new job so this might still be a bug... Looks like we need to check for
sched.ready after inserting the HW fence and for this we will need barrier or locking.Yeah, and at that point I think it's good to split up drm_sched.ready from a new thing for when the hw died, like drm_sched.wedged or .hw_death or similar, so that we can tell them apart. Trying to submit a job to a non-ready scheduler is a driver bug and should WARN, while submitting a job to a dead scheduler should probably result in
-EIObeing returned to userspace (instead of the current-ENOENT, assuming I haven't missed a errno remapping code somewhere in amdgpu).Also, then you could do a
drm_sched_die()or similar function which combines setting thehw_diedwith the right barriers and cleaning up all the jobs.
Quoted 8 lines
Wrt the fundamental race: I think that's not fixeable easily, so maybe the scheduler thread also needs to handle this and immediately fail these jobs by setting all fences to
-EIOand completing them, without even calling into the driver. If you try to catch this synchronously I think it would require some kind of locking inpush_job, plus failure handling, which would be a) slow and b) real ugly in the driver code. Just accepting that some jobs can slip through and letting the scheduler thread clean them up is I think cleaner.
I agree about moving this check to scheduler thread, I also not quite understand why in some places which are clearly post the job being pick-up by it's scheduler thread such as amdgpu_ib_schedule, still check for sched.ready... What's the point ? Also there are direct submission cases where IB insertion into HW ring is done without any scheduler involvement and even more in that case why we care that scheduler is not ready.
Andrey
Quoted 77 lines
If userspace then goes ahead and closes the ctx before all the jobs are cleaned up we can handle that with the normal
drm_sched_entitycleanup logic. Which would be another reason to split normal cleanup from hw death.
-DanielQuoted 68 lines
Andrey
Quoted 66 lines
E.g. there's also an
rmb(); indrm_sched_entity_is_idle(), which
- probably should be ansmp_rmb()
- really should document what it actually synchronizes against, and the lack of ansmp_wmb()somewhere else indicates it's probably busted. You always need two barriers.Quoted 2 lines
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Imo that's what we need to do. And the most important part for maintainability is to properly document thing with comments, and the most important part in that comment is pointing at the other side of a barrier (since a barrier on one side only orders nothing).
Also, on x86 almost nothing here matters, because both
rmb()andwmb()are no-op. Aside from the compiler barrier, which tends to not be the biggest issue. Onlymb()does anything, because x86 is only allowed to reorder reads ahead of writes.So in practice it's not quite as big a disaster, imo the big thing here is maintainability of all these tricks just not being documented. -Daniel
Quoted 44 lines
Regards,
Christian.Quoted 41 lines
-Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Candrey.grodzovsky%40amd.com%7C01c4933fcb364820067408d9461d9c29%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617915261739604%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=t6oYaz%2FvvN0GhRc35qksHXOHCLGfF1OxNKrqkRF6VWg%3D&reserved=0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 02/18] drm/sched: Barriers are needed for entity->last_scheduled
Quoted 168 lines · Andrey Grodzovsky
Quoted 156 lines · Daniel Vetter
Quoted 136 lines · Andrey Grodzovsky
Quoted 123 lines · Daniel Vetter
Quoted 104 lines · Christian König
Am 13.07.21 um 08:50 schrieb Daniel Vetter:
Quoted 69 lines
Quoted 44 lines · Christian König
Am 12.07.21 um 19:53 schrieb Daniel Vetter:
Quoted 43 lines
It might be good enough on x86 with just
READ_ONCE, but the write side should then at least beWRITE_ONCEbecause x86 has total store order.It's definitely not enough on arm.
Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each commentAlso pull out the !sched_list case as the first check, so that the code flow is clearer.
While at it sprinkle some comments around because it was very non-obvious to me what's actually going on here and why.
Note that we really need full barriers here, at first I thought store-release and load-acquire on ->last_scheduled would be enough, but we actually requiring ordering between that and the queue state.
v2: Put
smp_rmp()in the right place and fix up comment (Andrey)Signed-off-by Daniel Vetter <[email protected]>Cc "Christian König" <[email protected]>Cc Steven Price <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andrey Grodzovsky <[email protected]>Cc Lee Jones <[email protected]>Cc Boris Brezillon <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-0@@ -439,8 +439,16 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)dma_fence_set_error (&sched_job->s_fence->finished, -ECANCELED );dma_fence_put (entity->last_scheduled); + entity->last_scheduled =dma_fence_get (&sched_job->s_fence->finished);Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) · line 451
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+/* +* If the queue is empty we allow drm_sched_entity_select_rq() to +* locklessly access ->last_scheduled. This only works if we set the +* pointer before we dequeue and if we a write barrier here. +*/ +smp_wmb (); +Again, conceptual those barriers should be part of the
spsc_queuecontainer and not externally.That would be extremely unusual api. Let's assume that your queue is very dumb, and protected by a simple lock. That's about the maximum any user could expect.
But then you still need barriers here, because linux locks (spinlock, mutex) are defined to be one-way barriers: Stuff that's inside is guaranteed to be done insinde, but stuff outside of the locked region can leak in. They're load-acquire/store-release barriers. So not good enough.
You really need to have barriers here, and they really all need to be documented properly. And yes that's a shit-ton of work in drm/sched, because it's full of yolo lockless stuff.
Quoted 7 lines
The other case you could make is that this works like a wakeup queue, or similar. The rules there are:
-wake_up(i.e. pushing something into the queue) is a store-release barrier
- the waked up (i.e. popping an entry) is a load acquire barrier Which is obviuosly needed because otherwise you don't have coherency for the data queued up. And again not the barriers you're locking for here.Exactly that was the idea, yes.
Quoted 10 lines
Either way, we'd still need the comments, because it's still lockless trickery, and every single one of that needs to have a comment on both sides to explain what's going on.
Essentially replace
spsc_queuewith an llist underneath, and that's the amount of barriers a data structure should provide. Anything else is asking your datastructure to paper over bugs in your users.This is similar to how
atomic_tis by default completely unordered, and users need to add barriers as needed, with comments.My main problem is as always that kernel atomics work different than userspace atomics.
Quoted 4 lines
I think this is all to make sure people don't just write lockless algorithms because it's a cool idea, but are forced to think this all through. Which seems to not have happened very consistently for drm/sched, so I guess needs to be fixed.
Well at least initially that was all perfectly thought through. The problem is nobody is really maintaining that stuff.
Quoted 5 lines
I'm definitely not going to hide all that by making the
spsc_queuestuff provide random unjustified barriers just because that would paper over drm/sched bugs. We need to fix the actual bugs, and preferrable all of them. I've found a few, but I wasn't involved in drm/sched thus far, so best I can do is discover them as we go.Quoted 7 lines
I don't think that those are random unjustified barriers at all and it sounds like you didn't grip what I said here.
See the spsc queue must have the following semantics:
1. When you pop a job all changes made before you push the job must be visible.
This is the standard barriers that also wake-up queues have, it's just store-release+load-acquire.
Quoted 2 lines
2. When the queue becomes empty all the changes made before you pop the last job must be visible.
This is very much non-standard for a queue. I guess you could make that part of the
spsc_queueapi between pop andis_empty(really we shouldn't expose the_count()function for this), but that's all very clever.Quoted 4 lines
I think having explicit barriers in the code, with comments, is much more robust. Because it forces you to think about all this, and document it properly. Because there's also lockless stuff like drm_sched.ready, which doesn't look at all like it's ordered somehow.
At least for amdgpu, after
drm_sched_finiis called (setting sched.ready = false)
we callamdgpu_fence_wait_emptyto ensure all in progress jobs are done. Seems to me at least, this should guarantee that all in flight consumers of sched.ready (those who still see sched.ready == true) are finished while all later consumers will see sched.ready == fakle and will bail out.Quoted 6 lines
On second thought there is a gap between checking for sched.ready and inserting
the HW fence for the new job so this might still be a bug... Looks like we need to check for
sched.ready after inserting the HW fence and for this we will need barrier or locking.Yeah, and at that point I think it's good to split up drm_sched.ready from a new thing for when the hw died, like drm_sched.wedged or .hw_death or similar, so that we can tell them apart. Trying to submit a job to a non-ready scheduler is a driver bug and should WARN, while submitting a job to a dead scheduler should probably result in
-EIObeing returned to userspace (instead of the current-ENOENT, assuming I haven't missed a errno remapping code somewhere in amdgpu).Also, then you could do a
drm_sched_die()or similar function which combines setting thehw_diedwith the right barriers and cleaning up all the jobs.Quoted 8 lines
Wrt the fundamental race: I think that's not fixeable easily, so maybe the scheduler thread also needs to handle this and immediately fail these jobs by setting all fences to
-EIOand completing them, without even calling into the driver. If you try to catch this synchronously I think it would require some kind of locking inpush_job, plus failure handling, which would be a) slow and b) real ugly in the driver code. Just accepting that some jobs can slip through and letting the scheduler thread clean them up is I think cleaner.
Quoted 7 lines
I agree about moving this check to scheduler thread, I also not quite understand why in some places which are clearly post the job being pick-up by it's scheduler thread such as
amdgpu_ib_schedule, still check for sched.ready... What's the point ? Also there are direct submission cases where IB insertion into HW ring is done without any scheduler involvement
and even more in that case why we care that scheduler is not ready.
I think (but I haven't checked the code in full detail) that this is because there's a mixup of what ->ready means:
- Setup/teardown ordering, where we sometimes try to submit stuff without the scheduler actually being ready yet (or maybe the hw isn't ready yet) and want to transparently fall back to something else.
- The actual "the hw died irrecoverably and reset couldn't resurrect it" case.
That's why I want to tear these two apart, so it's clear why we check things. Also in general I think solving the former problem with checks littered all over is bad style, but sometimes unavoidable (like when you're deep in a callchain through ttm to evict buffers for suspend). Usually it's better to order the code such that you never try to submit to hw when it's not ready.
Ofc the hw death is a different beast and can happen any time, hence needs to be treated differently - there's actual races possible with that, the code ordering issues around suspend/resume and driver load/unload are all single threaded so not possible to race. Ok maybe hotunplug is more like hw death since it can happen while we use it.
-Daniel
Quoted 81 lines
Andrey
Quoted 77 lines
If userspace then goes ahead and closes the ctx before all the jobs are cleaned up we can handle that with the normal
drm_sched_entitycleanup logic. Which would be another reason to split normal cleanup from hw death.
-DanielQuoted 68 lines
Andrey
Quoted 66 lines
E.g. there's also an
rmb(); indrm_sched_entity_is_idle(), which
- probably should be ansmp_rmb()
- really should document what it actually synchronizes against, and the lack of ansmp_wmb()somewhere else indicates it's probably busted. You always need two barriers.Quoted 2 lines
Otherwise I completely agree with you that the whole scheduler doesn't work at all and we need to add tons of external barriers.
Imo that's what we need to do. And the most important part for maintainability is to properly document thing with comments, and the most important part in that comment is pointing at the other side of a barrier (since a barrier on one side only orders nothing).
Also, on x86 almost nothing here matters, because both
rmb()andwmb()are no-op. Aside from the compiler barrier, which tends to not be the biggest issue. Onlymb()does anything, because x86 is only allowed to reorder reads ahead of writes.So in practice it's not quite as big a disaster, imo the big thing here is maintainability of all these tricks just not being documented. -Daniel
Quoted 44 lines
Regards,
Christian.Quoted 41 lines
-Daniel
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1spsc_queue_pop (&entity->job_queue);return sched_job; }@@ -459,10 +467,25 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)struct drm_gpu_scheduler *sched;struct drm_sched_rq *rq; -if (spsc_queue_count (&entity->job_queue) || !entity->sched_list) +/* single possible engine and already selected */ +if (!entity->sched_list) +return ; + +/* queue non-empty, stay on the same engine */ +if (spsc_queue_count (&entity->job_queue))return ;Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1- fence =READ_ONCE (entity->last_scheduled); +/* +* Only when the queue is empty are we guaranteed that the scheduler +* thread cannot change ->last_scheduled. To enforce ordering we need +* a read barrier here. See drm_sched_entity_pop_job() for the other drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 491
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* side. +*/ +smp_rmb (); + + fence = entity->last_scheduled; + +/* stay on the same engine if the previous job hasn't finished */ if (fence && !dma_fence_is_signaled (fence))return ;--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7Candrey.grodzovsky%40amd.com%7C01c4933fcb364820067408d9461d9c29%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637617915261739604%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=t6oYaz%2FvvN0GhRc35qksHXOHCLGfF1OxNKrqkRF6VWg%3D&reserved=0
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 3/18 drm/sched: Add dependency tracking
In reply to Daniel VetterInstead of just a callback we can just glue in the gem helpers that panfrost, v3d and lima currently use. There's really not that many ways to skin this cat.
On the naming bikeshed: The idea for using _await_ to denote adding dependencies to a job comes from i915, where that's used quite extensively all over the place, in lots of datastructures.
v2/3: Rebased.
--- drivers/gpu/drm/scheduler/sched_entity.c | 18 +++- drivers/gpu/drm/scheduler/sched_main.c | 103 +++++++++++++++++++++++ include/drm/gpu_scheduler.h | 31 ++++++- 3 files changed, 146 insertions(+), 6 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +15 -3
@@ -211,6 +211,19 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, job->sched->ops->free_job (job); } +static struct dma_fence * +drm_sched_job_dependency (struct drm_sched_job *job, +struct drm_sched_entity *entity) +{ +if (!xa_empty (&job->dependencies)) +return xa_erase (&job->dependencies, job->last_dependency++); + +if (job->sched->ops->dependency) +return job->sched->ops->dependency (job, entity); + +return NULL ; +} +/** * drm_sched_entity_kill_jobs - Make sure all remaining jobs are killed *
@@ -229,7 +242,7 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity)struct drm_sched_fence *s_fence = job->s_fence;/* Wait for all dependencies to avoid data corruptions */ -while ((f = job->sched->ops->dependency (job, entity))) +while ((f =drm_sched_job_dependency (job, entity)))dma_fence_wait (f, false);drm_sched_fence_scheduled (s_fence);
@@ -419,7 +432,6 @@ static bool drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity)*/ struct drm_sched_job *drm_sched_entity_pop_job (struct drm_sched_entity *entity) { -struct drm_gpu_scheduler *sched = entity->rq->sched;struct drm_sched_job *sched_job; sched_job =to_drm_sched_job (spsc_queue_peek (&entity->job_queue));
@@ -427,7 +439,7 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)return NULL ;while ((entity->dependency = - sched->ops->dependency (sched_job, entity))) { +drm_sched_job_dependency (sched_job, entity))) {trace_drm_sched_job_wait_dep (sched_job, entity->dependency);if (drm_sched_entity_add_dependency_cb (entity))
drivers/gpu/drm/scheduler/sched_main.c +103 -0
127 lines not on this page · raw message
include/drm/gpu_scheduler.h +28 -3
@@ -27,9 +27,12 @@#include <drm/spsc_queue.h> #include <linux/dma-fence.h> #include <linux/completion.h> +#include <linux/xarray.h> #define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000) +struct drm_gem_object ; +struct drm_gpu_scheduler ;struct drm_sched_rq ;
@@ -198,6 +201,16 @@ struct drm_sched_job {enum drm_sched_priority s_priority;struct drm_sched_entity *entity;struct dma_fence_cb cb; +/** +* @dependencies: +* +* Contains the dependencies as struct dma_fence for this job, see +* drm_sched_job_await_fence() and drm_sched_job_await_implicit(). +*/ +struct xarray dependencies; + +/** @last_dependency: tracks @dependencies as they signal */ +unsigned long last_dependency; }; static inline bool drm_sched_invalidate_job(struct drm_sched_job *s_job,
@@ -220,9 +233,14 @@ enum drm_gpu_sched_stat {*/ struct drm_sched_backend_ops {/** -* @dependency: Called when the scheduler is considering scheduling -* this job next, to get another struct dma_fence for this job to -* block on. Once it returns NULL, run_job() may be called. +* @dependency: +* +* Called when the scheduler is considering scheduling this job next, to +* get another struct dma_fence for this job to block on. Once it +* returns NULL, run_job() may be called. +* +* If a driver exclusively uses drm_sched_job_await_fence() and +* drm_sched_job_await_implicit() this can be ommitted and left as NULL. */ struct dma_fence *(*dependency)(struct drm_sched_job *sched_job,struct drm_sched_entity *s_entity);
@@ -349,6 +367,13 @@ int drm_sched_job_init(struct drm_sched_job *job,struct drm_sched_entity *entity, void *owner);void drm_sched_job_arm (struct drm_sched_job *job); +int drm_sched_job_await_fence (struct drm_sched_job *job, +struct dma_fence *fence); +int drm_sched_job_await_implicit (struct drm_sched_job *job, +struct drm_gem_object *obj, +bool write); + +void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list);
Signature · 1 line
2.32.0
Re: [PATCH v4 03/18] drm/sched: Add dependency tracking
Adding a few more people to this bikeshed.
include/drm/gpu_scheduler.h int drm_sched_job_init(struct drm_sched_job *job, · line 376
Quoted 11 lines · Daniel Vetter
include/drm/gpu_scheduler.h +7
-0@@ -349,6 +367,13 @@ int drm_sched_job_init(struct drm_sched_job *job,struct drm_sched_entity *entity, void *owner);void drm_sched_job_arm (struct drm_sched_job *job); +int drm_sched_job_await_fence (struct drm_sched_job *job, +struct dma_fence *fence); +int drm_sched_job_await_implicit (struct drm_sched_job *job, +struct drm_gem_object *obj, +bool write); + +
I'm still waiting on the paint delivery for these two functions so I can finish this shed.
Thanks, Daniel
Quoted 6 lines
include/drm/gpu_scheduler.h +0
-1void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list); --2.32.0
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Christian König
reviewerRe: [Linaro-mm-sig] [PATCH v4 03/18] drm/sched: Add dependency tracking
Am 27.07.21 um 13:09 schrieb Daniel Vetter:
Quoted 4 lines
Adding a few more people to this bikeshed.
On Mon, Jul 12, 2021 at 10:02 PM Daniel Vetter <[email protected]> wrote:
Quoted 13 lines
include/drm/gpu_scheduler.h int drm_sched_job_init(struct drm_sched_job *job, · line 376
Quoted 11 lines
include/drm/gpu_scheduler.h +7
-0@@ -349,6 +367,13 @@ int drm_sched_job_init(struct drm_sched_job *job,struct drm_sched_entity *entity, void *owner);void drm_sched_job_arm (struct drm_sched_job *job); +int drm_sched_job_await_fence (struct drm_sched_job *job, +struct dma_fence *fence); +int drm_sched_job_await_implicit (struct drm_sched_job *job, +struct drm_gem_object *obj, +bool write); + +I'm still waiting on the paint delivery for these two functions so I can finish this shed.
Well I wouldn't call that bike shedding, good names are important.
Just imaging we would have called the exclusive-fence write-fence instead.
What speaks against calling them add_dependency() and _add_implicit_depencencies() ?
Regards,
Christian.
Quoted 10 lines
Thanks, Daniel
Quoted 6 lines
include/drm/gpu_scheduler.h +0
-1void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list); --2.32.0
Re: [Linaro-mm-sig] [PATCH v4 03/18] drm/sched: Add dependency tracking
Quoted 19 lines · Christian König
Am 27.07.21 um 13:09 schrieb Daniel Vetter:
Quoted 4 lines
Adding a few more people to this bikeshed.
On Mon, Jul 12, 2021 at 10:02 PM Daniel Vetter <[email protected]> wrote:
Quoted 13 lines
include/drm/gpu_scheduler.h int drm_sched_job_init(struct drm_sched_job *job, · line 376
Quoted 11 lines
include/drm/gpu_scheduler.h +7
-0@@ -349,6 +367,13 @@ int drm_sched_job_init(struct drm_sched_job *job,struct drm_sched_entity *entity, void *owner);void drm_sched_job_arm (struct drm_sched_job *job); +int drm_sched_job_await_fence (struct drm_sched_job *job, +struct dma_fence *fence); +int drm_sched_job_await_implicit (struct drm_sched_job *job, +struct drm_gem_object *obj, +bool write); + +I'm still waiting on the paint delivery for these two functions so I can finish this shed.
Quoted 3 lines
Well I wouldn't call that bike shedding, good names are important.
Just imaging we would have called the exclusive-fence write-fence instead.
Sure naming matters, but at least to my English understanding there's not a semantic different between telling something to await for something else (i.e. add a dependency) or to tell something to add a dependency (i.e. await that thing later on before you start doing your own thing).
Exclusive vs write fence otoh is a pretty big difference in what it means.
But also if there's consensus that I'm wrong then I'm happy to pick the more preferred of the two options I deem equivalent.
Quoted 2 lines
What speaks against calling them
add_dependency()and_add_implicit_depencencies()?
Nothing. I just like another ack on this before I rename it all. Also I wasnt sure what you'd want to name the implicit dependency thing.
Lucas, Boris, Melissa, any acks here?
-Daniel
Quoted 14 lines
Regards,
Christian.Quoted 10 lines
Thanks, Daniel
Quoted 6 lines
include/drm/gpu_scheduler.h +0
-1void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list); --2.32.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Christian König
maintainerRe: [Linaro-mm-sig] [PATCH v4 03/18] drm/sched: Add dependency tracking
Am 28.07.21 um 14:09 schrieb Daniel Vetter:
Quoted 20 lines
Quoted 18 lines · Christian König
Am 27.07.21 um 13:09 schrieb Daniel Vetter:
Quoted 17 lines
Adding a few more people to this bikeshed.
include/drm/gpu_scheduler.h int drm_sched_job_init(struct drm_sched_job *job, · line 376
Quoted 11 lines · Daniel Vetter
include/drm/gpu_scheduler.h +7
-0@@ -349,6 +367,13 @@ int drm_sched_job_init(struct drm_sched_job *job,struct drm_sched_entity *entity, void *owner);void drm_sched_job_arm (struct drm_sched_job *job); +int drm_sched_job_await_fence (struct drm_sched_job *job, +struct dma_fence *fence); +int drm_sched_job_await_implicit (struct drm_sched_job *job, +struct drm_gem_object *obj, +bool write); + +I'm still waiting on the paint delivery for these two functions so I can finish this shed.
Quoted 8 lines
Quoted 3 lines
Well I wouldn't call that bike shedding, good names are important.
Just imaging we would have called the exclusive-fence write-fence instead.
Sure naming matters, but at least to my English understanding there's not a semantic different between telling something to await for something else (i.e. add a dependency) or to tell something to add a dependency (i.e. await that thing later on before you start doing your own thing).
To be honest I had to google what await means when you first mentioned it because I didn't had that in my English vocabulary.
(But I have to note that my English education is basically non-existent. I speak German and a good bunch of Dutch and just interfere most of the words).
Regards,
Christian.
Quoted 5 lines
Exclusive vs write fence otoh is a pretty big difference in what it means.
But also if there's consensus that I'm wrong then I'm happy to pick the more preferred of the two options I deem equivalent.
Quoted 20 lines
Quoted 2 lines
What speaks against calling them
add_dependency()and_add_implicit_depencencies()?Nothing. I just like another ack on this before I rename it all. Also I wasnt sure what you'd want to name the implicit dependency thing.
Lucas, Boris, Melissa, any acks here?
-DanielQuoted 11 lines
Regards,
Christian.Quoted 8 lines
Thanks, Daniel
Quoted 6 lines
include/drm/gpu_scheduler.h +0
-1void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list); --2.32.0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Melissa Wen
maintainerRe: [Linaro-mm-sig] [PATCH v4 03/18] drm/sched: Add dependency tracking
In reply to Daniel VetterQuoted 36 lines · Daniel Vetter
Quoted 19 lines · Christian König
Am 27.07.21 um 13:09 schrieb Daniel Vetter:
Quoted 4 lines
Adding a few more people to this bikeshed.
On Mon, Jul 12, 2021 at 10:02 PM Daniel Vetter <[email protected]> wrote:
Quoted 13 lines
include/drm/gpu_scheduler.h int drm_sched_job_init(struct drm_sched_job *job, · line 376
Quoted 11 lines
include/drm/gpu_scheduler.h +7
-0@@ -349,6 +367,13 @@ int drm_sched_job_init(struct drm_sched_job *job,struct drm_sched_entity *entity, void *owner);void drm_sched_job_arm (struct drm_sched_job *job); +int drm_sched_job_await_fence (struct drm_sched_job *job, +struct dma_fence *fence); +int drm_sched_job_await_implicit (struct drm_sched_job *job, +struct drm_gem_object *obj, +bool write); + +I'm still waiting on the paint delivery for these two functions so I can finish this shed.
Quoted 3 lines
Well I wouldn't call that bike shedding, good names are important.
Just imaging we would have called the exclusive-fence write-fence instead.
Sure naming matters, but at least to my English understanding there's not a semantic different between telling something to await for something else (i.e. add a dependency) or to tell something to add a dependency (i.e. await that thing later on before you start doing your own thing).
Exclusive vs write fence otoh is a pretty big difference in what it means.
But also if there's consensus that I'm wrong then I'm happy to pick the more preferred of the two options I deem equivalent.
Quoted 7 lines
Quoted 2 lines
What speaks against calling them
add_dependency()and_add_implicit_depencencies()?Nothing. I just like another ack on this before I rename it all. Also I wasnt sure what you'd want to name the implicit dependency thing.
Lucas, Boris, Melissa, any acks here?
so, my English is far from good; but _add_dependency sounds good to me.
Melissa
Quoted 22 lines
-Daniel
Quoted 14 lines
Regards,
Christian.Quoted 10 lines
Thanks, Daniel
Quoted 6 lines
include/drm/gpu_scheduler.h +0
-1void drm_sched_entity_modify_sched (struct drm_sched_entity *entity,struct drm_gpu_scheduler **sched_list,unsigned int num_sched_list); --2.32.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH v4 4/18 drm/sched: drop entity parameter from drm_sched_push_job
In reply to Daniel VetterOriginally a job was only bound to the queue when we pushed this, but now that's done in drm_sched_job_init, making that parameter entirely redundant.
Remove it.
The same applies to the context parameter inlima_sched_context_queue_task, simplify that too.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 2 +- drivers/gpu/drm/lima/lima_gem.c | 3 +-- drivers/gpu/drm/lima/lima_sched.c | 5 ++--- drivers/gpu/drm/lima/lima_sched.h | 3 +-- drivers/gpu/drm/panfrost/panfrost_job.c | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 6 ++---- drivers/gpu/drm/v3d/v3d_gem.c | 2 +- include/drm/gpu_scheduler.h | 3 +-- 10 files changed, 12 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -1267,7 +1267,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,trace_amdgpu_cs_ioctl (job);amdgpu_vm_bo_trace_cs (&fpriv->vm, &p->ticket); -drm_sched_entity_push_job (&job->base, entity); +drm_sched_entity_push_job (&job->base);amdgpu_vm_move_to_lru_tail (p->adev, &fpriv->vm);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
@@ -174,7 +174,7 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity, *f =dma_fence_get (&job->base.s_fence->finished);amdgpu_job_free_resources (job); -drm_sched_entity_push_job (&job->base, entity); +drm_sched_entity_push_job (&job->base);return 0 ; }
drivers/gpu/drm/etnaviv/etnaviv_sched.c +1 -1
@@ -178,7 +178,7 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity,/* the scheduler holds on to the job now */ kref_get (&submit->refcount); -drm_sched_entity_push_job (&submit->sched_job, sched_entity); +drm_sched_entity_push_job (&submit->sched_job); out_unlock:mutex_unlock (&submit->gpu->fence_lock);
drivers/gpu/drm/lima/lima_gem.c +1 -2
@@ -359,8 +359,7 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) goto err_out2; } - fence =lima_sched_context_queue_task ( - submit->ctx->context + submit->pipe, submit->task); + fence =lima_sched_context_queue_task (submit->task);for (i =0 ; i < submit->nr_bos; i++) {if (submit->bos[i].flags &LIMA_SUBMIT_BO_WRITE )
drivers/gpu/drm/lima/lima_sched.c +2 -3
@@ -177,13 +177,12 @@ void lima_sched_context_fini(struct lima_sched_pipe *pipe,drm_sched_entity_fini (&context->base); } -struct dma_fence *lima_sched_context_queue_task (struct lima_sched_context *context, -struct lima_sched_task *task) +struct dma_fence *lima_sched_context_queue_task (struct lima_sched_task *task) {struct dma_fence *fence =dma_fence_get (&task->base.s_fence->finished);trace_lima_task_submit (task); -drm_sched_entity_push_job (&task->base, &context->base); +drm_sched_entity_push_job (&task->base);return fence; }
drivers/gpu/drm/lima/lima_sched.h +1 -2
@@ -98,8 +98,7 @@ int lima_sched_context_init(struct lima_sched_pipe *pipe, atomic_t *guilty);void lima_sched_context_fini (struct lima_sched_pipe *pipe,struct lima_sched_context *context); -struct dma_fence *lima_sched_context_queue_task (struct lima_sched_context *context, -struct lima_sched_task *task); +struct dma_fence *lima_sched_context_queue_task (struct lima_sched_task *task);int lima_sched_pipe_init (struct lima_sched_pipe *pipe,const char *name);void lima_sched_pipe_fini (struct lima_sched_pipe *pipe);
drivers/gpu/drm/panfrost/panfrost_job.c +1 -1
@@ -301,7 +301,7 @@ int panfrost_job_push(struct panfrost_job *job)kref_get (&job->refcount);/* put by scheduler job completion */ -drm_sched_entity_push_job (&job->base, entity); +drm_sched_entity_push_job (&job->base);mutex_unlock (&pfdev->sched_lock);
drivers/gpu/drm/scheduler/sched_entity.c +2 -4
@@ -516,9 +516,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)/** * drm_sched_entity_push_job - Submit a job to the entity's job queue -* * @sched_job: job to submit -* @entity: scheduler entity * * Note: To guarantee that the order of insertion to queue matches the job's * fence sequence number this function should be called with drm_sched_job_arm()
@@ -526,9 +524,9 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)* * Returns 0 for success, negative error code otherwise. */ -void drm_sched_entity_push_job (struct drm_sched_job *sched_job, -struct drm_sched_entity *entity) +void drm_sched_entity_push_job (struct drm_sched_job *sched_job) { +struct drm_sched_entity *entity = sched_job->entity;bool first;trace_drm_sched_job (sched_job, entity);
drivers/gpu/drm/v3d/v3d_gem.c +1 -1
@@ -482,7 +482,7 @@ v3d_push_job(struct v3d_file_priv *v3d_priv,/* put by scheduler job completion */ kref_get (&job->refcount); -drm_sched_entity_push_job (&job->base, &v3d_priv->sched_entity[queue]); +drm_sched_entity_push_job (&job->base);return 0 ; }
include/drm/gpu_scheduler.h +1 -2
@@ -407,8 +407,7 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity);void drm_sched_entity_destroy (struct drm_sched_entity *entity);void drm_sched_entity_select_rq (struct drm_sched_entity *entity);struct drm_sched_job *drm_sched_entity_pop_job (struct drm_sched_entity *entity); -void drm_sched_entity_push_job (struct drm_sched_job *sched_job, -struct drm_sched_entity *entity); +void drm_sched_entity_push_job (struct drm_sched_job *sched_job);void drm_sched_entity_set_priority (struct drm_sched_entity *entity,enum drm_sched_priority priority);bool drm_sched_entity_is_ready (struct drm_sched_entity *entity);
Signature · 1 line
2.32.0
PATCH v4 5/18 drm/sched: improve docs around drm_sched_entity
In reply to Daniel VetterI found a few too many things that are tricky and not documented, so I started typing.
I found a few more things that looked broken while typing, see the varios FIXME in drm_sched_entity.
Also some of the usual logics:
- actually include sched_entity.c declarations, that was lost in the move here: 620e762f9a98 ("drm/scheduler: move entity handling into separate file")
- Ditch the kerneldoc for internal functions, keep the comments where they're describing more than what the function name already implies.
- Switch drm_sched_entity to inline docs.
--- Documentation/gpu/drm-mm.rst | 3 + drivers/gpu/drm/scheduler/sched_entity.c | 85 ++++--------- include/drm/gpu_scheduler.h | 145 ++++++++++++++++++----- 3 files changed, 146 insertions(+), 87 deletions(-)
Documentation/gpu/drm-mm.rst +3 -0
@@ -504,3 +504,6 @@ Scheduler Function References .. kernel-doc:: drivers/gpu/drm/scheduler/sched_main.c :export: + +.. kernel-doc:: drivers/gpu/drm/scheduler/sched_entity.c + :export:
drivers/gpu/drm/scheduler/sched_entity.c +25 -60
166 lines not on this page · raw message
include/drm/gpu_scheduler.h +118 -27
174 lines not on this page · raw message
Signature · 1 line
2.32.0
PATCH v4 6/18 drm/panfrost: use scheduler dependency tracking
In reply to Daniel VetterJust deletes some code that's now more shared.
Note that thanks to the split into drm_sched_job_init/arm we can now easily pull the _init() part from under the submission lock way ahead where we're adding the sync file in-fences as dependencies.
v2: Correctly clean up the partially set up job, now that job_init() and job_arm() are apart (Emma).
--- drivers/gpu/drm/panfrost/panfrost_drv.c | 16 ++++++++--- drivers/gpu/drm/panfrost/panfrost_job.c | 37 +++---------------------- drivers/gpu/drm/panfrost/panfrost_job.h | 5 +--- 3 files changed, 17 insertions(+), 41 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +12 -4
@@ -218,7 +218,7 @@ panfrost_copy_in_sync(struct drm_device *dev,if (ret) goto fail; - ret =drm_gem_fence_array_add (&job->deps, fence); + ret =drm_sched_job_await_fence (&job->base, fence);if (ret) goto fail;
@@ -236,7 +236,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,struct drm_panfrost_submit *args = data;struct drm_syncobj *sync_out =NULL ;struct panfrost_job *job; -int ret =0 ; +int ret =0 , slot;if (!args->jc)return -EINVAL ;
@@ -258,14 +258,20 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,kref_init (&job->refcount); -xa_init_flags (&job->deps,XA_FLAGS_ALLOC ); - job->pfdev = pfdev; job->jc = args->jc; job->requirements = args->requirements; job->flush_id =panfrost_gpu_get_latest_flush_id (pfdev); job->file_priv = file->driver_priv; + slot =panfrost_job_get_slot (job); + + ret =drm_sched_job_init (&job->base, + &job->file_priv->sched_entity[slot], +NULL ); +if (ret) + goto fail_job_put; + ret =panfrost_copy_in_sync (dev, file, args, job);if (ret) goto fail_job;
@@ -283,6 +289,8 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,drm_syncobj_replace_fence (sync_out, job->render_done_fence); fail_job: +drm_sched_job_cleanup (&job->base); +fail_job_put:panfrost_job_put (job); fail_out_sync:if (sync_out)
drivers/gpu/drm/panfrost/panfrost_job.c +4 -33
@@ -102,7 +102,7 @@ static struct dma_fence *panfrost_fence_create(struct panfrost_device *pfdev, inreturn &fence->base; } -static int panfrost_job_get_slot (struct panfrost_job *job) +int panfrost_job_get_slot (struct panfrost_job *job) {/* JS0: fragment jobs. * JS1: vertex/tiler jobs
@@ -242,13 +242,13 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js)static int panfrost_acquire_object_fences (struct drm_gem_object **bos,int bo_count, -struct xarray *deps) +struct drm_sched_job *job) {int i, ret;for (i =0 ; i < bo_count; i++) {/* panfrost always uses write mode in its current uapi */ - ret =drm_gem_fence_array_add_implicit (deps, bos[i], true); + ret =drm_sched_job_await_implicit (job, bos[i], true);if (ret)return ret; }
@@ -269,31 +269,21 @@ static void panfrost_attach_object_fences(struct drm_gem_object **bos,int panfrost_job_push (struct panfrost_job *job) {struct panfrost_device *pfdev = job->pfdev; -int slot =panfrost_job_get_slot (job); -struct drm_sched_entity *entity = &job->file_priv->sched_entity[slot];struct ww_acquire_ctx acquire_ctx;int ret =0 ; - ret =drm_gem_lock_reservations (job->bos, job->bo_count, &acquire_ctx);if (ret)return ret;mutex_lock (&pfdev->sched_lock); - - ret =drm_sched_job_init (&job->base, entity,NULL ); -if (ret) { -mutex_unlock (&pfdev->sched_lock); - goto unlock; - } -drm_sched_job_arm (&job->base); job->render_done_fence =dma_fence_get (&job->base.s_fence->finished); ret =panfrost_acquire_object_fences (job->bos, job->bo_count, - &job->deps); + &job->base);if (ret) {mutex_unlock (&pfdev->sched_lock); goto unlock;
@@ -318,15 +308,8 @@ static void panfrost_job_cleanup(struct kref *ref) { struct panfrost_job *job = container_of(ref, struct panfrost_job, refcount); -struct dma_fence *fence; -unsigned long index;unsigned int i; -xa_for_each (&job->deps, index, fence) { -dma_fence_put (fence); - } -xa_destroy (&job->deps); -dma_fence_put (job->done_fence);dma_fence_put (job->render_done_fence);
@@ -365,17 +348,6 @@ static void panfrost_job_free(struct drm_sched_job *sched_job)panfrost_job_put (job); } -static struct dma_fence *panfrost_job_dependency (struct drm_sched_job *sched_job, -struct drm_sched_entity *s_entity) -{ -struct panfrost_job *job =to_panfrost_job (sched_job); - -if (!xa_empty (&job->deps)) -return xa_erase (&job->deps, job->last_dep++); - -return NULL ; -} -static struct dma_fence *panfrost_job_run (struct drm_sched_job *sched_job) {struct panfrost_job *job =to_panfrost_job (sched_job);
@@ -765,7 +737,6 @@ static void panfrost_reset_work(struct work_struct *work) }static const struct drm_sched_backend_ops panfrost_sched_ops = { - .dependency = panfrost_job_dependency, .run_job = panfrost_job_run, .timedout_job = panfrost_job_timedout, .free_job = panfrost_job_free
drivers/gpu/drm/panfrost/panfrost_job.h +1 -4
@@ -19,10 +19,6 @@ struct panfrost_job {struct panfrost_device *pfdev;struct panfrost_file_priv *file_priv; -/* Contains both explicit and implicit fences */ -struct xarray deps; -unsigned long last_dep; -/* Fence to be signaled by IRQ handler when the job is complete. */ struct dma_fence *done_fence;
@@ -42,6 +38,7 @@ int panfrost_job_init(struct panfrost_device *pfdev);void panfrost_job_fini (struct panfrost_device *pfdev);int panfrost_job_open (struct panfrost_file_priv *panfrost_priv);void panfrost_job_close (struct panfrost_file_priv *panfrost_priv); +int panfrost_job_get_slot (struct panfrost_job *job);int panfrost_job_push (struct panfrost_job *job);void panfrost_job_put (struct panfrost_job *job);void panfrost_job_enable_interrupts (struct panfrost_device *pfdev);
Signature · 1 line
2.32.0
PATCH v4 7/18 drm/lima: use scheduler dependency tracking
In reply to Daniel VetterNothing special going on here.
Aside reviewing the code, it seems like drm_sched_job_arm() should be moved into lima_sched_context_queue_task and put under some mutex together with drm_sched_push_job(). See the kerneldoc for drm_sched_push_job().
--- drivers/gpu/drm/lima/lima_gem.c | 4 ++-- drivers/gpu/drm/lima/lima_sched.c | 21 --------------------- drivers/gpu/drm/lima/lima_sched.h | 3 --- 3 files changed, 2 insertions(+), 26 deletions(-)
drivers/gpu/drm/lima/lima_gem.c +2 -2
@@ -267,7 +267,7 @@ static int lima_gem_sync_bo(struct lima_sched_task *task, struct lima_bo *bo,if (explicit)return 0 ; -return drm_gem_fence_array_add_implicit (&task->deps, &bo->base.base, write); +return drm_sched_job_await_implicit (&task->base, &bo->base.base, write); }static int lima_gem_add_deps (struct drm_file *file,struct lima_submit *submit)
@@ -285,7 +285,7 @@ static int lima_gem_add_deps(struct drm_file *file, struct lima_submit *submit)if (err)return err; - err =drm_gem_fence_array_add (&submit->task->deps, fence); + err =drm_sched_job_await_fence (&submit->task->base, fence);if (err) {dma_fence_put (fence);return err;
drivers/gpu/drm/lima/lima_sched.c +0 -21
@@ -134,24 +134,15 @@ int lima_sched_task_init(struct lima_sched_task *task, task->num_bos = num_bos; task->vm =lima_vm_get (vm); -xa_init_flags (&task->deps,XA_FLAGS_ALLOC ); -return 0 ; }void lima_sched_task_fini (struct lima_sched_task *task) { -struct dma_fence *fence; -unsigned long index;int i;drm_sched_job_cleanup (&task->base); -xa_for_each (&task->deps, index, fence) { -dma_fence_put (fence); - } -xa_destroy (&task->deps); -if (task->bos) {for (i =0 ; i < task->num_bos; i++)drm_gem_object_put (&task->bos[i]->base.base);
@@ -186,17 +177,6 @@ struct dma_fence *lima_sched_context_queue_task(struct lima_sched_task *task)return fence; } -static struct dma_fence *lima_sched_dependency (struct drm_sched_job *job, -struct drm_sched_entity *entity) -{ -struct lima_sched_task *task =to_lima_task (job); - -if (!xa_empty (&task->deps)) -return xa_erase (&task->deps, task->last_dep++); - -return NULL ; -} -static int lima_pm_busy (struct lima_device *ldev) {int ret;
@@ -472,7 +452,6 @@ static void lima_sched_free_job(struct drm_sched_job *job) }static const struct drm_sched_backend_ops lima_sched_ops = { - .dependency = lima_sched_dependency, .run_job = lima_sched_run_job, .timedout_job = lima_sched_timedout_job, .free_job = lima_sched_free_job,
drivers/gpu/drm/lima/lima_sched.h +0 -3
@@ -23,9 +23,6 @@ struct lima_sched_task {struct lima_vm *vm;void *frame; -struct xarray deps; -unsigned long last_dep; -struct lima_bo **bos;int num_bos;
Signature · 1 line
2.32.0
PATCH v4 8/18 drm/v3d: Move drm_sched_job_init to v3d_job_init
In reply to Daniel VetterPrep work for using the scheduler dependency handling. We need to call drm_sched_job_init earlier so we can use the new drm_sched_job_await* functions for dependency handling here.
v2: Slightly better commit message and rebase to include the drm_sched_job_arm() call (Emma).
v3: Cleanup jobs under construction correctly (Emma)
--- drivers/gpu/drm/v3d/v3d_drv.h | 1 + drivers/gpu/drm/v3d/v3d_gem.c | 88 ++++++++++++++------------------- drivers/gpu/drm/v3d/v3d_sched.c | 15 +++--- 3 files changed, 44 insertions(+), 60 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +1 -0
@@ -332,6 +332,7 @@ int v3d_submit_csd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int v3d_wait_bo_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +void v3d_job_cleanup (struct v3d_job *job);void v3d_job_put (struct v3d_job *job);void v3d_reset (struct v3d_dev *v3d);void v3d_invalidate_caches (struct v3d_dev *v3d);
drivers/gpu/drm/v3d/v3d_gem.c +36 -52
241 lines not on this page · raw message
drivers/gpu/drm/v3d/v3d_sched.c +7 -8
@@ -55,12 +55,11 @@ to_csd_job(struct drm_sched_job *sched_job) }static void -v3d_job_free (struct drm_sched_job *sched_job) +v3d_sched_job_free (struct drm_sched_job *sched_job) {struct v3d_job *job =to_v3d_job (sched_job); -drm_sched_job_cleanup (sched_job); -v3d_job_put (job); +v3d_job_cleanup (job); }/*
@@ -360,35 +359,35 @@ static const struct drm_sched_backend_ops v3d_bin_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_bin_job_run, .timedout_job = v3d_bin_job_timedout, - .free_job = v3d_job_free, + .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_render_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_render_job_run, .timedout_job = v3d_render_job_timedout, - .free_job = v3d_job_free, + .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_tfu_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_tfu_job_run, .timedout_job = v3d_generic_job_timedout, - .free_job = v3d_job_free, + .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_csd_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_csd_job_run, .timedout_job = v3d_csd_job_timedout, - .free_job = v3d_job_free + .free_job = v3d_sched_job_free };static const struct drm_sched_backend_ops v3d_cache_clean_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_cache_clean_job_run, .timedout_job = v3d_generic_job_timedout, - .free_job = v3d_job_free + .free_job = v3d_sched_job_free };int
Signature · 6 lines
2.32.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 08/18] drm/v3d: Move drm_sched_job_init to v3d_job_init
Quoted 344 lines · Daniel Vetter
Prep work for using the scheduler dependency handling. We need to call
drm_sched_job_initearlier so we can use the new drm_sched_job_await* functions for dependency handling here.v2: Slightly better commit message and rebase to include the
drm_sched_job_arm()call (Emma).v3: Cleanup jobs under construction correctly (Emma)
Cc Melissa Wen <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Emma Anholt <[email protected]>--- drivers/gpu/drm/v3d/v3d_drv.h | 1 + drivers/gpu/drm/v3d/v3d_gem.c | 88 ++++++++++++++------------------- drivers/gpu/drm/v3d/v3d_sched.c | 15 +++--- 3 files changed, 44 insertions(+), 60 deletions(-)drivers/gpu/drm/v3d/v3d_drv.h +1
-0@@ -332,6 +332,7 @@ int v3d_submit_csd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int v3d_wait_bo_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +void v3d_job_cleanup (struct v3d_job *job);void v3d_job_put (struct v3d_job *job);void v3d_reset (struct v3d_dev *v3d);void v3d_invalidate_caches (struct v3d_dev *v3d);drivers/gpu/drm/v3d/v3d_gem.c +36
-52@@ -392,6 +392,12 @@ v3d_render_job_free(struct kref *ref)v3d_job_free (ref); } +void v3d_job_cleanup (struct v3d_job *job) +{ +drm_sched_job_cleanup (&job->base); +v3d_job_put (job); +} +void v3d_job_put (struct v3d_job *job) {kref_put (&job->refcount, job->free);@@ -433,9 +439,10 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data,static int v3d_job_init (struct v3d_dev *v3d,struct drm_file *file_priv,struct v3d_job *job,void (*free)(struct kref *ref), -u32 in_sync) +u32 in_sync,enum v3d_queue queue) {struct dma_fence *in_fence =NULL ; +struct v3d_file_priv *v3d_priv = file_priv->driver_priv;int ret; job->v3d = v3d;@@ -446,35 +453,33 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,return ret;xa_init_flags (&job->deps,XA_FLAGS_ALLOC ); + ret =drm_sched_job_init (&job->base, &v3d_priv->sched_entity[queue], + v3d_priv); +if (ret) + goto fail; ret =drm_syncobj_find_fence (file_priv, in_sync,0 ,0 , &in_fence);if (ret == -EINVAL ) - goto fail; + goto fail_job; ret =drm_gem_fence_array_add (&job->deps, in_fence);if (ret) - goto fail; + goto fail_job;kref_init (&job->refcount);return 0 ; +fail_job: +drm_sched_job_cleanup (&job->base); fail:xa_destroy (&job->deps);pm_runtime_put_autosuspend (v3d->drm.dev);return ret; } -static int -v3d_push_job (struct v3d_file_priv *v3d_priv, -struct v3d_job *job,enum v3d_queue queue) +static void +v3d_push_job (struct v3d_job *job) { -int ret; - - ret =drm_sched_job_init (&job->base, &v3d_priv->sched_entity[queue], - v3d_priv); -if (ret) -return ret; -drm_sched_job_arm (&job->base); job->done_fence =dma_fence_get (&job->base.s_fence->finished);@@ -483,8 +488,6 @@ v3d_push_job(struct v3d_file_priv *v3d_priv,kref_get (&job->refcount);drm_sched_entity_push_job (&job->base); - -return 0 ; } static void@@ -530,7 +533,6 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) {struct v3d_dev *v3d =to_v3d_dev (dev); -struct v3d_file_priv *v3d_priv = file_priv->driver_priv;struct drm_v3d_submit_cl *args = data;struct v3d_bin_job *bin =NULL ;struct v3d_render_job *render;@@ -556,7 +558,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,INIT_LIST_HEAD (&render->unref_list); ret =v3d_job_init (v3d, file_priv, &render->base, - v3d_render_job_free, args->in_sync_rcl); + v3d_render_job_free, args->in_sync_rcl,V3D_RENDER );if (ret) {kfree (render);return ret;@@ -570,7 +572,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, } ret =v3d_job_init (v3d, file_priv, &bin->base, - v3d_job_free, args->in_sync_bcl); + v3d_job_free, args->in_sync_bcl,V3D_BIN );if (ret) {v3d_job_put (&render->base);kfree (bin);@@ -592,7 +594,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, goto fail; } - ret =v3d_job_init (v3d, file_priv, clean_job, v3d_job_free,0 ); + ret =v3d_job_init (v3d, file_priv, clean_job, v3d_job_free,0 ,V3D_CACHE_CLEAN );if (ret) {kfree (clean_job); clean_job =NULL ;@@ -615,9 +617,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,mutex_lock (&v3d->sched_lock);if (bin) { - ret =v3d_push_job (v3d_priv, &bin->base,V3D_BIN ); -if (ret) - goto fail_unreserve; +v3d_push_job (&bin->base); ret =drm_gem_fence_array_add (&render->base.deps,dma_fence_get (bin->base.done_fence));@@ -625,9 +625,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, goto fail_unreserve; } - ret =v3d_push_job (v3d_priv, &render->base,V3D_RENDER ); -if (ret) - goto fail_unreserve; +v3d_push_job (&render->base);if (clean_job) { struct dma_fence *render_fence =@@ -635,9 +633,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, ret =drm_gem_fence_array_add (&clean_job->deps, render_fence);if (ret) goto fail_unreserve; - ret =v3d_push_job (v3d_priv, clean_job,V3D_CACHE_CLEAN ); -if (ret) - goto fail_unreserve; +v3d_push_job (clean_job); }mutex_unlock (&v3d->sched_lock);@@ -662,10 +658,10 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, last_job->bo_count, &acquire_ctx); fail:if (bin) -v3d_job_put (&bin->base); -v3d_job_put (&render->base); +v3d_job_cleanup (&bin->base); +v3d_job_cleanup (&render->base);if (clean_job) -v3d_job_put (clean_job); +v3d_job_cleanup (clean_job);return ret; }@@ -684,7 +680,6 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) {struct v3d_dev *v3d =to_v3d_dev (dev); -struct v3d_file_priv *v3d_priv = file_priv->driver_priv;struct drm_v3d_submit_tfu *args = data;struct v3d_tfu_job *job;struct ww_acquire_ctx acquire_ctx;@@ -697,7 +692,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,return -ENOMEM ; ret =v3d_job_init (v3d, file_priv, &job->base, - v3d_job_free, args->in_sync); + v3d_job_free, args->in_sync,V3D_TFU );if (ret) {kfree (job);return ret;@@ -741,9 +736,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data, goto fail;mutex_lock (&v3d->sched_lock); - ret =v3d_push_job (v3d_priv, &job->base,V3D_TFU ); -if (ret) - goto fail_unreserve; +v3d_push_job (&job->base);mutex_unlock (&v3d->sched_lock); v3d_attach_fences_and_unlock_reservation(file_priv,@@ -755,12 +748,8 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,return 0 ; -fail_unreserve: -mutex_unlock (&v3d->sched_lock); -drm_gem_unlock_reservations (job->base.bo, job->base.bo_count, - &acquire_ctx); fail: -v3d_job_put (&job->base); +v3d_job_cleanup (&job->base);return ret; }@@ -779,7 +768,6 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) {struct v3d_dev *v3d =to_v3d_dev (dev); -struct v3d_file_priv *v3d_priv = file_priv->driver_priv;struct drm_v3d_submit_csd *args = data;struct v3d_csd_job *job;struct v3d_job *clean_job;@@ -798,7 +786,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,return -ENOMEM ; ret =v3d_job_init (v3d, file_priv, &job->base, - v3d_job_free, args->in_sync); + v3d_job_free, args->in_sync,V3D_CSD );if (ret) {kfree (job);return ret;@@ -811,7 +799,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,return -ENOMEM ; } - ret =v3d_job_init (v3d, file_priv, clean_job, v3d_job_free,0 ); + ret =v3d_job_init (v3d, file_priv, clean_job, v3d_job_free,0 ,V3D_CACHE_CLEAN );if (ret) {v3d_job_put (&job->base);kfree (clean_job);@@ -830,18 +818,14 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, goto fail;mutex_lock (&v3d->sched_lock); - ret =v3d_push_job (v3d_priv, &job->base,V3D_CSD ); -if (ret) - goto fail_unreserve; +v3d_push_job (&job->base); ret =drm_gem_fence_array_add (&clean_job->deps,dma_fence_get (job->base.done_fence));if (ret) goto fail_unreserve; - ret =v3d_push_job (v3d_priv, clean_job,V3D_CACHE_CLEAN ); -if (ret) - goto fail_unreserve; +v3d_push_job (clean_job);mutex_unlock (&v3d->sched_lock); v3d_attach_fences_and_unlock_reservation(file_priv,@@ -860,8 +844,8 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,drm_gem_unlock_reservations (clean_job->bo, clean_job->bo_count, &acquire_ctx); fail: -v3d_job_put (&job->base); -v3d_job_put (clean_job); +v3d_job_cleanup (&job->base); +v3d_job_cleanup (clean_job);return ret; }drivers/gpu/drm/v3d/v3d_sched.c +5
-7@@ -55,12 +55,11 @@ to_csd_job(struct drm_sched_job *sched_job) }static void -v3d_job_free (struct drm_sched_job *sched_job) +v3d_sched_job_free (struct drm_sched_job *sched_job) {struct v3d_job *job =to_v3d_job (sched_job); -drm_sched_job_cleanup (sched_job); -v3d_job_put (job); +v3d_job_cleanup (job); }/* @@ -360,35 +359,35 @@ static const struct drm_sched_backend_ops v3d_bin_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_bin_job_run, .timedout_job = v3d_bin_job_timedout, - .free_job = v3d_job_free, + .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_render_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_render_job_run, .timedout_job = v3d_render_job_timedout, - .free_job = v3d_job_free, + .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_tfu_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_tfu_job_run, .timedout_job = v3d_generic_job_timedout, - .free_job = v3d_job_free, + .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_csd_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_csd_job_run, .timedout_job = v3d_csd_job_timedout, - .free_job = v3d_job_free
drivers/gpu/drm/v3d/v3d_sched.c static const struct drm_sched_backend_ops v3d_bin_sched_ops = { · line 391
Quoted 10 lines
drivers/gpu/drm/v3d/v3d_sched.c +2
-1+ .free_job = v3d_sched_job_free };static const struct drm_sched_backend_ops v3d_cache_clean_sched_ops = { .dependency = v3d_job_dependency, .run_job = v3d_cache_clean_job_run, .timedout_job = v3d_generic_job_timedout, - .free_job = v3d_job_free + .free_job = v3d_sched_job_free };
Hi Daniel,
lgtm too.
Thanks,
Melissa
Quoted 5 lines
drivers/gpu/drm/v3d/v3d_sched.c +0
-0int Signature · 1 line
2.32.0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 9/18 drm/v3d: Use scheduler dependency handling
In reply to Daniel VetterWith the prep work out of the way this isn't tricky anymore.
Aside: The chaining of the various jobs is a bit awkward, with the possibility of failure in bad places. I think with the drm_sched_job_init/arm split and maybe preloading the job->dependencies xarray this should be fixable.
--- drivers/gpu/drm/v3d/v3d_drv.h | 5 ----- drivers/gpu/drm/v3d/v3d_gem.c | 25 ++++++++----------------- drivers/gpu/drm/v3d/v3d_sched.c | 29 +---------------------------- 3 files changed, 9 insertions(+), 50 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +0 -5
@@ -192,11 +192,6 @@ struct v3d_job {struct drm_gem_object **bo;u32 bo_count; -/* Array of struct dma_fence * to block on before submitting this job. -*/ -struct xarray deps; -unsigned long last_dep; -/* v3d fence to be signaled by IRQ handler when the job is complete. */ struct dma_fence *irq_fence;
drivers/gpu/drm/v3d/v3d_gem.c +8 -17
@@ -257,8 +257,8 @@ v3d_lock_bo_reservations(struct v3d_job *job,return ret;for (i =0 ; i < job->bo_count; i++) { - ret =drm_gem_fence_array_add_implicit (&job->deps, - job->bo[i], true); + ret =drm_sched_job_await_implicit (&job->base, + job->bo[i], true);if (ret) {drm_gem_unlock_reservations (job->bo, job->bo_count, acquire_ctx);
@@ -354,8 +354,6 @@ static void v3d_job_free(struct kref *ref) { struct v3d_job *job = container_of(ref, struct v3d_job, refcount); -unsigned long index; -struct dma_fence *fence;int i;for (i =0 ; i < job->bo_count; i++) {
@@ -364,11 +362,6 @@ v3d_job_free(struct kref *ref) }kvfree (job->bo); -xa_for_each (&job->deps, index, fence) { -dma_fence_put (fence); - } -xa_destroy (&job->deps); -dma_fence_put (job->irq_fence);dma_fence_put (job->done_fence);
@@ -452,7 +445,6 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,if (ret <0 )return ret; -xa_init_flags (&job->deps,XA_FLAGS_ALLOC ); ret =drm_sched_job_init (&job->base, &v3d_priv->sched_entity[queue], v3d_priv);if (ret)
@@ -462,7 +454,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,if (ret == -EINVAL ) goto fail_job; - ret =drm_gem_fence_array_add (&job->deps, in_fence); + ret =drm_sched_job_await_fence (&job->base, in_fence);if (ret) goto fail_job;
@@ -472,7 +464,6 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, fail_job:drm_sched_job_cleanup (&job->base); fail: -xa_destroy (&job->deps);pm_runtime_put_autosuspend (v3d->drm.dev);return ret; }
@@ -619,8 +610,8 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,if (bin) {v3d_push_job (&bin->base); - ret =drm_gem_fence_array_add (&render->base.deps, -dma_fence_get (bin->base.done_fence)); + ret =drm_sched_job_await_fence (&render->base.base, +dma_fence_get (bin->base.done_fence));if (ret) goto fail_unreserve; }
@@ -630,7 +621,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,if (clean_job) {struct dma_fence *render_fence =dma_fence_get (render->base.done_fence); - ret =drm_gem_fence_array_add (&clean_job->deps, render_fence); + ret =drm_sched_job_await_fence (&clean_job->base, render_fence);if (ret) goto fail_unreserve;v3d_push_job (clean_job);
@@ -820,8 +811,8 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,mutex_lock (&v3d->sched_lock);v3d_push_job (&job->base); - ret =drm_gem_fence_array_add (&clean_job->deps, -dma_fence_get (job->base.done_fence)); + ret =drm_sched_job_await_fence (&clean_job->base, +dma_fence_get (job->base.done_fence));if (ret) goto fail_unreserve;
drivers/gpu/drm/v3d/v3d_sched.c +1 -28
@@ -13,7 +13,7 @@* jobs when bulk background jobs are queued up, we submit a new job * to the HW only when it has completed the last one, instead of * filling up the CT[01]Q FIFOs with jobs. Similarly, we use -* v3d_job_dependency() to manage the dependency between bin and +* drm_sched_job_await_fence() to manage the dependency between bin and * render, instead of having the clients submit jobs using the HW's * semaphores to interlock between them. */
@@ -62,28 +62,6 @@ v3d_sched_job_free(struct drm_sched_job *sched_job)v3d_job_cleanup (job); } -/* -* Returns the fences that the job depends on, one by one. -* -* If placed in the scheduler's .dependency method, the corresponding -* .run_job won't be called until all of them have been signaled. -*/ -static struct dma_fence * -v3d_job_dependency (struct drm_sched_job *sched_job, -struct drm_sched_entity *s_entity) -{ -struct v3d_job *job =to_v3d_job (sched_job); - -/* XXX: Wait on a fence for switching the GMP if necessary, -* and then do so. -*/ - -if (!xa_empty (&job->deps)) -return xa_erase (&job->deps, job->last_dep++); - -return NULL ; -} -static struct dma_fence *v3d_bin_job_run (struct drm_sched_job *sched_job) {struct v3d_bin_job *job =to_bin_job (sched_job);
@@ -356,35 +334,30 @@ v3d_csd_job_timedout(struct drm_sched_job *sched_job) }static const struct drm_sched_backend_ops v3d_bin_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_bin_job_run, .timedout_job = v3d_bin_job_timedout, .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_render_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_render_job_run, .timedout_job = v3d_render_job_timedout, .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_tfu_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_tfu_job_run, .timedout_job = v3d_generic_job_timedout, .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_csd_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_csd_job_run, .timedout_job = v3d_csd_job_timedout, .free_job = v3d_sched_job_free };static const struct drm_sched_backend_ops v3d_cache_clean_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_cache_clean_job_run, .timedout_job = v3d_generic_job_timedout, .free_job = v3d_sched_job_free
Signature · 6 lines
2.32.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 09/18] drm/v3d: Use scheduler dependency handling
Quoted 192 lines · Daniel Vetter
With the prep work out of the way this isn't tricky anymore.
Aside: The chaining of the various jobs is a bit awkward, with the possibility of failure in bad places. I think with the drm_sched_job_init/arm split and maybe preloading the
job->dependenciesxarray this should be fixable.Cc Melissa Wen <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Cc: Emma Anholt <[email protected]>--- drivers/gpu/drm/v3d/v3d_drv.h | 5 ----- drivers/gpu/drm/v3d/v3d_gem.c | 25 ++++++++----------------- drivers/gpu/drm/v3d/v3d_sched.c | 29 +---------------------------- 3 files changed, 9 insertions(+), 50 deletions(-)drivers/gpu/drm/v3d/v3d_drv.h +0
-5@@ -192,11 +192,6 @@ struct v3d_job {struct drm_gem_object **bo;u32 bo_count; -/* Array of struct dma_fence * to block on before submitting this job. -*/ -struct xarray deps; -unsigned long last_dep; -/* v3d fence to be signaled by IRQ handler when the job is complete. */ struct dma_fence *irq_fence;drivers/gpu/drm/v3d/v3d_gem.c +8
-17@@ -257,8 +257,8 @@ v3d_lock_bo_reservations(struct v3d_job *job,return ret;for (i =0 ; i < job->bo_count; i++) { - ret =drm_gem_fence_array_add_implicit (&job->deps, - job->bo[i], true); + ret =drm_sched_job_await_implicit (&job->base, + job->bo[i], true);if (ret) {drm_gem_unlock_reservations (job->bo, job->bo_count, acquire_ctx);@@ -354,8 +354,6 @@ static void v3d_job_free(struct kref *ref) { struct v3d_job *job = container_of(ref, struct v3d_job, refcount); -unsigned long index; -struct dma_fence *fence;int i;for (i =0 ; i < job->bo_count; i++) {@@ -364,11 +362,6 @@ v3d_job_free(struct kref *ref) }kvfree (job->bo); -xa_for_each (&job->deps, index, fence) { -dma_fence_put (fence); - } -xa_destroy (&job->deps); -dma_fence_put (job->irq_fence);dma_fence_put (job->done_fence);@@ -452,7 +445,6 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,if (ret <0 )return ret; -xa_init_flags (&job->deps,XA_FLAGS_ALLOC ); ret =drm_sched_job_init (&job->base, &v3d_priv->sched_entity[queue], v3d_priv);if (ret)@@ -462,7 +454,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,if (ret == -EINVAL ) goto fail_job; - ret =drm_gem_fence_array_add (&job->deps, in_fence); + ret =drm_sched_job_await_fence (&job->base, in_fence);if (ret) goto fail_job;@@ -472,7 +464,6 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, fail_job:drm_sched_job_cleanup (&job->base); fail: -xa_destroy (&job->deps);pm_runtime_put_autosuspend (v3d->drm.dev);return ret; }@@ -619,8 +610,8 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,if (bin) {v3d_push_job (&bin->base); - ret =drm_gem_fence_array_add (&render->base.deps, -dma_fence_get (bin->base.done_fence)); + ret =drm_sched_job_await_fence (&render->base.base, +dma_fence_get (bin->base.done_fence));if (ret) goto fail_unreserve; }@@ -630,7 +621,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,if (clean_job) {struct dma_fence *render_fence =dma_fence_get (render->base.done_fence); - ret =drm_gem_fence_array_add (&clean_job->deps, render_fence); + ret =drm_sched_job_await_fence (&clean_job->base, render_fence);if (ret) goto fail_unreserve;v3d_push_job (clean_job);@@ -820,8 +811,8 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,mutex_lock (&v3d->sched_lock);v3d_push_job (&job->base); - ret =drm_gem_fence_array_add (&clean_job->deps, -dma_fence_get (job->base.done_fence)); + ret =drm_sched_job_await_fence (&clean_job->base, +dma_fence_get (job->base.done_fence));if (ret) goto fail_unreserve;drivers/gpu/drm/v3d/v3d_sched.c +1
-27@@ -13,7 +13,7 @@* jobs when bulk background jobs are queued up, we submit a new job * to the HW only when it has completed the last one, instead of * filling up the CT[01]Q FIFOs with jobs. Similarly, we use -* v3d_job_dependency() to manage the dependency between bin and +* drm_sched_job_await_fence() to manage the dependency between bin and * render, instead of having the clients submit jobs using the HW's * semaphores to interlock between them. */ @@ -62,28 +62,6 @@ v3d_sched_job_free(struct drm_sched_job *sched_job)v3d_job_cleanup (job); } -/* -* Returns the fences that the job depends on, one by one. -* -* If placed in the scheduler's .dependency method, the corresponding -* .run_job won't be called until all of them have been signaled. -*/ -static struct dma_fence * -v3d_job_dependency (struct drm_sched_job *sched_job, -struct drm_sched_entity *s_entity) -{ -struct v3d_job *job =to_v3d_job (sched_job); - -/* XXX: Wait on a fence for switching the GMP if necessary, -* and then do so. -*/ - -if (!xa_empty (&job->deps)) -return xa_erase (&job->deps, job->last_dep++); - -return NULL ; -} -static struct dma_fence *v3d_bin_job_run (struct drm_sched_job *sched_job) {struct v3d_bin_job *job =to_bin_job (sched_job);@@ -356,35 +334,30 @@ v3d_csd_job_timedout(struct drm_sched_job *sched_job) }static const struct drm_sched_backend_ops v3d_bin_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_bin_job_run, .timedout_job = v3d_bin_job_timedout, .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_render_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_render_job_run, .timedout_job = v3d_render_job_timedout, .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_tfu_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_tfu_job_run, .timedout_job = v3d_generic_job_timedout, .free_job = v3d_sched_job_free, };static const struct drm_sched_backend_ops v3d_csd_sched_ops = { - .dependency = v3d_job_dependency,
drivers/gpu/drm/v3d/v3d_sched.c v3d_csd_job_timedout(struct drm_sched_job *sched_job) · line 363
Quoted 10 lines
drivers/gpu/drm/v3d/v3d_sched.c +0
-1.run_job = v3d_csd_job_run, .timedout_job = v3d_csd_job_timedout, .free_job = v3d_sched_job_free };static const struct drm_sched_backend_ops v3d_cache_clean_sched_ops = { - .dependency = v3d_job_dependency, .run_job = v3d_cache_clean_job_run, .timedout_job = v3d_generic_job_timedout, .free_job = v3d_sched_job_free
Also here.
Quoted 3 lines
Signature · 1 line
2.32.0
PATCH v4 10/18 drm/etnaviv: Use scheduler dependency handling
In reply to Daniel VetterWe need to pull the drm_sched_job_init much earlier, but that's very minor surgery.
v2: Actually fix up cleanup paths by calling drm_sched_job_init, which I wanted to to in the previous round (and did, for all other drivers). Spotted by Lucas.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.h | 5 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 58 +++++++++--------- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 63 +------------------- drivers/gpu/drm/etnaviv/etnaviv_sched.h | 3 +- 4 files changed, 35 insertions(+), 94 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.h +1 -4
@@ -80,9 +80,6 @@ struct etnaviv_gem_submit_bo {u64 va;struct etnaviv_gem_object *obj;struct etnaviv_vram_mapping *mapping; -struct dma_fence *excl; -unsigned int nr_shared; -struct dma_fence **shared; };/* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
@@ -95,7 +92,7 @@ struct etnaviv_gem_submit {struct etnaviv_file_private *ctx;struct etnaviv_gpu *gpu;struct etnaviv_iommu_context *mmu_context, *prev_mmu_context; -struct dma_fence *out_fence, *in_fence; +struct dma_fence *out_fence;int out_fence_id;struct list_head node;/* GPU active submit list */ struct etnaviv_cmdbuf cmdbuf;
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +31 -27
127 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_sched.c +2 -61
89 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_sched.h +1 -2
@@ -18,7 +18,6 @@ struct etnaviv_gem_submit *to_etnaviv_submit(struct drm_sched_job *sched_job)int etnaviv_sched_init (struct etnaviv_gpu *gpu);void etnaviv_sched_fini (struct etnaviv_gpu *gpu); -int etnaviv_sched_push_job (struct drm_sched_entity *sched_entity, -struct etnaviv_gem_submit *submit); +int etnaviv_sched_push_job (struct etnaviv_gem_submit *submit);#endif /* __ETNAVIV_SCHED_H__ */
Signature · 1 line
2.32.0
PATCH v4 11/18 drm/gem: Delete gem array fencing helpers
In reply to Daniel VetterIntegrated into the scheduler now and all users converted over.
--- drivers/gpu/drm/drm_gem.c | 96 --------------------------------------- include/drm/drm_gem.h | 5 -- 2 files changed, 101 deletions(-)
drivers/gpu/drm/drm_gem.c +0 -96
@@ -1294,99 +1294,3 @@ drm_gem_unlock_reservations(struct drm_gem_object **objs, int count,ww_acquire_fini (acquire_ctx); }EXPORT_SYMBOL (drm_gem_unlock_reservations); - -/** -* drm_gem_fence_array_add - Adds the fence to an array of fences to be -* waited on, deduplicating fences from the same context. -* -* @fence_array: array of dma_fence * for the job to block on. -* @fence: the dma_fence to add to the list of dependencies. -* -* This functions consumes the reference for @fence both on success and error -* cases. -* -* Returns: -* 0 on success, or an error on failing to expand the array. -*/ -int drm_gem_fence_array_add (struct xarray *fence_array, -struct dma_fence *fence) -{ -struct dma_fence *entry; -unsigned long index; -u32 id =0 ; -int ret; - -if (!fence) -return 0 ; - -/* Deduplicate if we already depend on a fence from the same context. -* This lets the size of the array of deps scale with the number of -* engines involved, rather than the number of BOs. -*/ -xa_for_each (fence_array, index, entry) { -if (entry->context != fence->context) -continue ; - -if (dma_fence_is_later (fence, entry)) { -dma_fence_put (entry); -xa_store (fence_array, index, fence,GFP_KERNEL ); - }else { -dma_fence_put (fence); - } -return 0 ; - } - - ret =xa_alloc (fence_array, &id, fence, xa_limit_32b,GFP_KERNEL ); -if (ret !=0 ) -dma_fence_put (fence); - -return ret; -} -EXPORT_SYMBOL (drm_gem_fence_array_add); - -/** -* drm_gem_fence_array_add_implicit - Adds the implicit dependencies tracked -* in the GEM object's reservation object to an array of dma_fences for use in -* scheduling a rendering job. -* -* This should be called after drm_gem_lock_reservations() on your array of -* GEM objects used in the job but before updating the reservations with your -* own fences. -* -* @fence_array: array of dma_fence * for the job to block on. -* @obj: the gem object to add new dependencies from. -* @write: whether the job might write the object (so we need to depend on -* shared fences in the reservation object). -*/ -int drm_gem_fence_array_add_implicit (struct xarray *fence_array, -struct drm_gem_object *obj, -bool write) -{ -int ret; -struct dma_fence **fences; -unsigned int i, fence_count; - -if (!write) { -struct dma_fence *fence = -dma_resv_get_excl_unlocked (obj->resv); - -return drm_gem_fence_array_add (fence_array, fence); - } - - ret =dma_resv_get_fences (obj->resv,NULL , - &fence_count, &fences); -if (ret || !fence_count) -return ret; - -for (i =0 ; i < fence_count; i++) { - ret =drm_gem_fence_array_add (fence_array, fences[i]); -if (ret) -break ; - } - -for (; i < fence_count; i++) -dma_fence_put (fences[i]); -kfree (fences); -return ret; -} -EXPORT_SYMBOL (drm_gem_fence_array_add_implicit);
include/drm/drm_gem.h +0 -5
@@ -409,11 +409,6 @@ int drm_gem_lock_reservations(struct drm_gem_object **objs, int count, struct ww_acquire_ctx *acquire_ctx);void drm_gem_unlock_reservations (struct drm_gem_object **objs,int count,struct ww_acquire_ctx *acquire_ctx); -int drm_gem_fence_array_add (struct xarray *fence_array, -struct dma_fence *fence); -int drm_gem_fence_array_add_implicit (struct xarray *fence_array, -struct drm_gem_object *obj, -bool write);int drm_gem_dumb_map_offset (struct drm_file *file,struct drm_device *dev,u32 handle,u64 *offset);
Signature · 1 line
2.32.0
PATCH v4 12/18 drm/sched: Don't store self-dependencies
In reply to Daniel VetterThis is essentially part of drm_sched_dependency_optimized(), which only amdgpu seems to make use of. Use it a bit more.
This would mean that as-is amdgpu can't use the dependency helpers, at least not with the current approach amdgpu has for deciding whether a vm_flush is needed. Since amdgpu also has very special rules around implicit fencing it can't use those helpers either, and adding a drm_sched_job_await_fence_always or similar for amdgpu wouldn't be too onerous. That way the special case handling for amdgpu sticks even more out and we have higher chances that reviewers that go across all drivers wont miss it.
--- drivers/gpu/drm/scheduler/sched_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +7 -0
@@ -660,6 +660,13 @@ int drm_sched_job_await_fence(struct drm_sched_job *job,if (!fence)return 0 ; +/* if it's a fence from us it's guaranteed to be earlier */ +if (fence->context == job->entity->fence_context || + fence->context == job->entity->fence_context +1 ) { +dma_fence_put (fence); +return 0 ; + } +/* Deduplicate if we already depend on a fence from the same context. * This lets the size of the array of deps scale with the number of * engines involved, rather than the number of BOs.
Signature · 1 line
2.32.0
PATCH v4 13/18 drm/sched: Check locking in drm_sched_job_await_implicit
In reply to Daniel VetterYou really need to hold the reservation here or all kinds of funny things can happen between grabbing the dependencies and inserting the new fences.
--- drivers/gpu/drm/scheduler/sched_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +2 -0
@@ -714,6 +714,8 @@ int drm_sched_job_await_implicit(struct drm_sched_job *job,struct dma_fence **fences;unsigned int i, fence_count; +dma_resv_assert_held (obj->resv); +if (!write) {struct dma_fence *fence =dma_resv_get_excl_unlocked (obj->resv);
Signature · 6 lines
2.32.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 14/18 drm/msm: Don't break exclusive fence ordering
In reply to Daniel VetterThere's only one exclusive slot, and we must not break the ordering.
Adding a new exclusive fence drops all previous fences from the dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.
A better fix would be to us a dma_fence_chain or _array like e.g. amdgpu now uses, but
- msm has a synchronous dma_fence_wait for anything from another context, so doesn't seem to care much,
- and it probably makes sense to lift this into dma-resv.c code as a proper concept, so that drivers don't have to hack up their own solution each on their own.
v2: Improve commit message per Lucas' suggestion.
--- drivers/gpu/drm/msm/msm_gem_submit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gem_submit.c +2 -1
@@ -306,7 +306,8 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)return ret; } -if (no_implicit) +/* exclusive fences must be ordered */ +if (no_implicit && !write)continue ; ret = msm_gem_sync_object(&msm_obj->base, submit->ring->fctx,
Signature · 1 line
2.32.0
Re: [PATCH v4 14/18] drm/msm: Don't break exclusive fence ordering
Quoted 33 lines · Daniel Vetter
There's only one exclusive slot, and we must not break the ordering.
Adding a new exclusive fence drops all previous fences from the
dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.A better fix would be to us a
dma_fence_chainor_arraylike e.g. amdgpu now uses, but
- msm has a synchronousdma_fence_waitfor anything from another context, so doesn't seem to care much,
- and it probably makes sense to lift this intodma-resv.ccode as a proper concept, so that drivers don't have to hack up their own solution each on their own.v2: Improve commit message per Lucas' suggestion.
Cc Lucas Stach <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Sean Paul <[email protected]>--- drivers/gpu/drm/msm/msm_gem_submit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/msm_gem_submit.c +0
-0
drivers/gpu/drm/msm/msm_gem_submit.c static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) · line 311
Quoted 7 lines
drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -306,7 +306,8 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)return ret; } -if (no_implicit) +/* exclusive fences must be ordered */ +if (no_implicit && !write)continue ;
In practice, modern userspace (the kind that is more likely to set the no-implicit flag on every submit) also sets MSM_SUBMIT_BO_WRITE on every bo, to shave some cpu overhead so I suppose this would not really hurt anything
Do you know if this is covered in any piglit/etc test?
BR,
-R
Quoted 5 lines
drivers/gpu/drm/msm/msm_gem_submit.c +0
-1ret = msm_gem_sync_object(&msm_obj->base, submit->ring->fctx, --2.32.0
Re: [PATCH v4 14/18] drm/msm: Don't break exclusive fence ordering
Quoted 48 lines · Rob Clark
Quoted 33 lines · Daniel Vetter
There's only one exclusive slot, and we must not break the ordering.
Adding a new exclusive fence drops all previous fences from the
dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.A better fix would be to us a
dma_fence_chainor_arraylike e.g. amdgpu now uses, but
- msm has a synchronousdma_fence_waitfor anything from another context, so doesn't seem to care much,
- and it probably makes sense to lift this intodma-resv.ccode as a proper concept, so that drivers don't have to hack up their own solution each on their own.v2: Improve commit message per Lucas' suggestion.
Cc Lucas Stach <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Sean Paul <[email protected]>--- drivers/gpu/drm/msm/msm_gem_submit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/msm_gem_submit.c +0
-0drivers/gpu/drm/msm/msm_gem_submit.c static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) · line 311
Quoted 7 lines
drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -306,7 +306,8 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)return ret; } -if (no_implicit) +/* exclusive fences must be ordered */ +if (no_implicit && !write)continue ;In practice, modern userspace (the kind that is more likely to set the no-implicit flag on every submit) also sets
MSM_SUBMIT_BO_WRITEon every bo, to shave some cpu overhead so I suppose this would not really hurt anything
Quoted 1 line
Do you know if this is covered in any piglit/etc test?
You need some command submission, plus buffer sharing with vgem setting it's own exclusive fences, plus checking with dma_buf poll() whether it signals all in the right order. That's pretty low-level, so maybe something in igt, but I haven't typed that. Maybe I need to do that for i915 at least.
-Daniel
Quoted 8 lines
BR,
-RQuoted 5 lines
drivers/gpu/drm/msm/msm_gem_submit.c +0
-1ret = msm_gem_sync_object(&msm_obj->base, submit->ring->fctx, --2.32.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v4 14/18] drm/msm: Don't break exclusive fence ordering
Quoted 50 lines · Daniel Vetter
Quoted 48 lines · Rob Clark
Quoted 33 lines · Daniel Vetter
There's only one exclusive slot, and we must not break the ordering.
Adding a new exclusive fence drops all previous fences from the
dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.A better fix would be to us a
dma_fence_chainor_arraylike e.g. amdgpu now uses, but
- msm has a synchronousdma_fence_waitfor anything from another context, so doesn't seem to care much,
- and it probably makes sense to lift this intodma-resv.ccode as a proper concept, so that drivers don't have to hack up their own solution each on their own.v2: Improve commit message per Lucas' suggestion.
Cc Lucas Stach <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Sean Paul <[email protected]>--- drivers/gpu/drm/msm/msm_gem_submit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/msm_gem_submit.c +0
-0drivers/gpu/drm/msm/msm_gem_submit.c static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) · line 311
Quoted 7 lines
drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -306,7 +306,8 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)return ret; } -if (no_implicit) +/* exclusive fences must be ordered */ +if (no_implicit && !write)continue ;In practice, modern userspace (the kind that is more likely to set the no-implicit flag on every submit) also sets
MSM_SUBMIT_BO_WRITEon every bo, to shave some cpu overhead so I suppose this would not really hurt anything
Quoted 7 lines
Quoted 1 line
Do you know if this is covered in any piglit/etc test?
You need some command submission, plus buffer sharing with vgem setting it's own exclusive fences, plus checking with
dma_bufpoll()whether it signals all in the right order. That's pretty low-level, so maybe something in igt, but I haven't typed that. Maybe I need to do that for i915 at least.
ok, you lost me at vgem ;-)
(the vgem vs cache situation on arm is kinda hopeless)
BR,
-R
Quoted 17 lines
-Daniel
Quoted 8 lines
BR,
-RQuoted 5 lines
drivers/gpu/drm/msm/msm_gem_submit.c +0
-1ret = msm_gem_sync_object(&msm_obj->base, submit->ring->fctx, --2.32.0
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Re: [PATCH v4 14/18] drm/msm: Don't break exclusive fence ordering
Quoted 59 lines · Rob Clark
Quoted 50 lines · Daniel Vetter
Quoted 48 lines · Rob Clark
Quoted 33 lines · Daniel Vetter
There's only one exclusive slot, and we must not break the ordering.
Adding a new exclusive fence drops all previous fences from the
dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.A better fix would be to us a
dma_fence_chainor_arraylike e.g. amdgpu now uses, but
- msm has a synchronousdma_fence_waitfor anything from another context, so doesn't seem to care much,
- and it probably makes sense to lift this intodma-resv.ccode as a proper concept, so that drivers don't have to hack up their own solution each on their own.v2: Improve commit message per Lucas' suggestion.
Cc Lucas Stach <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Sean Paul <[email protected]>--- drivers/gpu/drm/msm/msm_gem_submit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/msm_gem_submit.c +0
-0drivers/gpu/drm/msm/msm_gem_submit.c static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) · line 311
Quoted 7 lines
drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -306,7 +306,8 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)return ret; } -if (no_implicit) +/* exclusive fences must be ordered */ +if (no_implicit && !write)continue ;In practice, modern userspace (the kind that is more likely to set the no-implicit flag on every submit) also sets
MSM_SUBMIT_BO_WRITEon every bo, to shave some cpu overhead so I suppose this would not really hurt anythingQuoted 7 lines
Quoted 1 line
Do you know if this is covered in any piglit/etc test?
You need some command submission, plus buffer sharing with vgem setting it's own exclusive fences, plus checking with
dma_bufpoll()whether it signals all in the right order. That's pretty low-level, so maybe something in igt, but I haven't typed that. Maybe I need to do that for i915 at least.
Quoted 3 lines
ok, you lost me at vgem ;-)
(the vgem vs cache situation on arm is kinda hopeless)
Oh that explains a few things ... I just found out why vgem is failing for wc buffers on x86 (on some of our less-coherent igpu at least), and wondered how the heck this works on arm. Sounds like it just doesn't :-/
On the testcase: You'd never actually check buffer contents, only fences, so the test would still work.
-Daniel
Quoted 21 lines
BR,
-RQuoted 17 lines
-Daniel
Quoted 8 lines
BR,
-RQuoted 5 lines
drivers/gpu/drm/msm/msm_gem_submit.c +0
-1ret = msm_gem_sync_object(&msm_obj->base, submit->ring->fctx, --2.32.0
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH v4 15/18 drm/etnaviv: Don't break exclusive fence ordering
In reply to Daniel VetterThere's only one exclusive slot, and we must not break the ordering. Adding a new exclusive fence drops all previous fences from the dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.
A better fix would be to us a dma_fence_chain or _array like e.g. amdgpu now uses, but it probably makes sense to lift this into dma-resv.c code as a proper concept, so that drivers don't have to hack up their own solution each on their own. Hence go with the simple fix for now.
Another option is the fence import ioctl from Jason:
https://lore.kernel.org/dri-devel/[email protected]/
v2: Improve commit message per Lucas' suggestion.
--- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +5 -3
@@ -178,18 +178,20 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)for (i =0 ; i < submit->nr_bos; i++) {struct etnaviv_gem_submit_bo *bo = &submit->bos[i];struct dma_resv *robj = bo->obj->base.resv; +bool write = bo->flags &ETNA_SUBMIT_BO_WRITE ; -if (!(bo->flags &ETNA_SUBMIT_BO_WRITE )) { +if (!(write)) { ret =dma_resv_reserve_shared (robj,1 );if (ret)return ret; } -if (submit->flags &ETNA_SUBMIT_NO_IMPLICIT ) +/* exclusive fences must be ordered */ +if (submit->flags &ETNA_SUBMIT_NO_IMPLICIT && !write)continue ; ret =drm_sched_job_await_implicit (&submit->sched_job, &bo->obj->base, - bo->flags &ETNA_SUBMIT_BO_WRITE ); + write);if (ret)return ret; }
Signature · 1 line
2.32.0
PATCH v4 16/18 drm/i915: delete exclude argument from i915_sw_fence_await_reservation
In reply to Daniel VetterNo longer used, the last user disappeared with
commit d07f0e59b2c762584478920cd2d11fba2980a94a
Author: Chris Wilson <[email protected]> Date: Fri Oct 28 13:58:44 2016 +0100
drm/i915: Move GEM activity tracking into a common struct reservation_object
--- drivers/gpu/drm/i915/display/intel_display.c | 4 ++-- drivers/gpu/drm/i915/gem/i915_gem_clflush.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 +- drivers/gpu/drm/i915/i915_sw_fence.c | 6 +----- drivers/gpu/drm/i915/i915_sw_fence.h | 1 - 5 files changed, 5 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +2 -2
@@ -11119,7 +11119,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,*/ if (intel_crtc_needs_modeset (crtc_state)) { ret =i915_sw_fence_await_reservation (&state->commit_ready, - old_obj->base.resv,NULL , + old_obj->base.resv, false,0 ,GFP_KERNEL );if (ret <0 )
@@ -11153,7 +11153,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,struct dma_fence *fence; ret =i915_sw_fence_await_reservation (&state->commit_ready, - obj->base.resv,NULL , + obj->base.resv, false,i915_fence_timeout (dev_priv),GFP_KERNEL );
drivers/gpu/drm/i915/gem/i915_gem_clflush.c +1 -1
@@ -106,7 +106,7 @@ bool i915_gem_clflush_object(struct drm_i915_gem_object *obj, clflush =clflush_work_create (obj);if (clflush) {i915_sw_fence_await_reservation (&clflush->base.chain, - obj->base.resv,NULL , true, + obj->base.resv, true,i915_fence_timeout (to_i915 (obj->base.dev)),I915_FENCE_GFP );dma_resv_add_excl_fence (obj->base.resv, &clflush->base.dma);
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +1 -1
@@ -2087,7 +2087,7 @@ static int eb_parse_pipeline(struct i915_execbuffer *eb,/* Wait for all writes (and relocs) into the batch to complete */ err =i915_sw_fence_await_reservation (&pw->base.chain, - pw->batch->resv,NULL , false, + pw->batch->resv, false,0 ,I915_FENCE_GFP );if (err <0 ) goto err_commit;
drivers/gpu/drm/i915/i915_sw_fence.c +1 -5
@@ -567,7 +567,6 @@ int __i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,int i915_sw_fence_await_reservation (struct i915_sw_fence *fence,struct dma_resv *resv, -const struct dma_fence_ops *exclude,bool write,unsigned long timeout,gfp_t gfp)
@@ -587,9 +586,6 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence,return ret;for (i =0 ; i < count; i++) { -if (shared[i]->ops == exclude) -continue ; - pending = i915_sw_fence_await_dma_fence(fence, shared[i], timeout,
@@ -609,7 +605,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, excl =dma_resv_get_excl_unlocked (resv); } -if (ret >=0 && excl && excl->ops != exclude) { +if (ret >=0 && excl) { pending = i915_sw_fence_await_dma_fence(fence, excl, timeout,
drivers/gpu/drm/i915/i915_sw_fence.h +0 -1
@@ -86,7 +86,6 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,int i915_sw_fence_await_reservation (struct i915_sw_fence *fence,struct dma_resv *resv, -const struct dma_fence_ops *exclude,bool write,unsigned long timeout,gfp_t gfp);
Signature · 6 lines
2.32.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 17/18 drm/i915: Don't break exclusive fence ordering
In reply to Daniel VetterThere's only one exclusive slot, and we must not break the ordering. Adding a new exclusive fence drops all previous fences from the dma_resv. To avoid violating the signalling order we err on the side of over-synchronizing by waiting for the existing fences, even if userspace asked us to ignore them.
A better fix would be to us a dma_fence_chain or _array like e.g. amdgpu now uses, but it probably makes sense to lift this into dma-resv.c code as a proper concept, so that drivers don't have to hack up their own solution each on their own. Hence go with the simple fix for now.
Another option is the fence import ioctl from Jason:
https://lore.kernel.org/dri-devel/[email protected]/
v2: Improve commit message per Lucas' suggestion.
--- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +5 -1
@@ -1767,6 +1767,7 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)struct i915_vma *vma = ev->vma;unsigned int flags = ev->flags;struct drm_i915_gem_object *obj = vma->obj; +bool async, write;assert_vma_held (vma);
@@ -1798,7 +1799,10 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb) flags &= ~EXEC_OBJECT_ASYNC ; } -if (err ==0 && !(flags &EXEC_OBJECT_ASYNC )) { + async = flags &EXEC_OBJECT_ASYNC ; + write = flags &EXEC_OBJECT_WRITE ; + +if (err ==0 && (!async || write)) { err =i915_request_await_object (eb->request, obj, flags &EXEC_OBJECT_WRITE ); }
Signature · 6 lines
2.32.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 18/18 dma-resv: Give the docs a do-over
In reply to Daniel VetterSpecifically document the new/clarified rules around how the shared fences do not have any ordering requirements against the exclusive fence.
But also document all the things a bit better, given how central struct dma_resv to dynamic buffer management the docs have been very inadequat.
- Lots more links to other pieces of the puzzle. Unfortunately ttm_buffer_object has no docs, so no links :-(
- Explain/complain a bit about dma_resv_locking_ctx(). I still don't like that one, but fixing the ttm call chains is going to be horrible. Plus we want to plug in real slowpath locking when we do that anyway.
- Main part of the patch is some actual docs for struct dma_resv.
Overall I think we still have a lot of bad naming in this area (e.g. dma_resv.fence is singular, but contains the multiple shared fences), but I think that's more indicative of how the semantics and rules are just not great.
Another thing that's real awkard is how chaining exclusive fences right now means direct dma_resv.exclusive_fence pointer access with an rcu_assign_pointer. Not so great either.
v2:
- Fix a pile of typos (Matt, Jason)
- Hammer it in that breaking the rules leads to use-after-free issues around dma-buf sharing (Christian)
--- drivers/dma-buf/dma-resv.c | 24 ++++++--- include/linux/dma-buf.h | 7 +++ include/linux/dma-resv.h | 104 +++++++++++++++++++++++++++++++++++-- 3 files changed, 124 insertions(+), 11 deletions(-)
drivers/dma-buf/dma-resv.c +18 -6
@@ -48,6 +48,8 @@* write operations) or N shared fences (read operations). The RCU * mechanism is used to protect read access to fences from locked * write-side updates. +* +* See struct dma_resv for more details. */ DEFINE_WD_CLASS (reservation_ww_class);
@@ -137,7 +139,11 @@ EXPORT_SYMBOL(dma_resv_fini);* @num_fences: number of fences we want to add * * Should be called before dma_resv_add_shared_fence(). Must -* be called with obj->lock held. +* be called with @obj locked through dma_resv_lock(). +* +* Note that the preallocated slots need to be re-reserved if @obj is unlocked +* at any time before calling dma_resv_add_shared_fence(). This is validated +* when CONFIG_DEBUG_MUTEXES is enabled. * * RETURNS * Zero for success, or -errno
@@ -234,8 +240,10 @@ EXPORT_SYMBOL(dma_resv_reset_shared_max);* @obj: the reservation object * @fence: the shared fence to add * -* Add a fence to a shared slot, obj->lock must be held, and +* Add a fence to a shared slot, @obj must be locked with dma_resv_lock(), and * dma_resv_reserve_shared() has been called. +* +* See also &dma_resv.fence for a discussion of the semantics. */ void dma_resv_add_shared_fence (struct dma_resv *obj,struct dma_fence *fence) {
@@ -278,9 +286,11 @@ EXPORT_SYMBOL(dma_resv_add_shared_fence);/** * dma_resv_add_excl_fence - Add an exclusive fence. * @obj: the reservation object -* @fence: the shared fence to add +* @fence: the exclusive fence to add * -* Add a fence to the exclusive slot. The obj->lock must be held. +* Add a fence to the exclusive slot. @obj must be locked with dma_resv_lock(). +* Note that this function replaces all fences attached to @obj, see also +* &dma_resv.fence_excl for a discussion of the semantics. */ void dma_resv_add_excl_fence (struct dma_resv *obj,struct dma_fence *fence) {
@@ -609,9 +619,11 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence)* fence * * Callers are not required to hold specific locks, but maybe hold -* dma_resv_lock() already +* dma_resv_lock() already. +* * RETURNS -* true if all fences signaled, else false +* +* True if all fences signaled, else false. */ bool dma_resv_test_signaled (struct dma_resv *obj,bool test_all) {
include/linux/dma-buf.h +7 -0
@@ -420,6 +420,13 @@ struct dma_buf {* - Dynamic importers should set fences for any access that they can't * disable immediately from their &dma_buf_attach_ops.move_notify * callback. +* +* IMPORTANT: +* +* All drivers must obey the struct dma_resv rules, specifically the +* rules for updating fences, see &dma_resv.fence_excl and +* &dma_resv.fence. If these dependency rules are broken access tracking +* can be lost resulting in use after free issues. */ struct dma_resv *resv;
include/linux/dma-resv.h +99 -5
146 lines not on this page · raw message
Signature · 1 line
2.32.0
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/sched dependency tracking and dma-resv fixes (rev3)
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: drm/sched dependency tracking and dma-resv fixes (rev3)
URL : https://patchwork.freedesktop.org/series/92333/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip fa00bbda8116 drm/sched: Split drm_sched_job_init -:210: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #210: FILE: drivers/gpu/drm/scheduler/sched_fence.c:173: + unsigned seq;
-:306: WARNING:AVOID_BUG: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #306: FILE: drivers/gpu/drm/scheduler/sched_main.c:623:
+ BUG_ON(!entity);
-:375: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #375: FILE: include/drm/gpu_scheduler.h:391:
+struct drm_sched_fence *drm_sched_fence_alloc(
-:383: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 3 warnings, 1 checks, 240 lines checkedcd01cdfb93e7 drm/sched: Barriers are needed for entity->last_scheduled
-:86: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 43 lines checked 1117822b2255 drm/sched: Add dependency tracking
-:193: CHECK:LINE_SPACING: Please don't use multiple blank lines #193: FILE: drivers/gpu/drm/scheduler/sched_main.c:728:
+
+
-:268: WARNING:TYPO_SPELLING: 'ommitted' may be misspelled - perhaps 'omitted'? #268: FILE: include/drm/gpu_scheduler.h:243:
+ * drm_sched_job_await_implicit() this can be ommitted and left as NULL.
^^^^^^^^
-:282: CHECK:LINE_SPACING: Please don't use multiple blank lines #282: FILE: include/drm/gpu_scheduler.h:376:
+
+
-:285: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 2 warnings, 2 checks, 227 lines checked8a6181903dc0 drm/sched: drop entity parameter from drm_sched_push_job
-:203: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 102 lines checkeda1900803cd8b drm/sched: improve docs around drm_sched_entity
-:14: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 620e762f9a98 ("drm/scheduler: move entity handling into separate file")' #14:
move here: 620e762f9a98 ("drm/scheduler: move entity handling into
-:396: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 1 errors, 1 warnings, 0 checks, 346 lines checked029320ff7db6 drm/panfrost: use scheduler dependency tracking
-:209: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 157 lines checkedc7f6cb0870bb drm/lima: use scheduler dependency tracking
-:114: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 73 lines checkedb021a09fdfd1 drm/v3d: Move drm_sched_job_init to v3d_job_init
-:356: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 302 lines checkedec9e93816f9b drm/v3d: Use scheduler dependency handling
-:202: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 161 lines checked f2e5d8c0db05 drm/etnaviv: Use scheduler dependency handling -:13: WARNING:REPEATED_WORD: Possible repeated word: 'to' #13:
I wanted to to in the previous round (and did, for all other drivers).
-:119: WARNING:LINE_SPACING: Missing a blank line after declarations #119: FILE: drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c:551:
+ struct dma_fence *in_fence = sync_file_get_fence(args->fence_fd);
+ if (!in_fence) {
-:293: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 3 warnings, 0 checks, 241 lines checked10bbe7e47ff2 drm/gem: Delete gem array fencing helpers
-:141: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 14 lines checked a29b9a4e9a6f drm/sched: Don't store self-dependencies
-:19: WARNING:TYPO_SPELLING: 'wont' may be misspelled - perhaps 'won't'? #19:
drivers wont miss it.
^^^^
-:47: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 2 warnings, 0 checks, 13 lines checkedbf91d1bed9e0 drm/sched: Check locking in drm_sched_job_await_implicit
-:33: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 8 lines checkedcacd99895adb drm/msm: Don't break exclusive fence ordering
-:43: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 9 lines checked62518f586849 drm/etnaviv: Don't break exclusive fence ordering
-:20: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #20:
https://lore.kernel.org/dri-devel/[email protected]/
-:57: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 2 warnings, 0 checks, 23 lines checkedd071ad427447 drm/i915: delete exclude argument from i915_sw_fence_await_reservation
-:12: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit d07f0e59b2c7 ("drm/i915: Move GEM activity tracking into a common struct reservation_object")' #12:
commit d07f0e59b2c762584478920cd2d11fba2980a94a
-:113: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 1 errors, 1 warnings, 0 checks, 63 lines checkede51083333682 drm/i915: Don't break exclusive fence ordering
-:23: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #23:
https://lore.kernel.org/dri-devel/[email protected]/
-:56: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 2 warnings, 0 checks, 18 lines checkedd021158c3459 dma-resv: Give the docs a do-over
-:290: WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address mismatch: 'From: Daniel Vetter <[email protected]>' != 'Signed-off-by: Daniel Vetter <[email protected]>'
total: 0 errors, 1 warnings, 0 checks, 216 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.BAT: success for drm/sched dependency tracking and dma-resv fixes (rev3)
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: drm/sched dependency tracking and dma-resv fixes (rev3)
URL : https://patchwork.freedesktop.org/series/92333/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_10335 -> Patchwork_20579
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/index.html
Changes
-------
No changes found
Participating hosts (40 -> 39)
------------------------------
Missing (1): fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_10335 -> Patchwork_20579
CI-20190529: 20190529
CI_DRM_10335: 6420d4c905cfd9a9098c7ab339992eafa628de4d @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6134: cd63c83e23789eb194d38b8d272247a88122f2f6 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_20579: d021158c3459d5aac4284f2c2d1ba6d2a3224523 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
d021158c3459 dma-resv: Give the docs a do-overe51083333682 drm/i915: Don't break exclusive fence ordering d071ad427447 drm/i915: delete exclude argument from i915_sw_fence_await_reservation 62518f586849 drm/etnaviv: Don't break exclusive fence ordering cacd99895adb drm/msm: Don't break exclusive fence ordering bf91d1bed9e0 drm/sched: Check locking in drm_sched_job_await_implicit a29b9a4e9a6f drm/sched: Don't store self-dependencies10bbe7e47ff2 drm/gem: Delete gem array fencing helpersf2e5d8c0db05 drm/etnaviv: Use scheduler dependency handling ec9e93816f9b drm/v3d: Use scheduler dependency handlingb021a09fdfd1 drm/v3d: Move drm_sched_job_init to v3d_job_init c7f6cb0870bb drm/lima: use scheduler dependency tracking029320ff7db6 drm/panfrost: use scheduler dependency tracking a1900803cd8b drm/sched: improve docs around drm_sched_entity 8a6181903dc0 drm/sched: drop entity parameter from drm_sched_push_job 1117822b2255 drm/sched: Add dependency trackingcd01cdfb93e7 drm/sched: Barriers are needed for entity->last_scheduled fa00bbda8116 drm/sched: Split drm_sched_job_init
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.IGT: failure for drm/sched dependency tracking and dma-resv fixes (rev3)
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: drm/sched dependency tracking and dma-resv fixes (rev3)
URL : https://patchwork.freedesktop.org/series/92333/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_10335_full -> Patchwork_20579_full
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_20579_full absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_20579_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_20579_full:
### IGT changes ###
#### Possible regressions ####
* igt@gem_exec_async@concurrent-writes@rcs0:
- shard-snb: NOTRUN -> [FAIL][1] +2 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb5/igt@gem_exec_async@[email protected]
* igt@gem_exec_async@concurrent-writes@vcs0:
- shard-iclb: [PASS][2] -> [FAIL][3]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb7/igt@gem_exec_async@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb1/igt@gem_exec_async@[email protected]
* igt@gem_exec_async@concurrent-writes@vcs1:
- shard-iclb: NOTRUN -> [FAIL][4]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb1/igt@gem_exec_async@[email protected]
* igt@gem_exec_async@concurrent-writes@vecs0:
- shard-kbl: [PASS][5] -> [FAIL][6] +2 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-kbl1/igt@gem_exec_async@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl2/igt@gem_exec_async@[email protected]
* igt@gem_exec_schedule@u-independent@rcs0:
- shard-tglb: [PASS][7] -> [FAIL][8] +5 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-tglb1/igt@gem_exec_schedule@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-tglb6/igt@gem_exec_schedule@[email protected]
* igt@gem_exec_whisper@basic-queues-all:
- shard-iclb: [PASS][9] -> [INCOMPLETE][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb3/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb5/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@gem_exec_async@concurrent-writes@rcs0:
- {shard-rkl}: [PASS][11] -> [FAIL][12] +2 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-5/igt@gem_exec_async@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-rkl-2/igt@gem_exec_async@[email protected]
Known issues
------------
Here are the changes found in Patchwork_20579_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@feature_discovery@psr2:
- shard-iclb: [PASS][13] -> [SKIP][14] ([i915#658])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb7/igt@[email protected]
* igt@gem_ctx_isolation@preservation-s3@bcs0:
- shard-kbl: NOTRUN -> [DMESG-WARN][15] ([i915#180]) +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@gem_ctx_isolation@[email protected]
* igt@gem_ctx_isolation@preservation-s3@vcs0:
- shard-apl: [PASS][16] -> [DMESG-WARN][17] ([i915#180])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-apl2/igt@gem_ctx_isolation@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl1/igt@gem_ctx_isolation@[email protected]
* igt@gem_ctx_persistence@legacy-engines-mixed:
- shard-snb: NOTRUN -> [SKIP][18] ([fdo#109271] / [i915#1099]) +1 similar issue
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb6/igt@[email protected]
* igt@gem_ctx_persistence@many-contexts:
- shard-tglb: [PASS][19] -> [FAIL][20] ([i915#2410])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-tglb7/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-tglb7/igt@[email protected]
* igt@gem_exec_fair@basic-deadline:
- shard-apl: NOTRUN -> [FAIL][21] ([i915#2846])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl8/igt@[email protected]
* igt@gem_exec_fair@basic-none@vecs0:
- shard-apl: NOTRUN -> [FAIL][22] ([i915#2842] / [i915#3468])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl3/igt@gem_exec_fair@[email protected]
* igt@gem_exec_fair@basic-pace-share@rcs0:
- shard-tglb: [PASS][23] -> [FAIL][24] ([i915#2842])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-tglb3/igt@gem_exec_fair@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-tglb6/igt@gem_exec_fair@[email protected]
* igt@gem_exec_fair@basic-pace@vcs0:
- shard-iclb: [PASS][25] -> [FAIL][26] ([i915#2842]) +2 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb7/igt@gem_exec_fair@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb1/igt@gem_exec_fair@[email protected]
* igt@gem_exec_fair@basic-pace@vcs1:
- shard-iclb: NOTRUN -> [FAIL][27] ([i915#2842]) +2 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb1/igt@gem_exec_fair@[email protected]
* igt@gem_exec_reloc@basic-wide-active@vcs1:
- shard-iclb: NOTRUN -> [FAIL][28] ([i915#3633])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb1/igt@gem_exec_reloc@[email protected]
* igt@gem_ppgtt@blt-vs-render-ctxn:
- shard-snb: [PASS][29] -> [DMESG-FAIL][30] ([i915#3692])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-snb7/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb7/igt@[email protected]
* igt@gem_render_copy@linear-to-vebox-y-tiled:
- shard-skl: NOTRUN -> [SKIP][31] ([fdo#109271]) +81 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl1/igt@[email protected]
* igt@gem_userptr_blits@dmabuf-sync:
- shard-apl: NOTRUN -> [SKIP][32] ([fdo#109271] / [i915#3323])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl1/igt@[email protected]
* igt@gem_userptr_blits@vma-merge:
- shard-snb: NOTRUN -> [FAIL][33] ([i915#2724])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb6/igt@[email protected]
* igt@gen9_exec_parse@batch-without-end:
- shard-iclb: NOTRUN -> [SKIP][34] ([fdo#112306]) +1 similar issue
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@[email protected]
* igt@gen9_exec_parse@bb-large:
- shard-skl: NOTRUN -> [FAIL][35] ([i915#3296])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl1/igt@[email protected]
- shard-apl: NOTRUN -> [FAIL][36] ([i915#3296])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl2/igt@[email protected]
* igt@i915_pm_dc@dc6-dpms:
- shard-kbl: NOTRUN -> [FAIL][37] ([i915#454])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@[email protected]
* igt@i915_pm_dc@dc6-psr:
- shard-iclb: [PASS][38] -> [FAIL][39] ([i915#454])
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb6/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb8/igt@[email protected]
* igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-dp:
- shard-apl: NOTRUN -> [SKIP][40] ([fdo#109271] / [i915#1937])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl8/igt@i915_pm_lpsp@[email protected]
* igt@i915_pm_rc6_residency@rc6-fence:
- shard-iclb: NOTRUN -> [WARN][41] ([i915#1804] / [i915#2684])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@[email protected]
* igt@i915_suspend@fence-restore-untiled:
- shard-skl: NOTRUN -> [INCOMPLETE][42] ([i915#198])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl3/igt@[email protected]
* igt@i915_suspend@forcewake:
- shard-apl: NOTRUN -> [DMESG-WARN][43] ([i915#180])
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl2/igt@[email protected]
* igt@i915_suspend@sysfs-reader:
- shard-kbl: [PASS][44] -> [DMESG-WARN][45] ([i915#180])
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-kbl3/igt@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl2/igt@[email protected]
* igt@kms_big_fb@yf-tiled-64bpp-rotate-270:
- shard-iclb: NOTRUN -> [SKIP][46] ([fdo#110723])
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0:
- shard-apl: NOTRUN -> [SKIP][47] ([fdo#109271]) +295 similar issues
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl3/igt@[email protected]
* igt@kms_big_joiner@2x-modeset:
- shard-iclb: NOTRUN -> [SKIP][48] ([i915#2705])
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd:
- shard-skl: NOTRUN -> [SKIP][49] ([fdo#109271] / [fdo#111827]) +7 similar issues
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl1/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd-enable-disable-mode:
- shard-snb: NOTRUN -> [SKIP][50] ([fdo#109271] / [fdo#111827]) +15 similar issues
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb5/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd-storm:
- shard-kbl: NOTRUN -> [SKIP][51] ([fdo#109271] / [fdo#111827]) +11 similar issues
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@[email protected]
* igt@kms_chamelium@vga-edid-read:
- shard-iclb: NOTRUN -> [SKIP][52] ([fdo#109284] / [fdo#111827]) +4 similar issues
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_color@pipe-b-ctm-negative:
- shard-skl: [PASS][53] -> [DMESG-WARN][54] ([i915#1982])
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-skl10/igt@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl7/igt@[email protected]
* igt@kms_color@pipe-d-ctm-blue-to-red:
- shard-iclb: NOTRUN -> [SKIP][55] ([fdo#109278] / [i915#1149])
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_color_chamelium@pipe-a-ctm-limited-range:
- shard-glk: NOTRUN -> [SKIP][56] ([fdo#109271] / [fdo#111827]) +4 similar issues
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk7/igt@[email protected]
* igt@kms_color_chamelium@pipe-d-ctm-limited-range:
- shard-apl: NOTRUN -> [SKIP][57] ([fdo#109271] / [fdo#111827]) +23 similar issues
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl6/igt@[email protected]
* igt@kms_color_chamelium@pipe-d-ctm-negative:
- shard-iclb: NOTRUN -> [SKIP][58] ([fdo#109278] / [fdo#109284] / [fdo#111827]) +1 similar issue
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_content_protection@atomic:
- shard-kbl: NOTRUN -> [TIMEOUT][59] ([i915#1319]) +1 similar issue
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl7/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][60] ([fdo#109300] / [fdo#111066])
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@[email protected]
* igt@kms_content_protection@atomic-dpms:
- shard-apl: NOTRUN -> [TIMEOUT][61] ([i915#1319]) +1 similar issue
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl3/igt@[email protected]
* igt@kms_cursor_crc@pipe-b-cursor-512x512-random:
- shard-iclb: NOTRUN -> [SKIP][62] ([fdo#109278] / [fdo#109279]) +2 similar issues
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_cursor_crc@pipe-d-cursor-256x256-rapid-movement:
- shard-iclb: NOTRUN -> [SKIP][63] ([fdo#109278]) +18 similar issues
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy:
- shard-iclb: NOTRUN -> [SKIP][64] ([fdo#109274] / [fdo#109278]) +1 similar issue
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_cursor_legacy@cursora-vs-flipa-atomic-transitions-varying-size:
- shard-kbl: [PASS][65] -> [INCOMPLETE][66] ([fdo#109052])
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-kbl1/igt@kms_cursor_legacy@cursora-vs-flipa-atomic-transitions-varying-size.html
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl2/igt@kms_cursor_legacy@cursora-vs-flipa-atomic-transitions-varying-size.html
* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions:
- shard-skl: [PASS][67] -> [FAIL][68] ([i915#2346])
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-skl7/igt@[email protected]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl5/igt@[email protected]
* igt@kms_flip@2x-flip-vs-expired-vblank@ab-hdmi-a1-hdmi-a2:
- shard-glk: [PASS][69] -> [FAIL][70] ([i915#2122])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-glk5/igt@kms_flip@[email protected]
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk6/igt@kms_flip@[email protected]
* igt@kms_flip@flip-vs-expired-vblank@b-edp1:
- shard-skl: [PASS][71] -> [FAIL][72] ([i915#79])
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-skl8/igt@kms_flip@[email protected]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl4/igt@kms_flip@[email protected]
* igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs:
- shard-apl: NOTRUN -> [SKIP][73] ([fdo#109271] / [i915#2672])
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl6/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs.html
* igt@kms_flip_scaled_crc@flip-64bpp-ytile-to-32bpp-ytilercccs:
- shard-kbl: NOTRUN -> [SKIP][74] ([fdo#109271] / [i915#2672])
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbcpsr-1p-offscren-pri-indfb-draw-mmap-cpu:
- shard-glk: NOTRUN -> [SKIP][75] ([fdo#109271]) +59 similar issues
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk7/igt@kms_frontbuffer_tracking@fbcpsr-1p-offscren-pri-indfb-draw-mmap-cpu.html
* igt@kms_frontbuffer_tracking@fbcpsr-2p-shrfb-fliptrack-mmap-gtt:
- shard-iclb: NOTRUN -> [SKIP][76] ([fdo#109280]) +9 similar issues
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb7/igt@[email protected]
* igt@kms_hdr@static-toggle-suspend:
- shard-iclb: NOTRUN -> [SKIP][77] ([i915#1187])
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_panel_fitting@legacy:
- shard-kbl: NOTRUN -> [SKIP][78] ([fdo#109271]) +159 similar issues
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@[email protected]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-d-frame-sequence:
- shard-kbl: NOTRUN -> [SKIP][79] ([fdo#109271] / [i915#533]) +1 similar issue
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl4/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb:
- shard-kbl: NOTRUN -> [FAIL][80] ([fdo#108145] / [i915#265])
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl4/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-a-alpha-transparent-fb:
- shard-kbl: NOTRUN -> [FAIL][81] ([i915#265])
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-c-alpha-basic:
- shard-apl: NOTRUN -> [FAIL][82] ([fdo#108145] / [i915#265]) +1 similar issue
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl2/igt@[email protected]
- shard-skl: NOTRUN -> [FAIL][83] ([fdo#108145] / [i915#265])
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl1/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-c-alpha-transparent-fb:
- shard-glk: NOTRUN -> [FAIL][84] ([i915#265])
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk7/igt@[email protected]
* igt@kms_plane_lowres@pipe-a-tiling-none:
- shard-iclb: NOTRUN -> [SKIP][85] ([i915#3536]) +2 similar issues
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-1:
- shard-kbl: NOTRUN -> [SKIP][86] ([fdo#109271] / [i915#658]) +5 similar issues
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl7/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][87] ([i915#658]) +1 similar issue
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@[email protected]
* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-4:
- shard-glk: NOTRUN -> [SKIP][88] ([fdo#109271] / [i915#658]) +1 similar issue
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk7/igt@[email protected]
* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-5:
- shard-skl: NOTRUN -> [SKIP][89] ([fdo#109271] / [i915#658])
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl1/igt@[email protected]
* igt@kms_psr2_sf@plane-move-sf-dmg-area-2:
- shard-apl: NOTRUN -> [SKIP][90] ([fdo#109271] / [i915#658]) +4 similar issues
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl7/igt@[email protected]
* igt@kms_psr2_su@page_flip:
- shard-iclb: NOTRUN -> [SKIP][91] ([fdo#109642] / [fdo#111068] / [i915#658])
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@kms_psr2_su@page_flip.html
* igt@kms_psr@psr2_cursor_render:
- shard-iclb: [PASS][92] -> [SKIP][93] ([fdo#109441]) +1 similar issue
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb2/igt@kms_psr@psr2_cursor_render.html
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@kms_psr@psr2_cursor_render.html
* igt@kms_psr@psr2_primary_mmap_cpu:
- shard-iclb: NOTRUN -> [SKIP][94] ([fdo#109441])
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@kms_psr@psr2_primary_mmap_cpu.html
* igt@kms_vblank@pipe-d-query-forked-hang:
- shard-snb: NOTRUN -> [SKIP][95] ([fdo#109271]) +280 similar issues
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb2/igt@[email protected]
* igt@kms_vblank@pipe-d-wait-idle:
- shard-apl: NOTRUN -> [SKIP][96] ([fdo#109271] / [i915#533]) +1 similar issue
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl2/igt@[email protected]
* igt@kms_writeback@writeback-fb-id:
- shard-apl: NOTRUN -> [SKIP][97] ([fdo#109271] / [i915#2437])
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl8/igt@[email protected]
* igt@nouveau_crc@pipe-c-ctx-flip-detection:
- shard-iclb: NOTRUN -> [SKIP][98] ([i915#2530])
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@[email protected]
* igt@prime_nv_api@i915_nv_import_twice:
- shard-iclb: NOTRUN -> [SKIP][99] ([fdo#109291]) +2 similar issues
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@prime_nv_api@i915_nv_import_twice.html
* igt@sysfs_clients@fair-7:
- shard-apl: NOTRUN -> [SKIP][100] ([fdo#109271] / [i915#2994]) +5 similar issues
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl7/igt@[email protected]
- shard-kbl: NOTRUN -> [SKIP][101] ([fdo#109271] / [i915#2994]) +1 similar issue
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl3/igt@[email protected]
* igt@sysfs_clients@recycle:
- shard-iclb: NOTRUN -> [SKIP][102] ([i915#2994])
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb6/igt@[email protected]
* igt@sysfs_clients@split-10:
- shard-skl: NOTRUN -> [SKIP][103] ([fdo#109271] / [i915#2994]) +1 similar issue
[103]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl1/igt@[email protected]
#### Possible fixes ####
* igt@fbdev@nullptr:
- {shard-rkl}: [SKIP][104] ([i915#2582]) -> [PASS][105]
[104]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-1/igt@[email protected]
[105]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-rkl-6/igt@[email protected]
* igt@gem_ctx_isolation@preservation-s3@bcs0:
- shard-apl: [DMESG-WARN][106] ([i915#180]) -> [PASS][107] +1 similar issue
[106]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-apl2/igt@gem_ctx_isolation@[email protected]
[107]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-apl1/igt@gem_ctx_isolation@[email protected]
* igt@gem_ctx_persistence@many-contexts:
- {shard-rkl}: [FAIL][108] ([i915#2410]) -> [PASS][109]
[108]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-2/igt@[email protected]
[109]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-rkl-5/igt@[email protected]
* igt@gem_exec_fair@basic-deadline:
- shard-kbl: [FAIL][110] ([i915#2846]) -> [PASS][111]
[110]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-kbl4/igt@[email protected]
[111]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl1/igt@[email protected]
* igt@gem_exec_fair@basic-pace-solo@rcs0:
- shard-glk: [FAIL][112] ([i915#2842]) -> [PASS][113]
[112]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-glk1/igt@gem_exec_fair@[email protected]
[113]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk3/igt@gem_exec_fair@[email protected]
* igt@gem_exec_fair@basic-pace@vcs1:
- shard-tglb: [FAIL][114] ([i915#2842]) -> [PASS][115]
[114]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-tglb6/igt@gem_exec_fair@[email protected]
[115]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-tglb3/igt@gem_exec_fair@[email protected]
* igt@gem_exec_fair@basic-pace@vecs0:
- shard-kbl: [FAIL][116] ([i915#2842]) -> [PASS][117]
[116]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-kbl4/igt@gem_exec_fair@[email protected]
[117]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-kbl2/igt@gem_exec_fair@[email protected]
- shard-iclb: [FAIL][118] ([i915#2842]) -> [PASS][119]
[118]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb7/igt@gem_exec_fair@[email protected]
[119]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb1/igt@gem_exec_fair@[email protected]
* igt@gem_exec_fair@basic-throttle@rcs0:
- shard-iclb: [FAIL][120] ([i915#2849]) -> [PASS][121]
[120]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb6/igt@gem_exec_fair@[email protected]
[121]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb5/igt@gem_exec_fair@[email protected]
* igt@gem_exec_parallel@fds@rcs0:
- {shard-rkl}: [INCOMPLETE][122] -> [PASS][123]
[122]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-1/igt@gem_exec_parallel@[email protected]
[123]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-rkl-6/igt@gem_exec_parallel@[email protected]
* igt@gem_huc_copy@huc-copy:
- shard-tglb: [SKIP][124] ([i915#2190]) -> [PASS][125]
[124]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-tglb6/igt@[email protected]
[125]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-tglb3/igt@[email protected]
* igt@gem_mmap_gtt@big-copy:
- shard-skl: [FAIL][126] ([i915#307]) -> [PASS][127]
[126]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-skl1/igt@[email protected]
[127]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-skl3/igt@[email protected]
* igt@gem_mmap_gtt@cpuset-big-copy:
- shard-glk: [FAIL][128] ([i915#307]) -> [PASS][129]
[128]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-glk6/igt@[email protected]
[129]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk9/igt@[email protected]
* igt@gem_mmap_gtt@cpuset-big-copy-xy:
- shard-iclb: [FAIL][130] ([i915#307]) -> [PASS][131]
[130]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-iclb5/igt@[email protected]
[131]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-iclb3/igt@[email protected]
* igt@gem_mmap_offset@clear:
- {shard-rkl}: [FAIL][132] ([i915#3160]) -> [PASS][133]
[132]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-1/igt@[email protected]
[133]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-rkl-6/igt@[email protected]
* igt@gen9_exec_parse@allowed-all:
- shard-glk: [DMESG-WARN][134] ([i915#1436] / [i915#716]) -> [PASS][135]
[134]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-glk6/igt@[email protected]
[135]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-glk2/igt@[email protected]
* igt@i915_pm_rpm@gem-pread:
- {shard-rkl}: [SKIP][136] ([fdo#109308]) -> [PASS][137] +1 similar issue
[136]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-1/igt@[email protected]
[137]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-rkl-6/igt@[email protected]
* igt@i915_selftest@live@hangcheck:
- shard-snb: [INCOMPLETE][138] ([i915#2782]) -> [PASS][139]
[138]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-snb5/igt@i915_selftest@[email protected]
[139]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/shard-snb6/igt@i915_selftest@[email protected]
* igt@i915_suspend@sysfs-reader:
- {shard-rkl}: [FAIL][140] ([fdo#103375]) -> [PASS][141]
[140]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10335/shard-rkl-6/igt@[email protected]
[141]: https://intel-gfx-ci.01.org/t
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20579/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 14 lines · On Mon, 12 Jul 2021 19:53:34 +0200 Daniel Vetter <[email protected]> wrote:
Hi all,
Quick new version since the previous one was a bit too broken:
- dropped the bug-on patch to avoid breaking amdgpu's gpu reset failure games
- another attempt at splitting job_init/arm, hopefully we're getting there.Note that Christian has brought up a bikeshed on the new functions to add dependencies to
drm_sched_jobs. I'm happy to repaint, if there's some kind of consensus on what it should be.Testing and review very much welcome, as usual.
Quoted 8 lines
Cheers, Daniel
Daniel Vetter (18):
drm/sched: Splitdrm_sched_job_init
drm/sched: Barriers are needed forentity->last_scheduleddrm/sched: Add dependency tracking
drm/sched: drop entity parameter fromdrm_sched_push_jobdrm/sched: improve docs arounddrm_sched_entity
Patches 1, 3, 4 and 5 are
Quoted 47 lines
drm/panfrost: use scheduler dependency tracking
drm/lima: use scheduler dependency tracking
drm/v3d: Movedrm_sched_job_inittov3d_job_init
drm/v3d: Use scheduler dependency handling
drm/etnaviv: Use scheduler dependency handling
drm/gem: Delete gem array fencing helpers
drm/sched: Don't store self-dependencies
drm/sched: Check locking indrm_sched_job_await_implicitdrm/msm: Don't break exclusive fence ordering
drm/etnaviv: Don't break exclusive fence ordering drm/i915: delete exclude argument fromi915_sw_fence_await_reservationdrm/i915: Don't break exclusive fence ordering
dma-resv: Give the docs a do-overDocumentation/gpu/drm-mm.rst | 3 + drivers/dma-buf/dma-resv.c | 24 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 4 +- drivers/gpu/drm/drm_gem.c | 96 --------- drivers/gpu/drm/etnaviv/etnaviv_gem.h | 5 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 64 +++--- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 65 +----- drivers/gpu/drm/etnaviv/etnaviv_sched.h | 3 +- drivers/gpu/drm/i915/display/intel_display.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_clflush.c | 2 +- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 8 +- drivers/gpu/drm/i915/i915_sw_fence.c | 6 +- drivers/gpu/drm/i915/i915_sw_fence.h | 1 - drivers/gpu/drm/lima/lima_gem.c | 7 +- drivers/gpu/drm/lima/lima_sched.c | 28 +-- drivers/gpu/drm/lima/lima_sched.h | 6 +- drivers/gpu/drm/msm/msm_gem_submit.c | 3 +- drivers/gpu/drm/panfrost/panfrost_drv.c | 16 +- drivers/gpu/drm/panfrost/panfrost_job.c | 39 +--- drivers/gpu/drm/panfrost/panfrost_job.h | 5 +- drivers/gpu/drm/scheduler/sched_entity.c | 140 +++++++------ drivers/gpu/drm/scheduler/sched_fence.c | 19 +- drivers/gpu/drm/scheduler/sched_main.c | 181 +++++++++++++++-- drivers/gpu/drm/v3d/v3d_drv.h | 6 +- drivers/gpu/drm/v3d/v3d_gem.c | 115 +++++------ drivers/gpu/drm/v3d/v3d_sched.c | 44 +---- include/drm/drm_gem.h | 5 - include/drm/gpu_scheduler.h | 186 ++++++++++++++---- include/linux/dma-buf.h | 7 + include/linux/dma-resv.h | 104 +++++++++- 31 files changed, 672 insertions(+), 528 deletions(-)
Quoted 8 lines · Daniel Vetter
Hi all,
Quick new version since the previous one was a bit too broken:
- dropped the bug-on patch to avoid breaking amdgpu's gpu reset failure games
- another attempt at splitting job_init/arm, hopefully we're getting there.
Quoted 5 lines
Note that Christian has brought up a bikeshed on the new functions to add dependencies to
drm_sched_jobs. I'm happy to repaint, if there's some kind of consensus on what it should be.Testing and review very much welcome, as usual.
Hi,
I've tested it some time ago; but now, for v3d, don't forget to rebase.
Also, common parts lgtm, so for them:
Quoted 59 lines
Cheers, Daniel
Daniel Vetter (18):
drm/sched: Splitdrm_sched_job_init
drm/sched: Barriers are needed forentity->last_scheduleddrm/sched: Add dependency tracking
drm/sched: drop entity parameter fromdrm_sched_push_jobdrm/sched: improve docs arounddrm_sched_entitydrm/panfrost: use scheduler dependency tracking
drm/lima: use scheduler dependency tracking
drm/v3d: Movedrm_sched_job_inittov3d_job_init
drm/v3d: Use scheduler dependency handling
drm/etnaviv: Use scheduler dependency handling
drm/gem: Delete gem array fencing helpers
drm/sched: Don't store self-dependencies
drm/sched: Check locking indrm_sched_job_await_implicitdrm/msm: Don't break exclusive fence ordering
drm/etnaviv: Don't break exclusive fence ordering drm/i915: delete exclude argument fromi915_sw_fence_await_reservationdrm/i915: Don't break exclusive fence ordering
dma-resv: Give the docs a do-overDocumentation/gpu/drm-mm.rst | 3 + drivers/dma-buf/dma-resv.c | 24 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 4 +- drivers/gpu/drm/drm_gem.c | 96 --------- drivers/gpu/drm/etnaviv/etnaviv_gem.h | 5 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 64 +++--- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 65 +----- drivers/gpu/drm/etnaviv/etnaviv_sched.h | 3 +- drivers/gpu/drm/i915/display/intel_display.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_clflush.c | 2 +- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 8 +- drivers/gpu/drm/i915/i915_sw_fence.c | 6 +- drivers/gpu/drm/i915/i915_sw_fence.h | 1 - drivers/gpu/drm/lima/lima_gem.c | 7 +- drivers/gpu/drm/lima/lima_sched.c | 28 +-- drivers/gpu/drm/lima/lima_sched.h | 6 +- drivers/gpu/drm/msm/msm_gem_submit.c | 3 +- drivers/gpu/drm/panfrost/panfrost_drv.c | 16 +- drivers/gpu/drm/panfrost/panfrost_job.c | 39 +--- drivers/gpu/drm/panfrost/panfrost_job.h | 5 +- drivers/gpu/drm/scheduler/sched_entity.c | 140 +++++++------ drivers/gpu/drm/scheduler/sched_fence.c | 19 +- drivers/gpu/drm/scheduler/sched_main.c | 181 +++++++++++++++-- drivers/gpu/drm/v3d/v3d_drv.h | 6 +- drivers/gpu/drm/v3d/v3d_gem.c | 115 +++++------ drivers/gpu/drm/v3d/v3d_sched.c | 44 +---- include/drm/drm_gem.h | 5 - include/drm/gpu_scheduler.h | 186 ++++++++++++++---- include/linux/dma-buf.h | 7 + include/linux/dma-resv.h | 104 +++++++++- 31 files changed, 672 insertions(+), 528 deletions(-)Signature · 1 line
2.32.0