1 From 4aad27d1201b4dc3974d682ba52eb798bdb557cd Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 22 Nov 2023 18:36:54 +0000
4 Subject: [PATCH 0740/1085] drm: vc4: Free the dlist alloc immediately if it
7 atomic_check creates a state, and allocates the dlist memory for
8 it such that atomic_flush can not fail.
10 On destroy that dlist allocation was being put in the stale list,
11 even though it had never been programmed into the hardware,
12 therefore doing lots of atomic_checks could consume all the dlist
15 If the dlist has never been programmed into the hardware, then
18 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
20 drivers/gpu/drm/vc4/vc4_drv.h | 1 +
21 drivers/gpu/drm/vc4/vc4_hvs.c | 6 +++++-
22 2 files changed, 6 insertions(+), 1 deletion(-)
24 --- a/drivers/gpu/drm/vc4/vc4_drv.h
25 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
26 @@ -667,6 +667,7 @@ struct vc4_hvs_dlist_allocation {
27 struct drm_mm_node mm_node;
29 u8 target_frame_count;
30 + bool dlist_programmed;
33 struct vc4_crtc_state {
34 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
35 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
36 @@ -697,8 +697,11 @@ void vc4_hvs_mark_dlist_entry_stale(stru
37 * Kunit tests run with a mock device and we consider any hardware
38 * access a test failure. Let's free the dlist allocation right away if
39 * we're running under kunit, we won't risk a dlist corruption anyway.
41 + * Likewise if the allocation was only checked and never programmed, we
42 + * can destroy the allocation immediately.
44 - if (kunit_get_current_test()) {
45 + if (kunit_get_current_test() || !alloc->dlist_programmed) {
46 spin_lock_irqsave(&hvs->mm_lock, flags);
47 vc4_hvs_free_dlist_entry_locked(hvs, alloc);
48 spin_unlock_irqrestore(&hvs->mm_lock, flags);
49 @@ -1201,6 +1204,7 @@ static void vc4_hvs_install_dlist(struct
52 WARN_ON(!vc4_state->mm);
53 + vc4_state->mm->dlist_programmed = true;
55 if (vc4->gen >= VC4_GEN_6)
56 HVS_WRITE(SCALER6_DISPX_LPTRS(vc4_state->assigned_channel),