dced86878d1eb82c206b02238247873cf7b6fd9e
[openwrt/staging/stintel.git] /
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
5 never hit the hw
6
7 atomic_check creates a state, and allocates the dlist memory for
8 it such that atomic_flush can not fail.
9
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
13 memory and fail.
14
15 If the dlist has never been programmed into the hardware, then
16 free it immediately.
17
18 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
19 ---
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(-)
23
24 --- a/drivers/gpu/drm/vc4/vc4_drv.h
25 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
26 @@ -665,6 +665,7 @@ struct vc4_hvs_dlist_allocation {
27 struct drm_mm_node mm_node;
28 unsigned int channel;
29 u8 target_frame_count;
30 + bool dlist_programmed;
31 };
32
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.
40 + *
41 + * Likewise if the allocation was only checked and never programmed, we
42 + * can destroy the allocation immediately.
43 */
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 @@ -1195,6 +1198,7 @@ static void vc4_hvs_install_dlist(struct
50 return;
51
52 WARN_ON(!vc4_state->mm);
53 + vc4_state->mm->dlist_programmed = true;
54
55 if (vc4->gen >= VC4_GEN_6)
56 HVS_WRITE(SCALER6_DISPX_LPTRS(vc4_state->assigned_channel),