bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0441-drm-vc4-Increase-the-core-clock-based-on-HVS-load.patch
1 From 7971426f2462b02ea1bf12d902ca066e07eeb64b Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 26 May 2021 16:13:02 +0200
4 Subject: [PATCH] drm/vc4: Increase the core clock based on HVS load
5
6 Depending on a given HVS output (HVS to PixelValves) and input (planes
7 attached to a channel) load, the HVS needs for the core clock to be
8 raised above its boot time default.
9
10 Failing to do so will result in a vblank timeout and a stalled display
11 pipeline.
12
13 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
14 ---
15 drivers/gpu/drm/vc4/vc4_drv.h | 1 +
16 drivers/gpu/drm/vc4/vc4_kms.c | 13 +++++++++++++
17 2 files changed, 14 insertions(+)
18
19 --- a/drivers/gpu/drm/vc4/vc4_drv.h
20 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
21 @@ -321,6 +321,7 @@ struct vc4_hvs {
22 u32 __iomem *dlist;
23
24 struct clk *core_clk;
25 + struct clk_request *core_req;
26
27 /* Memory manager for CRTCs to allocate space in the display
28 * list. Units are dwords.
29 --- a/drivers/gpu/drm/vc4/vc4_kms.c
30 +++ b/drivers/gpu/drm/vc4/vc4_kms.c
31 @@ -391,6 +391,11 @@ static void vc4_atomic_commit_tail(struc
32 new_hvs_state->core_clock_rate);
33
34 core_req = clk_request_start(hvs->core_clk, core_rate);
35 + /*
36 + * And remove the previous one based on the HVS
37 + * requirements if any.
38 + */
39 + clk_request_done(hvs->core_req);
40 }
41
42 drm_atomic_helper_commit_modeset_disables(dev, state);
43 @@ -418,6 +423,14 @@ static void vc4_atomic_commit_tail(struc
44 drm_dbg(dev, "Running the core clock at %lu Hz\n",
45 new_hvs_state->core_clock_rate);
46
47 + /*
48 + * Request a clock rate based on the current HVS
49 + * requirements.
50 + */
51 + hvs->core_req = clk_request_start(hvs->core_clk,
52 + new_hvs_state->core_clock_rate);
53 +
54 + /* And drop the temporary request */
55 clk_request_done(core_req);
56 }
57 }