1 From 81072e19a85bfa3f80c23acdff6156522d945efa Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 11 Feb 2020 16:55:02 +0000
4 Subject: [PATCH] drm/vc4: plane: Improve LBM usage
6 LBM allocations were always taking the worst case sizing of
7 max(src_width, dst_width) * 16. This is significantly over
8 the required sizing, and stops us rendering multiple 4k images
11 Add some of the additional constraints to more accurately
12 describe the LBM requirements.
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
17 drivers/gpu/drm/vc4/vc4_plane.c | 31 ++++++++++++++++++++-----------
18 1 file changed, 20 insertions(+), 11 deletions(-)
20 --- a/drivers/gpu/drm/vc4/vc4_plane.c
21 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
22 @@ -142,9 +142,10 @@ static const struct hvs_format *vc4_get_
26 -static enum vc4_scaling_mode vc4_get_scaling_mode(u32 src, u32 dst)
27 +static enum vc4_scaling_mode vc4_get_scaling_mode(u32 src, u32 dst,
31 + if (dst == src && !chroma_vrep)
32 return VC4_SCALING_NONE;
33 if (3 * dst >= 2 * src)
34 return VC4_SCALING_PPF;
35 @@ -377,9 +378,11 @@ static int vc4_plane_setup_clipping_and_
38 vc4_state->x_scaling[0] = vc4_get_scaling_mode(vc4_state->src_w[0],
42 vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],
47 vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE &&
48 vc4_state->y_scaling[0] == VC4_SCALING_NONE);
49 @@ -392,10 +395,12 @@ static int vc4_plane_setup_clipping_and_
51 vc4_state->x_scaling[1] =
52 vc4_get_scaling_mode(vc4_state->src_w[1],
56 vc4_state->y_scaling[1] =
57 vc4_get_scaling_mode(vc4_state->src_h[1],
62 /* YUV conversion requires that horizontal scaling be enabled
63 * on the UV plane even if vc4_get_scaling_mode() returned
64 @@ -445,10 +450,7 @@ static void vc4_write_ppf(struct vc4_pla
65 static u32 vc4_lbm_size(struct drm_plane_state *state)
67 struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
68 - /* This is the worst case number. One of the two sizes will
69 - * be used depending on the scaling configuration.
71 - u32 pix_per_line = max(vc4_state->src_w[0], (u32)vc4_state->crtc_w);
75 /* LBM is not needed when there's no vertical scaling. */
76 @@ -456,6 +458,11 @@ static u32 vc4_lbm_size(struct drm_plane
77 vc4_state->y_scaling[1] == VC4_SCALING_NONE)
80 + if (vc4_state->x_scaling[0] == VC4_SCALING_TPZ)
81 + pix_per_line = vc4_state->crtc_w;
83 + pix_per_line = vc4_state->src_w[0];
85 if (!vc4_state->is_yuv) {
86 if (vc4_state->y_scaling[0] == VC4_SCALING_TPZ)
87 lbm = pix_per_line * 8;
88 @@ -591,7 +598,9 @@ static int vc4_plane_allocate_lbm(struct
89 spin_lock_irqsave(&vc4->hvs->mm_lock, irqflags);
90 ret = drm_mm_insert_node_generic(&vc4->hvs->lbm_mm,
92 - lbm_size, 32, 0, 0);
94 + vc4->hvs->hvs5 ? 64 : 32,
96 spin_unlock_irqrestore(&vc4->hvs->mm_lock, irqflags);