1e2893381df2b7b8cf8bc18bfc500e72af49bda7
[openwrt/staging/ldir.git] /
1 From d8e53e0b83c947123c38c81d2fb5162c86d26fb5 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 4 Jan 2024 12:39:33 +0000
4 Subject: [PATCH 1247/1295] drm/vc4: Optimise vc4_hvs_dlist_free_work to only
5 read frcnt and active once
6
7 vc4_hvs_dlist_free_work was iterating through the list of stale
8 dlist entries and reading the frame count and active flags from
9 the hardware for each one.
10
11 Read the frame count and active flags once, and then use the
12 cached value in the loop.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 ---
16 drivers/gpu/drm/vc4/vc4_hvs.c | 15 ++++++++++-----
17 1 file changed, 10 insertions(+), 5 deletions(-)
18
19 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
20 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
21 @@ -796,14 +796,19 @@ static void vc4_hvs_dlist_free_work(stru
22 struct vc4_hvs *hvs = container_of(work, struct vc4_hvs, free_dlist_work);
23 struct vc4_hvs_dlist_allocation *cur, *next;
24 unsigned long flags;
25 + bool active[3];
26 + u8 frcnt[3];
27 + int i;
28 +
29
30 spin_lock_irqsave(&hvs->mm_lock, flags);
31 + for (i = 0; i < 3; i++) {
32 + frcnt[i] = vc4_hvs_get_fifo_frame_count(hvs, i);
33 + active[i] = vc4_hvs_check_channel_active(hvs, i);
34 + }
35 list_for_each_entry_safe(cur, next, &hvs->stale_dlist_entries, node) {
36 - u8 frcnt;
37 -
38 - frcnt = vc4_hvs_get_fifo_frame_count(hvs, cur->channel);
39 - if (vc4_hvs_check_channel_active(hvs, cur->channel) &&
40 - !vc4_hvs_frcnt_lte(cur->target_frame_count, frcnt))
41 + if (active[cur->channel] &&
42 + !vc4_hvs_frcnt_lte(cur->target_frame_count, frcnt[cur->channel]))
43 continue;
44
45 vc4_hvs_free_dlist_entry_locked(hvs, cur);