bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1163-drm-vc4-Free-the-dlist-alloc-immediately-if-it-never.patch
1 From 51712a6493bf8824419f51ca7950e7d88f48b699 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] drm: vc4: Free the dlist alloc immediately if it never hit
5 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 @@ -696,6 +696,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 @@ -1201,6 +1204,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),