df7a98fc548160432f68a101994ca60cfa3cab8b
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0546-drm-vc4-plane-Improve-LBM-usage.patch
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
5
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
9 to the screen.
10
11 Add some of the additional constraints to more accurately
12 describe the LBM requirements.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
16 ---
17 drivers/gpu/drm/vc4/vc4_plane.c | 31 ++++++++++++++++++++-----------
18 1 file changed, 20 insertions(+), 11 deletions(-)
19
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_
23 return NULL;
24 }
25
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,
28 + bool chroma_vrep)
29 {
30 - if (dst == src)
31 + if (dst == src && !chroma_vrep)
32 return VC4_SCALING_NONE;
33 if (3 * dst >= 2 * src)
34 return VC4_SCALING_PPF;
35 @@ -369,9 +370,11 @@ static int vc4_plane_setup_clipping_and_
36 return ret;
37
38 vc4_state->x_scaling[0] = vc4_get_scaling_mode(vc4_state->src_w[0],
39 - vc4_state->crtc_w);
40 + vc4_state->crtc_w,
41 + false);
42 vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],
43 - vc4_state->crtc_h);
44 + vc4_state->crtc_h,
45 + false);
46
47 vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE &&
48 vc4_state->y_scaling[0] == VC4_SCALING_NONE);
49 @@ -384,10 +387,12 @@ static int vc4_plane_setup_clipping_and_
50
51 vc4_state->x_scaling[1] =
52 vc4_get_scaling_mode(vc4_state->src_w[1],
53 - vc4_state->crtc_w);
54 + vc4_state->crtc_w,
55 + v_subsample == 2);
56 vc4_state->y_scaling[1] =
57 vc4_get_scaling_mode(vc4_state->src_h[1],
58 - vc4_state->crtc_h);
59 + vc4_state->crtc_h,
60 + v_subsample == 2);
61
62 /* YUV conversion requires that horizontal scaling be enabled
63 * on the UV plane even if vc4_get_scaling_mode() returned
64 @@ -437,10 +442,7 @@ static void vc4_write_ppf(struct vc4_pla
65 static u32 vc4_lbm_size(struct drm_plane_state *state)
66 {
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.
70 - */
71 - u32 pix_per_line = max(vc4_state->src_w[0], (u32)vc4_state->crtc_w);
72 + u32 pix_per_line;
73 u32 lbm;
74
75 /* LBM is not needed when there's no vertical scaling. */
76 @@ -448,6 +450,11 @@ static u32 vc4_lbm_size(struct drm_plane
77 vc4_state->y_scaling[1] == VC4_SCALING_NONE)
78 return 0;
79
80 + if (vc4_state->x_scaling[0] == VC4_SCALING_TPZ)
81 + pix_per_line = vc4_state->crtc_w;
82 + else
83 + pix_per_line = vc4_state->src_w[0];
84 +
85 if (!vc4_state->is_yuv) {
86 if (vc4_state->y_scaling[0] == VC4_SCALING_TPZ)
87 lbm = pix_per_line * 8;
88 @@ -583,7 +590,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,
91 &vc4_state->lbm,
92 - lbm_size, 32, 0, 0);
93 + lbm_size,
94 + vc4->hvs->hvs5 ? 64 : 32,
95 + 0, 0);
96 spin_unlock_irqrestore(&vc4->hvs->mm_lock, irqflags);
97
98 if (ret)