@@ -263,38 +263,14 @@ drm_sched_rq_select_entity_rr(struct drm_gpu_scheduler *sched,
263
263
entity = rq -> current_entity ;
264
264
if (entity ) {
265
265
list_for_each_entry_continue (entity , & rq -> entities , list ) {
266
- if (drm_sched_entity_is_ready (entity )) {
267
- /* If we can't queue yet, preserve the current
268
- * entity in terms of fairness.
269
- */
270
- if (!drm_sched_can_queue (sched , entity )) {
271
- spin_unlock (& rq -> lock );
272
- return ERR_PTR (- ENOSPC );
273
- }
274
-
275
- rq -> current_entity = entity ;
276
- reinit_completion (& entity -> entity_idle );
277
- spin_unlock (& rq -> lock );
278
- return entity ;
279
- }
266
+ if (drm_sched_entity_is_ready (entity ))
267
+ goto found ;
280
268
}
281
269
}
282
270
283
271
list_for_each_entry (entity , & rq -> entities , list ) {
284
- if (drm_sched_entity_is_ready (entity )) {
285
- /* If we can't queue yet, preserve the current entity in
286
- * terms of fairness.
287
- */
288
- if (!drm_sched_can_queue (sched , entity )) {
289
- spin_unlock (& rq -> lock );
290
- return ERR_PTR (- ENOSPC );
291
- }
292
-
293
- rq -> current_entity = entity ;
294
- reinit_completion (& entity -> entity_idle );
295
- spin_unlock (& rq -> lock );
296
- return entity ;
297
- }
272
+ if (drm_sched_entity_is_ready (entity ))
273
+ goto found ;
298
274
299
275
if (entity == rq -> current_entity )
300
276
break ;
@@ -303,6 +279,22 @@ drm_sched_rq_select_entity_rr(struct drm_gpu_scheduler *sched,
303
279
spin_unlock (& rq -> lock );
304
280
305
281
return NULL ;
282
+
283
+ found :
284
+ if (!drm_sched_can_queue (sched , entity )) {
285
+ /*
286
+ * If scheduler cannot take more jobs signal the caller to not
287
+ * consider lower priority queues.
288
+ */
289
+ entity = ERR_PTR (- ENOSPC );
290
+ } else {
291
+ rq -> current_entity = entity ;
292
+ reinit_completion (& entity -> entity_idle );
293
+ }
294
+
295
+ spin_unlock (& rq -> lock );
296
+
297
+ return entity ;
306
298
}
307
299
308
300
/**
0 commit comments