On Fri, Dec 10, 2021 at 04:47:06PM +0530, Jagan Teki wrote:
> Existing host driver will keep looking for DRM pointer in
> sun6i_dsi_attach and defers even if the particular DSI device
> is found for the first time. Meanwhile it triggers the bind
> callback and gets the DRM pointer and then continues the
> sun6i_dsi_attach.
> 
> This makes a deadlock situation if sun6i_dsi_attach is trying
> to find the bridge.

I'm not sure what you mean by deadlock here, there's no lock involved?

> If interface bridge is trying to call host attach, then host
> sun6i_dsi_attach is trying to find bridge and defers the
> interface bridge even if it found the bridge as bind callback
> does not complete at the movement. So, this sun6i_dsi_attach
> defers interface bridge and triggers the bind callback and
> tries to attach the bridge with a bridge pointer which is not
> available at the moment.
>
> Eventually these callbacks are triggered recursively, as
> sun6i_dsi_attach defers interface bridge and bind callback
> defers sun6i_dsi_attach due to invalid bridge ponter.

                                                ^ pointer

> 
> This patch prevents this situation by probing all DSI devices
> on the pipeline first and then triggers the bind callback by
> dropping exing DRM binding logic.

           ^ existing I guess?

> 
> Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
> ---
> Changes for v6:
> - none
> Changes for v5:
> - new patch
> 
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +---------
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h |  1 -
>  2 files changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c 
> b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> index 527c7b2474da..4bdcce8f1d84 100644
> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> @@ -967,14 +967,10 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host,
>  
>       if (IS_ERR(panel))
>               return PTR_ERR(panel);
> -     if (!dsi->drm || !dsi->drm->registered)
> -             return -EPROBE_DEFER;
>  
>       dsi->panel = panel;
>       dsi->device = device;
>  
> -     drm_kms_helper_hotplug_event(dsi->drm);
> -
>       dev_info(host->dev, "Attached device %s\n", device->name);
>  
>       return 0;
> @@ -988,8 +984,6 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host,
>       dsi->panel = NULL;
>       dsi->device = NULL;
>  
> -     drm_kms_helper_hotplug_event(dsi->drm);
> -
>       return 0;
>  }
>  
> @@ -1077,8 +1071,6 @@ static int sun6i_dsi_bind(struct device *dev, struct 
> device *master,
>  
>       drm_connector_attach_encoder(&dsi->connector, &dsi->encoder);
>  
> -     dsi->drm = drm;
> -
>       return 0;
>  
>  err_cleanup_connector:
> @@ -1091,7 +1083,7 @@ static void sun6i_dsi_unbind(struct device *dev, struct 
> device *master,
>  {
>       struct sun6i_dsi *dsi = dev_get_drvdata(dev);
>  
> -     dsi->drm = NULL;
> +     drm_encoder_cleanup(&dsi->encoder);
>  }
>  
>  static const struct component_ops sun6i_dsi_ops = {
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h 
> b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
> index c863900ae3b4..61e88ea6044d 100644
> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
> @@ -29,7 +29,6 @@ struct sun6i_dsi {
>  
>       struct device           *dev;
>       struct mipi_dsi_device  *device;
> -     struct drm_device       *drm;
>       struct drm_panel        *panel;
>  };
>  
> -- 
> 2.25.1
> 

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20211213170223.fx5656vjk3fwizbg%40houat.

Attachment: signature.asc
Description: PGP signature

Reply via email to