All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jocelyn Falempe <jfalempe@redhat.com>
To: 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, noralf@tronnes.org
Cc: gpiccoli@igalia.com, Jocelyn Falempe <jfalempe@redhat.com>
Subject: [PATCH v8 4/8] drm/fb_dma: Add generic set_scanout_buffer() for drm_panic
Date: Tue, 27 Feb 2024 11:04:15 +0100	[thread overview]
Message-ID: <20240227100459.194478-5-jfalempe@redhat.com> (raw)
In-Reply-To: <20240227100459.194478-1-jfalempe@redhat.com>

This was initialy done for imx6, but should work on most drivers
using drm_fb_dma_helper.

v8:
 * Replace get_scanout_buffer() logic with drm_panic_set_buffer()
   (Thomas Zimmermann)

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
---
 drivers/gpu/drm/drm_fb_dma_helper.c | 37 +++++++++++++++++++++++++++++
 include/drm/drm_fb_dma_helper.h     |  4 ++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_dma_helper.c b/drivers/gpu/drm/drm_fb_dma_helper.c
index 3b535ad1b07c..31ba71644e2b 100644
--- a/drivers/gpu/drm/drm_fb_dma_helper.c
+++ b/drivers/gpu/drm/drm_fb_dma_helper.c
@@ -15,6 +15,7 @@
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_gem_dma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_panic.h>
 #include <drm/drm_plane.h>
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
@@ -148,3 +149,39 @@ void drm_fb_dma_sync_non_coherent(struct drm_device *drm,
 	}
 }
 EXPORT_SYMBOL_GPL(drm_fb_dma_sync_non_coherent);
+
+#if defined(CONFIG_DRM_PANIC)
+/**
+ * drm_panic_gem_set_scanout_buffer - helper around drm_panic_set_buffer()
+ *
+ * @plane: primary plane registered to drm_panic
+ * @fb: framebuffer attached to the plane state
+ *
+ * Update plane->panic_scanout with the new framebuffer.
+ */
+void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
+				      struct drm_framebuffer *fb)
+{
+	struct drm_gem_dma_object *dma_obj;
+	struct iosys_map map;
+
+	if (!plane->panic_scanout)
+		return;
+
+	if (fb->modifier == DRM_FORMAT_MOD_LINEAR) {
+		dma_obj = drm_fb_dma_get_gem_obj(fb, 0);
+		if (dma_obj && dma_obj->vaddr) {
+			iosys_map_set_vaddr(&map, dma_obj->vaddr);
+			drm_panic_set_buffer(plane->panic_scanout, fb, &map);
+			return;
+		}
+	}
+	drm_panic_unset_buffer(plane->panic_scanout);
+}
+#else
+void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
+				      struct drm_framebuffer *fb)
+{
+}
+#endif
+EXPORT_SYMBOL(drm_panic_gem_set_scanout_buffer);
diff --git a/include/drm/drm_fb_dma_helper.h b/include/drm/drm_fb_dma_helper.h
index d5e036c57801..9f9ec11343cd 100644
--- a/include/drm/drm_fb_dma_helper.h
+++ b/include/drm/drm_fb_dma_helper.h
@@ -7,6 +7,7 @@
 struct drm_device;
 struct drm_framebuffer;
 struct drm_plane_state;
+struct drm_scanout_buffer;
 
 struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb,
 	unsigned int plane);
@@ -19,5 +20,8 @@ void drm_fb_dma_sync_non_coherent(struct drm_device *drm,
 				  struct drm_plane_state *old_state,
 				  struct drm_plane_state *state);
 
+void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
+				     struct drm_framebuffer *fb);
+
 #endif
 
-- 
2.43.0


  parent reply	other threads:[~2024-02-27 10:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 10:04 [RFC][PATCH v8 0/8] drm/panic: Add a drm panic handler Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 1/8] drm/format-helper: Add drm_fb_blit_from_r1 and drm_fb_fill Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 2/8] drm/panic: Add a drm panic handler Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 3/8] drm/panic: Add debugfs entry to test without triggering panic Jocelyn Falempe
2024-02-29 11:21   ` Daniel Vetter
2024-02-29 13:56     ` Jocelyn Falempe
2024-02-29 19:08   ` kernel test robot
2024-02-27 10:04 ` Jocelyn Falempe [this message]
2024-02-29 15:12   ` [PATCH v8 4/8] drm/fb_dma: Add generic set_scanout_buffer() for drm_panic kernel test robot
2024-03-01  2:13   ` kernel test robot
2024-02-27 10:04 ` [PATCH v8 5/8] drm/simpledrm: Add drm_panic support Jocelyn Falempe
2024-02-29 11:17   ` Daniel Vetter
2024-02-29 14:02     ` Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 6/8] drm/mgag200: " Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 7/8] drm/imx: " Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 8/8] drm/ast: " 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=20240227100459.194478-5-jfalempe@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.