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
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.
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.
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 drivers/gpu/drm/vc4/vc4_hvs.c | 27 ++++++++++++++++++++++++---
18 1 file changed, 24 insertions(+), 3 deletions(-)
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;
26 +static void vc4_hvs_free_dlist_entry_locked(struct vc4_hvs *hvs,
27 + struct vc4_hvs_dlist_allocation *alloc);
29 static struct vc4_hvs_dlist_allocation *
30 vc4_hvs_alloc_dlist_entry(struct vc4_hvs *hvs,
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;
40 @@ -718,9 +722,26 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
42 spin_unlock_irqrestore(&hvs->mm_lock, flags);
44 - drm_err(dev, "Failed to allocate DLIST entry. Requested size=%zu. ret=%d\n",
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));
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
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);
61 + ret = drm_mm_insert_node(&hvs->dlist_mm, &alloc->mm_node,
63 + spin_unlock_irqrestore(&hvs->mm_lock, flags);
66 + return ERR_PTR(ret);
69 alloc->channel = channel;