diff mbox series

drm/vmwgfx/stdu: Use drm_mode_config_reset

Message ID 20200806154227.2255197-1-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series drm/vmwgfx/stdu: Use drm_mode_config_reset | expand

Commit Message

Daniel Vetter Aug. 6, 2020, 3:42 p.m. UTC
When converting to atomic the state reset was done by directly calling
the functions, and before the modeset object was fully initialized.
This means the various ->dev pointers weren't set up.

After

commit 51f644b40b4b794b28b982fdd5d0dd8ee63f9272
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Fri Jun 12 18:00:49 2020 +0200

    drm/atomic-helper: reset vblank on crtc reset

this started to oops because now we're trying to derefence
drm_crtc->dev. Fix this up by entirely switching over to
drm_mode_config_reset, called once everything is set up.

Fixes: 51f644b40b4b ("drm/atomic-helper: reset vblank on crtc reset")
Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>
Cc: Roland Scheidegger <sroland@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Roland Scheidegger Aug. 7, 2020, 5:27 a.m. UTC | #1
I was investigating this bug too and this seems correct to me.
I've tested it with a kernel which doesn't have the other crash issue,
and indeed it seems to work fine.

That said, this also needs to be fixed in the older paths (these will be
used by vms using older hw version lacking some capabilities),
vmwgfx_sou_[display_]init and vmwgfx_ldu_[display_]init, it'll crash
there just the same.
Exactly the same patch lines work there as well. Although for the ldu
path, while there was nothing unusual in the logs, I could not actually
get a display. Need to do some more testing, but it's probably an
unrelated older issue...

I'll send out a patch for these older paths, I'll apply this one to
vmwgfx-next branch, though until the other crash is fixed it won't help
all that much yet.

Roland



Am 06.08.20 um 17:42 schrieb Daniel Vetter:
> When converting to atomic the state reset was done by directly calling
> the functions, and before the modeset object was fully initialized.
> This means the various ->dev pointers weren't set up.
> 
> After
> 
> commit 51f644b40b4b794b28b982fdd5d0dd8ee63f9272
> Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> Date:   Fri Jun 12 18:00:49 2020 +0200
> 
>     drm/atomic-helper: reset vblank on crtc reset
> 
> this started to oops because now we're trying to derefence
> drm_crtc->dev. Fix this up by entirely switching over to
> drm_mode_config_reset, called once everything is set up.
> 
> Fixes: 51f644b40b4b ("drm/atomic-helper: reset vblank on crtc reset")
> Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>
> Cc: Roland Scheidegger <sroland@vmware.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> index 16b385629688..cf3aafd00837 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> @@ -1738,8 +1738,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
>  	stdu->base.is_implicit = false;
>  
>  	/* Initialize primary plane */
> -	vmw_du_plane_reset(primary);
> -
>  	ret = drm_universal_plane_init(dev, primary,
>  				       0, &vmw_stdu_plane_funcs,
>  				       vmw_primary_plane_formats,
> @@ -1754,8 +1752,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
>  	drm_plane_enable_fb_damage_clips(primary);
>  
>  	/* Initialize cursor plane */
> -	vmw_du_plane_reset(cursor);
> -
>  	ret = drm_universal_plane_init(dev, cursor,
>  			0, &vmw_stdu_cursor_funcs,
>  			vmw_cursor_plane_formats,
> @@ -1769,8 +1765,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
>  
>  	drm_plane_helper_add(cursor, &vmw_stdu_cursor_plane_helper_funcs);
>  
> -	vmw_du_connector_reset(connector);
> -
>  	ret = drm_connector_init(dev, connector, &vmw_stdu_connector_funcs,
>  				 DRM_MODE_CONNECTOR_VIRTUAL);
>  	if (ret) {
> @@ -1798,7 +1792,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
>  		goto err_free_encoder;
>  	}
>  
> -	vmw_du_crtc_reset(crtc);
>  	ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary,
>  					&stdu->base.cursor,
>  					&vmw_stdu_crtc_funcs, NULL);
> @@ -1894,6 +1887,8 @@ int vmw_kms_stdu_init_display(struct vmw_private *dev_priv)
>  		}
>  	}
>  
> +	drm_mode_config_reset(dev);
> +
>  	DRM_INFO("Screen Target Display device initialized\n");
>  
>  	return 0;
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 16b385629688..cf3aafd00837 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -1738,8 +1738,6 @@  static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
 	stdu->base.is_implicit = false;
 
 	/* Initialize primary plane */
-	vmw_du_plane_reset(primary);
-
 	ret = drm_universal_plane_init(dev, primary,
 				       0, &vmw_stdu_plane_funcs,
 				       vmw_primary_plane_formats,
@@ -1754,8 +1752,6 @@  static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
 	drm_plane_enable_fb_damage_clips(primary);
 
 	/* Initialize cursor plane */
-	vmw_du_plane_reset(cursor);
-
 	ret = drm_universal_plane_init(dev, cursor,
 			0, &vmw_stdu_cursor_funcs,
 			vmw_cursor_plane_formats,
@@ -1769,8 +1765,6 @@  static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
 
 	drm_plane_helper_add(cursor, &vmw_stdu_cursor_plane_helper_funcs);
 
-	vmw_du_connector_reset(connector);
-
 	ret = drm_connector_init(dev, connector, &vmw_stdu_connector_funcs,
 				 DRM_MODE_CONNECTOR_VIRTUAL);
 	if (ret) {
@@ -1798,7 +1792,6 @@  static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
 		goto err_free_encoder;
 	}
 
-	vmw_du_crtc_reset(crtc);
 	ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary,
 					&stdu->base.cursor,
 					&vmw_stdu_crtc_funcs, NULL);
@@ -1894,6 +1887,8 @@  int vmw_kms_stdu_init_display(struct vmw_private *dev_priv)
 		}
 	}
 
+	drm_mode_config_reset(dev);
+
 	DRM_INFO("Screen Target Display device initialized\n");
 
 	return 0;