Switch to using drmm_mode_config_init() so that the mode config is
released when the last reference to the DRM device is dropped rather
than unconditionally at unbind() (which may be too soon).
Signed-off-by: Johan Hovold <[email protected]>
---
drivers/gpu/drm/msm/msm_drv.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 73c597565f99..ade17947d1e5 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -247,8 +247,6 @@ static int msm_drm_uninit(struct device *dev)
if (kms)
msm_disp_snapshot_destroy(ddev);
- drm_mode_config_cleanup(ddev);
-
for (i = 0; i < priv->num_bridges; i++)
drm_bridge_remove(priv->bridges[i]);
priv->num_bridges = 0;
@@ -454,11 +452,13 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
might_lock(&priv->lru.lock);
fs_reclaim_release(GFP_KERNEL);
- drm_mode_config_init(ddev);
+ ret = drmm_mode_config_init(ddev);
+ if (ret)
+ goto err_destroy_wq;
ret = msm_init_vram(ddev);
if (ret)
- goto err_cleanup_mode_config;
+ goto err_destroy_wq;
/* Bind all our sub-components: */
ret = component_bind_all(dev, ddev);
@@ -563,8 +563,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
err_deinit_vram:
msm_deinit_vram(ddev);
-err_cleanup_mode_config:
- drm_mode_config_cleanup(ddev);
+err_destroy_wq:
destroy_workqueue(priv->wq);
err_put_dev:
drm_dev_put(ddev);
--
2.39.2
On 06/03/2023 12:07, Johan Hovold wrote:
> Switch to using drmm_mode_config_init() so that the mode config is
> released when the last reference to the DRM device is dropped rather
> than unconditionally at unbind() (which may be too soon).
This also means that drm_bridge_detach() might be called at some point
after unbind(), which might be too late.
>
> Signed-off-by: Johan Hovold <[email protected]>
> ---
> drivers/gpu/drm/msm/msm_drv.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 73c597565f99..ade17947d1e5 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -247,8 +247,6 @@ static int msm_drm_uninit(struct device *dev)
> if (kms)
> msm_disp_snapshot_destroy(ddev);
>
> - drm_mode_config_cleanup(ddev);
> -
> for (i = 0; i < priv->num_bridges; i++)
> drm_bridge_remove(priv->bridges[i]);
> priv->num_bridges = 0;
> @@ -454,11 +452,13 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
> might_lock(&priv->lru.lock);
> fs_reclaim_release(GFP_KERNEL);
>
> - drm_mode_config_init(ddev);
> + ret = drmm_mode_config_init(ddev);
> + if (ret)
> + goto err_destroy_wq;
>
> ret = msm_init_vram(ddev);
> if (ret)
> - goto err_cleanup_mode_config;
> + goto err_destroy_wq;
>
> /* Bind all our sub-components: */
> ret = component_bind_all(dev, ddev);
> @@ -563,8 +563,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
>
> err_deinit_vram:
> msm_deinit_vram(ddev);
> -err_cleanup_mode_config:
> - drm_mode_config_cleanup(ddev);
> +err_destroy_wq:
> destroy_workqueue(priv->wq);
> err_put_dev:
> drm_dev_put(ddev);
--
With best wishes
Dmitry
On Mon, Mar 06, 2023 at 02:38:37PM +0200, Dmitry Baryshkov wrote:
> On 06/03/2023 12:07, Johan Hovold wrote:
> > Switch to using drmm_mode_config_init() so that the mode config is
> > released when the last reference to the DRM device is dropped rather
> > than unconditionally at unbind() (which may be too soon).
>
> This also means that drm_bridge_detach() might be called at some point
> after unbind(), which might be too late.
Indeed.
Please disregard this patch. It's not needed to fix the bind error paths
anyway.
Johan