* [PATCH] drm/sched: Consolidate drm_sched_rq_select_entity_rr
@ 2025-07-08 12:21 Tvrtko Ursulin
2025-07-08 19:24 ` Matthew Brost
2025-07-09 9:50 ` Philipp Stanner
0 siblings, 2 replies; 3+ messages in thread
From: Tvrtko Ursulin @ 2025-07-08 12:21 UTC (permalink / raw)
To: dri-devel
Cc: intel-xe, amd-gfx, kernel-dev, Tvrtko Ursulin,
Christian König, Danilo Krummrich, Matthew Brost,
Philipp Stanner
Extract out two copies of the identical code to function epilogue to make
it smaller and more readable.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
---
drivers/gpu/drm/scheduler/sched_main.c | 48 +++++++++++---------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 2335df4de2b8..9212ebae7476 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -263,38 +263,14 @@ drm_sched_rq_select_entity_rr(struct drm_gpu_scheduler *sched,
entity = rq->current_entity;
if (entity) {
list_for_each_entry_continue(entity, &rq->entities, list) {
- if (drm_sched_entity_is_ready(entity)) {
- /* If we can't queue yet, preserve the current
- * entity in terms of fairness.
- */
- if (!drm_sched_can_queue(sched, entity)) {
- spin_unlock(&rq->lock);
- return ERR_PTR(-ENOSPC);
- }
-
- rq->current_entity = entity;
- reinit_completion(&entity->entity_idle);
- spin_unlock(&rq->lock);
- return entity;
- }
+ if (drm_sched_entity_is_ready(entity))
+ goto found;
}
}
list_for_each_entry(entity, &rq->entities, list) {
- if (drm_sched_entity_is_ready(entity)) {
- /* If we can't queue yet, preserve the current entity in
- * terms of fairness.
- */
- if (!drm_sched_can_queue(sched, entity)) {
- spin_unlock(&rq->lock);
- return ERR_PTR(-ENOSPC);
- }
-
- rq->current_entity = entity;
- reinit_completion(&entity->entity_idle);
- spin_unlock(&rq->lock);
- return entity;
- }
+ if (drm_sched_entity_is_ready(entity))
+ goto found;
if (entity == rq->current_entity)
break;
@@ -303,6 +279,22 @@ drm_sched_rq_select_entity_rr(struct drm_gpu_scheduler *sched,
spin_unlock(&rq->lock);
return NULL;
+
+found:
+ if (!drm_sched_can_queue(sched, entity)) {
+ /*
+ * If scheduler cannot take more jobs signal the caller to not
+ * consider lower priority queues.
+ */
+ entity = ERR_PTR(-ENOSPC);
+ } else {
+ rq->current_entity = entity;
+ reinit_completion(&entity->entity_idle);
+ }
+
+ spin_unlock(&rq->lock);
+
+ return entity;
}
/**
--
2.48.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/sched: Consolidate drm_sched_rq_select_entity_rr
2025-07-08 12:21 [PATCH] drm/sched: Consolidate drm_sched_rq_select_entity_rr Tvrtko Ursulin
@ 2025-07-08 19:24 ` Matthew Brost
2025-07-09 9:50 ` Philipp Stanner
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Brost @ 2025-07-08 19:24 UTC (permalink / raw)
To: Tvrtko Ursulin
Cc: dri-devel, intel-xe, amd-gfx, kernel-dev, Christian König,
Danilo Krummrich, Philipp Stanner
On Tue, Jul 08, 2025 at 01:21:21PM +0100, Tvrtko Ursulin wrote:
> Extract out two copies of the identical code to function epilogue to make
> it smaller and more readable.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Danilo Krummrich <dakr@kernel.org>
> Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> ---
> drivers/gpu/drm/scheduler/sched_main.c | 48 +++++++++++---------------
> 1 file changed, 20 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 2335df4de2b8..9212ebae7476 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -263,38 +263,14 @@ drm_sched_rq_select_entity_rr(struct drm_gpu_scheduler *sched,
> entity = rq->current_entity;
> if (entity) {
> list_for_each_entry_continue(entity, &rq->entities, list) {
> - if (drm_sched_entity_is_ready(entity)) {
> - /* If we can't queue yet, preserve the current
> - * entity in terms of fairness.
> - */
> - if (!drm_sched_can_queue(sched, entity)) {
> - spin_unlock(&rq->lock);
> - return ERR_PTR(-ENOSPC);
> - }
> -
> - rq->current_entity = entity;
> - reinit_completion(&entity->entity_idle);
> - spin_unlock(&rq->lock);
> - return entity;
> - }
> + if (drm_sched_entity_is_ready(entity))
> + goto found;
> }
> }
>
> list_for_each_entry(entity, &rq->entities, list) {
> - if (drm_sched_entity_is_ready(entity)) {
> - /* If we can't queue yet, preserve the current entity in
> - * terms of fairness.
> - */
> - if (!drm_sched_can_queue(sched, entity)) {
> - spin_unlock(&rq->lock);
> - return ERR_PTR(-ENOSPC);
> - }
> -
> - rq->current_entity = entity;
> - reinit_completion(&entity->entity_idle);
> - spin_unlock(&rq->lock);
> - return entity;
> - }
> + if (drm_sched_entity_is_ready(entity))
> + goto found;
>
> if (entity == rq->current_entity)
> break;
> @@ -303,6 +279,22 @@ drm_sched_rq_select_entity_rr(struct drm_gpu_scheduler *sched,
> spin_unlock(&rq->lock);
>
> return NULL;
> +
> +found:
> + if (!drm_sched_can_queue(sched, entity)) {
> + /*
> + * If scheduler cannot take more jobs signal the caller to not
> + * consider lower priority queues.
> + */
> + entity = ERR_PTR(-ENOSPC);
> + } else {
> + rq->current_entity = entity;
> + reinit_completion(&entity->entity_idle);
> + }
> +
> + spin_unlock(&rq->lock);
> +
> + return entity;
> }
>
> /**
> --
> 2.48.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/sched: Consolidate drm_sched_rq_select_entity_rr
2025-07-08 12:21 [PATCH] drm/sched: Consolidate drm_sched_rq_select_entity_rr Tvrtko Ursulin
2025-07-08 19:24 ` Matthew Brost
@ 2025-07-09 9:50 ` Philipp Stanner
1 sibling, 0 replies; 3+ messages in thread
From: Philipp Stanner @ 2025-07-09 9:50 UTC (permalink / raw)
To: Tvrtko Ursulin, dri-devel
Cc: intel-xe, amd-gfx, kernel-dev, Christian König,
Danilo Krummrich, Matthew Brost, Philipp Stanner
On Tue, 2025-07-08 at 13:21 +0100, Tvrtko Ursulin wrote:
> Extract out two copies of the identical code to function epilogue to
> make
> it smaller and more readable.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Danilo Krummrich <dakr@kernel.org>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Philipp Stanner <phasta@kernel.org>
Pushed to drm-misc-next, thx.
P.
> ---
> drivers/gpu/drm/scheduler/sched_main.c | 48 +++++++++++-------------
> --
> 1 file changed, 20 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c
> b/drivers/gpu/drm/scheduler/sched_main.c
> index 2335df4de2b8..9212ebae7476 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -263,38 +263,14 @@ drm_sched_rq_select_entity_rr(struct
> drm_gpu_scheduler *sched,
> entity = rq->current_entity;
> if (entity) {
> list_for_each_entry_continue(entity, &rq->entities,
> list) {
> - if (drm_sched_entity_is_ready(entity)) {
> - /* If we can't queue yet, preserve
> the current
> - * entity in terms of fairness.
> - */
> - if (!drm_sched_can_queue(sched,
> entity)) {
> - spin_unlock(&rq->lock);
> - return ERR_PTR(-ENOSPC);
> - }
> -
> - rq->current_entity = entity;
> - reinit_completion(&entity-
> >entity_idle);
> - spin_unlock(&rq->lock);
> - return entity;
> - }
> + if (drm_sched_entity_is_ready(entity))
> + goto found;
> }
> }
>
> list_for_each_entry(entity, &rq->entities, list) {
> - if (drm_sched_entity_is_ready(entity)) {
> - /* If we can't queue yet, preserve the
> current entity in
> - * terms of fairness.
> - */
> - if (!drm_sched_can_queue(sched, entity)) {
> - spin_unlock(&rq->lock);
> - return ERR_PTR(-ENOSPC);
> - }
> -
> - rq->current_entity = entity;
> - reinit_completion(&entity->entity_idle);
> - spin_unlock(&rq->lock);
> - return entity;
> - }
> + if (drm_sched_entity_is_ready(entity))
> + goto found;
>
> if (entity == rq->current_entity)
> break;
> @@ -303,6 +279,22 @@ drm_sched_rq_select_entity_rr(struct
> drm_gpu_scheduler *sched,
> spin_unlock(&rq->lock);
>
> return NULL;
> +
> +found:
> + if (!drm_sched_can_queue(sched, entity)) {
> + /*
> + * If scheduler cannot take more jobs signal the
> caller to not
> + * consider lower priority queues.
> + */
> + entity = ERR_PTR(-ENOSPC);
> + } else {
> + rq->current_entity = entity;
> + reinit_completion(&entity->entity_idle);
> + }
> +
> + spin_unlock(&rq->lock);
> +
> + return entity;
> }
>
> /**
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-09 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 12:21 [PATCH] drm/sched: Consolidate drm_sched_rq_select_entity_rr Tvrtko Ursulin
2025-07-08 19:24 ` Matthew Brost
2025-07-09 9:50 ` Philipp Stanner
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).