Re: [PATCH] drm: renesas: shmobile: Call drm_helper_force_disable_all() at shutdown time

2024-05-03 Thread Doug Anderson
Hi,

On Tue, Dec 5, 2023 at 9:35 AM Doug Anderson  wrote:
>
> Hi,
>
> On Tue, Dec 5, 2023 at 5:40 AM Laurent Pinchart
>  wrote:
> >
> > On Tue, Dec 05, 2023 at 02:31:24PM +0100, Geert Uytterhoeven wrote:
> > > On Tue, Dec 5, 2023 at 1:16 PM Laurent Pinchart wrote:
> > > > On Tue, Dec 05, 2023 at 12:30:02PM +0100, Geert Uytterhoeven wrote:
> > > > > From: Douglas Anderson 
> > > > >
> > > > > Based on grepping through the source code, this driver appears to be
> > > > > missing a call to drm_atomic_helper_shutdown() at system shutdown 
> > > > > time.
> > > > > This is important because drm_helper_force_disable_all() will cause
> > > > > panels to get disabled cleanly which may be important for their power
> > > > > sequencing.  Future changes will remove any custom powering off in
> > > > > individual panel drivers so the DRM drivers need to start getting this
> > > > > right.
> > > > >
> > > > > The fact that we should call drm_atomic_helper_shutdown() in the case 
> > > > > of
> > > > > OS shutdown comes straight out of the kernel doc "driver instance
> > > > > overview" in drm_drv.c.
> > > > >
> > > > > Suggested-by: Maxime Ripard 
> > > > > Signed-off-by: Douglas Anderson 
> > > > > Link: 
> > > > > https://lore.kernel.org/r/20230901164111.RFT.15.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@changeid
> > > > > [geert: s/drm_helper_force_disable_all/drm_atomic_helper_shutdown/]
> > > > > [geert: shmob_drm_remove() already calls drm_atomic_helper_shutdown]
> > > > > Signed-off-by: Geert Uytterhoeven 
> > > >
> > > > Reviewed-by: Laurent Pinchart 
> > >
> > > Thanks!
> > >
> > > > > Panel-simple does print two new warnings:
> > > > >
> > > > > +panel-simple panel: Skipping disable of already disabled panel
> > > > > +panel-simple panel: Skipping unprepare of already unprepared 
> > > > > panel
> > > >
> > > > Have you investigated where this comes from ?
> > >
> > > Meh, I knew I forgot something ;-)
> > >
> > > The panel is unprepared and disabled a first time from shmob_drm's
> > > .shutdown() callback:
> > >
> > >   shmob_drm_shutdown
> > > drm_atomic_helper_shutdown
> > >   drm_atomic_helper_disable_all
> > > drm_atomic_commit
> > >   drm_atomic_helper_commit
> > > commit_tail
> > >   drm_atomic_helper_commit_tail
> > > drm_atomic_helper_commit_modeset_disables
> > >   disable_outputs
> > > drm_atomic_bridge_chain_disable
> > > drm_panel_disable
> > > drm_atomic_bridge_chain_post_disable
> > > drm_panel_unprepare
> > >
> > > And a second time from simple_panel's .shutdown() callback():
> > >
> > >   panel_simple_platform_shutdown
> > > panel_simple_shutdown
> > >   drm_panel_disable
> > >   drm_panel_unprepare
> >
> > That looks like what Doug mentioned should be removed in the commit
> > message of this patch (a confirmation would be nice). It should be fine
> > for now.
>
> Yup, this is completely expected right now and is actually a _good_
> sign that your patch is doing what it should be. We unfortunately
> can't remove the panel_simple_shutdown() until all DRM modeset drivers
> (or at least all the ones that could be used w/ panel_simple) are
> properly calling drm_helper_force_disable_all(), though.

FWIW, I've sent out a new version of the series that removes most
panel-specific enable/prepare tracking and also adjusts the TODO to
make it clear that these warnings are expected for panel-simple and
panel-edp [1]. For all other panels my series removes the extra
drm_panel_disable() and drm_panel_unprepare().

I noticed that ${SUBJECT} patch hasn't landed yet, but from grepping I
couldn't find it used with any panels that I was touching... In any
case, it seems like it would be nice if it could land...

I'm not sure the best way to deal with panel-simple / panel-edp. I'm a
little scared to just remove the disable/unprepare since they are used
across so many different DRM modeset drivers, but the annoying thing
is that the warning shows up only on DRM modeset drivers that have
been fixed and _not_ on ones that weren't fixed. :( To get a warning
at the right times we'd need something that runs _after_ driver
shutdown to check whether the DRM modeset driver forgot to call
drm_atomic_helper_shutdown()...

[1] https://lore.kernel.org/r/20240503213441.177109-1-diand...@chromium.org


Re: [PATCH] drm: renesas: shmobile: Call drm_helper_force_disable_all() at shutdown time

2023-12-05 Thread Doug Anderson
Hi,

On Tue, Dec 5, 2023 at 5:40 AM Laurent Pinchart
 wrote:
>
> On Tue, Dec 05, 2023 at 02:31:24PM +0100, Geert Uytterhoeven wrote:
> > On Tue, Dec 5, 2023 at 1:16 PM Laurent Pinchart wrote:
> > > On Tue, Dec 05, 2023 at 12:30:02PM +0100, Geert Uytterhoeven wrote:
> > > > From: Douglas Anderson 
> > > >
> > > > Based on grepping through the source code, this driver appears to be
> > > > missing a call to drm_atomic_helper_shutdown() at system shutdown time.
> > > > This is important because drm_helper_force_disable_all() will cause
> > > > panels to get disabled cleanly which may be important for their power
> > > > sequencing.  Future changes will remove any custom powering off in
> > > > individual panel drivers so the DRM drivers need to start getting this
> > > > right.
> > > >
> > > > The fact that we should call drm_atomic_helper_shutdown() in the case of
> > > > OS shutdown comes straight out of the kernel doc "driver instance
> > > > overview" in drm_drv.c.
> > > >
> > > > Suggested-by: Maxime Ripard 
> > > > Signed-off-by: Douglas Anderson 
> > > > Link: 
> > > > https://lore.kernel.org/r/20230901164111.RFT.15.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@changeid
> > > > [geert: s/drm_helper_force_disable_all/drm_atomic_helper_shutdown/]
> > > > [geert: shmob_drm_remove() already calls drm_atomic_helper_shutdown]
> > > > Signed-off-by: Geert Uytterhoeven 
> > >
> > > Reviewed-by: Laurent Pinchart 
> >
> > Thanks!
> >
> > > > Panel-simple does print two new warnings:
> > > >
> > > > +panel-simple panel: Skipping disable of already disabled panel
> > > > +panel-simple panel: Skipping unprepare of already unprepared panel
> > >
> > > Have you investigated where this comes from ?
> >
> > Meh, I knew I forgot something ;-)
> >
> > The panel is unprepared and disabled a first time from shmob_drm's
> > .shutdown() callback:
> >
> >   shmob_drm_shutdown
> > drm_atomic_helper_shutdown
> >   drm_atomic_helper_disable_all
> > drm_atomic_commit
> >   drm_atomic_helper_commit
> > commit_tail
> >   drm_atomic_helper_commit_tail
> > drm_atomic_helper_commit_modeset_disables
> >   disable_outputs
> > drm_atomic_bridge_chain_disable
> > drm_panel_disable
> > drm_atomic_bridge_chain_post_disable
> > drm_panel_unprepare
> >
> > And a second time from simple_panel's .shutdown() callback():
> >
> >   panel_simple_platform_shutdown
> > panel_simple_shutdown
> >   drm_panel_disable
> >   drm_panel_unprepare
>
> That looks like what Doug mentioned should be removed in the commit
> message of this patch (a confirmation would be nice). It should be fine
> for now.

Yup, this is completely expected right now and is actually a _good_
sign that your patch is doing what it should be. We unfortunately
can't remove the panel_simple_shutdown() until all DRM modeset drivers
(or at least all the ones that could be used w/ panel_simple) are
properly calling drm_helper_force_disable_all(), though.

-Doug


Re: [PATCH] drm: renesas: shmobile: Call drm_helper_force_disable_all() at shutdown time

2023-12-05 Thread Laurent Pinchart
On Tue, Dec 05, 2023 at 02:31:24PM +0100, Geert Uytterhoeven wrote:
> On Tue, Dec 5, 2023 at 1:16 PM Laurent Pinchart wrote:
> > On Tue, Dec 05, 2023 at 12:30:02PM +0100, Geert Uytterhoeven wrote:
> > > From: Douglas Anderson 
> > >
> > > Based on grepping through the source code, this driver appears to be
> > > missing a call to drm_atomic_helper_shutdown() at system shutdown time.
> > > This is important because drm_helper_force_disable_all() will cause
> > > panels to get disabled cleanly which may be important for their power
> > > sequencing.  Future changes will remove any custom powering off in
> > > individual panel drivers so the DRM drivers need to start getting this
> > > right.
> > >
> > > The fact that we should call drm_atomic_helper_shutdown() in the case of
> > > OS shutdown comes straight out of the kernel doc "driver instance
> > > overview" in drm_drv.c.
> > >
> > > Suggested-by: Maxime Ripard 
> > > Signed-off-by: Douglas Anderson 
> > > Link: 
> > > https://lore.kernel.org/r/20230901164111.RFT.15.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@changeid
> > > [geert: s/drm_helper_force_disable_all/drm_atomic_helper_shutdown/]
> > > [geert: shmob_drm_remove() already calls drm_atomic_helper_shutdown]
> > > Signed-off-by: Geert Uytterhoeven 
> >
> > Reviewed-by: Laurent Pinchart 
> 
> Thanks!
> 
> > > Panel-simple does print two new warnings:
> > >
> > > +panel-simple panel: Skipping disable of already disabled panel
> > > +panel-simple panel: Skipping unprepare of already unprepared panel
> >
> > Have you investigated where this comes from ?
> 
> Meh, I knew I forgot something ;-)
> 
> The panel is unprepared and disabled a first time from shmob_drm's
> .shutdown() callback:
> 
>   shmob_drm_shutdown
> drm_atomic_helper_shutdown
>   drm_atomic_helper_disable_all
> drm_atomic_commit
>   drm_atomic_helper_commit
> commit_tail
>   drm_atomic_helper_commit_tail
> drm_atomic_helper_commit_modeset_disables
>   disable_outputs
> drm_atomic_bridge_chain_disable
> drm_panel_disable
> drm_atomic_bridge_chain_post_disable
> drm_panel_unprepare
> 
> And a second time from simple_panel's .shutdown() callback():
> 
>   panel_simple_platform_shutdown
> panel_simple_shutdown
>   drm_panel_disable
>   drm_panel_unprepare

That looks like what Doug mentioned should be removed in the commit
message of this patch (a confirmation would be nice). It should be fine
for now.

-- 
Regards,

Laurent Pinchart


Re: [PATCH] drm: renesas: shmobile: Call drm_helper_force_disable_all() at shutdown time

2023-12-05 Thread Geert Uytterhoeven
Hi Laurent,

On Tue, Dec 5, 2023 at 1:16 PM Laurent Pinchart
 wrote:
> On Tue, Dec 05, 2023 at 12:30:02PM +0100, Geert Uytterhoeven wrote:
> > From: Douglas Anderson 
> >
> > Based on grepping through the source code, this driver appears to be
> > missing a call to drm_atomic_helper_shutdown() at system shutdown time.
> > This is important because drm_helper_force_disable_all() will cause
> > panels to get disabled cleanly which may be important for their power
> > sequencing.  Future changes will remove any custom powering off in
> > individual panel drivers so the DRM drivers need to start getting this
> > right.
> >
> > The fact that we should call drm_atomic_helper_shutdown() in the case of
> > OS shutdown comes straight out of the kernel doc "driver instance
> > overview" in drm_drv.c.
> >
> > Suggested-by: Maxime Ripard 
> > Signed-off-by: Douglas Anderson 
> > Link: 
> > https://lore.kernel.org/r/20230901164111.RFT.15.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@changeid
> > [geert: s/drm_helper_force_disable_all/drm_atomic_helper_shutdown/]
> > [geert: shmob_drm_remove() already calls drm_atomic_helper_shutdown]
> > Signed-off-by: Geert Uytterhoeven 
>
> Reviewed-by: Laurent Pinchart 

Thanks!

> > Panel-simple does print two new warnings:
> >
> > +panel-simple panel: Skipping disable of already disabled panel
> > +panel-simple panel: Skipping unprepare of already unprepared panel
>
> Have you investigated where this comes from ?

Meh, I knew I forgot something ;-)

The panel is unprepared and disabled a first time from shmob_drm's
.shutdown() callback:

  shmob_drm_shutdown
drm_atomic_helper_shutdown
  drm_atomic_helper_disable_all
drm_atomic_commit
  drm_atomic_helper_commit
commit_tail
  drm_atomic_helper_commit_tail
drm_atomic_helper_commit_modeset_disables
  disable_outputs
drm_atomic_bridge_chain_disable
drm_panel_disable
drm_atomic_bridge_chain_post_disable
drm_panel_unprepare

And a second time from simple_panel's .shutdown() callback():

  panel_simple_platform_shutdown
panel_simple_shutdown
  drm_panel_disable
  drm_panel_unprepare

Gr{oetje,eeting}s,

Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] drm: renesas: shmobile: Call drm_helper_force_disable_all() at shutdown time

2023-12-05 Thread Laurent Pinchart
Hi Geert and Doug,

Thank you for the patch.

On Tue, Dec 05, 2023 at 12:30:02PM +0100, Geert Uytterhoeven wrote:
> From: Douglas Anderson 
> 
> Based on grepping through the source code, this driver appears to be
> missing a call to drm_atomic_helper_shutdown() at system shutdown time.
> This is important because drm_helper_force_disable_all() will cause
> panels to get disabled cleanly which may be important for their power
> sequencing.  Future changes will remove any custom powering off in
> individual panel drivers so the DRM drivers need to start getting this
> right.
> 
> The fact that we should call drm_atomic_helper_shutdown() in the case of
> OS shutdown comes straight out of the kernel doc "driver instance
> overview" in drm_drv.c.
> 
> Suggested-by: Maxime Ripard 
> Signed-off-by: Douglas Anderson 
> Link: 
> https://lore.kernel.org/r/20230901164111.RFT.15.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@changeid
> [geert: s/drm_helper_force_disable_all/drm_atomic_helper_shutdown/]
> [geert: shmob_drm_remove() already calls drm_atomic_helper_shutdown]
> Signed-off-by: Geert Uytterhoeven 

Reviewed-by: Laurent Pinchart 

> ---
> Tested on Atmark Techno Armadillo-800-EVA, where the PWM instance
> driving the backlight is now stopped on shutdown.
> Panel-simple does print two new warnings:
> 
> +panel-simple panel: Skipping disable of already disabled panel
> +panel-simple panel: Skipping unprepare of already unprepared panel

Have you investigated where this comes from ?

>  reboot: System halted
> ---
>  drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c 
> b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
> index bd16d4780c6436c3..a15162be26f259a4 100644
> --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
> @@ -171,6 +171,13 @@ static void shmob_drm_remove(struct platform_device 
> *pdev)
>   drm_kms_helper_poll_fini(ddev);
>  }
>  
> +static void shmob_drm_shutdown(struct platform_device *pdev)
> +{
> + struct shmob_drm_device *sdev = platform_get_drvdata(pdev);
> +
> + drm_atomic_helper_shutdown(>ddev);
> +}
> +
>  static int shmob_drm_probe(struct platform_device *pdev)
>  {
>   struct shmob_drm_platform_data *pdata = pdev->dev.platform_data;
> @@ -274,6 +281,7 @@ static const struct of_device_id shmob_drm_of_table[] 
> __maybe_unused = {
>  static struct platform_driver shmob_drm_platform_driver = {
>   .probe  = shmob_drm_probe,
>   .remove_new = shmob_drm_remove,
> + .shutdown   = shmob_drm_shutdown,
>   .driver = {
>   .name   = "shmob-drm",
>   .of_match_table = of_match_ptr(shmob_drm_of_table),

-- 
Regards,

Laurent Pinchart