On 12/24/25 09:25, Bingxi Guo wrote:
> Issue: jobs submitted to a killed entity can still succeed, except for
> a dmesg error when the job is the first been pushed to the killed
> entity
> 
> Force-signal fence when job is submitted to killed entity

Well once more absolutely clear NAK to stuff like that.

Please read up on the dma_fence documentation before touching the code because 
patches like that one here clearly shows that even the basic are not understood 
correctly.

Christian.

> 
> Signed-off-by: Emily Deng <[email protected]>
> Signed-off-by: Bingxi Guo <[email protected]>
> ---
>  drivers/gpu/drm/scheduler/sched_entity.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
> b/drivers/gpu/drm/scheduler/sched_entity.c
> index 8867b95ab089..998e35a1a261 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -570,6 +570,14 @@ void drm_sched_entity_push_job(struct drm_sched_job 
> *sched_job)
>       bool first;
>       ktime_t submit_ts;
>  
> +     spin_lock(&entity->lock);
> +     if (entity->stopped) {
> +             spin_unlock(&entity->lock);
> +             DRM_ERROR("Trying to push job to a killed entity\n");
> +             goto error;
> +     }
> +     spin_unlock(&entity->lock);
> +
>       trace_drm_sched_job_queue(sched_job, entity);
>  
>       if (trace_drm_sched_job_add_dep_enabled()) {
> @@ -597,12 +605,6 @@ void drm_sched_entity_push_job(struct drm_sched_job 
> *sched_job)
>  
>               /* Add the entity to the run queue */
>               spin_lock(&entity->lock);
> -             if (entity->stopped) {
> -                     spin_unlock(&entity->lock);
> -
> -                     DRM_ERROR("Trying to push to a killed entity\n");
> -                     return;
> -             }
>  
>               rq = entity->rq;
>               sched = rq->sched;
> @@ -618,5 +620,12 @@ void drm_sched_entity_push_job(struct drm_sched_job 
> *sched_job)
>  
>               drm_sched_wakeup(sched);
>       }
> +
> +     return;
> +
> +error:
> +     dma_fence_set_error(&sched_job->s_fence->finished, -EPERM);
> +     drm_sched_fence_scheduled(sched_job->s_fence, NULL);
> +     drm_sched_fence_finished(sched_job->s_fence, -EPERM);
>  }
>  EXPORT_SYMBOL(drm_sched_entity_push_job);

Reply via email to