[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZgTGEQ3B5M9BtDfUdyMiH+VQkWcFHU2fOJgE_1=a4E1bxMTA@mail.gmail.com>
Date: Wed, 31 May 2023 11:19:32 +0200
From: Nicolas Belin <nbelin@...libre.com>
To: Neil Armstrong <neil.armstrong@...aro.org>
Cc: Jerome Brunet <jbrunet@...libre.com>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Kevin Hilman <khilman@...libre.com>,
Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Philipp Zabel <p.zabel@...gutronix.de>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Sam Ravnborg <sam@...nborg.org>,
"Lukas F. Hartmann" <lukas@...re.com>,
linux-amlogic@...ts.infradead.org, linux-clk@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-phy@...ts.infradead.org
Subject: Re: [PATCH v5 08/17] drm/meson: fix unbind path if HDMI fails to bind
Le mar. 30 mai 2023 à 09:38, Neil Armstrong
<neil.armstrong@...aro.org> a écrit :
>
> If the case the HDMI controller fails to bind, we try to unbind
> all components before calling drm_dev_put() which makes drm_bridge_detach()
> crash because unbinding the HDMI controller frees the bridge memory.
>
> The solution is the unbind all components at the end like in the remove
> path.
>
> Signed-off-by: Neil Armstrong <neil.armstrong@...aro.org>
> ---
> drivers/gpu/drm/meson/meson_drv.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index ca6d1e59e5d9..e060279dc80a 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -316,32 +316,34 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
> goto exit_afbcd;
>
> if (has_components) {
> - ret = component_bind_all(drm->dev, drm);
> + ret = component_bind_all(dev, drm);
> if (ret) {
> dev_err(drm->dev, "Couldn't bind all components\n");
> + /* Do not try to unbind */
> + has_components = false;
> goto exit_afbcd;
> }
> }
>
> ret = meson_encoder_hdmi_init(priv);
> if (ret)
> - goto unbind_all;
> + goto exit_afbcd;
>
> ret = meson_plane_create(priv);
> if (ret)
> - goto unbind_all;
> + goto exit_afbcd;
>
> ret = meson_overlay_create(priv);
> if (ret)
> - goto unbind_all;
> + goto exit_afbcd;
>
> ret = meson_crtc_create(priv);
> if (ret)
> - goto unbind_all;
> + goto exit_afbcd;
>
> ret = request_irq(priv->vsync_irq, meson_irq, 0, drm->driver->name, drm);
> if (ret)
> - goto unbind_all;
> + goto exit_afbcd;
>
> drm_mode_config_reset(drm);
>
> @@ -359,15 +361,18 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
>
> uninstall_irq:
> free_irq(priv->vsync_irq, drm);
> -unbind_all:
> - if (has_components)
> - component_unbind_all(drm->dev, drm);
> exit_afbcd:
> if (priv->afbcd.ops)
> priv->afbcd.ops->exit(priv);
> free_drm:
> drm_dev_put(drm);
>
> + meson_encoder_hdmi_remove(priv);
> + meson_encoder_cvbs_remove(priv);
> +
> + if (has_components)
> + component_unbind_all(dev, drm);
> +
> return ret;
> }
>
>
> --
> 2.34.1
>
Works fine on a Khadas VIM3 using a TS050 panel,
Thanks
Reviewed-by: Nicolas Belin <nbelin@...libre.com>
Tested-by: Nicolas Belin <nbelin@...libre.com>
Powered by blists - more mailing lists