1 From c0af63193bd307f281211e7fb32a02a52c2869b2 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 22 Mar 2023 09:53:17 +0100
4 Subject: [PATCH] drm/vc4: hvs: Print error if we fail an allocation
6 We need to allocate a few additional structures when checking our
7 atomic_state, especially related to hardware SRAM that will hold the
8 plane descriptors (DLIST) and the current line context (LBM) during
11 Since those allocation can fail, let's add some error message in that
12 case to help debug what goes wrong.
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
16 drivers/gpu/drm/vc4/vc4_hvs.c | 6 +++++-
17 drivers/gpu/drm/vc4/vc4_plane.c | 7 +++++--
18 2 files changed, 10 insertions(+), 3 deletions(-)
20 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
21 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
22 @@ -441,6 +441,8 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
26 + struct vc4_dev *vc4 = hvs->vc4;
27 + struct drm_device *dev = &vc4->base;
28 struct vc4_hvs_dlist_allocation *alloc;
31 @@ -458,8 +460,10 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
32 ret = drm_mm_insert_node(&hvs->dlist_mm, &alloc->mm_node,
34 spin_unlock_irqrestore(&hvs->mm_lock, flags);
37 + drm_err(dev, "Failed to allocate DLIST entry: %d\n", ret);
41 alloc->channel = channel;
43 --- a/drivers/gpu/drm/vc4/vc4_plane.c
44 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
45 @@ -733,7 +733,8 @@ static void vc4_plane_calc_load(struct d
47 static int vc4_plane_allocate_lbm(struct drm_plane_state *state)
49 - struct vc4_dev *vc4 = to_vc4_dev(state->plane->dev);
50 + struct drm_device *drm = state->plane->dev;
51 + struct vc4_dev *vc4 = to_vc4_dev(drm);
52 struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
53 unsigned long irqflags;
55 @@ -759,8 +760,10 @@ static int vc4_plane_allocate_lbm(struct
57 spin_unlock_irqrestore(&vc4->hvs->mm_lock, irqflags);
61 + drm_err(drm, "Failed to allocate LBM entry: %d\n", ret);
65 WARN_ON_ONCE(lbm_size != vc4_state->lbm.size);