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
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
10 Signed-off-by: Samuel Holland <samuel@sholland.org>
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(-)
16 --- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c
17 +++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
19 * Maxime Ripard <maxime.ripard@free-electrons.com>
22 +#include <linux/clk.h>
23 #include <linux/clk-provider.h>
24 #include <linux/regmap.h>
26 @@ -194,12 +195,15 @@ int sun4i_dclk_create(struct device *dev
27 if (IS_ERR(tcon->dclk))
28 return PTR_ERR(tcon->dclk);
30 + clk_rate_exclusive_get(tcon->dclk);
34 EXPORT_SYMBOL(sun4i_dclk_create);
36 int sun4i_dclk_free(struct sun4i_tcon *tcon)
38 + clk_rate_exclusive_put(tcon->dclk);
39 clk_unregister(tcon->dclk);
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
47 clk_prepare_enable(clk);
48 - clk_rate_exclusive_get(clk);
49 + if (clk != tcon->dclk)
50 + clk_rate_exclusive_get(clk);
52 - clk_rate_exclusive_put(clk);
53 + if (clk != tcon->dclk)
54 + clk_rate_exclusive_put(clk);
55 clk_disable_unprepare(clk);