Skip to contentSkip to conversation

drm/amdgpu: Force-signal fence when job is submitted to killed entity

PATCH In review Bingxi Guo 2 participants 2 messages Dec 24, 2025 – Jan 7

Subsystems (3)
lore
Share & tools
lore

Bingxi Guo

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Force-signal fence when job is submitted to killed entity

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

---
 drivers/gpu/drm/scheduler/sched_entity.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +15 -6
index 8867b95ab089..998e35a1a261 100644
@@ -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);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · Bingxi Guo

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.

Quoted 52 lines
---
 drivers/gpu/drm/scheduler/sched_entity.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +15 -6
index 8867b95ab089..998e35a1a261 100644
@@ -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);