From: Jocelyn Falempe <jfalempe@redhat.com>
To: "Noralf Trønnes" <noralf@tronnes.org>,
dri-devel@lists.freedesktop.org, tzimmermann@suse.de,
airlied@redhat.com, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, daniel@ffwll.ch, javierm@redhat.com,
bluescreen_avenger@verizon.net
Cc: gpiccoli@igalia.com
Subject: Re: [PATCH v4 4/4] drm/mgag200: Add drm_panic support
Date: Mon, 9 Oct 2023 12:01:33 +0200 [thread overview]
Message-ID: <21b24a8d-265e-cb31-0ecb-d702bf2528f8@redhat.com> (raw)
In-Reply-To: <b010433e-ab8f-44b4-b3db-23966f5e6526@tronnes.org>
On 07/10/2023 16:30, Noralf Trønnes wrote:
>
>
> On 10/3/23 16:22, Jocelyn Falempe wrote:
>> Add support for the drm_panic module, which displays a message to
>> the screen when a kernel panic occurs.
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
>> ---
>> drivers/gpu/drm/mgag200/mgag200_drv.c | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
>> index 976f0ab2006b..229d9c116b42 100644
>> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
>> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
>> @@ -12,10 +12,12 @@
>> #include <drm/drm_aperture.h>
>> #include <drm/drm_drv.h>
>> #include <drm/drm_fbdev_generic.h>
>> +#include <drm/drm_framebuffer.h>
>> #include <drm/drm_file.h>
>> #include <drm/drm_ioctl.h>
>> #include <drm/drm_managed.h>
>> #include <drm/drm_module.h>
>> +#include <drm/drm_panic.h>
>> #include <drm/drm_pciids.h>
>>
>> #include "mgag200_drv.h"
>> @@ -83,6 +85,27 @@ resource_size_t mgag200_probe_vram(void __iomem *mem, resource_size_t size)
>> return offset - 65536;
>> }
>>
>> +static int mgag200_get_scanout_buffer(struct drm_device *dev,
>> + struct drm_scanout_buffer *sb)
>> +{
>> + struct drm_plane *plane;
>> + struct mga_device *mdev = to_mga_device(dev);
>> + struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(mdev->vram);
>> +
>> + /* mgag200 has only one plane */
>> + drm_for_each_plane(plane, dev) {
>
> In my first 2016 attempt on a panic handler I was told to trylock crtc
> and plane and skip if it wasn't possible:
>
> - We need locking. One of the biggest problems with the old oops handling
> was that it was very good at trampling over driver state, causing more
> (unrelated) oopses in kms code and making sure the original oops was no
> longer visible. I think the shared code must take care of all the
> locking needs to avoid fragile code in drivers. ww_mutex_trylock on the
> drm_crtc and drm_plane should be enough (we need both for drivers where
> planes can be reassigned between drivers).
drm_panic register a panic handler, so it won't get called on oopses.
So when the panic handler is called, no other task can run in parallel,
and no drm code will run after it.
Also for the Matrox driver, it's always safe to write to the VRAM. The
only risk is that if you're in the middle of a modeset, you may get
garbage output.
There might still be a race condition for fb->format, width, height and
pitches, and looping through the plane list.
I also need to check if crtc and plane locks are not taken when the
driver is copying the damage region to the VRAM, otherwise the
probability to actually see the panic will be very low.
I also need to wake up the monitor, if it's currently in DPMS off.
--
Jocelyn
>
> See [1] for a list of other things to consider.
>
> Noralf.
>
> [1]
> https://lore.kernel.org/dri-devel/20160810091529.GQ6232@phenom.ffwll.local/
>
>> + if (!plane->state || !plane->state->fb)
>> + return -ENODEV;
>> + sb->format = plane->state->fb->format;
>> + sb->width = plane->state->fb->width;
>> + sb->height = plane->state->fb->height;
>> + sb->pitch = plane->state->fb->pitches[0];
>> + sb->map = map;
>> + return 0;
>> + }
>> + return -ENODEV;
>> +}
>> +
>> /*
>> * DRM driver
>> */
>> @@ -98,6 +121,7 @@ static const struct drm_driver mgag200_driver = {
>> .major = DRIVER_MAJOR,
>> .minor = DRIVER_MINOR,
>> .patchlevel = DRIVER_PATCHLEVEL,
>> + .get_scanout_buffer = mgag200_get_scanout_buffer,
>> DRM_GEM_SHMEM_DRIVER_OPS,
>> };
>>
>
next prev parent reply other threads:[~2023-10-09 10:01 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
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 [this message]
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=21b24a8d-265e-cb31-0ecb-d702bf2528f8@redhat.com \
--to=jfalempe@redhat.com \
--cc=airlied@redhat.com \
--cc=bluescreen_avenger@verizon.net \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gpiccoli@igalia.com \
--cc=javierm@redhat.com \
--cc=maarten.lankhorst@linux.intel.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