[PATCH v2 3/6] drm: lcdif: rework runtime PM handling in the atomic commit

Ying Liu victor.liu at nxp.com
Fri Sep 22 02:51:34 PDT 2023


On Friday, September 22, 2023 4:03 AM Lucas Stach <l.stach at pengutronix.de> wrote:
> drm_atomic_helper_commit_tail_rpm makes it hard for drivers to follow
> the documented encoder/bridge enable flow, as it commits all CRTC enables
> before the planes are fully set up, so drivers that can't enable the
> display link without valid plane setup either need to do the plane setup
> in the CRTC enable or violate the flow by enabling the display link after
> the planes have been set up. Neither of those options seem like a good
> idea.
> 
> For devices that only do coarse-grained runtime PM for the whole display
> controller and not per CRTC, like the i.MX LCDIF, we can handle hardware
> wakeup and suspend in the atomic_commit_tail. Add a commit tail which
> follows the more conventional atomic commit flow of first diabling any
> unused CRTCs, setting up all the active plane state, then enable all
> active display pipes and also handles the device runtime PM at the
> appropriate times.
> 
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> ---
> v2: new patch
> ---
>  drivers/gpu/drm/mxsfb/lcdif_drv.c | 22 +++++++++++++++++++++-
>  drivers/gpu/drm/mxsfb/lcdif_kms.c | 12 ++++++++++--
>  2 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> b/drivers/gpu/drm/mxsfb/lcdif_drv.c
> index 18de2f17e249..205f6855fb1b 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
> @@ -36,8 +36,28 @@ static const struct drm_mode_config_funcs
> lcdif_mode_config_funcs = {
>  	.atomic_commit		= drm_atomic_helper_commit,
>  };
> 
> +void lcdif_commit_tail(struct drm_atomic_state *old_state)
> +{
> +	struct drm_device *drm = old_state->dev;
> +
> +	pm_runtime_get_sync(drm->dev);

Here, pixel clock lcdif->clk is enabled via lcdif_rpm_resume(), and then ...

> +
> +	drm_atomic_helper_commit_modeset_disables(drm, old_state);
> +	drm_atomic_helper_commit_planes(drm, old_state,
> +
> 	DRM_PLANE_COMMIT_ACTIVE_ONLY);
> +	drm_atomic_helper_commit_modeset_enables(drm, old_state);

... here, clk_set_rate() is called for lcdif->clk via lcdif_crtc_atomic_enable().
Set rate with clock enabled?

Another concern is lcdif_reset_block() is called via lcdif_crtc_mode_set_nofb()
here, while plane is already set up, which means plane settings are potentially
reset.

With this patch series, display shows constant color by running modetest to
change fb pixel format.  However, doing page flip with "-v" option seems fine.
Also, seems the issue doesn't reproduce without fbdev emulation.

Regards,
Liu Ying

> +
> +	drm_atomic_helper_fake_vblank(old_state);
> +	drm_atomic_helper_commit_hw_done(old_state);
> +	drm_atomic_helper_wait_for_vblanks(drm, old_state);
> +
> +	pm_runtime_put(drm->dev);
> +
> +	drm_atomic_helper_cleanup_planes(drm, old_state);
> +}
> +
>  static const struct drm_mode_config_helper_funcs
> lcdif_mode_config_helpers = {
> -	.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
> +	.atomic_commit_tail = lcdif_commit_tail,
>  };
> 
>  static const struct drm_encoder_funcs lcdif_encoder_funcs = {
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> b/drivers/gpu/drm/mxsfb/lcdif_kms.c
> index e277592e5fa5..ccee5e28f236 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
> @@ -540,7 +540,11 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc
> *crtc,
> 
>  	clk_set_rate(lcdif->clk, m->crtc_clock * 1000);
> 
> -	pm_runtime_get_sync(drm->dev);
> +	/*
> +	 * Update the RPM usage count, actual resume already happened in
> +	 * lcdif_commit_tail wrapping all the atomic update.
> +	 */
> +	pm_runtime_get_noresume(drm->dev);
> 
>  	lcdif_crtc_mode_set_nofb(new_cstate, new_pstate);
> 
> @@ -576,7 +580,11 @@ static void lcdif_crtc_atomic_disable(struct drm_crtc
> *crtc,
>  	}
>  	spin_unlock_irq(&drm->event_lock);
> 
> -	pm_runtime_put_sync(drm->dev);
> +	/*
> +	 * Update the RPM usage count, actual suspend happens in
> +	 * lcdif_commit_tail wrapping all the atomic update.
> +	 */
> +	pm_runtime_put(drm->dev);
>  }
> 
>  static void lcdif_crtc_atomic_destroy_state(struct drm_crtc *crtc,
> --
> 2.39.2




More information about the linux-arm-kernel mailing list