d1: add new target
[openwrt/staging/pepe2k.git] / target / linux / d1 / patches-6.1 / 0087-drm-sun4i-tcon-Always-protect-the-LCD-dotclock-rate.patch
1 From 9ea0c216d4f85a8ea888a38853e9573bbd9e995a Mon Sep 17 00:00:00 2001
2 From: Samuel Holland <samuel@sholland.org>
3 Date: Sun, 7 Aug 2022 21:09:39 -0500
4 Subject: [PATCH 087/117] drm/sun4i: tcon: Always protect the LCD dotclock rate
5
6 This handles the case where multiple CRTCs get their .mode_set function
7 called during the same atomic commit, before rate protection is applied
8 by enabling the CRTC.
9
10 Signed-off-by: Samuel Holland <samuel@sholland.org>
11 ---
12 drivers/gpu/drm/sun4i/sun4i_dotclock.c | 4 ++++
13 drivers/gpu/drm/sun4i/sun4i_tcon.c | 6 ++++--
14 2 files changed, 8 insertions(+), 2 deletions(-)
15
16 --- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c
17 +++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
18 @@ -6,6 +6,7 @@
19 * Maxime Ripard <maxime.ripard@free-electrons.com>
20 */
21
22 +#include <linux/clk.h>
23 #include <linux/clk-provider.h>
24 #include <linux/regmap.h>
25
26 @@ -194,12 +195,15 @@ int sun4i_dclk_create(struct device *dev
27 if (IS_ERR(tcon->dclk))
28 return PTR_ERR(tcon->dclk);
29
30 + clk_rate_exclusive_get(tcon->dclk);
31 +
32 return 0;
33 }
34 EXPORT_SYMBOL(sun4i_dclk_create);
35
36 int sun4i_dclk_free(struct sun4i_tcon *tcon)
37 {
38 + clk_rate_exclusive_put(tcon->dclk);
39 clk_unregister(tcon->dclk);
40 return 0;
41 }
42 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
43 +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
44 @@ -108,9 +108,11 @@ static void sun4i_tcon_channel_set_statu
45
46 if (enabled) {
47 clk_prepare_enable(clk);
48 - clk_rate_exclusive_get(clk);
49 + if (clk != tcon->dclk)
50 + clk_rate_exclusive_get(clk);
51 } else {
52 - clk_rate_exclusive_put(clk);
53 + if (clk != tcon->dclk)
54 + clk_rate_exclusive_put(clk);
55 clk_disable_unprepare(clk);
56 }
57 }