1 From 268e65023226cc59363dd9c9d9ad56a11588f4c3 Mon Sep 17 00:00:00 2001
2 From: Daniel Vetter <daniel.vetter@ffwll.ch>
3 Date: Fri, 23 Oct 2020 14:39:23 +0200
4 Subject: [PATCH 0025/1085] drm/atomic-helpers: remove legacy_cursor_update
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 The stuff never really worked, and leads to lots of fun because it
11 out-of-order frees atomic states. Which upsets KASAN, among other
14 For async updates we now have a more solid solution with the
15 ->atomic_async_check and ->atomic_async_commit hooks. Support for that
16 for msm and vc4 landed. nouveau and i915 have their own commit
17 routines, doing something similar.
19 For everyone else it's probably better to remove the use-after-free
20 bug, and encourage folks to use the async support instead. The
21 affected drivers which register a legacy cursor plane and don't either
22 use the new async stuff or their own commit routine are: amdgpu,
23 atmel, mediatek, qxl, rockchip, sti, sun4i, tegra, virtio, and vmwgfx.
25 Inspired by an amdgpu bug report.
27 v2: Drop RFC, I think with amdgpu converted over to use
28 atomic_async_check/commit done in
30 commit 674e78acae0dfb4beb56132e41cbae5b60f7d662
31 Author: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
32 Date: Wed Dec 5 14:59:07 2018 -0500
34 drm/amd/display: Add fast path for cursor plane updates
36 we don't have any driver anymore where we have userspace expecting
37 solid legacy cursor support _and_ they are using the atomic helpers in
38 their fully glory. So we can retire this.
40 v3: Paper over msm and i915 regression. The complete_all is the only
43 v4: Rebased on recent kernel, added extra link for vc4 bug.
45 Link: https://bugzilla.kernel.org/show_bug.cgi?id=199425
46 Link: https://lore.kernel.org/all/20220221134155.125447-9-maxime@cerno.tech/
47 Cc: mikita.lipski@amd.com
48 Cc: Michel Dänzer <michel@daenzer.net>
49 Cc: harry.wentland@amd.com
50 Cc: Rob Clark <robdclark@gmail.com>
51 Cc: "Kazlauskas, Nicholas" <nicholas.kazlauskas@amd.com>
52 Tested-by: Maxime Ripard <maxime@cerno.tech>
53 Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
54 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
56 drivers/gpu/drm/drm_atomic_helper.c | 13 -------------
57 drivers/gpu/drm/i915/display/intel_display.c | 13 +++++++++++++
58 drivers/gpu/drm/msm/msm_atomic.c | 2 ++
59 3 files changed, 15 insertions(+), 13 deletions(-)
61 --- a/drivers/gpu/drm/drm_atomic_helper.c
62 +++ b/drivers/gpu/drm/drm_atomic_helper.c
63 @@ -1653,13 +1653,6 @@ drm_atomic_helper_wait_for_vblanks(struc
65 unsigned int crtc_mask = 0;
68 - * Legacy cursor ioctls are completely unsynced, and userspace
69 - * relies on that (by doing tons of cursor updates).
71 - if (old_state->legacy_cursor_update)
74 for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
75 if (!new_crtc_state->active)
77 @@ -2309,12 +2302,6 @@ int drm_atomic_helper_setup_commit(struc
78 complete_all(&commit->flip_done);
82 - /* Legacy cursor updates are fully unsynced. */
83 - if (state->legacy_cursor_update) {
84 - complete_all(&commit->flip_done);
88 if (!new_crtc_state->event) {
89 commit->event = kzalloc(sizeof(*commit->event),
90 --- a/drivers/gpu/drm/i915/display/intel_display.c
91 +++ b/drivers/gpu/drm/i915/display/intel_display.c
92 @@ -7280,6 +7280,19 @@ int intel_atomic_commit(struct drm_devic
93 state->base.legacy_cursor_update = false;
97 + * FIXME: Cut over to (async) commit helpers instead of hand-rolling
100 + if (state->base.legacy_cursor_update) {
101 + struct intel_crtc_state *new_crtc_state;
102 + struct intel_crtc *crtc;
105 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i)
106 + complete_all(&new_crtc_state->uapi.commit->flip_done);
109 ret = intel_atomic_prepare_commit(state);
111 drm_dbg_atomic(&dev_priv->drm,
112 --- a/drivers/gpu/drm/msm/msm_atomic.c
113 +++ b/drivers/gpu/drm/msm/msm_atomic.c
114 @@ -242,6 +242,8 @@ void msm_atomic_commit_tail(struct drm_a
115 /* async updates are limited to single-crtc updates: */
116 WARN_ON(crtc_mask != drm_crtc_mask(async_crtc));
118 + complete_all(&async_crtc->state->commit->flip_done);
121 * Start timer if we don't already have an update pending