Linux virtualization list
 help / color / mirror / Atom feed
From: Jocelyn Falempe <jfalempe@redhat.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
	javierm@redhat.com, airlied@gmail.com, simona@ffwll.ch,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	geert@linux-m68k.org, rdunlap@infradead.org
Cc: dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	linux-hyperv@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	nouveau@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org,
	virtualization@lists.linux.dev, sashiko-reviews@lists.linux.dev
Subject: Re: [PATCH v3 12/14] drm/panic: Internalize panic locking in DRM core and helpers
Date: Mon, 7 Sep 2026 23:27:06 +0200	[thread overview]
Message-ID: <dfe32fca-d02c-4d8b-b112-d430c19be509@redhat.com> (raw)
In-Reply-To: <20260902121930.597222-13-tzimmermann@suse.de>

On 9/2/26 14:13, Thomas Zimmermann wrote:
> None of the DRM drivers handles panic locking. Declare the interfaces
> in an internal header file. Move the trylock required during the panic
> into the DRM core's sources.

Thanks, it looks good to me.

Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>

> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>   Documentation/gpu/drm-kms.rst        |  3 ++
>   MAINTAINERS                          |  3 +-
>   drivers/gpu/drm/drm_atomic_helper.c  |  2 +-
>   drivers/gpu/drm/drm_drv.c            |  2 +-
>   drivers/gpu/drm/drm_panic.c          |  4 ++
>   drivers/gpu/drm/drm_panic_internal.h | 55 +++++++++++++++++++++++
>   include/drm/drm_panic.h              | 65 ----------------------------
>   7 files changed, 66 insertions(+), 68 deletions(-)
>   create mode 100644 drivers/gpu/drm/drm_panic_internal.h
> 
> diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
> index 0dd440a14946..8988fd64369b 100644
> --- a/Documentation/gpu/drm-kms.rst
> +++ b/Documentation/gpu/drm-kms.rst
> @@ -421,6 +421,9 @@ Plane Panic Functions Reference
>   .. kernel-doc:: include/drm/drm_panic.h
>      :internal:
>   
> +.. kernel-doc:: drivers/gpu/drm/drm_panic_internal.h
> +   :internal:
> +
>   .. kernel-doc:: drivers/gpu/drm/drm_panic.c
>      :export:
>   
> diff --git a/MAINTAINERS b/MAINTAINERS
> index c66c3fe93f3d..ccc5dc0a01ae 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9111,7 +9111,8 @@ S:	Supported
>   T:	git https://gitlab.freedesktop.org/drm/misc/kernel.git
>   F:	drivers/gpu/drm/drm_draw.c
>   F:	drivers/gpu/drm/drm_draw_internal.h
> -F:	drivers/gpu/drm/drm_panic*.c
> +F:	drivers/gpu/drm/drm_panic.c
> +F:	drivers/gpu/drm/drm_panic_internal.h
>   F:	drivers/gpu/drm/tests/drm_panic_test.c
>   F:	include/drm/drm_panic.h
>   F:	include/drm/drm_panic_helper.h
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 285aac3554df..af3934df3313 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -41,7 +41,6 @@
>   #include <drm/drm_drv.h>
>   #include <drm/drm_framebuffer.h>
>   #include <drm/drm_gem_atomic_helper.h>
> -#include <drm/drm_panic.h>
>   #include <drm/drm_print.h>
>   #include <drm/drm_self_refresh_helper.h>
>   #include <drm/drm_vblank.h>
> @@ -49,6 +48,7 @@
>   
>   #include "drm_crtc_helper_internal.h"
>   #include "drm_crtc_internal.h"
> +#include "drm_panic_internal.h"
>   
>   /**
>    * DOC: overview
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 8c0879c336e5..64055514acbf 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -51,13 +51,13 @@
>   #include <drm/drm_file.h>
>   #include <drm/drm_managed.h>
>   #include <drm/drm_mode_object.h>
> -#include <drm/drm_panic.h>
>   #include <drm/drm_print.h>
>   #include <drm/drm_privacy_screen_machine.h>
>   #include <drm/drm_ras_genl_family.h>
>   
>   #include "drm_crtc_internal.h"
>   #include "drm_internal.h"
> +#include "drm_panic_internal.h"
>   
>   MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
>   MODULE_DESCRIPTION("DRM shared core routines");
> diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
> index 7b9864857577..41ba0c4b050e 100644
> --- a/drivers/gpu/drm/drm_panic.c
> +++ b/drivers/gpu/drm/drm_panic.c
> @@ -35,6 +35,7 @@
>   
>   #include "drm_crtc_internal.h"
>   #include "drm_draw_internal.h"
> +#include "drm_panic_internal.h"
>   
>   MODULE_AUTHOR("Jocelyn Falempe");
>   MODULE_DESCRIPTION("DRM panic handler");
> @@ -976,6 +977,9 @@ int drm_plane_helper_display_panic_screen(struct drm_plane *plane, const char *d
>   }
>   EXPORT_SYMBOL(drm_plane_helper_display_panic_screen);
>   
> +#define drm_panic_trylock(dev, flags) \
> +	raw_spin_trylock_irqsave(&(dev)->mode_config.panic_lock, flags)
> +
>   static void drm_panic_display_panic_screen(struct drm_plane *plane, const char *description)
>   {
>   #if defined(CONFIG_DRM_PANIC_FOREGROUND_COLOR)
> diff --git a/drivers/gpu/drm/drm_panic_internal.h b/drivers/gpu/drm/drm_panic_internal.h
> new file mode 100644
> index 000000000000..c68d64c56e15
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_panic_internal.h
> @@ -0,0 +1,55 @@
> +/* SPDX-License-Identifier: GPL-2.0 or MIT */
> +
> +/*
> + * Copyright (c) 2024 Intel
> + * Copyright (c) 2024 Red Hat
> + */
> +
> +#ifndef __DRM_PANIC_INTERNAL_H__
> +#define __DRM_PANIC_INTERNAL_H__
> +
> +#include <linux/spinlock.h>
> +
> +struct drm_device;
> +
> +#ifdef CONFIG_DRM_PANIC
> +
> +/**
> + * drm_panic_lock - protect panic printing relevant state
> + * @dev: struct drm_device
> + * @flags: unsigned long irq flags you need to pass to the unlock() counterpart
> + *
> + * This function must be called to protect software and hardware state that the
> + * panic printing code must be able to rely on. The protected sections must be
> + * as small as possible. It uses the irqsave/irqrestore variant, and can be
> + * called from irq handler. Examples include:
> + *
> + * - Access to peek/poke or other similar registers, if that is the way the
> + *   driver prints the pixels into the scanout buffer at panic time.
> + *
> + * - Updates to pointers like &drm_plane.state, allowing the panic handler to
> + *   safely deference these. This is done in drm_atomic_helper_swap_state().
> + *
> + * - An state that isn't invariant and that the driver must be able to access
> + *   during panic printing.
> + */
> +#define drm_panic_lock(dev, flags) \
> +	raw_spin_lock_irqsave(&(dev)->mode_config.panic_lock, flags)
> +
> +/**
> + * drm_panic_unlock - end of the panic printing critical section
> + * @dev: struct drm_device
> + * @flags: irq flags that were returned when acquiring the lock
> + *
> + * Unlocks the raw spinlock acquired by either drm_panic_lock() or
> + * drm_panic_trylock().
> + */
> +#define drm_panic_unlock(dev, flags) \
> +	raw_spin_unlock_irqrestore(&(dev)->mode_config.panic_lock, flags)
> +
> +#else
> +static inline void drm_panic_lock(struct drm_device *dev, unsigned long flags) {}
> +static inline void drm_panic_unlock(struct drm_device *dev, unsigned long flags) {}
> +#endif
> +
> +#endif /* __DRM_PANIC_INTERNAL_H__ */
> diff --git a/include/drm/drm_panic.h b/include/drm/drm_panic.h
> index 430df536de14..99572b7eeab9 100644
> --- a/include/drm/drm_panic.h
> +++ b/include/drm/drm_panic.h
> @@ -8,11 +8,9 @@
>   #ifndef __DRM_PANIC_H__
>   #define __DRM_PANIC_H__
>   
> -#include <linux/module.h>
>   #include <linux/types.h>
>   #include <linux/iosys-map.h>
>   
> -#include <drm/drm_device.h>
>   #include <drm/drm_fourcc.h>
>   
>   struct page;
> @@ -85,71 +83,8 @@ struct drm_scanout_buffer {
>   	 * set_pixel()
>   	 */
>   	void *private;
> -
>   };
>   
> -#ifdef CONFIG_DRM_PANIC
> -
> -/**
> - * drm_panic_trylock - try to enter the panic printing critical section
> - * @dev: struct drm_device
> - * @flags: unsigned long irq flags you need to pass to the unlock() counterpart
> - *
> - * The panic-printing code calls this function. The panic printing attempt must
> - * be aborted if the trylock fails.
> - *
> - * Return:
> - * %0 when failing to acquire the raw spinlock, nonzero on success.
> - */
> -#define drm_panic_trylock(dev, flags) \
> -	raw_spin_trylock_irqsave(&(dev)->mode_config.panic_lock, flags)
> -
> -/**
> - * drm_panic_lock - protect panic printing relevant state
> - * @dev: struct drm_device
> - * @flags: unsigned long irq flags you need to pass to the unlock() counterpart
> - *
> - * This function must be called to protect software and hardware state that the
> - * panic printing code must be able to rely on. The protected sections must be
> - * as small as possible. It uses the irqsave/irqrestore variant, and can be
> - * called from irq handler. Examples include:
> - *
> - * - Access to peek/poke or other similar registers, if that is the way the
> - *   driver prints the pixels into the scanout buffer at panic time.
> - *
> - * - Updates to pointers like &drm_plane.state, allowing the panic handler to
> - *   safely deference these. This is done in drm_atomic_helper_swap_state().
> - *
> - * - An state that isn't invariant and that the driver must be able to access
> - *   during panic printing.
> - */
> -
> -#define drm_panic_lock(dev, flags) \
> -	raw_spin_lock_irqsave(&(dev)->mode_config.panic_lock, flags)
> -
> -/**
> - * drm_panic_unlock - end of the panic printing critical section
> - * @dev: struct drm_device
> - * @flags: irq flags that were returned when acquiring the lock
> - *
> - * Unlocks the raw spinlock acquired by either drm_panic_lock() or
> - * drm_panic_trylock().
> - */
> -#define drm_panic_unlock(dev, flags) \
> -	raw_spin_unlock_irqrestore(&(dev)->mode_config.panic_lock, flags)
> -
> -#else
> -
> -static inline bool drm_panic_trylock(struct drm_device *dev, unsigned long flags)
> -{
> -	return true;
> -}
> -
> -static inline void drm_panic_lock(struct drm_device *dev, unsigned long flags) {}
> -static inline void drm_panic_unlock(struct drm_device *dev, unsigned long flags) {}
> -
> -#endif
> -
>   #if defined(CONFIG_DRM_PANIC_SCREEN_QR_CODE)
>   size_t drm_panic_qr_max_data_size(u8 version, size_t url_len);
>   


  reply	other threads:[~2026-09-07 21:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 12:13 [PATCH v3 00/14] drm/panic: Split into core and helpers Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 01/14] drm/panic: Do not use un-escaped URL as format string Thomas Zimmermann
2026-09-07 21:00   ` Jocelyn Falempe
2026-09-02 12:13 ` [PATCH v3 02/14] drm/panic: Test address from kmap op for NULL Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 03/14] drm/panic: Return -EINVAL if font is not available Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 04/14] drm/panic: Return errno codes if panic output fails Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 05/14] drm/panic: Pass colors to draw_panic_dispatch() Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 06/14] drm/panic: Pass global module parameters to drm_panic_dispatch() Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 07/14] drm/panic: Return from screen_user if display is too small Thomas Zimmermann
2026-09-07 21:09   ` Jocelyn Falempe
2026-09-02 12:13 ` [PATCH v3 08/14] drm/panic: Retry in dispatch function if panic output fails Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 09/14] drm/panic: Split draw_panic_plane() Thomas Zimmermann
2026-09-07 21:11   ` Jocelyn Falempe
2026-09-02 12:13 ` [PATCH v3 10/14] drm/panic: Restrict to primary planes Thomas Zimmermann
2026-09-02 12:13 ` [PATCH v3 11/14] drm/panic: Display panic screen via per-plane callback Thomas Zimmermann
2026-09-07 21:24   ` Jocelyn Falempe
2026-09-02 12:13 ` [PATCH v3 12/14] drm/panic: Internalize panic locking in DRM core and helpers Thomas Zimmermann
2026-09-07 21:27   ` Jocelyn Falempe [this message]
2026-09-02 12:13 ` [PATCH v3 13/14] drm/panic: Move panic display code into helper library Thomas Zimmermann
2026-09-07 21:29   ` Jocelyn Falempe
2026-09-02 12:13 ` [PATCH v3 14/14] drm/panic: Compile KUnit tests as module Thomas Zimmermann
2026-09-07 21:35   ` Jocelyn Falempe

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=dfe32fca-d02c-4d8b-b112-d430c19be509@redhat.com \
    --to=jfalempe@redhat.com \
    --cc=airlied@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert@linux-m68k.org \
    --cc=imx@lists.linux.dev \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rdunlap@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux.dev \
    /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