]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/drm-arm-hdlcd-actually-validate-crtc-modes.patch
fixes for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / drm-arm-hdlcd-actually-validate-crtc-modes.patch
1 From 97cb5df6d43cedb16b9fdd12464d87f1fe58b0d4 Mon Sep 17 00:00:00 2001
2 From: Robin Murphy <robin.murphy@arm.com>
3 Date: Fri, 17 May 2019 17:37:21 +0100
4 Subject: drm/arm/hdlcd: Actually validate CRTC modes
5
6 [ Upstream commit b96151edced4edb6a18aa89a5fa02c7066efff45 ]
7
8 Rather than allowing any old mode through, then subsequently refusing
9 unmatchable clock rates in atomic_check when it's too late to back out
10 and pick a different mode, let's do that validation up-front where it
11 will cause unsupported modes to be correctly pruned in the first place.
12
13 This also eliminates an issue whereby a perceived clock rate of 0 would
14 cause atomic disable to fail and prevent the module from being unloaded.
15
16 Signed-off-by: Robin Murphy <robin.murphy@arm.com>
17 Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
18 Signed-off-by: Sasha Levin <sashal@kernel.org>
19 ---
20 drivers/gpu/drm/arm/hdlcd_crtc.c | 11 +++++------
21 1 file changed, 5 insertions(+), 6 deletions(-)
22
23 diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
24 index 72b22b805412..4a108660cc8f 100644
25 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
26 +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
27 @@ -186,20 +186,19 @@ static void hdlcd_crtc_atomic_disable(struct drm_crtc *crtc,
28 clk_disable_unprepare(hdlcd->clk);
29 }
30
31 -static int hdlcd_crtc_atomic_check(struct drm_crtc *crtc,
32 - struct drm_crtc_state *state)
33 +static enum drm_mode_status hdlcd_crtc_mode_valid(struct drm_crtc *crtc,
34 + const struct drm_display_mode *mode)
35 {
36 struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
37 - struct drm_display_mode *mode = &state->adjusted_mode;
38 long rate, clk_rate = mode->clock * 1000;
39
40 rate = clk_round_rate(hdlcd->clk, clk_rate);
41 if (rate != clk_rate) {
42 /* clock required by mode not supported by hardware */
43 - return -EINVAL;
44 + return MODE_NOCLOCK;
45 }
46
47 - return 0;
48 + return MODE_OK;
49 }
50
51 static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc,
52 @@ -220,7 +219,7 @@ static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc,
53 }
54
55 static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
56 - .atomic_check = hdlcd_crtc_atomic_check,
57 + .mode_valid = hdlcd_crtc_mode_valid,
58 .atomic_begin = hdlcd_crtc_atomic_begin,
59 .atomic_enable = hdlcd_crtc_atomic_enable,
60 .atomic_disable = hdlcd_crtc_atomic_disable,
61 --
62 2.20.1
63