diff mbox series

[2/3] drm/msm/dsi: move next bridge acquisition to dsi_bind

Message ID 20240309-fd-dsi-cleanup-bridges-v1-2-962ebdba82ed@linaro.org
State Accepted
Commit c73588c091684ea5cd7d77a4f1ce9a538a461ad6
Headers show
Series drm/msm/dsi: rework drm_connector instantiation | expand

Commit Message

Dmitry Baryshkov March 9, 2024, 3:09 p.m. UTC
Currently the MSM DSI driver looks for the next bridge during
msm_dsi_modeset_init(). If the bridge is not registered at that point,
this might result in -EPROBE_DEFER, which can be problematic that late
during the device probe process. Move next bridge acquisition to the
dsi_bind state so that probe deferral is returned as early as possible.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi.c         | 16 ++++++++++++++++
 drivers/gpu/drm/msm/dsi/dsi.h         |  2 ++
 drivers/gpu/drm/msm/dsi/dsi_manager.c |  8 +-------
 3 files changed, 19 insertions(+), 7 deletions(-)

Comments

Abhinav Kumar April 5, 2024, 5:35 p.m. UTC | #1
On 3/9/2024 7:09 AM, Dmitry Baryshkov wrote:
> Currently the MSM DSI driver looks for the next bridge during
> msm_dsi_modeset_init(). If the bridge is not registered at that point,
> this might result in -EPROBE_DEFER, which can be problematic that late
> during the device probe process. Move next bridge acquisition to the
> dsi_bind state so that probe deferral is returned as early as possible.
> 

But msm_dsi_modeset)init() is also called during msm_drm_bind() only.

What issue are you suggesting will be fixed by moving this from 
msm_drm_bind() to dsi_bind()?

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>   drivers/gpu/drm/msm/dsi/dsi.c         | 16 ++++++++++++++++
>   drivers/gpu/drm/msm/dsi/dsi.h         |  2 ++
>   drivers/gpu/drm/msm/dsi/dsi_manager.c |  8 +-------
>   3 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
> index 37c4c07005fe..38f10f7a10d3 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi.c
> @@ -120,6 +120,22 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>   	struct msm_drm_private *priv = dev_get_drvdata(master);
>   	struct msm_dsi *msm_dsi = dev_get_drvdata(dev);
>   
> +	/*
> +	 * Next bridge doesn't exist for the secondary DSI host in a bonded
> +	 * pair.
> +	 */
> +	if (!msm_dsi_is_bonded_dsi(msm_dsi) ||
> +	    msm_dsi_is_master_dsi(msm_dsi)) {
> +		struct drm_bridge *ext_bridge;
> +
> +		ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev,
> +						    msm_dsi->pdev->dev.of_node, 1, 0);
> +		if (IS_ERR(ext_bridge))
> +			return PTR_ERR(ext_bridge);
> +
> +		msm_dsi->next_bridge = ext_bridge;
> +	}
> +
>   	priv->dsi[msm_dsi->id] = msm_dsi;
>   
>   	return 0;
> diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
> index 2ad9a842c678..0adef65be1de 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi.h
> +++ b/drivers/gpu/drm/msm/dsi/dsi.h
> @@ -38,6 +38,8 @@ struct msm_dsi {
>   	struct mipi_dsi_host *host;
>   	struct msm_dsi_phy *phy;
>   
> +	struct drm_bridge *next_bridge;
> +
>   	struct device *phy_dev;
>   	bool phy_enabled;
>   
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> index a7c7f85b73e4..b7c52b14c790 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> @@ -464,18 +464,12 @@ int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge)
>   	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
>   	struct drm_device *dev = msm_dsi->dev;
>   	struct drm_encoder *encoder;
> -	struct drm_bridge *ext_bridge;
>   	struct drm_connector *connector;
>   	int ret;
>   
> -	ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev,
> -					    msm_dsi->pdev->dev.of_node, 1, 0);
> -	if (IS_ERR(ext_bridge))
> -		return PTR_ERR(ext_bridge);
> -
>   	encoder = int_bridge->encoder;
>   
> -	ret = drm_bridge_attach(encoder, ext_bridge, int_bridge,
> +	ret = drm_bridge_attach(encoder, msm_dsi->next_bridge, int_bridge,
>   			DRM_BRIDGE_ATTACH_NO_CONNECTOR);
>   	if (ret)
>   		return ret;
>
Dmitry Baryshkov April 5, 2024, 6:15 p.m. UTC | #2
On Fri, 5 Apr 2024 at 20:35, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote:
>
>
>
> On 3/9/2024 7:09 AM, Dmitry Baryshkov wrote:
> > Currently the MSM DSI driver looks for the next bridge during
> > msm_dsi_modeset_init(). If the bridge is not registered at that point,
> > this might result in -EPROBE_DEFER, which can be problematic that late
> > during the device probe process. Move next bridge acquisition to the
> > dsi_bind state so that probe deferral is returned as early as possible.
> >
>
> But msm_dsi_modeset)init() is also called during msm_drm_bind() only.
>
> What issue are you suggesting will be fixed by moving this from
> msm_drm_bind() to dsi_bind()?

The goal is to return as early as possible as not not cause
probe-deferral loops. See commit fbc35b45f9f6 ("Add documentation on
meaning of -EPROBE_DEFER"). It discusses returning from probe() but
the same logic applies to bind().

> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >   drivers/gpu/drm/msm/dsi/dsi.c         | 16 ++++++++++++++++
> >   drivers/gpu/drm/msm/dsi/dsi.h         |  2 ++
> >   drivers/gpu/drm/msm/dsi/dsi_manager.c |  8 +-------
> >   3 files changed, 19 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
> > index 37c4c07005fe..38f10f7a10d3 100644
> > --- a/drivers/gpu/drm/msm/dsi/dsi.c
> > +++ b/drivers/gpu/drm/msm/dsi/dsi.c
> > @@ -120,6 +120,22 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
> >       struct msm_drm_private *priv = dev_get_drvdata(master);
> >       struct msm_dsi *msm_dsi = dev_get_drvdata(dev);
> >
> > +     /*
> > +      * Next bridge doesn't exist for the secondary DSI host in a bonded
> > +      * pair.
> > +      */
> > +     if (!msm_dsi_is_bonded_dsi(msm_dsi) ||
> > +         msm_dsi_is_master_dsi(msm_dsi)) {
> > +             struct drm_bridge *ext_bridge;
> > +
> > +             ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev,
> > +                                                 msm_dsi->pdev->dev.of_node, 1, 0);
> > +             if (IS_ERR(ext_bridge))
> > +                     return PTR_ERR(ext_bridge);
> > +
> > +             msm_dsi->next_bridge = ext_bridge;
> > +     }
> > +
> >       priv->dsi[msm_dsi->id] = msm_dsi;
> >
> >       return 0;
> > diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
> > index 2ad9a842c678..0adef65be1de 100644
> > --- a/drivers/gpu/drm/msm/dsi/dsi.h
> > +++ b/drivers/gpu/drm/msm/dsi/dsi.h
> > @@ -38,6 +38,8 @@ struct msm_dsi {
> >       struct mipi_dsi_host *host;
> >       struct msm_dsi_phy *phy;
> >
> > +     struct drm_bridge *next_bridge;
> > +
> >       struct device *phy_dev;
> >       bool phy_enabled;
> >
> > diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> > index a7c7f85b73e4..b7c52b14c790 100644
> > --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
> > +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> > @@ -464,18 +464,12 @@ int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge)
> >       struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
> >       struct drm_device *dev = msm_dsi->dev;
> >       struct drm_encoder *encoder;
> > -     struct drm_bridge *ext_bridge;
> >       struct drm_connector *connector;
> >       int ret;
> >
> > -     ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev,
> > -                                         msm_dsi->pdev->dev.of_node, 1, 0);
> > -     if (IS_ERR(ext_bridge))
> > -             return PTR_ERR(ext_bridge);
> > -
> >       encoder = int_bridge->encoder;
> >
> > -     ret = drm_bridge_attach(encoder, ext_bridge, int_bridge,
> > +     ret = drm_bridge_attach(encoder, msm_dsi->next_bridge, int_bridge,
> >                       DRM_BRIDGE_ATTACH_NO_CONNECTOR);
> >       if (ret)
> >               return ret;
> >
Abhinav Kumar April 8, 2024, 9:45 p.m. UTC | #3
On 4/5/2024 11:15 AM, Dmitry Baryshkov wrote:
> On Fri, 5 Apr 2024 at 20:35, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote:
>>
>>
>>
>> On 3/9/2024 7:09 AM, Dmitry Baryshkov wrote:
>>> Currently the MSM DSI driver looks for the next bridge during
>>> msm_dsi_modeset_init(). If the bridge is not registered at that point,
>>> this might result in -EPROBE_DEFER, which can be problematic that late
>>> during the device probe process. Move next bridge acquisition to the
>>> dsi_bind state so that probe deferral is returned as early as possible.
>>>
>>
>> But msm_dsi_modeset)init() is also called during msm_drm_bind() only.
>>
>> What issue are you suggesting will be fixed by moving this from
>> msm_drm_bind() to dsi_bind()?
> 
> The goal is to return as early as possible as not not cause
> probe-deferral loops. See commit fbc35b45f9f6 ("Add documentation on
> meaning of -EPROBE_DEFER"). It discusses returning from probe() but
> the same logic applies to bind().
> 

Understood. I was trying to make sure the purpose of the patch is that 
"deferral in component_bind() is better than component_master_bind()"

But yes, overall that is better since the unbounding path will be more 
in the master case.

>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>> ---
>>>    drivers/gpu/drm/msm/dsi/dsi.c         | 16 ++++++++++++++++
>>>    drivers/gpu/drm/msm/dsi/dsi.h         |  2 ++
>>>    drivers/gpu/drm/msm/dsi/dsi_manager.c |  8 +-------
>>>    3 files changed, 19 insertions(+), 7 deletions(-)
>>>

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 37c4c07005fe..38f10f7a10d3 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -120,6 +120,22 @@  static int dsi_bind(struct device *dev, struct device *master, void *data)
 	struct msm_drm_private *priv = dev_get_drvdata(master);
 	struct msm_dsi *msm_dsi = dev_get_drvdata(dev);
 
+	/*
+	 * Next bridge doesn't exist for the secondary DSI host in a bonded
+	 * pair.
+	 */
+	if (!msm_dsi_is_bonded_dsi(msm_dsi) ||
+	    msm_dsi_is_master_dsi(msm_dsi)) {
+		struct drm_bridge *ext_bridge;
+
+		ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev,
+						    msm_dsi->pdev->dev.of_node, 1, 0);
+		if (IS_ERR(ext_bridge))
+			return PTR_ERR(ext_bridge);
+
+		msm_dsi->next_bridge = ext_bridge;
+	}
+
 	priv->dsi[msm_dsi->id] = msm_dsi;
 
 	return 0;
diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index 2ad9a842c678..0adef65be1de 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -38,6 +38,8 @@  struct msm_dsi {
 	struct mipi_dsi_host *host;
 	struct msm_dsi_phy *phy;
 
+	struct drm_bridge *next_bridge;
+
 	struct device *phy_dev;
 	bool phy_enabled;
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index a7c7f85b73e4..b7c52b14c790 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -464,18 +464,12 @@  int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge)
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
 	struct drm_device *dev = msm_dsi->dev;
 	struct drm_encoder *encoder;
-	struct drm_bridge *ext_bridge;
 	struct drm_connector *connector;
 	int ret;
 
-	ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev,
-					    msm_dsi->pdev->dev.of_node, 1, 0);
-	if (IS_ERR(ext_bridge))
-		return PTR_ERR(ext_bridge);
-
 	encoder = int_bridge->encoder;
 
-	ret = drm_bridge_attach(encoder, ext_bridge, int_bridge,
+	ret = drm_bridge_attach(encoder, msm_dsi->next_bridge, int_bridge,
 			DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
 		return ret;