60a90136c93bf19900ae2d112f84a864853c26b8
[openwrt/staging/pepe2k.git] / target / linux / generic / backport-6.1 / 810-v6.3-i915-Move-list_count-to-list.h-as-list_count_nodes-f.patch
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
5 broader use
6
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.
10
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>
16 ---
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(-)
20
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);
25 }
26
27 -static unsigned long list_count(struct list_head *list)
28 -{
29 - struct list_head *pos;
30 - unsigned long count = 0;
31 -
32 - list_for_each(pos, list)
33 - count++;
34 -
35 - return count;
36 -}
37 -
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
42
43 intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
44
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));
49
50 spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
51 }
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)
56
57 /**
58 + * list_count_nodes - count nodes in the list
59 + * @head: the head for your list.
60 + */
61 +static inline size_t list_count_nodes(struct list_head *head)
62 +{
63 + struct list_head *pos;
64 + size_t count = 0;
65 +
66 + list_for_each(pos, head)
67 + count++;
68 +
69 + return count;
70 +}
71 +
72 +/**
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.