bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0617-drm-vc4-kms-Take-old-state-core-clock-rate-into-acco.patch
1 From ae03b35cf2792e7c4cf55c44dc37322487b72d1d Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 18 Nov 2021 14:04:00 +0100
4 Subject: [PATCH] drm/vc4: kms: Take old state core clock rate into
5 account
6
7 During a commit, the core clock, which feeds the HVS, needs to run at
8 a minimum of 500MHz.
9
10 While doing that commit, we can also change the mode to one that
11 requires a higher core clock, so we take the core clock rate associated
12 to that new state into account for that boost.
13
14 However, the old state also needs to be taken into account if it
15 requires a core clock higher that the new one and our 500MHz limit,
16 since it's still live in hardware at the beginning of our commit.
17
18 Fixes: 16e101051f32 ("drm/vc4: Increase the core clock based on HVS load")
19 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
20 ---
21 drivers/gpu/drm/vc4/vc4_kms.c | 5 +++--
22 1 file changed, 3 insertions(+), 2 deletions(-)
23
24 --- a/drivers/gpu/drm/vc4/vc4_kms.c
25 +++ b/drivers/gpu/drm/vc4/vc4_kms.c
26 @@ -390,9 +390,10 @@ static void vc4_atomic_commit_tail(struc
27 }
28
29 if (vc4->hvs && vc4->hvs->hvs5) {
30 + unsigned long state_rate = max(old_hvs_state->core_clock_rate,
31 + new_hvs_state->core_clock_rate);
32 unsigned long core_rate = max_t(unsigned long,
33 - 500000000,
34 - new_hvs_state->core_clock_rate);
35 + 500000000, state_rate);
36
37 core_req = clk_request_start(hvs->core_clk, core_rate);
38 /*