kernel: bump 5.4 to 5.4.48
[oweals/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0549-drm-vc4-plane-Register-all-the-planes-at-once.patch
1 From bb2b068209d73b320cac7222a3b8ecef9b0dcc9a Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 6 Feb 2020 14:46:14 +0100
4 Subject: [PATCH] drm/vc4: plane: Register all the planes at once
5
6 Instead of creating planes for each CRTC, we eventually want to create all
7 the planes for each CRTCs.
8
9 In order to make that more convenient, let's iterate on the CRTCs in the
10 plane creation function instead of its caller.
11
12 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
13 ---
14  drivers/gpu/drm/vc4/vc4_drv.c   |  9 ++----
15  drivers/gpu/drm/vc4/vc4_drv.h   |  3 +-
16  drivers/gpu/drm/vc4/vc4_plane.c | 54 +++++++++++++++++----------------
17  3 files changed, 32 insertions(+), 34 deletions(-)
18
19 --- a/drivers/gpu/drm/vc4/vc4_drv.c
20 +++ b/drivers/gpu/drm/vc4/vc4_drv.c
21 @@ -253,7 +253,6 @@ static int vc4_drm_bind(struct device *d
22  {
23         struct platform_device *pdev = to_platform_device(dev);
24         struct drm_device *drm;
25 -       struct drm_crtc *crtc;
26         struct vc4_dev *vc4;
27         struct device_node *node;
28         int ret = 0;
29 @@ -292,11 +291,9 @@ static int vc4_drm_bind(struct device *d
30         if (ret)
31                 goto gem_destroy;
32  
33 -       drm_for_each_crtc(crtc, drm) {
34 -               ret = vc4_plane_create_additional_planes(drm, crtc);
35 -               if (ret)
36 -                       continue;
37 -       }
38 +       ret = vc4_plane_create_additional_planes(drm);
39 +       if (ret)
40 +               goto unbind_all;
41  
42         drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false);
43  
44 --- a/drivers/gpu/drm/vc4/vc4_drv.h
45 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
46 @@ -855,8 +855,7 @@ int vc4_kms_load(struct drm_device *dev)
47  /* vc4_plane.c */
48  struct drm_plane *vc4_plane_init(struct drm_device *dev,
49                                  enum drm_plane_type type);
50 -int vc4_plane_create_additional_planes(struct drm_device *dev,
51 -                                      struct drm_crtc *crtc);
52 +int vc4_plane_create_additional_planes(struct drm_device *dev);
53  u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
54  u32 vc4_plane_dlist_size(const struct drm_plane_state *state);
55  void vc4_plane_async_set_fb(struct drm_plane *plane,
56 --- a/drivers/gpu/drm/vc4/vc4_plane.c
57 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
58 @@ -1438,39 +1438,41 @@ struct drm_plane *vc4_plane_init(struct
59         return plane;
60  }
61  
62 -int vc4_plane_create_additional_planes(struct drm_device *drm,
63 -                                      struct drm_crtc *crtc)
64 +int vc4_plane_create_additional_planes(struct drm_device *drm)
65  {
66         struct drm_plane *cursor_plane;
67 +       struct drm_crtc *crtc;
68         unsigned int i;
69  
70 -       /* Set up some arbitrary number of planes.  We're not limited
71 -        * by a set number of physical registers, just the space in
72 -        * the HVS (16k) and how small an plane can be (28 bytes).
73 -        * However, each plane we set up takes up some memory, and
74 -        * increases the cost of looping over planes, which atomic
75 -        * modesetting does quite a bit.  As a result, we pick a
76 -        * modest number of planes to expose, that should hopefully
77 -        * still cover any sane usecase.
78 -        */
79 -       for (i = 0; i < 8; i++) {
80 -               struct drm_plane *plane =
81 -                       vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
82 -
83 -               if (IS_ERR(plane))
84 -                       continue;
85 -
86 -               plane->possible_crtcs = drm_crtc_mask(crtc);
87 -       }
88 -
89 -       /* Set up the legacy cursor after overlay initialization,
90 -        * since we overlay planes on the CRTC in the order they were
91 -        * initialized.
92 -        */
93 -       cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
94 -       if (!IS_ERR(cursor_plane)) {
95 -               cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
96 -               crtc->cursor = cursor_plane;
97 +       drm_for_each_crtc(crtc, drm) {
98 +               /* Set up some arbitrary number of planes.  We're not limited
99 +                * by a set number of physical registers, just the space in
100 +                * the HVS (16k) and how small an plane can be (28 bytes).
101 +                * However, each plane we set up takes up some memory, and
102 +                * increases the cost of looping over planes, which atomic
103 +                * modesetting does quite a bit.  As a result, we pick a
104 +                * modest number of planes to expose, that should hopefully
105 +                * still cover any sane usecase.
106 +                */
107 +               for (i = 0; i < 8; i++) {
108 +                       struct drm_plane *plane =
109 +                               vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
110 +
111 +                       if (IS_ERR(plane))
112 +                               continue;
113 +
114 +                       plane->possible_crtcs = drm_crtc_mask(crtc);
115 +               }
116 +
117 +               /* Set up the legacy cursor after overlay initialization,
118 +                * since we overlay planes on the CRTC in the order they were
119 +                * initialized.
120 +                */
121 +               cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
122 +               if (!IS_ERR(cursor_plane)) {
123 +                       cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
124 +                       crtc->cursor = cursor_plane;
125 +               }
126         }
127  
128         return 0;