67be70d9a2894712e0fcf2aa27b37180b2d3cb90
[openwrt/staging/xback.git] /
1 From e33f46eba97edbaff7744bfd5c5a093cd2c567d3 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 17 Jan 2024 18:36:11 +0000
4 Subject: [PATCH 0837/1085] drm/vc4: Flush stale dlist entries if allocation
5 fails
6
7 This is largely for debug at present.
8 For reasons unknown we are not getting the end of frame interrupts
9 that should trigger a sweep of stale dlist entries.
10
11 On allocation failure clear out ALL stale entries, and retry the
12 allocation. Log the interrupt status so we have debug regarding
13 whether the HVS believes the interrupt is enabled.
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 ---
17 drivers/gpu/drm/vc4/vc4_hvs.c | 27 ++++++++++++++++++++++++---
18 1 file changed, 24 insertions(+), 3 deletions(-)
19
20 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
21 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
22 @@ -693,6 +693,9 @@ static void vc4_hvs_irq_clear_eof(struct
23 hvs->eof_irq[channel].enabled = false;
24 }
25
26 +static void vc4_hvs_free_dlist_entry_locked(struct vc4_hvs *hvs,
27 + struct vc4_hvs_dlist_allocation *alloc);
28 +
29 static struct vc4_hvs_dlist_allocation *
30 vc4_hvs_alloc_dlist_entry(struct vc4_hvs *hvs,
31 unsigned int channel,
32 @@ -701,6 +704,7 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
33 struct vc4_dev *vc4 = hvs->vc4;
34 struct drm_device *dev = &vc4->base;
35 struct vc4_hvs_dlist_allocation *alloc;
36 + struct vc4_hvs_dlist_allocation *cur, *next;
37 unsigned long flags;
38 int ret;
39
40 @@ -718,9 +722,26 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
41 dlist_count);
42 spin_unlock_irqrestore(&hvs->mm_lock, flags);
43 if (ret) {
44 - drm_err(dev, "Failed to allocate DLIST entry. Requested size=%zu. ret=%d\n",
45 - dlist_count, ret);
46 - return ERR_PTR(ret);
47 + drm_err(dev, "Failed to allocate DLIST entry. Requested size=%zu. ret=%d. DISPCTRL is %08x\n",
48 + dlist_count, ret, HVS_READ(SCALER_DISPCTRL));
49 +
50 + /* This should never happen as stale entries should get released
51 + * as the frame counter interrupt triggers.
52 + * However we've seen this fail for reasons currently unknown.
53 + * Free all stale entries now so we should be able to complete
54 + * this allocation.
55 + */
56 + spin_lock_irqsave(&hvs->mm_lock, flags);
57 + list_for_each_entry_safe(cur, next, &hvs->stale_dlist_entries, node) {
58 + vc4_hvs_free_dlist_entry_locked(hvs, cur);
59 + }
60 +
61 + ret = drm_mm_insert_node(&hvs->dlist_mm, &alloc->mm_node,
62 + dlist_count);
63 + spin_unlock_irqrestore(&hvs->mm_lock, flags);
64 +
65 + if (ret)
66 + return ERR_PTR(ret);
67 }
68
69 alloc->channel = channel;