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
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.
11 Read the frame count and active flags once, and then use the
12 cached value in the loop.
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 drivers/gpu/drm/vc4/vc4_hvs.c | 15 ++++++++++-----
17 1 file changed, 10 insertions(+), 5 deletions(-)
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;
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);
35 list_for_each_entry_safe(cur, next, &hvs->stale_dlist_entries, node) {
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]))
45 vc4_hvs_free_dlist_entry_locked(hvs, cur);