diff mbox series

[2/2] drm/sched: add missing NULL check in drm_sched_get_cleanup_job

Message ID 20220929180151.139751-2-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/scheduler: fix fence ref counting | expand

Commit Message

Christian König Sept. 29, 2022, 6:01 p.m. UTC
Otherwise we would crash if the job is not resubmitted.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/scheduler/sched_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steven Price Sept. 30, 2022, 9:12 a.m. UTC | #1
On 29/09/2022 19:01, Christian König wrote:
> Otherwise we would crash if the job is not resubmitted.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 4f2395d1a791..23e5e8275dc7 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -829,7 +829,8 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
>  	job = list_first_entry_or_null(&sched->pending_list,
>  				       struct drm_sched_job, list);
>  
> -	if (job && dma_fence_is_signaled(job->s_fence->parent)) {
> +	if (job && (!job->s_fence->parent ||
> +		    dma_fence_is_signaled(job->s_fence->parent))) {
>  		/* remove job from pending_list */
>  		list_del_init(&job->list);
>  

Sadly there's another use further down, so this isn't a complete fix:

> 		/* cancel this job's TO timer */
> 		cancel_delayed_work(&sched->work_tdr);
> 		/* make the scheduled timestamp more accurate */
> 		next = list_first_entry_or_null(&sched->pending_list,
> 						typeof(*next), list);
> 
> 		if (next) {
> 			next->s_fence->scheduled.timestamp =
> 				job->s_fence->parent->timestamp;

From the comment I presume that just skipping this section (when parent
is NULL) would be fine.

Steve
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 4f2395d1a791..23e5e8275dc7 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -829,7 +829,8 @@  drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
 	job = list_first_entry_or_null(&sched->pending_list,
 				       struct drm_sched_job, list);
 
-	if (job && dma_fence_is_signaled(job->s_fence->parent)) {
+	if (job && (!job->s_fence->parent ||
+		    dma_fence_is_signaled(job->s_fence->parent))) {
 		/* remove job from pending_list */
 		list_del_init(&job->list);