drm/sti: Use drm_atomic_helper_shutdown
Subsystems (3)
PATCH 12/21 drm/sti: Use drm_atomic_helper_shutdown
From: Daniel Vetter <[email protected]>
drm_plane_helper_disable is a non-atomic drivers only function, and will blow up (since no one passes the locking context it needs).
Atomic drivers which want to quiescent their hw on unload should use drm_atomic_helper_shutdown() instead.
The sti cleanup code seems supremely confused:
- In the load error path it calls drm_mode_config_cleanup before it stops various kms services like poll worker or fbdev emulation. That's going to oops.
- The actual unload code doesn't even bother with the cleanup and just leaks.
Try to fix this while at it.
Complements original patch after testing on board.
--- drivers/gpu/drm/sti/sti_crtc.c | 2 ++ drivers/gpu/drm/sti/sti_cursor.c | 10 +--------- drivers/gpu/drm/sti/sti_drv.c | 6 +++--- drivers/gpu/drm/sti/sti_gdp.c | 10 +--------- drivers/gpu/drm/sti/sti_hqvdp.c | 10 +--------- drivers/gpu/drm/sti/sti_tvout.c | 24 ------------------------ 6 files changed, 8 insertions(+), 54 deletions(-)
drivers/gpu/drm/sti/sti_crtc.c +2 -0
@@ -40,6 +40,8 @@ static void sti_crtc_atomic_disable(struct drm_crtc *crtc,DRM_DEBUG_DRIVER ("\n" ); mixer->status =STI_MIXER_DISABLING ; + +drm_crtc_wait_one_vblank (crtc); } static int
drivers/gpu/drm/sti/sti_cursor.c +1 -9
@@ -328,14 +328,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { .atomic_disable = sti_cursor_atomic_disable, }; -static void sti_cursor_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_cursor_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);
@@ -347,7 +339,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_cursor_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
drivers/gpu/drm/sti/sti_drv.c +3 -3
@@ -206,6 +206,8 @@ static void sti_cleanup(struct drm_device *ddev)struct sti_private *private = ddev->dev_private;drm_kms_helper_poll_fini (ddev); +drm_atomic_helper_shutdown (ddev); +drm_mode_config_cleanup (ddev);component_unbind_all (ddev->dev, ddev);kfree (private); ddev->dev_private =NULL ;
@@ -230,7 +232,7 @@ static int sti_bind(struct device *dev) ret =drm_dev_register (ddev,0 );if (ret) - goto err_register; + goto err_cleanup;drm_mode_config_reset (ddev);
@@ -238,8 +240,6 @@ static int sti_bind(struct device *dev)return 0 ; -err_register: -drm_mode_config_cleanup (ddev); err_cleanup:sti_cleanup (ddev); err_drm_dev_put:
drivers/gpu/drm/sti/sti_gdp.c +1 -9
@@ -879,14 +879,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { .atomic_disable = sti_gdp_atomic_disable, }; -static void sti_gdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_gdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);
@@ -898,7 +890,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_gdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
drivers/gpu/drm/sti/sti_hqvdp.c +1 -9
@@ -1256,14 +1256,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { .atomic_disable = sti_hqvdp_atomic_disable, }; -static void sti_hqvdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_hqvdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);
@@ -1275,7 +1267,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_hqvdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
drivers/gpu/drm/sti/sti_tvout.c +0 -24
@@ -788,21 +788,6 @@ static void sti_tvout_create_encoders(struct drm_device *dev, tvout->dvo =sti_tvout_create_dvo_encoder (dev, tvout); } -static void sti_tvout_destroy_encoders (struct sti_tvout *tvout) -{ -if (tvout->hdmi) -drm_encoder_cleanup (tvout->hdmi); - tvout->hdmi =NULL ; - -if (tvout->hda) -drm_encoder_cleanup (tvout->hda); - tvout->hda =NULL ; - -if (tvout->dvo) -drm_encoder_cleanup (tvout->dvo); - tvout->dvo =NULL ; -} -static int sti_tvout_bind (struct device *dev,struct device *master,void *data) {struct sti_tvout *tvout =dev_get_drvdata (dev);
@@ -815,17 +800,8 @@ static int sti_tvout_bind(struct device *dev, struct device *master, void *data)return 0 ; } -static void sti_tvout_unbind (struct device *dev,struct device *master, -void *data) -{ -struct sti_tvout *tvout =dev_get_drvdata (dev); - -sti_tvout_destroy_encoders (tvout); -} -static const struct component_ops sti_tvout_ops = { .bind = sti_tvout_bind, - .unbind = sti_tvout_unbind, };static int sti_tvout_probe (struct platform_device *pdev)
Signature · 6 lines
2.15.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 16 lines · Benjamin Gaignard
From: Daniel Vetter <[email protected]>
drm_plane_helper_disableis a non-atomic drivers only function, and will blow up (since no one passes the locking context it needs).Atomic drivers which want to quiescent their hw on unload should use
drm_atomic_helper_shutdown()instead.The sti cleanup code seems supremely confused:
- In the load error path it callsdrm_mode_config_cleanupbefore it stops various kms services like poll worker or fbdev emulation. That's going to oops.
- The actual unload code doesn't even bother with the cleanup and just leaks.
Quoted 5 lines
Try to fix this while at it.
Signed-off-by Daniel Vetter <[email protected]>Complements original patch after testing on board.
I think it's better to split out your fixup and cc: stable it, since I think you'll hit the same error also just when shutting down a CRTC at runtime. Which is something compositors and fbcon tends to do. Then we could put your patch into -fixes, and my cleanup (which really isn't a fix) into -next. Sounds good?
Adding the drm_crtc_wait_one_vblank has my r-b (if it's just the bugfix patch only).
-Daniel
Quoted 187 lines
Signed-off-by Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/sti/sti_crtc.c | 2 ++ drivers/gpu/drm/sti/sti_cursor.c | 10 +--------- drivers/gpu/drm/sti/sti_drv.c | 6 +++--- drivers/gpu/drm/sti/sti_gdp.c | 10 +--------- drivers/gpu/drm/sti/sti_hqvdp.c | 10 +--------- drivers/gpu/drm/sti/sti_tvout.c | 24 ------------------------ 6 files changed, 8 insertions(+), 54 deletions(-)drivers/gpu/drm/sti/sti_crtc.c +2
-0@@ -40,6 +40,8 @@ static void sti_crtc_atomic_disable(struct drm_crtc *crtc,DRM_DEBUG_DRIVER ("\n" ); mixer->status =STI_MIXER_DISABLING ; + +drm_crtc_wait_one_vblank (crtc); } static intdrivers/gpu/drm/sti/sti_cursor.c +1
-9@@ -328,14 +328,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { .atomic_disable = sti_cursor_atomic_disable, }; -static void sti_cursor_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_cursor_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -347,7 +339,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_cursor_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_drv.c +3
-3@@ -206,6 +206,8 @@ static void sti_cleanup(struct drm_device *ddev)struct sti_private *private = ddev->dev_private;drm_kms_helper_poll_fini (ddev); +drm_atomic_helper_shutdown (ddev); +drm_mode_config_cleanup (ddev);component_unbind_all (ddev->dev, ddev);kfree (private); ddev->dev_private =NULL ;@@ -230,7 +232,7 @@ static int sti_bind(struct device *dev) ret =drm_dev_register (ddev,0 );if (ret) - goto err_register; + goto err_cleanup;drm_mode_config_reset (ddev);@@ -238,8 +240,6 @@ static int sti_bind(struct device *dev)return 0 ; -err_register: -drm_mode_config_cleanup (ddev); err_cleanup:sti_cleanup (ddev); err_drm_dev_put:drivers/gpu/drm/sti/sti_gdp.c +1
-9@@ -879,14 +879,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { .atomic_disable = sti_gdp_atomic_disable, }; -static void sti_gdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_gdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -898,7 +890,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_gdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_hqvdp.c +1
-9@@ -1256,14 +1256,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { .atomic_disable = sti_hqvdp_atomic_disable, }; -static void sti_hqvdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_hqvdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -1275,7 +1267,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_hqvdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_tvout.c +0
-25@@ -788,21 +788,6 @@ static void sti_tvout_create_encoders(struct drm_device *dev, tvout->dvo =sti_tvout_create_dvo_encoder (dev, tvout); } -static void sti_tvout_destroy_encoders (struct sti_tvout *tvout) -{ -if (tvout->hdmi) -drm_encoder_cleanup (tvout->hdmi); - tvout->hdmi =NULL ; - -if (tvout->hda) -drm_encoder_cleanup (tvout->hda); - tvout->hda =NULL ; - -if (tvout->dvo) -drm_encoder_cleanup (tvout->dvo); - tvout->dvo =NULL ; -} -static int sti_tvout_bind (struct device *dev,struct device *master,void *data) {struct sti_tvout *tvout =dev_get_drvdata (dev);@@ -815,17 +800,8 @@ static int sti_tvout_bind(struct device *dev, struct device *master, void *data)return 0 ; } -static void sti_tvout_unbind (struct device *dev,struct device *master, -void *data) -{ -struct sti_tvout *tvout =dev_get_drvdata (dev); - -sti_tvout_destroy_encoders (tvout); -} -static const struct component_ops sti_tvout_ops = { .bind = sti_tvout_bind, - .unbind = sti_tvout_unbind, };static int sti_tvout_probe (struct platform_device *pdev) --2.15.0
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 23 lines · Daniel Vetter
Quoted 20 lines · Benjamin Gaignard
From: Daniel Vetter <[email protected]>
drm_plane_helper_disableis a non-atomic drivers only function, and will blow up (since no one passes the locking context it needs).Atomic drivers which want to quiescent their hw on unload should use
drm_atomic_helper_shutdown()instead.The sti cleanup code seems supremely confused:
- In the load error path it callsdrm_mode_config_cleanupbefore it stops various kms services like poll worker or fbdev emulation. That's going to oops.
- The actual unload code doesn't even bother with the cleanup and just leaks.Try to fix this while at it.
Signed-off-by Daniel Vetter <[email protected]>
Quoted 7 lines
Quoted 1 line
Complements original patch after testing on board.
I think it's better to split out your fixup and cc: stable it, since I think you'll hit the same error also just when shutting down a CRTC at runtime. Which is something compositors and fbcon tends to do. Then we could put your patch into -fixes, and my cleanup (which really isn't a fix) into -next. Sounds good?
I have added more than drm_crtc_wait_one_vblank(), I also change the clean up for encoders and remove functions that becomes unneeded. sti driver is used on setup-box platform where nobody load/unload the driver. I could do a patch to use drm_crtc_wait_one_vblank(), wait for you patch to be apply and then do the additional clean up or merge everything in one shot with this version.
What do you prefer ?
Quoted 198 lines
Adding the
drm_crtc_wait_one_vblankhas my r-b (if it's just the bugfix patch only).
-DanielQuoted 185 lines
Signed-off-by Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/sti/sti_crtc.c | 2 ++ drivers/gpu/drm/sti/sti_cursor.c | 10 +--------- drivers/gpu/drm/sti/sti_drv.c | 6 +++--- drivers/gpu/drm/sti/sti_gdp.c | 10 +--------- drivers/gpu/drm/sti/sti_hqvdp.c | 10 +--------- drivers/gpu/drm/sti/sti_tvout.c | 24 ------------------------ 6 files changed, 8 insertions(+), 54 deletions(-)drivers/gpu/drm/sti/sti_crtc.c +2
-0@@ -40,6 +40,8 @@ static void sti_crtc_atomic_disable(struct drm_crtc *crtc,DRM_DEBUG_DRIVER ("\n" ); mixer->status =STI_MIXER_DISABLING ; + +drm_crtc_wait_one_vblank (crtc); } static intdrivers/gpu/drm/sti/sti_cursor.c +1
-9@@ -328,14 +328,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { .atomic_disable = sti_cursor_atomic_disable, }; -static void sti_cursor_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_cursor_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -347,7 +339,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_cursor_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_drv.c +3
-3@@ -206,6 +206,8 @@ static void sti_cleanup(struct drm_device *ddev)struct sti_private *private = ddev->dev_private;drm_kms_helper_poll_fini (ddev); +drm_atomic_helper_shutdown (ddev); +drm_mode_config_cleanup (ddev);component_unbind_all (ddev->dev, ddev);kfree (private); ddev->dev_private =NULL ;@@ -230,7 +232,7 @@ static int sti_bind(struct device *dev) ret =drm_dev_register (ddev,0 );if (ret) - goto err_register; + goto err_cleanup;drm_mode_config_reset (ddev);@@ -238,8 +240,6 @@ static int sti_bind(struct device *dev)return 0 ; -err_register: -drm_mode_config_cleanup (ddev); err_cleanup:sti_cleanup (ddev); err_drm_dev_put:drivers/gpu/drm/sti/sti_gdp.c +1
-9@@ -879,14 +879,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { .atomic_disable = sti_gdp_atomic_disable, }; -static void sti_gdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_gdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -898,7 +890,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_gdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_hqvdp.c +1
-9@@ -1256,14 +1256,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { .atomic_disable = sti_hqvdp_atomic_disable, }; -static void sti_hqvdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_hqvdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -1275,7 +1267,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_hqvdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_tvout.c +0
-25@@ -788,21 +788,6 @@ static void sti_tvout_create_encoders(struct drm_device *dev, tvout->dvo =sti_tvout_create_dvo_encoder (dev, tvout); } -static void sti_tvout_destroy_encoders (struct sti_tvout *tvout) -{ -if (tvout->hdmi) -drm_encoder_cleanup (tvout->hdmi); - tvout->hdmi =NULL ; - -if (tvout->hda) -drm_encoder_cleanup (tvout->hda); - tvout->hda =NULL ; - -if (tvout->dvo) -drm_encoder_cleanup (tvout->dvo); - tvout->dvo =NULL ; -} -static int sti_tvout_bind (struct device *dev,struct device *master,void *data) {struct sti_tvout *tvout =dev_get_drvdata (dev);@@ -815,17 +800,8 @@ static int sti_tvout_bind(struct device *dev, struct device *master, void *data)return 0 ; } -static void sti_tvout_unbind (struct device *dev,struct device *master, -void *data) -{ -struct sti_tvout *tvout =dev_get_drvdata (dev); - -sti_tvout_destroy_encoders (tvout); -} -static const struct component_ops sti_tvout_ops = { .bind = sti_tvout_bind, - .unbind = sti_tvout_unbind, };static int sti_tvout_probe (struct platform_device *pdev) --Quoted 2 lines
2.15.0
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 11 lines
Benjamin Gaignard Graphic Study Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 32 lines · Benjamin Gaignard
Quoted 23 lines · Daniel Vetter
Quoted 20 lines · Benjamin Gaignard
From: Daniel Vetter <[email protected]>
drm_plane_helper_disableis a non-atomic drivers only function, and will blow up (since no one passes the locking context it needs).Atomic drivers which want to quiescent their hw on unload should use
drm_atomic_helper_shutdown()instead.The sti cleanup code seems supremely confused:
- In the load error path it callsdrm_mode_config_cleanupbefore it stops various kms services like poll worker or fbdev emulation. That's going to oops.
- The actual unload code doesn't even bother with the cleanup and just leaks.Try to fix this while at it.
Signed-off-by Daniel Vetter <[email protected]>Quoted 7 lines
Quoted 1 line
Complements original patch after testing on board.
I think it's better to split out your fixup and cc: stable it, since I think you'll hit the same error also just when shutting down a CRTC at runtime. Which is something compositors and fbcon tends to do. Then we could put your patch into -fixes, and my cleanup (which really isn't a fix) into -next. Sounds good?
Quoted 7 lines
I have added more than
drm_crtc_wait_one_vblank(), I also change the clean up for encoders and remove functions that becomes unneeded. sti driver is used on setup-box platform where nobody load/unload the driver. I could do a patch to usedrm_crtc_wait_one_vblank(), wait for you patch to be apply and then do the additional clean up or merge everything in one shot with this version.
What do you prefer ?
In the end up to you (but I think I pushed the _shutdown refactor already), but in general I think splitting the cleanup from the bugfixes is good practice.
Also note that just doing a CRTC dpms off will hit this already, not just module unload. At least I'm pretty sure of that. That looks like something worth of backporting to stable kernels.
-Daniel
Quoted 210 lines
Quoted 199 lines
Adding the
drm_crtc_wait_one_vblankhas my r-b (if it's just the bugfix patch only).
-DanielQuoted 185 lines
Signed-off-by Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/sti/sti_crtc.c | 2 ++ drivers/gpu/drm/sti/sti_cursor.c | 10 +--------- drivers/gpu/drm/sti/sti_drv.c | 6 +++--- drivers/gpu/drm/sti/sti_gdp.c | 10 +--------- drivers/gpu/drm/sti/sti_hqvdp.c | 10 +--------- drivers/gpu/drm/sti/sti_tvout.c | 24 ------------------------ 6 files changed, 8 insertions(+), 54 deletions(-)drivers/gpu/drm/sti/sti_crtc.c +2
-0@@ -40,6 +40,8 @@ static void sti_crtc_atomic_disable(struct drm_crtc *crtc,DRM_DEBUG_DRIVER ("\n" ); mixer->status =STI_MIXER_DISABLING ; + +drm_crtc_wait_one_vblank (crtc); } static intdrivers/gpu/drm/sti/sti_cursor.c +1
-9@@ -328,14 +328,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { .atomic_disable = sti_cursor_atomic_disable, }; -static void sti_cursor_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_cursor_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -347,7 +339,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_cursor_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_drv.c +3
-3@@ -206,6 +206,8 @@ static void sti_cleanup(struct drm_device *ddev)struct sti_private *private = ddev->dev_private;drm_kms_helper_poll_fini (ddev); +drm_atomic_helper_shutdown (ddev); +drm_mode_config_cleanup (ddev);component_unbind_all (ddev->dev, ddev);kfree (private); ddev->dev_private =NULL ;@@ -230,7 +232,7 @@ static int sti_bind(struct device *dev) ret =drm_dev_register (ddev,0 );if (ret) - goto err_register; + goto err_cleanup;drm_mode_config_reset (ddev);@@ -238,8 +240,6 @@ static int sti_bind(struct device *dev)return 0 ; -err_register: -drm_mode_config_cleanup (ddev); err_cleanup:sti_cleanup (ddev); err_drm_dev_put:drivers/gpu/drm/sti/sti_gdp.c +1
-9@@ -879,14 +879,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { .atomic_disable = sti_gdp_atomic_disable, }; -static void sti_gdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_gdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -898,7 +890,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_gdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_hqvdp.c +1
-9@@ -1256,14 +1256,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { .atomic_disable = sti_hqvdp_atomic_disable, }; -static void sti_hqvdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_hqvdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -1275,7 +1267,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_hqvdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_tvout.c +0
-25@@ -788,21 +788,6 @@ static void sti_tvout_create_encoders(struct drm_device *dev, tvout->dvo =sti_tvout_create_dvo_encoder (dev, tvout); } -static void sti_tvout_destroy_encoders (struct sti_tvout *tvout) -{ -if (tvout->hdmi) -drm_encoder_cleanup (tvout->hdmi); - tvout->hdmi =NULL ; - -if (tvout->hda) -drm_encoder_cleanup (tvout->hda); - tvout->hda =NULL ; - -if (tvout->dvo) -drm_encoder_cleanup (tvout->dvo); - tvout->dvo =NULL ; -} -static int sti_tvout_bind (struct device *dev,struct device *master,void *data) {struct sti_tvout *tvout =dev_get_drvdata (dev);@@ -815,17 +800,8 @@ static int sti_tvout_bind(struct device *dev, struct device *master, void *data)return 0 ; } -static void sti_tvout_unbind (struct device *dev,struct device *master, -void *data) -{ -struct sti_tvout *tvout =dev_get_drvdata (dev); - -sti_tvout_destroy_encoders (tvout); -} -static const struct component_ops sti_tvout_ops = { .bind = sti_tvout_bind, - .unbind = sti_tvout_unbind, };static int sti_tvout_probe (struct platform_device *pdev) --Quoted 2 lines
2.15.0
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.chSignature · 7 lines
Benjamin Gaignard Graphic Study Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 42 lines · Daniel Vetter
Quoted 32 lines · Benjamin Gaignard
Quoted 23 lines · Daniel Vetter
Quoted 20 lines · Benjamin Gaignard
From: Daniel Vetter <[email protected]>
drm_plane_helper_disableis a non-atomic drivers only function, and will blow up (since no one passes the locking context it needs).Atomic drivers which want to quiescent their hw on unload should use
drm_atomic_helper_shutdown()instead.The sti cleanup code seems supremely confused:
- In the load error path it callsdrm_mode_config_cleanupbefore it stops various kms services like poll worker or fbdev emulation. That's going to oops.
- The actual unload code doesn't even bother with the cleanup and just leaks.Try to fix this while at it.
Signed-off-by Daniel Vetter <[email protected]>Quoted 7 lines
Quoted 1 line
Complements original patch after testing on board.
I think it's better to split out your fixup and cc: stable it, since I think you'll hit the same error also just when shutting down a CRTC at runtime. Which is something compositors and fbcon tends to do. Then we could put your patch into -fixes, and my cleanup (which really isn't a fix) into -next. Sounds good?
Quoted 7 lines
I have added more than
drm_crtc_wait_one_vblank(), I also change the clean up for encoders and remove functions that becomes unneeded. sti driver is used on setup-box platform where nobody load/unload the driver. I could do a patch to usedrm_crtc_wait_one_vblank(), wait for you patch to be apply and then do the additional clean up or merge everything in one shot with this version.
What do you prefer ?
Quoted 3 lines
In the end up to you (but I think I pushed the
_shutdownrefactor already), but in general I think splitting the cleanup from the bugfixes is good practice.
Yes you have pushed the _shutdown refactor so I will follow the good practice way
and send patches for additional clean up and bug fixes :-)
Benjamin
Quoted 213 lines
Also note that just doing a CRTC dpms off will hit this already, not just module unload. At least I'm pretty sure of that. That looks like something worth of backporting to stable kernels.
-DanielQuoted 207 lines
Quoted 189 lines
Adding the
drm_crtc_wait_one_vblankhas my r-b (if it's just the bugfix patch only).
-DanielQuoted 183 lines
Signed-off-by Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/sti/sti_crtc.c | 2 ++ drivers/gpu/drm/sti/sti_cursor.c | 10 +--------- drivers/gpu/drm/sti/sti_drv.c | 6 +++--- drivers/gpu/drm/sti/sti_gdp.c | 10 +--------- drivers/gpu/drm/sti/sti_hqvdp.c | 10 +--------- drivers/gpu/drm/sti/sti_tvout.c | 24 ------------------------ 6 files changed, 8 insertions(+), 54 deletions(-)drivers/gpu/drm/sti/sti_crtc.c +2
-0@@ -40,6 +40,8 @@ static void sti_crtc_atomic_disable(struct drm_crtc *crtc,DRM_DEBUG_DRIVER ("\n" ); mixer->status =STI_MIXER_DISABLING ; + +drm_crtc_wait_one_vblank (crtc); } static intdrivers/gpu/drm/sti/sti_cursor.c +1
-9@@ -328,14 +328,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { .atomic_disable = sti_cursor_atomic_disable, }; -static void sti_cursor_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_cursor_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -347,7 +339,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_cursor_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_drv.c +3
-3@@ -206,6 +206,8 @@ static void sti_cleanup(struct drm_device *ddev)struct sti_private *private = ddev->dev_private;drm_kms_helper_poll_fini (ddev); +drm_atomic_helper_shutdown (ddev); +drm_mode_config_cleanup (ddev);component_unbind_all (ddev->dev, ddev);kfree (private); ddev->dev_private =NULL ;@@ -230,7 +232,7 @@ static int sti_bind(struct device *dev) ret =drm_dev_register (ddev,0 );if (ret) - goto err_register; + goto err_cleanup;drm_mode_config_reset (ddev);@@ -238,8 +240,6 @@ static int sti_bind(struct device *dev)return 0 ; -err_register: -drm_mode_config_cleanup (ddev); err_cleanup:sti_cleanup (ddev); err_drm_dev_put:drivers/gpu/drm/sti/sti_gdp.c +1
-9@@ -879,14 +879,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { .atomic_disable = sti_gdp_atomic_disable, }; -static void sti_gdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_gdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -898,7 +890,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_gdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_hqvdp.c +1
-9@@ -1256,14 +1256,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { .atomic_disable = sti_hqvdp_atomic_disable, }; -static void sti_hqvdp_destroy (struct drm_plane *drm_plane) -{ -DRM_DEBUG_DRIVER ("\n" ); - -drm_plane_helper_disable (drm_plane,NULL ); -drm_plane_cleanup (drm_plane); -} -static int sti_hqvdp_late_register (struct drm_plane *drm_plane) {struct sti_plane *plane =to_sti_plane (drm_plane);@@ -1275,7 +1267,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane)static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_hqvdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,drivers/gpu/drm/sti/sti_tvout.c +0
-24@@ -788,21 +788,6 @@ static void sti_tvout_create_encoders(struct drm_device *dev, tvout->dvo =sti_tvout_create_dvo_encoder (dev, tvout); } -static void sti_tvout_destroy_encoders (struct sti_tvout *tvout) -{ -if (tvout->hdmi) -drm_encoder_cleanup (tvout->hdmi); - tvout->hdmi =NULL ; - -if (tvout->hda) -drm_encoder_cleanup (tvout->hda); - tvout->hda =NULL ; - -if (tvout->dvo) -drm_encoder_cleanup (tvout->dvo); - tvout->dvo =NULL ; -} -static int sti_tvout_bind (struct device *dev,struct device *master,void *data) {struct sti_tvout *tvout =dev_get_drvdata (dev);@@ -815,17 +800,8 @@ static int sti_tvout_bind(struct device *dev, struct device *master, void *data)return 0 ; } -static void sti_tvout_unbind (struct device *dev,struct device *master, -void *data) -{ -struct sti_tvout *tvout =dev_get_drvdata (dev); - -sti_tvout_destroy_encoders (tvout); -} -static const struct component_ops sti_tvout_ops = { .bind = sti_tvout_bind, - .unbind = sti_tvout_unbind, };Quoted 10 lines
Quoted 4 lines
drivers/gpu/drm/sti/sti_tvout.c +0
-1static int sti_tvout_probe (struct platform_device *pdev) --2.15.0
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch--
Benjamin GaignardGraphic Study Group
Quoted 8 lines
Quoted 3 lines
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel