[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <wgxqkelcwum4y7ggc36avwcnnsdyu3nfjj7lp4mvopws6p23f5@h22uk464s62t>
Date: Sun, 20 Oct 2024 14:42:15 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Aradhya Bhatia <aradhya.bhatia@...ux.dev>
Cc: Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>, Andrzej Hajda <andrzej.hajda@...el.com>,
Neil Armstrong <neil.armstrong@...aro.org>, Robert Foss <rfoss@...nel.org>, Jonas Karlman <jonas@...boo.se>,
Jernej Skrabec <jernej.skrabec@...il.com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Dominik Haller <d.haller@...tec.de>, Sam Ravnborg <sam@...nborg.org>,
Kieran Bingham <kieran.bingham+renesas@...asonboard.com>, Nishanth Menon <nm@...com>,
Vignesh Raghavendra <vigneshr@...com>, Devarsh Thakkar <devarsht@...com>,
Praneeth Bajjuri <praneeth@...com>, Udit Kumar <u-kumar1@...com>,
Jayesh Choudhary <j-choudhary@...com>, DRI Development List <dri-devel@...ts.freedesktop.org>,
Linux Kernel List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 10/13] drm/bridge: cdns-dsi: Move DSI mode check to
_atomic_check()
On Sun, Oct 20, 2024 at 01:35:27AM +0530, Aradhya Bhatia wrote:
> From: Aradhya Bhatia <a-bhatia1@...com>
>
> At present, the DSI mode configuration check happens during the
> _atomic_enable() phase, which is not really the best place for this.
> Moreover, if the mode is not valid, the driver gives a warning and
> continues the hardware configuration.
>
> Move the DSI mode configuration check to _atomic_check() instead, which
> can properly report back any invalid mode, before the _enable phase even
> begins.
>
> Signed-off-by: Aradhya Bhatia <a-bhatia1@...com>
> Signed-off-by: Aradhya Bhatia <aradhya.bhatia@...ux.dev>
> ---
> drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c | 18 +++++++++++++++---
> drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h | 1 +
> 2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
> index 7341e609dc8b..79d8c2264c14 100644
> --- a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
> +++ b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
> @@ -769,7 +769,7 @@ static void cdns_dsi_bridge_atomic_enable(struct drm_bridge *bridge,
> struct drm_display_mode *mode;
> struct phy_configure_opts_mipi_dphy *phy_cfg = &output->phy_opts.mipi_dphy;
> unsigned long tx_byte_period;
> - struct cdns_dsi_cfg dsi_cfg;
> + struct cdns_dsi_cfg dsi_cfg = dsi->dsi_cfg;
> u32 tmp, reg_wakeup, div, status;
> int nlanes;
>
> @@ -782,8 +782,6 @@ static void cdns_dsi_bridge_atomic_enable(struct drm_bridge *bridge,
> mode = &bridge->encoder->crtc->state->adjusted_mode;
> nlanes = output->dev->lanes;
>
> - WARN_ON_ONCE(cdns_dsi_check_conf(dsi, mode, &dsi_cfg, false));
> -
> cdns_dsi_init_link(dsi);
> cdns_dsi_hs_init(dsi);
>
> @@ -954,6 +952,19 @@ static u32 *cdns_dsi_bridge_get_input_bus_fmts(struct drm_bridge *bridge,
> return input_fmts;
> }
>
> +static int cdns_dsi_bridge_atomic_check(struct drm_bridge *bridge,
> + struct drm_bridge_state *bridge_state,
> + struct drm_crtc_state *crtc_state,
> + struct drm_connector_state *conn_state)
> +{
> + struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
> + struct cdns_dsi *dsi = input_to_dsi(input);
> + struct drm_display_mode *mode = &crtc_state->mode;
> + struct cdns_dsi_cfg *dsi_cfg = &dsi->dsi_cfg;
This makes .atomic_check store data in the non-state structure. However
it is not guaranteed that each atomic_check() will result in the
atomic_commit(). So in addition to moving the check to the
atomic_check() callback you also have to move the cdns_dsi_cfg and all
other structures written during the check to the new structure, wrapping
drm_bridge_state.
> +
> + return cdns_dsi_check_conf(dsi, mode, dsi_cfg, false);
> +}
> +
> static const struct drm_bridge_funcs cdns_dsi_bridge_funcs = {
> .attach = cdns_dsi_bridge_attach,
> .mode_valid = cdns_dsi_bridge_mode_valid,
> @@ -961,6 +972,7 @@ static const struct drm_bridge_funcs cdns_dsi_bridge_funcs = {
> .atomic_pre_enable = cdns_dsi_bridge_atomic_pre_enable,
> .atomic_enable = cdns_dsi_bridge_atomic_enable,
> .atomic_post_disable = cdns_dsi_bridge_atomic_post_disable,
> + .atomic_check = cdns_dsi_bridge_atomic_check,
> .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> .atomic_reset = drm_atomic_helper_bridge_reset,
> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h
> index 5db5dbbbcaad..b785df45bc59 100644
> --- a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h
> +++ b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h
> @@ -77,6 +77,7 @@ struct cdns_dsi {
> bool link_initialized;
> bool phy_initialized;
> struct phy *dphy;
> + struct cdns_dsi_cfg dsi_cfg;
> };
>
> #endif /* !__CDNS_DSI_H__ */
> --
> 2.34.1
>
--
With best wishes
Dmitry
Powered by blists - more mailing lists