Message ID | 20200708094446.508414-1-daniel.vetter@ffwll.ch (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | drm/tilcdc: Use standard drm_atomic_helper_commit | expand |
On 08/07/2020 12:44, Daniel Vetter wrote: > 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). > Reverted the old and applied this new. It works a bit better as the fbconsole comes up without any warnings, but after that it is almost as bad. The kmstest is able to make the commit but it does not finish and nothing comes visible on the screen until couple of "flip_done timed outs". A new kernel log is attached. Best regards, Jyri > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > Cc: Jyri Sarha <jsarha@ti.com> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> > -- > I'm not really sure whether the event handling is correct for when a > crtc gets disabled. dpms off or similar would be a good test, assuming > this patch here fixes the first issue. > -Daniel > --- > drivers/gpu/drm/tilcdc/tilcdc_drv.c | 47 +-------------------------- > drivers/gpu/drm/tilcdc/tilcdc_plane.c | 8 +++-- > 2 files changed, 6 insertions(+), 49 deletions(-) > > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c > index 0d74a6443263..4f5fc3e87383 100644 > --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c > +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c > @@ -87,55 +87,10 @@ static int tilcdc_atomic_check(struct drm_device *dev, > return ret; > } > > -static int tilcdc_commit(struct drm_device *dev, > - struct drm_atomic_state *state, > - bool async) > -{ > - int ret; > - > - ret = drm_atomic_helper_prepare_planes(dev, state); > - if (ret) > - return ret; > - > - ret = drm_atomic_helper_swap_state(state, true); > - if (ret) { > - drm_atomic_helper_cleanup_planes(dev, state); > - return ret; > - } > - > - /* > - * Everything below can be run asynchronously without the need to grab > - * any modeset locks at all under one condition: It must be guaranteed > - * that the asynchronous work has either been cancelled (if the driver > - * supports it, which at least requires that the framebuffers get > - * cleaned up with drm_atomic_helper_cleanup_planes()) or completed > - * before the new state gets committed on the software side with > - * drm_atomic_helper_swap_state(). > - * > - * This scheme allows new atomic state updates to be prepared and > - * checked in parallel to the asynchronous completion of the previous > - * update. Which is important since compositors need to figure out the > - * composition of the next frame right after having submitted the > - * current layout. > - */ > - > - drm_atomic_helper_commit_modeset_disables(dev, state); > - > - drm_atomic_helper_commit_planes(dev, state, 0); > - > - drm_atomic_helper_commit_modeset_enables(dev, state); > - > - drm_atomic_helper_wait_for_vblanks(dev, state); > - > - drm_atomic_helper_cleanup_planes(dev, state); > - > - return 0; > -} > - > static const struct drm_mode_config_funcs mode_config_funcs = { > .fb_create = drm_gem_fb_create, > .atomic_check = tilcdc_atomic_check, > - .atomic_commit = tilcdc_commit, > + .atomic_commit = drm_atomic_helper_commit, > }; > > static void modeset_init(struct drm_device *dev) > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c > index 0d09b31ae759..2f681a713815 100644 > --- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c > +++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c > @@ -83,9 +83,11 @@ static void tilcdc_plane_atomic_update(struct drm_plane *plane, > if (WARN_ON(!state->fb || !state->crtc->state)) > return; > > - tilcdc_crtc_update_fb(state->crtc, > - state->fb, > - state->crtc->state->event); > + if (tilcdc_crtc_update_fb(state->crtc, > + state->fb, > + state->crtc->state->event) == 0) { > + state->crtc->state->event = NULL; > + } > } > > static const struct drm_plane_helper_funcs plane_helper_funcs = { >
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 0d74a6443263..4f5fc3e87383 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c @@ -87,55 +87,10 @@ static int tilcdc_atomic_check(struct drm_device *dev, return ret; } -static int tilcdc_commit(struct drm_device *dev, - struct drm_atomic_state *state, - bool async) -{ - int ret; - - ret = drm_atomic_helper_prepare_planes(dev, state); - if (ret) - return ret; - - ret = drm_atomic_helper_swap_state(state, true); - if (ret) { - drm_atomic_helper_cleanup_planes(dev, state); - return ret; - } - - /* - * Everything below can be run asynchronously without the need to grab - * any modeset locks at all under one condition: It must be guaranteed - * that the asynchronous work has either been cancelled (if the driver - * supports it, which at least requires that the framebuffers get - * cleaned up with drm_atomic_helper_cleanup_planes()) or completed - * before the new state gets committed on the software side with - * drm_atomic_helper_swap_state(). - * - * This scheme allows new atomic state updates to be prepared and - * checked in parallel to the asynchronous completion of the previous - * update. Which is important since compositors need to figure out the - * composition of the next frame right after having submitted the - * current layout. - */ - - drm_atomic_helper_commit_modeset_disables(dev, state); - - drm_atomic_helper_commit_planes(dev, state, 0); - - drm_atomic_helper_commit_modeset_enables(dev, state); - - drm_atomic_helper_wait_for_vblanks(dev, state); - - drm_atomic_helper_cleanup_planes(dev, state); - - return 0; -} - static const struct drm_mode_config_funcs mode_config_funcs = { .fb_create = drm_gem_fb_create, .atomic_check = tilcdc_atomic_check, - .atomic_commit = tilcdc_commit, + .atomic_commit = drm_atomic_helper_commit, }; static void modeset_init(struct drm_device *dev) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c index 0d09b31ae759..2f681a713815 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c @@ -83,9 +83,11 @@ static void tilcdc_plane_atomic_update(struct drm_plane *plane, if (WARN_ON(!state->fb || !state->crtc->state)) return; - tilcdc_crtc_update_fb(state->crtc, - state->fb, - state->crtc->state->event); + if (tilcdc_crtc_update_fb(state->crtc, + state->fb, + state->crtc->state->event) == 0) { + state->crtc->state->event = NULL; + } } static const struct drm_plane_helper_funcs plane_helper_funcs = {
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). Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Jyri Sarha <jsarha@ti.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> -- I'm not really sure whether the event handling is correct for when a crtc gets disabled. dpms off or similar would be a good test, assuming this patch here fixes the first issue. -Daniel --- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 47 +-------------------------- drivers/gpu/drm/tilcdc/tilcdc_plane.c | 8 +++-- 2 files changed, 6 insertions(+), 49 deletions(-)