From: Nayan Deshmukh <nayan26deshmukh@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Nayan Deshmukh <nayan26deshmukh@gmail.com>, christian.koenig@amd.com
Subject: [PATCH 1/2] drm/scheduler: add a current job field to scheduler
Date: Wed, 19 Sep 2018 01:17:09 +0900 [thread overview]
Message-ID: <20180918161710.2669-1-nayan26deshmukh@gmail.com> (raw)
Which points to the job running on the hardware. This is
useful when we need to access the currently executing job
from the scheduler.
Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
---
drivers/gpu/drm/scheduler/sched_main.c | 17 +++++++++++------
include/drm/gpu_scheduler.h | 2 ++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 9ca741f3a0bc..0e6ccc8243db 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -189,6 +189,7 @@ static void drm_sched_job_finish(struct work_struct *work)
struct drm_sched_job *s_job = container_of(work, struct drm_sched_job,
finish_work);
struct drm_gpu_scheduler *sched = s_job->sched;
+ struct drm_sched_job *next;
/*
* Canceling the timeout without removing our job from the ring mirror
@@ -201,10 +202,10 @@ static void drm_sched_job_finish(struct work_struct *work)
spin_lock(&sched->job_list_lock);
/* queue TDR for next job */
+ next = list_next_entry(s_job, node);
+ sched->curr_job = next;
if (sched->timeout != MAX_SCHEDULE_TIMEOUT &&
!list_is_last(&s_job->node, &sched->ring_mirror_list)) {
- struct drm_sched_job *next = list_next_entry(s_job, node);
-
if (!dma_fence_is_signaled(&next->s_fence->finished))
schedule_delayed_work(&next->work_tdr, sched->timeout);
}
@@ -233,10 +234,12 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)
spin_lock(&sched->job_list_lock);
list_add_tail(&s_job->node, &sched->ring_mirror_list);
- 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);
+ if (list_first_entry_or_null(&sched->ring_mirror_list,
+ struct drm_sched_job, node) == s_job) {
+ if (sched->timeout != MAX_SCHEDULE_TIMEOUT)
+ schedule_delayed_work(&s_job->work_tdr, sched->timeout);
+ sched->curr_job = s_job;
+ }
spin_unlock(&sched->job_list_lock);
}
@@ -316,6 +319,8 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched)
struct drm_sched_job, node);
if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT)
schedule_delayed_work(&s_job->work_tdr, sched->timeout);
+ if (s_job)
+ sched->curr_job = 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 daec50f887b3..07e776b1ca42 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -252,6 +252,7 @@ struct drm_sched_backend_ops {
* @timeout: the time after which a job is removed from the scheduler.
* @name: name of the ring for which this scheduler is being used.
* @sched_rq: priority wise array of run queues.
+ * @curr_job: points to the job currently running on the hardware
* @wake_up_worker: the wait queue on which the scheduler sleeps until a job
* is ready to be scheduled.
* @job_scheduled: once @drm_sched_entity_do_release is called the scheduler
@@ -274,6 +275,7 @@ struct drm_gpu_scheduler {
long timeout;
const char *name;
struct drm_sched_rq sched_rq[DRM_SCHED_PRIORITY_MAX];
+ struct drm_sched_job *curr_job;
wait_queue_head_t wake_up_worker;
wait_queue_head_t job_scheduled;
atomic_t hw_rq_count;
--
2.14.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2018-09-18 16:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 16:17 Nayan Deshmukh [this message]
2018-09-18 16:17 ` [PATCH 2/2] drm/scheduler: remove timeout work_struct from drm_sched_job Nayan Deshmukh
2018-09-19 12:30 ` Christian König
2018-09-19 15:39 ` Michel Dänzer
2018-09-20 6:41 ` Christian König
2018-09-20 11:25 ` Nayan Deshmukh
2018-09-20 11:30 ` Christian König
2018-09-18 17:09 ` [PATCH 1/2] drm/scheduler: add a current job field to scheduler Koenig, Christian
2018-09-18 23:13 ` Nayan Deshmukh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180918161710.2669-1-nayan26deshmukh@gmail.com \
--to=nayan26deshmukh@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).