* [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown
@ 2018-10-05 10:14 Benjamin Gaignard
2018-10-05 14:25 ` Daniel Vetter
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Gaignard @ 2018-10-05 10:14 UTC (permalink / raw)
To: dri-devel, daniel.vetter, vincent.abriou, ville.syrjala
From: Daniel Vetter <daniel.vetter@ffwll.ch>
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.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Complements original patch after testing on board.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
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(-)
diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index 5824e6aca8f4..61c2379fba87 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -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
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
index 57b870e1e696..e1ba253055c7 100644
--- a/drivers/gpu/drm/sti/sti_cursor.c
+++ b/drivers/gpu/drm/sti/sti_cursor.c
@@ -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,
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 6dced8abcf16..ac54e0f9caea 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -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:
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index c32de6cbf061..87b50451afd7 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -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,
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index 03ac3b4a4469..065a5b08a702 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -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,
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
index ea4a3b87fa55..4dc3b2ec40eb 100644
--- a/drivers/gpu/drm/sti/sti_tvout.c
+++ b/drivers/gpu/drm/sti/sti_tvout.c
@@ -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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown
2018-10-05 10:14 [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown Benjamin Gaignard
@ 2018-10-05 14:25 ` Daniel Vetter
2018-10-08 8:08 ` Benjamin Gaignard
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2018-10-05 14:25 UTC (permalink / raw)
To: Benjamin Gaignard; +Cc: Vincent Abriou, dri-devel
On Fri, Oct 5, 2018 at 12:14 PM Benjamin Gaignard
<benjamin.gaignard@linaro.org> wrote:
>
> From: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> 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.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> 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
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Cc: Vincent Abriou <vincent.abriou@st.com>
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> index 5824e6aca8f4..61c2379fba87 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.c
> +++ b/drivers/gpu/drm/sti/sti_crtc.c
> @@ -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
> diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
> index 57b870e1e696..e1ba253055c7 100644
> --- a/drivers/gpu/drm/sti/sti_cursor.c
> +++ b/drivers/gpu/drm/sti/sti_cursor.c
> @@ -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,
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 6dced8abcf16..ac54e0f9caea 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -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:
> diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
> index c32de6cbf061..87b50451afd7 100644
> --- a/drivers/gpu/drm/sti/sti_gdp.c
> +++ b/drivers/gpu/drm/sti/sti_gdp.c
> @@ -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,
> diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> index 03ac3b4a4469..065a5b08a702 100644
> --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> @@ -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,
> diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
> index ea4a3b87fa55..4dc3b2ec40eb 100644
> --- a/drivers/gpu/drm/sti/sti_tvout.c
> +++ b/drivers/gpu/drm/sti/sti_tvout.c
> @@ -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
>
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown
2018-10-05 14:25 ` Daniel Vetter
@ 2018-10-08 8:08 ` Benjamin Gaignard
2018-10-11 8:32 ` Daniel Vetter
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Gaignard @ 2018-10-08 8:08 UTC (permalink / raw)
To: Daniel Vetter; +Cc: Vincent Abriou, ML dri-devel
Le ven. 5 oct. 2018 à 16:25, Daniel Vetter <daniel.vetter@ffwll.ch> a écrit :
>
> On Fri, Oct 5, 2018 at 12:14 PM Benjamin Gaignard
> <benjamin.gaignard@linaro.org> wrote:
> >
> > From: Daniel Vetter <daniel.vetter@ffwll.ch>
> >
> > 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.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> >
> > 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 ?
>
> Adding the drm_crtc_wait_one_vblank has my r-b (if it's just the
> bugfix patch only).
> -Daniel
>
> > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> > Cc: Vincent Abriou <vincent.abriou@st.com>
> > Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> > 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(-)
> >
> > diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> > index 5824e6aca8f4..61c2379fba87 100644
> > --- a/drivers/gpu/drm/sti/sti_crtc.c
> > +++ b/drivers/gpu/drm/sti/sti_crtc.c
> > @@ -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
> > diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
> > index 57b870e1e696..e1ba253055c7 100644
> > --- a/drivers/gpu/drm/sti/sti_cursor.c
> > +++ b/drivers/gpu/drm/sti/sti_cursor.c
> > @@ -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,
> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > index 6dced8abcf16..ac54e0f9caea 100644
> > --- a/drivers/gpu/drm/sti/sti_drv.c
> > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > @@ -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:
> > diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
> > index c32de6cbf061..87b50451afd7 100644
> > --- a/drivers/gpu/drm/sti/sti_gdp.c
> > +++ b/drivers/gpu/drm/sti/sti_gdp.c
> > @@ -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,
> > diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> > index 03ac3b4a4469..065a5b08a702 100644
> > --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> > +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> > @@ -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,
> > diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
> > index ea4a3b87fa55..4dc3b2ec40eb 100644
> > --- a/drivers/gpu/drm/sti/sti_tvout.c
> > +++ b/drivers/gpu/drm/sti/sti_tvout.c
> > @@ -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
> >
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
Benjamin Gaignard
Graphic Study Group
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown
2018-10-08 8:08 ` Benjamin Gaignard
@ 2018-10-11 8:32 ` Daniel Vetter
2018-10-11 9:17 ` Benjamin Gaignard
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2018-10-11 8:32 UTC (permalink / raw)
To: Benjamin Gaignard; +Cc: Daniel Vetter, Vincent Abriou, ML dri-devel
On Mon, Oct 08, 2018 at 10:08:06AM +0200, Benjamin Gaignard wrote:
> Le ven. 5 oct. 2018 à 16:25, Daniel Vetter <daniel.vetter@ffwll.ch> a écrit :
> >
> > On Fri, Oct 5, 2018 at 12:14 PM Benjamin Gaignard
> > <benjamin.gaignard@linaro.org> wrote:
> > >
> > > From: Daniel Vetter <daniel.vetter@ffwll.ch>
> > >
> > > 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.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > >
> > > 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 ?
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
>
> >
> > Adding the drm_crtc_wait_one_vblank has my r-b (if it's just the
> > bugfix patch only).
> > -Daniel
> >
> > > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> > > Cc: Vincent Abriou <vincent.abriou@st.com>
> > > Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > > 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(-)
> > >
> > > diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> > > index 5824e6aca8f4..61c2379fba87 100644
> > > --- a/drivers/gpu/drm/sti/sti_crtc.c
> > > +++ b/drivers/gpu/drm/sti/sti_crtc.c
> > > @@ -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
> > > diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
> > > index 57b870e1e696..e1ba253055c7 100644
> > > --- a/drivers/gpu/drm/sti/sti_cursor.c
> > > +++ b/drivers/gpu/drm/sti/sti_cursor.c
> > > @@ -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,
> > > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > > index 6dced8abcf16..ac54e0f9caea 100644
> > > --- a/drivers/gpu/drm/sti/sti_drv.c
> > > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > > @@ -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:
> > > diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
> > > index c32de6cbf061..87b50451afd7 100644
> > > --- a/drivers/gpu/drm/sti/sti_gdp.c
> > > +++ b/drivers/gpu/drm/sti/sti_gdp.c
> > > @@ -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,
> > > diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> > > index 03ac3b4a4469..065a5b08a702 100644
> > > --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> > > +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> > > @@ -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,
> > > diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
> > > index ea4a3b87fa55..4dc3b2ec40eb 100644
> > > --- a/drivers/gpu/drm/sti/sti_tvout.c
> > > +++ b/drivers/gpu/drm/sti/sti_tvout.c
> > > @@ -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
> > >
> >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > +41 (0) 79 365 57 48 - http://blog.ffwll.ch
>
>
>
> --
> Benjamin Gaignard
>
> Graphic Study Group
>
> 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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown
2018-10-11 8:32 ` Daniel Vetter
@ 2018-10-11 9:17 ` Benjamin Gaignard
0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Gaignard @ 2018-10-11 9:17 UTC (permalink / raw)
To: Daniel Vetter; +Cc: Daniel Vetter, Vincent Abriou, ML dri-devel
Le jeu. 11 oct. 2018 à 10:32, Daniel Vetter <daniel@ffwll.ch> a écrit :
>
> On Mon, Oct 08, 2018 at 10:08:06AM +0200, Benjamin Gaignard wrote:
> > Le ven. 5 oct. 2018 à 16:25, Daniel Vetter <daniel.vetter@ffwll.ch> a écrit :
> > >
> > > On Fri, Oct 5, 2018 at 12:14 PM Benjamin Gaignard
> > > <benjamin.gaignard@linaro.org> wrote:
> > > >
> > > > From: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > >
> > > > 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.
> > > >
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > >
> > > > 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 ?
>
> 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.
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
>
> 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
>
> >
> > >
> > > Adding the drm_crtc_wait_one_vblank has my r-b (if it's just the
> > > bugfix patch only).
> > > -Daniel
> > >
> > > > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> > > > Cc: Vincent Abriou <vincent.abriou@st.com>
> > > > Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > > 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(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> > > > index 5824e6aca8f4..61c2379fba87 100644
> > > > --- a/drivers/gpu/drm/sti/sti_crtc.c
> > > > +++ b/drivers/gpu/drm/sti/sti_crtc.c
> > > > @@ -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
> > > > diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
> > > > index 57b870e1e696..e1ba253055c7 100644
> > > > --- a/drivers/gpu/drm/sti/sti_cursor.c
> > > > +++ b/drivers/gpu/drm/sti/sti_cursor.c
> > > > @@ -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,
> > > > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > > > index 6dced8abcf16..ac54e0f9caea 100644
> > > > --- a/drivers/gpu/drm/sti/sti_drv.c
> > > > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > > > @@ -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:
> > > > diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
> > > > index c32de6cbf061..87b50451afd7 100644
> > > > --- a/drivers/gpu/drm/sti/sti_gdp.c
> > > > +++ b/drivers/gpu/drm/sti/sti_gdp.c
> > > > @@ -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,
> > > > diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> > > > index 03ac3b4a4469..065a5b08a702 100644
> > > > --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> > > > +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> > > > @@ -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,
> > > > diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
> > > > index ea4a3b87fa55..4dc3b2ec40eb 100644
> > > > --- a/drivers/gpu/drm/sti/sti_tvout.c
> > > > +++ b/drivers/gpu/drm/sti/sti_tvout.c
> > > > @@ -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
> > > >
> > >
> > >
> > > --
> > > Daniel Vetter
> > > Software Engineer, Intel Corporation
> > > +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> >
> >
> >
> > --
> > Benjamin Gaignard
> >
> > Graphic Study Group
> >
> > 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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 00/21] atomic helper cleanup, take 2
@ 2018-10-04 20:24 Daniel Vetter
2018-10-04 20:24 ` [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown Daniel Vetter
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2018-10-04 20:24 UTC (permalink / raw)
To: DRI Development; +Cc: Daniel Vetter
Hi all,
Resend mostly unchanged, except a few patches tacked on a the end. Main
goal here is to get intel-gfx-ci to approve this, since last time around
patchwork didn't parse what I've done :-)
Still a bunch of unreviewed stuff, so feedback highly welcome.
Cheers, Daniel
Daniel Vetter (20):
drm/amdgpu: Remove default best_encoder hook from DC
drm/atomic-helper: Unexport drm_atomic_helper_best_encoder
drm: Extract drm_atomic_state_helper.[hc]
drm/vmwgfx: Don't look at state->allow_modeset
drm/vmwgfx: Remove confused comment from
vmw_du_connector_atomic_set_property
drm/atomic: Improve docs for drm_atomic_state->allow_modeset
drm/vmwgfx: Add FIXME comments for customer page_flip handlers
drm/arcpgu: Drop transitional hooks
drm/atmel: Drop transitional hooks
drm/arcpgu: Use drm_atomic_helper_shutdown
drm/msm: Use drm_atomic_helper_shutdown
drm/sti: Use drm_atomic_helper_shutdown
drm/vc4: Use drm_atomic_helper_shutdown
drm/zte: Use drm_atomic_helper_shutdown
drm: Remove transitional helpers
drm: Unexport drm_plane_helper_check_update
drm: Unexport primary plane helpers
drm/doc: fix drm_driver_legacy_fb_format
drm/todo: Add some cleanup tasks
drm/doc: kerneldoc for quirk_addfb_prefer_xbgr_30bpp
Thomas Hellstrom (1):
drm/vmwgfx: Fix vmw_du_cursor_plane_atomic_check
Documentation/gpu/drm-kms-helpers.rst | 19 +-
Documentation/gpu/todo.rst | 10 +
drivers/gpu/drm/Makefile | 3 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +-
drivers/gpu/drm/arc/arcpgu_crtc.c | 3 -
drivers/gpu/drm/arc/arcpgu_drv.c | 1 +
.../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 2 -
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 1 -
drivers/gpu/drm/drm_atomic_helper.c | 598 +----------------
drivers/gpu/drm/drm_atomic_state_helper.c | 601 ++++++++++++++++++
drivers/gpu/drm/drm_crtc_helper.c | 115 ----
drivers/gpu/drm/drm_fourcc.c | 6 +-
drivers/gpu/drm/drm_plane_helper.c | 331 +---------
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 -
drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 1 -
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 1 -
drivers/gpu/drm/msm/msm_drv.c | 1 +
drivers/gpu/drm/sti/sti_cursor.c | 1 -
drivers/gpu/drm/sti/sti_drv.c | 6 +-
drivers/gpu/drm/sti/sti_gdp.c | 1 -
drivers/gpu/drm/sti/sti_hqvdp.c | 1 -
drivers/gpu/drm/vc4/vc4_drv.c | 3 +
drivers/gpu/drm/vc4/vc4_plane.c | 1 -
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 38 +-
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 1 -
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 3 +-
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 2 +-
drivers/gpu/drm/zte/zx_drm_drv.c | 1 +
drivers/gpu/drm/zte/zx_plane.c | 1 -
include/drm/drm_atomic.h | 10 +-
include/drm/drm_atomic_helper.h | 46 +-
include/drm/drm_atomic_state_helper.h | 80 +++
include/drm/drm_crtc_helper.h | 6 -
include/drm/drm_mode_config.h | 7 +
include/drm/drm_plane_helper.h | 35 -
35 files changed, 793 insertions(+), 1159 deletions(-)
create mode 100644 drivers/gpu/drm/drm_atomic_state_helper.c
create mode 100644 include/drm/drm_atomic_state_helper.h
--
2.19.0.rc2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown
2018-10-04 20:24 [PATCH 00/21] atomic helper cleanup, take 2 Daniel Vetter
@ 2018-10-04 20:24 ` Daniel Vetter
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-10-04 20:24 UTC (permalink / raw)
To: DRI Development; +Cc: Daniel Vetter, Vincent Abriou
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.
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
---
drivers/gpu/drm/sti/sti_cursor.c | 1 -
drivers/gpu/drm/sti/sti_drv.c | 6 +++---
drivers/gpu/drm/sti/sti_gdp.c | 1 -
drivers/gpu/drm/sti/sti_hqvdp.c | 1 -
4 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
index 57b870e1e696..bc908453ffb3 100644
--- a/drivers/gpu/drm/sti/sti_cursor.c
+++ b/drivers/gpu/drm/sti/sti_cursor.c
@@ -332,7 +332,6 @@ 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);
}
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 6dced8abcf16..ac54e0f9caea 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -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:
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index c32de6cbf061..3c19614d3f75 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -883,7 +883,6 @@ 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);
}
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index 03ac3b4a4469..23565f52dd71 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -1260,7 +1260,6 @@ 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);
}
--
2.19.0.rc2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-10-11 9:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05 10:14 [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown Benjamin Gaignard
2018-10-05 14:25 ` Daniel Vetter
2018-10-08 8:08 ` Benjamin Gaignard
2018-10-11 8:32 ` Daniel Vetter
2018-10-11 9:17 ` Benjamin Gaignard
-- strict thread matches above, loose matches on Subject: below --
2018-10-04 20:24 [PATCH 00/21] atomic helper cleanup, take 2 Daniel Vetter
2018-10-04 20:24 ` [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.