drm/etnaviv: Fix armed job not being pushed to the DRM scheduler
Subsystems (2)
PATCH 1/1 drm/etnaviv: Fix armed job not being pushed to the DRM scheduler
When xa_alloc_cyclic() failed in etnaviv_sched_push_job(), the error path skipped drm_sched_entity_push_job(). This is a violation of the DRM scheduler contract, as once a job has been armed with drm_sched_job_arm(), it must be pushed with drm_sched_entity_push_job(). From the DRM scheduler documentation,
"""drm_sched_job_arm() is a point of no return since it initializes the fences and their sequence number etc. Once that function has been called, you *must* submit it with drm_sched_entity_push_job() and cannot simply abort it by calling drm_sched_job_cleanup().
"""
Fix this by splitting the fence ID allocation into two phases: first, alloc an xarray slot before arming the job (which can fail), then fill in the actual fence with xa_store() after arming. This way, allocation failures are handled before the job is armed, and once armed, the job is always pushed to the scheduler.
This also fixes a double call to drm_sched_job_cleanup(), as both etnaviv_sched_push_job() and its caller would call it on failure.
--- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_sched.c +9 -7
@@ -116,16 +116,18 @@ int etnaviv_sched_push_job(struct etnaviv_gem_submit *submit)*/ mutex_lock (&gpu->sched_lock); + ret =xa_alloc_cyclic (&gpu->user_fences, &submit->out_fence_id, +NULL , xa_limit_32b, &gpu->next_user_fence, +GFP_KERNEL ); +if (ret <0 ) + goto out_unlock; +drm_sched_job_arm (&submit->sched_job); submit->out_fence =dma_fence_get (&submit->sched_job.s_fence->finished); - ret =xa_alloc_cyclic (&gpu->user_fences, &submit->out_fence_id, - submit->out_fence, xa_limit_32b, - &gpu->next_user_fence,GFP_KERNEL ); -if (ret <0 ) { -drm_sched_job_cleanup (&submit->sched_job); - goto out_unlock; - } + +xa_store (&gpu->user_fences, submit->out_fence_id, + submit->out_fence,GFP_KERNEL );/* the scheduler holds on to the job now */ kref_get (&submit->refcount);
Signature · 1 line
2.53.0
Hi,
Quoted 19 lines · Maíra Canal
When
xa_alloc_cyclic()failed inetnaviv_sched_push_job(), the error path skippeddrm_sched_entity_push_job(). This is a violation of the DRM scheduler contract, as once a job has been armed withdrm_sched_job_arm(), it must be pushed withdrm_sched_entity_push_job(). From the DRM scheduler documentation,"""
drm_sched_job_arm()is a point of no return since it initializes the fences and their sequence number etc. Once that function has been called, you *must* submit it withdrm_sched_entity_push_job()and cannot simply abort it by callingdrm_sched_job_cleanup().
"""Fix this by splitting the fence ID allocation into two phases: first, alloc an xarray slot before arming the job (which can fail), then fill in the actual fence with
xa_store()after arming. This way, allocation failures are handled before the job is armed, and once armed, the job is always pushed to the scheduler.
Quoted 5 lines
This also fixes a double call to
drm_sched_job_cleanup(), as bothetnaviv_sched_push_job()and its caller would call it on failure.Fixes 764be12345c3 ("drm/etnaviv: convert user fence tracking to XArray")Signed-off-by Maíra Canal <[email protected]>
Gentle ping
Best regards,
- Maíra
Quoted 34 lines
--- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_sched.c +9
-7@@ -116,16 +116,18 @@ int etnaviv_sched_push_job(struct etnaviv_gem_submit *submit)*/ mutex_lock (&gpu->sched_lock); + ret =xa_alloc_cyclic (&gpu->user_fences, &submit->out_fence_id, +NULL , xa_limit_32b, &gpu->next_user_fence, +GFP_KERNEL ); +if (ret <0 ) + goto out_unlock; +drm_sched_job_arm (&submit->sched_job); submit->out_fence =dma_fence_get (&submit->sched_job.s_fence->finished); - ret =xa_alloc_cyclic (&gpu->user_fences, &submit->out_fence_id, - submit->out_fence, xa_limit_32b, - &gpu->next_user_fence,GFP_KERNEL ); -if (ret <0 ) { -drm_sched_job_cleanup (&submit->sched_job); - goto out_unlock; - } + +xa_store (&gpu->user_fences, submit->out_fence_id, + submit->out_fence,GFP_KERNEL );/* the scheduler holds on to the job now */ kref_get (&submit->refcount);
Christian Gmeiner
reviewerHi Maíra
Quoted 21 lines · Maíra Canal
Quoted 19 lines
When
xa_alloc_cyclic()failed inetnaviv_sched_push_job(), the error path skippeddrm_sched_entity_push_job(). This is a violation of the DRM scheduler contract, as once a job has been armed withdrm_sched_job_arm(), it must be pushed withdrm_sched_entity_push_job(). From the DRM scheduler documentation,"""
drm_sched_job_arm()is a point of no return since it initializes the fences and their sequence number etc. Once that function has been called, you *must* submit it withdrm_sched_entity_push_job()and cannot simply abort it by callingdrm_sched_job_cleanup().
"""Fix this by splitting the fence ID allocation into two phases: first, alloc an xarray slot before arming the job (which can fail), then fill in the actual fence with
xa_store()after arming. This way, allocation failures are handled before the job is armed, and once armed, the job is always pushed to the scheduler.
Quoted 8 lines
Quoted 5 lines
This also fixes a double call to
drm_sched_job_cleanup(), as bothetnaviv_sched_push_job()and its caller would call it on failure.Fixes 764be12345c3 ("drm/etnaviv: convert user fence tracking to XArray")Signed-off-by Maíra Canal <[email protected]>Gentle ping
Thanks for the patch - looks good. I’ll take care of it over the next few days.
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
Hi Christian,
Quoted 26 lines · Christian Gmeiner
Hi Maíra
Quoted 24 lines · Maíra Canal
Quoted 22 lines
When
xa_alloc_cyclic()failed inetnaviv_sched_push_job(), the error path skippeddrm_sched_entity_push_job(). This is a violation of the DRM scheduler contract, as once a job has been armed withdrm_sched_job_arm(), it must be pushed withdrm_sched_entity_push_job(). From the DRM scheduler documentation,"""
drm_sched_job_arm()is a point of no return since it initializes the fences and their sequence number etc. Once that function has been called, you *must* submit it withdrm_sched_entity_push_job()and cannot simply abort it by callingdrm_sched_job_cleanup().
"""Fix this by splitting the fence ID allocation into two phases: first, alloc an xarray slot before arming the job (which can fail), then fill in the actual fence with
xa_store()after arming. This way, allocation failures are handled before the job is armed, and once armed, the job is always pushed to the scheduler.This also fixes a double call to
drm_sched_job_cleanup(), as bothetnaviv_sched_push_job()and its caller would call it on failure.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fixes 764be12345c3 ("drm/etnaviv: convert user fence tracking to XArray")Signed-off-by Maíra Canal <[email protected]>Gentle ping
Thanks for the patch - looks good. I’ll take care of it over the next few days.
Any update?
Best regards,
- Maíra
Quoted 1 line
Hi Maíra
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines · Maíra Canal
Quoted 24 lines
When
xa_alloc_cyclic()failed inetnaviv_sched_push_job(), the error path skippeddrm_sched_entity_push_job(). This is a violation of the DRM scheduler contract, as once a job has been armed withdrm_sched_job_arm(), it must be pushed withdrm_sched_entity_push_job(). From the DRM scheduler documentation,"""
drm_sched_job_arm()is a point of no return since it initializes the fences and their sequence number etc. Once that function has been called, you *must* submit it withdrm_sched_entity_push_job()and cannot simply abort it by callingdrm_sched_job_cleanup().
"""Fix this by splitting the fence ID allocation into two phases: first, alloc an xarray slot before arming the job (which can fail), then fill in the actual fence with
xa_store()after arming. This way, allocation failures are handled before the job is armed, and once armed, the job is always pushed to the scheduler.This also fixes a double call to
drm_sched_job_cleanup(), as bothetnaviv_sched_push_job()and its caller would call it on failure.Fixes 764be12345c3 ("drm/etnaviv: convert user fence tracking to XArray")Signed-off-by Maíra Canal <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Gentle ping
Thanks for the patch - looks good. I’ll take care of it over the next few days.
Any update?
Applied to drm-misc-fixes.
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy