Skip to content

Commit cb345de

Browse files
committed
drm/tilcdc: Use standard drm_atomic_helper_commit
Gives us proper nonblocking support for free, and a pile of other things. The tilcdc code is simply old enough that it was never converted over, but was stuck forever with the copypasta from when it was initially merged. The riskiest thing with this conversion is maybe that there's an issue with the vblank handling or vblank event handling, which will upset the modern commit support in atomic helpers. But from a cursory review drm_crtc_vblank_on/off is called in the right places, and the event handling also seems to exist (albeit with much hand-rolling and probably some races, could perhaps be converted over to drm_crtc_arm_vblank_event without any real loss). Motivated by me not having to hand-roll the dma-fence annotations for this. v2: Clear out crtc_state->event when we're handling the event, to avoid upsetting the helpers (reported by Jyri). v3: Also send out even whent the crtc is getting disabled. Tilcdc looks a bit like conversion to simple display helpers would work out really nice. Tested-by: Jyri Sarha <[email protected]> Reviewed-by: Jyri Sarha <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Cc: Jyri Sarha <[email protected]> Cc: Tomi Valkeinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 895a479 commit cb345de

File tree

3 files changed

+19
-49
lines changed

3 files changed

+19
-49
lines changed

drivers/gpu/drm/tilcdc/tilcdc_crtc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,18 @@ static void tilcdc_crtc_atomic_disable(struct drm_crtc *crtc,
537537
tilcdc_crtc_disable(crtc);
538538
}
539539

540+
static void tilcdc_crtc_atomic_flush(struct drm_crtc *crtc,
541+
struct drm_crtc_state *old_state)
542+
{
543+
if (!crtc->state->event)
544+
return;
545+
546+
spin_lock_irq(&crtc->dev->event_lock);
547+
drm_crtc_send_vblank_event(crtc, crtc->state->event);
548+
crtc->state->event = NULL;
549+
spin_unlock_irq(&crtc->dev->event_lock);
550+
}
551+
540552
void tilcdc_crtc_shutdown(struct drm_crtc *crtc)
541553
{
542554
tilcdc_crtc_off(crtc, true);
@@ -822,6 +834,7 @@ static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
822834
.atomic_check = tilcdc_crtc_atomic_check,
823835
.atomic_enable = tilcdc_crtc_atomic_enable,
824836
.atomic_disable = tilcdc_crtc_atomic_disable,
837+
.atomic_flush = tilcdc_crtc_atomic_flush,
825838
};
826839

827840
void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,

drivers/gpu/drm/tilcdc/tilcdc_drv.c

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -87,55 +87,10 @@ static int tilcdc_atomic_check(struct drm_device *dev,
8787
return ret;
8888
}
8989

90-
static int tilcdc_commit(struct drm_device *dev,
91-
struct drm_atomic_state *state,
92-
bool async)
93-
{
94-
int ret;
95-
96-
ret = drm_atomic_helper_prepare_planes(dev, state);
97-
if (ret)
98-
return ret;
99-
100-
ret = drm_atomic_helper_swap_state(state, true);
101-
if (ret) {
102-
drm_atomic_helper_cleanup_planes(dev, state);
103-
return ret;
104-
}
105-
106-
/*
107-
* Everything below can be run asynchronously without the need to grab
108-
* any modeset locks at all under one condition: It must be guaranteed
109-
* that the asynchronous work has either been cancelled (if the driver
110-
* supports it, which at least requires that the framebuffers get
111-
* cleaned up with drm_atomic_helper_cleanup_planes()) or completed
112-
* before the new state gets committed on the software side with
113-
* drm_atomic_helper_swap_state().
114-
*
115-
* This scheme allows new atomic state updates to be prepared and
116-
* checked in parallel to the asynchronous completion of the previous
117-
* update. Which is important since compositors need to figure out the
118-
* composition of the next frame right after having submitted the
119-
* current layout.
120-
*/
121-
122-
drm_atomic_helper_commit_modeset_disables(dev, state);
123-
124-
drm_atomic_helper_commit_planes(dev, state, 0);
125-
126-
drm_atomic_helper_commit_modeset_enables(dev, state);
127-
128-
drm_atomic_helper_wait_for_vblanks(dev, state);
129-
130-
drm_atomic_helper_cleanup_planes(dev, state);
131-
132-
return 0;
133-
}
134-
13590
static const struct drm_mode_config_funcs mode_config_funcs = {
13691
.fb_create = drm_gem_fb_create,
13792
.atomic_check = tilcdc_atomic_check,
138-
.atomic_commit = tilcdc_commit,
93+
.atomic_commit = drm_atomic_helper_commit,
13994
};
14095

14196
static void modeset_init(struct drm_device *dev)

drivers/gpu/drm/tilcdc/tilcdc_plane.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ static void tilcdc_plane_atomic_update(struct drm_plane *plane,
8383
if (WARN_ON(!state->fb || !state->crtc->state))
8484
return;
8585

86-
tilcdc_crtc_update_fb(state->crtc,
87-
state->fb,
88-
state->crtc->state->event);
86+
if (tilcdc_crtc_update_fb(state->crtc,
87+
state->fb,
88+
state->crtc->state->event) == 0) {
89+
state->crtc->state->event = NULL;
90+
}
8991
}
9092

9193
static const struct drm_plane_helper_funcs plane_helper_funcs = {

0 commit comments

Comments
 (0)