Re: [PATCH v2 3/6] drm: rcar-du: Add pre/post commit CRTC helpers

From: Laurent Pinchart
Date: Sun May 12 2019 - 09:37:31 EST


Hi Kieran,

Thank you for the patch.

On Fri, Mar 15, 2019 at 05:01:07PM +0000, Kieran Bingham wrote:
> Provide helpers to allow CRTC configuration to be separated from the power
> state handling. rcar_du_crtc_atomic_post_commit() is a no-op, but maintained
> for API symmetry.

Do you think we will need to fill rcar_du_crtc_atomic_post_commit()
later ? If not I wouldn't add it, and I may even rename
rcar_du_crtc_atomic_pre_commit() to rcar_du_crtc_atomic_setup() to make
its purpose clearer.

>

Missing SoB line ?

> ---
> drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 25 +++++++++++++++++++++++--
> drivers/gpu/drm/rcar-du/rcar_du_crtc.h | 5 +++++
> drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 ++
> 3 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index 6109a97b0bb9..2606de788688 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -515,8 +515,6 @@ static int rcar_du_crtc_enable(struct rcar_du_crtc *rcrtc)
> if (ret < 0)
> goto error_group;
>
> - rcar_du_crtc_setup(rcrtc);
> -
> return 0;
>
> error_group:
> @@ -683,6 +681,29 @@ int rcar_du_crtc_atomic_enter_standby(struct drm_device *dev,
> return 0;
> }
>
> +int rcar_du_crtc_atomic_pre_commit(struct drm_device *dev,
> + struct drm_atomic_state *state)
> +{
> + struct drm_crtc *crtc;
> + struct drm_crtc_state *crtc_state;
> + unsigned int i;
> +
> + for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
> + struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
> +
> + if (crtc_state->active_changed && crtc_state->active)
> + rcar_du_crtc_setup(rcrtc);

I wondered why you didn't merge this with the existing
rcar_du_crtc_atomic_exit_standby() function, and saw in a later patch
that you have to introduce another operation in-between. I would explain
this in the commit message.

> + }
> +
> + return 0;

As this function and the next one are called in a context that can never
fail, and as the functions never return a failure, I would make them
void.

Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>

> +}
> +
> +int rcar_du_crtc_atomic_post_commit(struct drm_device *dev,
> + struct drm_atomic_state *state)
> +{
> + return 0;
> +}
> +
> static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
> struct drm_crtc_state *old_state)
> {
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> index d12d4a788e9f..0b60a6e0b753 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> @@ -105,6 +105,11 @@ int rcar_du_crtc_atomic_exit_standby(struct drm_device *dev,
> int rcar_du_crtc_atomic_enter_standby(struct drm_device *dev,
> struct drm_atomic_state *state);
>
> +int rcar_du_crtc_atomic_pre_commit(struct drm_device *dev,
> + struct drm_atomic_state *state);
> +int rcar_du_crtc_atomic_post_commit(struct drm_device *dev,
> + struct drm_atomic_state *state);
> +
> void rcar_du_crtc_dsysr_clr_set(struct rcar_du_crtc *rcrtc, u32 clr, u32 set);
>
> #endif /* __RCAR_DU_CRTC_H__ */
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index b8da4dfc79d2..e4befb1937f8 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -304,12 +304,14 @@ static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state)
>
> /* Apply the atomic update. */
> rcar_du_crtc_atomic_exit_standby(dev, old_state);
> + rcar_du_crtc_atomic_pre_commit(dev, old_state);
>
> drm_atomic_helper_commit_modeset_disables(dev, old_state);
> drm_atomic_helper_commit_planes(dev, old_state,
> DRM_PLANE_COMMIT_ACTIVE_ONLY);
> drm_atomic_helper_commit_modeset_enables(dev, old_state);
>
> + rcar_du_crtc_atomic_post_commit(dev, old_state);
> rcar_du_crtc_atomic_enter_standby(dev, old_state);
>
> drm_atomic_helper_commit_hw_done(old_state);

--
Regards,

Laurent Pinchart