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 @@ -4175,8 +4164,8 @@ void intel_execlists_dump_active_request
43 intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
45 - drm_printf(m, "\tOn hold?: %lu\n",
46 - list_count(&engine->sched_engine->hold));
47 + drm_printf(m, "\tOn hold?: %zu\n",
48 + list_count_nodes(&engine->sched_engine->hold));
50 spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
52 --- a/include/linux/list.h
53 +++ b/include/linux/list.h
54 @@ -656,6 +656,21 @@ static inline void list_splice_tail_init
55 pos = n, n = pos->prev)
58 + * list_count_nodes - count nodes in the list
59 + * @head: the head for your list.
61 +static inline size_t list_count_nodes(struct list_head *head)
63 + struct list_head *pos;
66 + list_for_each(pos, head)
73 * list_entry_is_head - test if the entry points to the head of the list
74 * @pos: the type * to cursor
75 * @head: the head for your list.