6f26f0f2817b8d8922e833c6e0529472fb87ae4e
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0017-drm-vc4-Leverage-the-load-tracker-on-the-BCM2711.patch
1 From 1cc57695d3103fa93eda71bb6ba212c3e5806b4a Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 21 Jun 2021 17:19:22 +0200
4 Subject: [PATCH] drm/vc4: Leverage the load tracker on the BCM2711
5
6 The load tracker was initially designed to report and warn about a load
7 too high for the HVS. To do so, it computes for each plane the impact
8 it's going to have on the HVS, and will warn (if it's enabled) if we go
9 over what the hardware can process.
10
11 While the limits being used are a bit irrelevant to the BCM2711, the
12 algorithm to compute the HVS load will be one component used in order to
13 compute the core clock rate on the BCM2711.
14
15 Let's remove the hooks to prevent the load tracker to do its
16 computation, but since we don't have the same limits, don't check them
17 against them, and prevent the debugfs file to enable it from being
18 created.
19
20 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
21 ---
22 drivers/gpu/drm/vc4/vc4_debugfs.c | 7 +++++--
23 drivers/gpu/drm/vc4/vc4_drv.h | 3 ---
24 drivers/gpu/drm/vc4/vc4_kms.c | 16 +++++-----------
25 drivers/gpu/drm/vc4/vc4_plane.c | 5 -----
26 4 files changed, 10 insertions(+), 21 deletions(-)
27
28 --- a/drivers/gpu/drm/vc4/vc4_debugfs.c
29 +++ b/drivers/gpu/drm/vc4/vc4_debugfs.c
30 @@ -7,6 +7,7 @@
31 #include <linux/circ_buf.h>
32 #include <linux/ctype.h>
33 #include <linux/debugfs.h>
34 +#include <linux/platform_device.h>
35
36 #include "vc4_drv.h"
37 #include "vc4_regs.h"
38 @@ -26,8 +27,10 @@ vc4_debugfs_init(struct drm_minor *minor
39 struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
40 struct vc4_debugfs_info_entry *entry;
41
42 - debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
43 - minor->debugfs_root, &vc4->load_tracker_enabled);
44 + if (!of_device_is_compatible(vc4->hvs->pdev->dev.of_node,
45 + "brcm,bcm2711-vc5"))
46 + debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
47 + minor->debugfs_root, &vc4->load_tracker_enabled);
48
49 list_for_each_entry(entry, &vc4->debugfs_list, link) {
50 drm_debugfs_create_files(&entry->info, 1,
51 --- a/drivers/gpu/drm/vc4/vc4_drv.h
52 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
53 @@ -202,9 +202,6 @@ struct vc4_dev {
54
55 int power_refcount;
56
57 - /* Set to true when the load tracker is supported. */
58 - bool load_tracker_available;
59 -
60 /* Set to true when the load tracker is active. */
61 bool load_tracker_enabled;
62
63 --- a/drivers/gpu/drm/vc4/vc4_kms.c
64 +++ b/drivers/gpu/drm/vc4/vc4_kms.c
65 @@ -554,9 +554,6 @@ static int vc4_load_tracker_atomic_check
66 struct drm_plane *plane;
67 int i;
68
69 - if (!vc4->load_tracker_available)
70 - return 0;
71 -
72 priv_state = drm_atomic_get_private_obj_state(state,
73 &vc4->load_tracker);
74 if (IS_ERR(priv_state))
75 @@ -631,9 +628,6 @@ static void vc4_load_tracker_obj_fini(st
76 {
77 struct vc4_dev *vc4 = to_vc4_dev(dev);
78
79 - if (!vc4->load_tracker_available)
80 - return;
81 -
82 drm_atomic_private_obj_fini(&vc4->load_tracker);
83 }
84
85 @@ -641,9 +635,6 @@ static int vc4_load_tracker_obj_init(str
86 {
87 struct vc4_load_tracker_state *load_state;
88
89 - if (!vc4->load_tracker_available)
90 - return 0;
91 -
92 load_state = kzalloc(sizeof(*load_state), GFP_KERNEL);
93 if (!load_state)
94 return -ENOMEM;
95 @@ -865,9 +856,12 @@ int vc4_kms_load(struct drm_device *dev)
96 "brcm,bcm2711-vc5");
97 int ret;
98
99 + /*
100 + * The limits enforced by the load tracker aren't relevant for
101 + * the BCM2711, but the load tracker computations are used for
102 + * the core clock rate calculation.
103 + */
104 if (!is_vc5) {
105 - vc4->load_tracker_available = true;
106 -
107 /* Start with the load tracker enabled. Can be
108 * disabled through the debugfs load_tracker file.
109 */
110 --- a/drivers/gpu/drm/vc4/vc4_plane.c
111 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
112 @@ -525,11 +525,6 @@ static void vc4_plane_calc_load(struct d
113 struct vc4_plane_state *vc4_state;
114 struct drm_crtc_state *crtc_state;
115 unsigned int vscale_factor;
116 - struct vc4_dev *vc4;
117 -
118 - vc4 = to_vc4_dev(state->plane->dev);
119 - if (!vc4->load_tracker_available)
120 - return;
121
122 vc4_state = to_vc4_plane_state(state);
123 crtc_state = drm_atomic_get_existing_crtc_state(state->state,