diff mbox series

[11/13] drm/scheduler: Add a timeout_start_notify function op

Message ID 1538397105-19581-12-git-send-email-smasetty@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series drm/msm: Hook up the DRM gpu scheduler | expand

Commit Message

Sharat Masetty Oct. 1, 2018, 12:31 p.m. UTC
Add an optional backend function op which will let the scheduler clients
know when the timeout work got scheduled for a job. This will help
drivers with multiple schedulers(one per ring) measure time spent on the
ring accurately, eventually helping with better timeout detection.

Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
---
 drivers/gpu/drm/scheduler/gpu_scheduler.c | 16 +++++++++++++---
 include/drm/gpu_scheduler.h               |  6 ++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c
index bf0e0c9..f5534ff 100644
--- a/drivers/gpu/drm/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c
@@ -69,6 +69,16 @@  static void drm_sched_rq_remove_entity(struct drm_sched_rq *rq,
 	spin_unlock(&rq->lock);
 }
 
+static void drm_sched_queue_delayed_work(struct drm_sched_job *s_job)
+{
+	struct drm_gpu_scheduler *sched = s_job->sched;
+
+	schedule_delayed_work(&s_job->work_tdr, sched->timeout);
+
+	if (sched->ops->timeout_start_notify)
+		sched->ops->timeout_start_notify(s_job);
+}
+
 /**
  * Select an entity which could provide a job to run
  *
@@ -467,7 +477,7 @@  static void drm_sched_job_finish(struct work_struct *work)
 						struct drm_sched_job, node);
 
 		if (next)
-			schedule_delayed_work(&next->work_tdr, sched->timeout);
+			drm_sched_queue_delayed_work(next);
 	}
 	spin_unlock(&sched->job_list_lock);
 	dma_fence_put(&s_job->s_fence->finished);
@@ -494,7 +504,7 @@  static void drm_sched_job_begin(struct drm_sched_job *s_job)
 	if (sched->timeout != MAX_SCHEDULE_TIMEOUT &&
 	    list_first_entry_or_null(&sched->ring_mirror_list,
 				     struct drm_sched_job, node) == s_job)
-		schedule_delayed_work(&s_job->work_tdr, sched->timeout);
+		drm_sched_queue_delayed_work(s_job);
 	spin_unlock(&sched->job_list_lock);
 }
 
@@ -560,7 +570,7 @@  void drm_sched_job_recovery(struct drm_gpu_scheduler *sched)
 	s_job = list_first_entry_or_null(&sched->ring_mirror_list,
 					 struct drm_sched_job, node);
 	if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT)
-		schedule_delayed_work(&s_job->work_tdr, sched->timeout);
+		drm_sched_queue_delayed_work(s_job);
 
 	list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) {
 		struct drm_sched_fence *s_fence = s_job->s_fence;
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
index dec6558..5c59c38 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -157,6 +157,12 @@  struct drm_sched_backend_ops {
 	 * it's time to clean it up.
 	 */
 	void (*free_job)(struct drm_sched_job *sched_job);
+
+	/*
+	 * (Optional) Called to let the driver know that a timeout detection
+	 * timer has been started for this job.
+	 */
+	void (*timeout_start_notify)(struct drm_sched_job *sched_job);
 };
 
 /**