dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Maxime Ripard <mripard@kernel.org>
Cc: "Jocelyn Falempe" <jfalempe@redhat.com>,
	bluescreen_avenger@verizon.net,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	javierm@redhat.com, dri-devel@lists.freedesktop.org,
	gpiccoli@igalia.com, "Noralf Trønnes" <noralf@tronnes.org>,
	airlied@redhat.com
Subject: Re: [PATCH v4 2/4] drm/panic: Add a drm panic handler
Date: Tue, 10 Oct 2023 14:59:33 +0200	[thread overview]
Message-ID: <ZSVKtbkm6Sq_kkk7@phenom.ffwll.local> (raw)
In-Reply-To: <5l4wotvmflkl42ms2wbw6mcz7bevk246abouj33fjn5wzfh72i@3vhxratfu3xi>

On Tue, Oct 10, 2023 at 02:15:47PM +0200, Maxime Ripard wrote:
> On Tue, Oct 10, 2023 at 01:29:52PM +0200, Noralf Trønnes wrote:
> > 
> > 
> > On 10/10/23 11:25, Maxime Ripard wrote:
> > > 
> > > 
> > > On Tue, Oct 10, 2023 at 10:55:09AM +0200, Thomas Zimmermann wrote:
> > >>>> So if I understand correctly, drm_panic would pre-allocate a plane/commit,
> > >>>> and use that when a panic occurs ?
> > >>>
> > >>> And have it checked already, yes. We would only wait for a panic to
> > >>> happen to pull the trigger on the commit.
> > >>>
> > >>>> I have two concern about this approach:
> > >>>> - How much memory would be allocated for this ? a whole framebuffer can be
> > >>>> big for just this use case.
> > >>
> > >> As I outlined in my email at [1], there are a number of different scenarios.
> > >> The question of atomic state and commits is entirely separate from the DRM
> > >> panic handler. We should not throw them together. Whatever is necessary is
> > >> get a scanout buffer, should happen on the driver side of
> > >> get_scanout_buffer, not on the drm_panic side.
> > >>
> > >> [1] https://lore.kernel.org/dri-devel/39bd4c35-8a61-42ee-8675-ccea4f5d4ac6@suse.de/T/#m22f116e9438e00a5f0a9dc43987d4153424f8be1
> > >>
> > >>>
> > >>> I'dd expect a whole framebuffer for the current
> > >>> configuration/resolution. It would be typically 4MB for a full-HD system
> > >>> which isn't a lot really and I guess we can always add an option to
> > >>> disable the mechanism if needed.
> > >>>
> > >>>> - I find it risky to completely reconfigure the hardware in a panic handler.
> > >>>
> > >>> I would expect to only change the format and base address of the
> > >>> framebuffer. I guess it can fail, but it doesn't seem that different to
> > >>> the async plane update we already have and works well.
> > >>
> > >> The one thing I don't understand is: Why should we use atomic commits in the
> > >> first place? It doesn't make sense for firmware-based drivers.
> > > 
> > > Because this is generic infrastructure that is valuable for any drivers
> > > and not only firmware-based drivers?
> > > 
> > >> In some drivers, even the simple ast, we hold locks during the regular
> > >> commit. Trying to run the panic commit concurrently will likely give a
> > >> deadlock.
> > > 
> > > You're in the middle of a panic. Don't take any locks and you won't deadlock.
> > > 
> > >> In the end it's a per-driver decision, but in most cases, the driver can
> > >> easily switch to a default mode with some ad-hoc code.
> > > 
> > > When was the last time a per-driver decision has been a good thing? I'm
> > > sorry, but the get_scanout_buffer approach buffer won't work for any
> > > driver out there.
> > > 
> > > I'm fine with discussing alternatives if you don't like the ones I
> > > suggested, but they must allow the panic handler infrastructure to work
> > > with any driver we have, not just 4.
> > > 
> > 
> > Why can't we use the model[1] suggested by Daniel using a draw_pixel
> > callback giving drivers full control on how they can put a pixel on the
> > display?
> 
> I share kind of the same general ideas/conclusions: "qthe idea is that
> all the fb selection and lookup is handled in shared code (and with
> proper locking, but only for atomic drivers)."
> 
> 2016 is a bit old though and multiple developments happened since
> (secure playback is a thing now, framebuffer compression too), so I
> still think that their expectation that the framebuffer is accessible to
> / writable by the CPU no longer holds true.

I think largely it should still be ok, because the idea behind the draw_xy
callback was that the driver could take care of anything special, like
- tiling
- clearing compression bits so that just writing the raw pixels works (if
  your compression format allows for that)
- handling any differences in how the pixels need to be written, like
  cache flushing, mmio_write vs normal memory, amd also has peek/poke
  registers to be able to write even into unmappable memory

What would probably be a good idea is to do an s/void */uinptr_t/ over my
interface proposal, or maybe an even more opaque cookie since really the
only thing you can do is get the void * that ->panic_vmap returns and pass
it into ->panic_draw_xy.

I thought (but I didn't dig through details) that the panic fb struct is
essentially meant to serve this purpose in the current series?

> > This will even work for the AMD debug interface.
> > In the linear CPU accessible buffer case, we can provide a helper for
> > that, maybe we can do helpers for other common cases as well.
> 
> Yeah, their idea of a panic_draw would work great for that.
> 
> > Adding to that we would need a panic_setup/enter and panic_teardown/exit
> > callback.
> 
> What for?

So panic teardown would be for testing in CI, to make it non-destructive
and clean up anything panic_vmap (or _enter or whatever you call it) has
done. I thought John Oggness was also looking into how the new panic
handlers/consoles could be made testable in the panic paths, including
lock stealing and getting called from nmi.
-Sima
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2023-10-10 12:59 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 14:22 [RFC][PATCH v4 0/4] drm/panic: Add a drm panic handler Jocelyn Falempe
2023-10-03 14:22 ` [PATCH v4 1/4] drm/format-helper: Export line conversion helper for drm_panic Jocelyn Falempe
2023-10-03 15:56   ` kernel test robot
2023-10-04  1:45   ` nerdopolis
2023-10-05  7:37     ` Jocelyn Falempe
2023-10-16 10:47   ` Thomas Zimmermann
2023-10-16 10:50     ` Thomas Zimmermann
2023-10-16 16:22     ` Jocelyn Falempe
2023-10-03 14:22 ` [PATCH v4 2/4] drm/panic: Add a drm panic handler Jocelyn Falempe
2023-10-05  3:39   ` kernel test robot
2023-10-05  8:18   ` Maxime Ripard
2023-10-05  9:16     ` Jocelyn Falempe
2023-10-06 14:35       ` Maxime Ripard
2023-10-06 16:54         ` Noralf Trønnes
2023-10-09  7:47           ` Jocelyn Falempe
2023-10-09  8:28             ` Maxime Ripard
2023-10-09  9:48               ` Jocelyn Falempe
2023-10-09 11:33                 ` Maxime Ripard
2023-10-09 14:05                   ` Jocelyn Falempe
2023-10-09 16:07                     ` Maxime Ripard
2023-10-10  7:55                       ` Jocelyn Falempe
2023-10-10  8:30                         ` Maxime Ripard
2023-10-10  9:04                       ` Thomas Zimmermann
2023-10-10  9:33                         ` Maxime Ripard
2023-10-10 13:05                           ` Thomas Zimmermann
2023-10-10 13:32                             ` Jocelyn Falempe
2023-10-10  8:55                   ` Thomas Zimmermann
2023-10-10  9:25                     ` Maxime Ripard
2023-10-10 11:29                       ` Noralf Trønnes
2023-10-10 12:15                         ` Maxime Ripard
2023-10-10 12:59                           ` Daniel Vetter [this message]
2023-10-10 13:24                             ` Thomas Zimmermann
2023-10-10 13:24                             ` Jocelyn Falempe
2023-10-07 12:38   ` Noralf Trønnes
2023-10-09  8:01     ` Jocelyn Falempe
2023-10-03 14:22 ` [PATCH v4 3/4] drm/simpledrm: Add drm_panic support Jocelyn Falempe
2023-10-03 14:22 ` [PATCH v4 4/4] drm/mgag200: " Jocelyn Falempe
2023-10-07 14:30   ` Noralf Trønnes
2023-10-09 10:01     ` Jocelyn Falempe
2023-10-10  9:23   ` Thomas Zimmermann

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=ZSVKtbkm6Sq_kkk7@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@redhat.com \
    --cc=bluescreen_avenger@verizon.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gpiccoli@igalia.com \
    --cc=javierm@redhat.com \
    --cc=jfalempe@redhat.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=tzimmermann@suse.de \
    /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