From: Maxime Ripard <mripard@kernel.org>
To: Doug Anderson <dianders@chromium.org>
Cc: dri-devel@lists.freedesktop.org,
Neil Armstrong <neil.armstrong@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
Yuran Pereira <yuran.pereira@hotmail.com>,
Chris Morgan <macromorgan@hotmail.com>,
David Airlie <airlied@gmail.com>,
Jessica Zhang <quic_jesszhan@quicinc.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-kernel@vger.kernel.org, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH] drm/panel: Avoid warnings w/ panel-simple/panel-edp at shutdown
Date: Wed, 12 Jun 2024 17:03:34 +0200 [thread overview]
Message-ID: <20240612-lean-intrepid-sponge-bb30e6@houat> (raw)
In-Reply-To: <CAD=FV=V4C1AYVqG4gig+SiQr4n_mAPVASxneDDZT1a=7AY3Hzw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5414 bytes --]
On Wed, Jun 12, 2024 at 07:49:31AM GMT, Doug Anderson wrote:
> Hi,
>
> On Wed, Jun 12, 2024 at 1:58 AM Daniel Vetter <daniel@ffwll.ch> wrote:
> >
> > On Tue, Jun 11, 2024 at 07:48:51AM -0700, Douglas Anderson wrote:
> > > At shutdown if you've got a _properly_ coded DRM modeset driver then
> > > you'll get these two warnings at shutdown time:
> > >
> > > Skipping disable of already disabled panel
> > > Skipping unprepare of already unprepared panel
> > >
> > > These warnings are ugly and sound concerning, but they're actually a
> > > sign of a properly working system. That's not great.
> > >
> > > It's not easy to get rid of these warnings. Until we know that all DRM
> > > modeset drivers used with panel-simple and panel-edp are properly
> > > calling drm_atomic_helper_shutdown() or drm_helper_force_disable_all()
> > > then the panel drivers _need_ to disable/unprepare themselves in order
> > > to power off the panel cleanly. However, there are lots of DRM modeset
> > > drivers used with panel-edp and panel-simple and it's hard to know
> > > when we've got them all. Since the warning happens only on the drivers
> > > that _are_ updated there's nothing to encourage broken DRM modeset
> > > drivers to get fixed.
> > >
> > > In order to flip the warning to the proper place, we need to know
> > > which modeset drivers are going to shutdown properly. Though ugly, do
> > > this by creating a list of everyone that shuts down properly. This
> > > allows us to generate a warning for the correct case and also lets us
> > > get rid of the warning for drivers that are shutting down properly.
> > >
> > > Maintaining this list is ugly, but the idea is that it's only short
> > > term. Once everyone is converted we can delete the list and call it
> > > done. The list is ugly enough and adding to it is annoying enough that
> > > people should push to make this happen.
> > >
> > > Implement this all in a shared "header" file included by the two panel
> > > drivers that need it. This avoids us adding an new exports while still
> > > allowing the panel drivers to be modules. The code waste should be
> > > small and, as per above, the whole solution is temporary.
> > >
> > > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> > > ---
> > > I came up with this idea to help us move forward since otherwise I
> > > couldn't see how we were ever going to fix panel-simple and panel-edp
> > > since they're used by so many DRM Modeset drivers. It's a bit ugly but
> > > I don't hate it. What do others think?
> >
> > I think it's terrible :-)
>
> Well, we're in agreement. It is terrible. However, in my opinion it's
> still a reasonable way to move forward.
>
>
> > Why does something like this now work?
> >
> > drm_panel_shutdown_fixup(panel)
> > {
> > /* if you get warnings here, fix your main drm driver to call
> > * drm_atomic_helper_shutdown()
> > */
> > if (WARN_ON(panel->enabled))
> > drm_panel_disable(panel);
> >
> > if (WARN_ON(panel->prepared))
> > drm_panel_unprepare(panel);
> > }
> >
> > And then call that little helper in the relevant panel drivers? Also feel
> > free to bikeshed the name and maybe put a more lengthly explainer into the
> > kerneldoc for that ...
> >
> > Or am I completely missing the point here?
>
> The problem is that the ordering is wrong, I think. Even if the OS was
> calling driver shutdown functions in the perfect order (which I'm not
> convinced about since panels aren't always child "struct device"s of
> the DRM device), the OS should be calling panel shutdown _before_
> shutting down the DRM device. That means that with your suggestion:
>
> 1. Shutdown starts and panel is on.
>
> 2. OS calls panel shutdown call, which prints warnings because panel
> is still on.
>
> 3. OS calls DRM driver shutdown call, which prints warnings because
> someone else turned the panel off.
>
> :-P
>
> Certainly if I goofed and the above is wrong then let me know--I did
> my experiments on this many months ago and didn't try repeating them
> again now.
>
> In any case, the only way I could figure out around this was some sort
> of list. As mentioned in the commit message, it's super ugly and
> intended to be temporary. Once we solve all the current in-tree
> drivers, I'd imagine that long term for new DRM drivers this kind of
> thing would be discovered during bringup of new boards. Usually during
> bringup of new boards EEs measure timing signals and complain if
> they're not right. If some EE cared and said we weren't disabling the
> panel correctly at shutdown time then we'd know there was a problem.
Based on a discussion we had today With Sima on IRC, I think there's
another way forward.
We were actually discussing refcount'ing the panels to avoid lifetime
issues. It would require some API overhaul to have a function to
allocate the drm_panel structure and init'ing the refcount, plus some to
get / put the references.
Having this refcount would mean that we also get a release function now,
called when the panel is free'd.
Could we warn if the panel is still prepared/enabled and is about to be
freed?
It would require to switch panel-simple and panel-edp to that new API,
but it should be easy enough.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2024-06-12 15:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-11 14:48 [PATCH] drm/panel: Avoid warnings w/ panel-simple/panel-edp at shutdown Douglas Anderson
2024-06-12 8:09 ` Maxime Ripard
2024-06-12 14:39 ` Doug Anderson
2024-06-12 15:13 ` Daniel Vetter
2024-06-12 16:03 ` Doug Anderson
2024-06-12 16:52 ` Doug Anderson
2024-06-17 14:09 ` Daniel Vetter
2024-06-12 8:58 ` Daniel Vetter
2024-06-12 14:49 ` Doug Anderson
2024-06-12 15:03 ` Maxime Ripard [this message]
2024-06-12 16:00 ` Doug Anderson
2024-06-12 15:11 ` Daniel Vetter
2024-06-12 16:00 ` Doug Anderson
2024-06-17 14:17 ` Daniel Vetter
2024-06-18 23:49 ` Doug Anderson
2024-06-21 16:04 ` Daniel Vetter
2024-06-12 16:47 ` Linus Walleij
2024-06-12 17:22 ` Doug Anderson
2024-06-17 14:22 ` Daniel Vetter
2024-06-18 23:49 ` Doug Anderson
2024-06-21 16:14 ` Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2024-06-21 20:44 Douglas Anderson
2024-06-21 20:46 ` Doug Anderson
2024-07-15 16:40 ` Doug Anderson
2024-07-22 16:04 ` Doug Anderson
2024-07-16 10:53 ` Neil Armstrong
2024-07-16 20:19 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612-lean-intrepid-sponge-bb30e6@houat \
--to=mripard@kernel.org \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=macromorgan@hotmail.com \
--cc=neil.armstrong@linaro.org \
--cc=quic_jesszhan@quicinc.com \
--cc=tzimmermann@suse.de \
--cc=yuran.pereira@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox