dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: James Zhu <James.Zhu@amd.com>
To: <amd-gfx@lists.freedesktop.org>, <dri-devel@lists.freedesktop.org>
Cc: alexander.deucher@amd.com, christian.koenig@amd.com
Subject: [PATCH 2/4] drm/sched: implement new drm_sched_pick_best
Date: Wed, 7 Sep 2022 16:57:03 -0400	[thread overview]
Message-ID: <20220907205705.934688-2-James.Zhu@amd.com> (raw)
In-Reply-To: <20220907205705.934688-1-James.Zhu@amd.com>

drm_sched_pick_best return best selecetd ring schedul list's address.

Signed-off-by: James Zhu <James.Zhu@amd.com>
---
 drivers/gpu/drm/scheduler/sched_entity.c |  2 +-
 drivers/gpu/drm/scheduler/sched_main.c   | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 191c56064f19..f5595607995b 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -475,7 +475,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
 		return;
 
 	spin_lock(&entity->rq_lock);
-	sched = drm_sched_pick_best(entity->sched_list, entity->num_sched_list);
+	sched = *drm_sched_pick_best(entity->sched_list, entity->num_sched_list);
 	rq = sched ? &sched->sched_rq[entity->priority] : NULL;
 	if (rq != entity->rq) {
 		drm_sched_rq_remove_entity(entity->rq, entity);
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 68317d3a7a27..111277f6c53c 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -863,12 +863,12 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
  * Returns pointer of the sched with the least load or NULL if none of the
  * drm_gpu_schedulers are ready
  */
-struct drm_gpu_scheduler *
+struct drm_gpu_scheduler **
 drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
 		     unsigned int num_sched_list)
 {
-	struct drm_gpu_scheduler *sched, *picked_sched = NULL;
-	int i;
+	struct drm_gpu_scheduler *sched;
+	int i, picked_idx = -1;
 	unsigned int min_score = UINT_MAX, num_score;
 
 	for (i = 0; i < num_sched_list; ++i) {
@@ -883,11 +883,13 @@ drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
 		num_score = atomic_read(sched->score);
 		if (num_score < min_score) {
 			min_score = num_score;
-			picked_sched = sched;
+			picked_idx = i;
 		}
 	}
-
-	return picked_sched;
+	if (picked_idx != -1)
+		return &(sched_list[picked_idx]);
+	else
+		return (struct drm_gpu_scheduler **)(NULL);
 }
 EXPORT_SYMBOL(drm_sched_pick_best);
 
-- 
2.25.1


  reply	other threads:[~2022-09-07 20:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07 20:57 [PATCH 1/4] drm/sched: returns struct drm_gpu_scheduler ** for drm_sched_pick_best James Zhu
2022-09-07 20:57 ` James Zhu [this message]
2022-09-07 20:57 ` [PATCH 3/4] drm/sched: always keep selecetd ring sched list in ctx entity James Zhu
2022-09-07 21:12   ` [PATCH v2 3/4] drm/sched: always keep selected " James Zhu
2022-09-08  6:15   ` [PATCH 3/4] drm/sched: always keep selecetd " Christian König
2022-09-08 13:19     ` James Zhu
2022-09-09 11:18       ` Christian König
2022-09-08 15:29   ` [PATCH v3 3/4] drm/sched: always keep selected " James Zhu
2022-09-07 20:57 ` [PATCH 4/4] drm/amdgpu: update amdgpu_ctx_init_entity James Zhu
2022-09-08  6:12 ` [PATCH 1/4] drm/sched: returns struct drm_gpu_scheduler ** for drm_sched_pick_best Christian König
2022-09-08 14:08 ` Andrey Grodzovsky
2022-09-08 14:17   ` James Zhu
2022-09-08 14:38     ` Andrey Grodzovsky
2022-09-08 14:45       ` James Zhu
2022-09-08 15:05         ` Andrey Grodzovsky
2022-09-08 15:09           ` James Zhu
2022-09-08 18:30             ` Andrey Grodzovsky

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=20220907205705.934688-2-James.Zhu@amd.com \
    --to=james.zhu@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --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).