diff mbox series

[v8,4/8] drm/fb_dma: Add generic set_scanout_buffer() for drm_panic

Message ID 20240227100459.194478-5-jfalempe@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/panic: Add a drm panic handler | expand

Commit Message

Jocelyn Falempe Feb. 27, 2024, 10:04 a.m. UTC
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(+)

Comments

kernel test robot Feb. 29, 2024, 3:12 p.m. UTC | #1
Hi Jocelyn,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bfa4437fd3938ae2e186e7664b2db65bb8775670]

url:    https://github.com/intel-lab-lkp/linux/commits/Jocelyn-Falempe/drm-format-helper-Add-drm_fb_blit_from_r1-and-drm_fb_fill/20240227-185901
base:   bfa4437fd3938ae2e186e7664b2db65bb8775670
patch link:    https://lore.kernel.org/r/20240227100459.194478-5-jfalempe%40redhat.com
patch subject: [PATCH v8 4/8] drm/fb_dma: Add generic set_scanout_buffer() for drm_panic
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240229/202402292348.4l5K5ZmN-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240229/202402292348.4l5K5ZmN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402292348.4l5K5ZmN-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/pl111/pl111_display.c:18:
>> include/drm/drm_fb_dma_helper.h:23:46: warning: declaration of 'struct drm_plane' will not be visible outside of this function [-Wvisibility]
   void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
                                                ^
   1 warning generated.


vim +23 include/drm/drm_fb_dma_helper.h

    11	
    12	struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb,
    13		unsigned int plane);
    14	
    15	dma_addr_t drm_fb_dma_get_gem_addr(struct drm_framebuffer *fb,
    16					   struct drm_plane_state *state,
    17					   unsigned int plane);
    18	
    19	void drm_fb_dma_sync_non_coherent(struct drm_device *drm,
    20					  struct drm_plane_state *old_state,
    21					  struct drm_plane_state *state);
    22	
  > 23	void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
    24					     struct drm_framebuffer *fb);
    25
kernel test robot March 1, 2024, 2:13 a.m. UTC | #2
Hi Jocelyn,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bfa4437fd3938ae2e186e7664b2db65bb8775670]

url:    https://github.com/intel-lab-lkp/linux/commits/Jocelyn-Falempe/drm-format-helper-Add-drm_fb_blit_from_r1-and-drm_fb_fill/20240227-185901
base:   bfa4437fd3938ae2e186e7664b2db65bb8775670
patch link:    https://lore.kernel.org/r/20240227100459.194478-5-jfalempe%40redhat.com
patch subject: [PATCH v8 4/8] drm/fb_dma: Add generic set_scanout_buffer() for drm_panic
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240301/202403010934.Yop7HCSQ-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240301/202403010934.Yop7HCSQ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403010934.Yop7HCSQ-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/pl111/pl111_display.c:18:
>> include/drm/drm_fb_dma_helper.h:23:46: warning: 'struct drm_plane' declared inside parameter list will not be visible outside of this definition or declaration
      23 | void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
         |                                              ^~~~~~~~~


vim +23 include/drm/drm_fb_dma_helper.h

    11	
    12	struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb,
    13		unsigned int plane);
    14	
    15	dma_addr_t drm_fb_dma_get_gem_addr(struct drm_framebuffer *fb,
    16					   struct drm_plane_state *state,
    17					   unsigned int plane);
    18	
    19	void drm_fb_dma_sync_non_coherent(struct drm_device *drm,
    20					  struct drm_plane_state *old_state,
    21					  struct drm_plane_state *state);
    22	
  > 23	void drm_panic_gem_set_scanout_buffer(struct drm_plane *plane,
    24					     struct drm_framebuffer *fb);
    25
diff mbox series

Patch

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