1 From 4d70c74659d9746502b23d055dba03d1d28ec388 Mon Sep 17 00:00:00 2001
2 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 Date: Wed, 30 Nov 2022 15:48:35 +0200
4 Subject: [PATCH] i915: Move list_count() to list.h as list_count_nodes() for
7 Some of the existing users, and definitely will be new ones, want to
8 count existing nodes in the list. Provide a generic API for that by
9 moving code from i915 to list.h.
11 Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
12 Acked-by: Jani Nikula <jani.nikula@intel.com>
13 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
14 Link: https://lore.kernel.org/r/20221130134838.23805-1-andriy.shevchenko@linux.intel.com
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 drivers/gpu/drm/i915/gt/intel_engine_cs.c | 15 ++-------------
18 include/linux/list.h | 15 +++++++++++++++
19 2 files changed, 17 insertions(+), 13 deletions(-)
21 --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
22 +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
23 @@ -4154,17 +4154,6 @@ void intel_execlists_show_requests(struc
24 spin_unlock_irqrestore(&sched_engine->lock, flags);
27 -static unsigned long list_count(struct list_head *list)
29 - struct list_head *pos;
30 - unsigned long count = 0;
32 - list_for_each(pos, list)
38 void intel_execlists_dump_active_requests(struct intel_engine_cs *engine,
39 struct i915_request *hung_rq,
40 struct drm_printer *m)
41 @@ -4176,7 +4165,7 @@ void intel_execlists_dump_active_request
42 intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
44 drm_printf(m, "\tOn hold?: %lu\n",
45 - list_count(&engine->sched_engine->hold));
46 + list_count_nodes(&engine->sched_engine->hold));
48 spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
50 --- a/include/linux/list.h
51 +++ b/include/linux/list.h
52 @@ -656,6 +656,21 @@ static inline void list_splice_tail_init
53 pos = n, n = pos->prev)
56 + * list_count_nodes - count nodes in the list
57 + * @head: the head for your list.
59 +static inline size_t list_count_nodes(struct list_head *head)
61 + struct list_head *pos;
64 + list_for_each(pos, head)
71 * list_entry_is_head - test if the entry points to the head of the list
72 * @pos: the type * to cursor
73 * @head: the head for your list.