Commit 6843cd85 authored by Jani Nikula's avatar Jani Nikula
Browse files

drm/i915/display: add intel_display_snapshot abstraction



The error state capture still handles display info at a too detailed
level. Start abstracting the whole display snapshot capture and printing
at a higher level. Move overlay to display snapshot first.

Use the same nomenclature and style as in xe devcoredump, in preparation
for perhaps some day bolting the snapshots there as well.

v3: Fix build harder for CONFIG_DRM_I915_CAPTURE_ERROR=n

v2: Fix build for CONFIG_DRM_I915_CAPTURE_ERROR=n (kernel test robot)

Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ba6a36759600c2d35405c41a0fc9d69f676df77d.1726151571.git.jani.nikula@intel.com


Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 8d8c3ceb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ i915-y += \
	display/intel_display_power_well.o \
	display/intel_display_reset.o \
	display/intel_display_rps.o \
	display/intel_display_snapshot.o \
	display/intel_display_wa.o \
	display/intel_dmc.o \
	display/intel_dmc_wl.o \
+42 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: MIT
/* Copyright © 2024 Intel Corporation */

#include <linux/slab.h>

#include "intel_display_snapshot.h"
#include "intel_overlay.h"

struct intel_display_snapshot {
	struct intel_overlay_snapshot *overlay;
};

struct intel_display_snapshot *intel_display_snapshot_capture(struct intel_display *display)
{
	struct intel_display_snapshot *snapshot;

	snapshot = kzalloc(sizeof(*snapshot), GFP_ATOMIC);
	if (!snapshot)
		return NULL;

	snapshot->overlay = intel_overlay_snapshot_capture(display);

	return snapshot;
}

void intel_display_snapshot_print(const struct intel_display_snapshot *snapshot,
				  struct drm_printer *p)
{
	if (!snapshot)
		return;

	intel_overlay_snapshot_print(snapshot->overlay, p);
}

void intel_display_snapshot_free(struct intel_display_snapshot *snapshot)
{
	if (!snapshot)
		return;

	kfree(snapshot->overlay);
	kfree(snapshot);
}
+16 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: MIT */
/* Copyright © 2024 Intel Corporation */

#ifndef __INTEL_DISPLAY_SNAPSHOT_H__
#define __INTEL_DISPLAY_SNAPSHOT_H__

struct drm_printer;
struct intel_display;
struct intel_display_snapshot;

struct intel_display_snapshot *intel_display_snapshot_capture(struct intel_display *display);
void intel_display_snapshot_print(const struct intel_display_snapshot *snapshot,
				  struct drm_printer *p);
void intel_display_snapshot_free(struct intel_display_snapshot *snapshot);

#endif /* __INTEL_DISPLAY_SNAPSHOT_H__ */
+10 −6
Original line number Diff line number Diff line
@@ -1457,18 +1457,19 @@ void intel_overlay_cleanup(struct drm_i915_private *dev_priv)

#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)

struct intel_overlay_error_state {
struct intel_overlay_snapshot {
	struct overlay_registers regs;
	unsigned long base;
	u32 dovsta;
	u32 isr;
};

struct intel_overlay_error_state *
intel_overlay_capture_error_state(struct drm_i915_private *dev_priv)
struct intel_overlay_snapshot *
intel_overlay_snapshot_capture(struct intel_display *display)
{
	struct drm_i915_private *dev_priv = to_i915(display->drm);
	struct intel_overlay *overlay = dev_priv->display.overlay;
	struct intel_overlay_error_state *error;
	struct intel_overlay_snapshot *error;

	if (!overlay || !overlay->active)
		return NULL;
@@ -1487,9 +1488,12 @@ intel_overlay_capture_error_state(struct drm_i915_private *dev_priv)
}

void
intel_overlay_print_error_state(struct drm_printer *p,
				struct intel_overlay_error_state *error)
intel_overlay_snapshot_print(const struct intel_overlay_snapshot *error,
			     struct drm_printer *p)
{
	if (!error)
		return;

	drm_printf(p, "Overlay, status: 0x%08x, interrupt: 0x%08x\n",
		   error->dovsta, error->isr);
	drm_printf(p, "  Register file at 0x%08lx:\n", error->base);
+16 −9
Original line number Diff line number Diff line
@@ -6,12 +6,15 @@
#ifndef __INTEL_OVERLAY_H__
#define __INTEL_OVERLAY_H__

#include <linux/types.h>

struct drm_device;
struct drm_file;
struct drm_i915_private;
struct drm_printer;
struct intel_display;
struct intel_overlay;
struct intel_overlay_error_state;
struct intel_overlay_snapshot;

#ifdef I915
void intel_overlay_setup(struct drm_i915_private *dev_priv);
@@ -22,10 +25,6 @@ int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data,
			      struct drm_file *file_priv);
void intel_overlay_reset(struct drm_i915_private *dev_priv);
struct intel_overlay_error_state *
intel_overlay_capture_error_state(struct drm_i915_private *dev_priv);
void intel_overlay_print_error_state(struct drm_printer *p,
				     struct intel_overlay_error_state *error);
#else
static inline void intel_overlay_setup(struct drm_i915_private *dev_priv)
{
@@ -50,13 +49,21 @@ static inline int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data,
static inline void intel_overlay_reset(struct drm_i915_private *dev_priv)
{
}
static inline struct intel_overlay_error_state *
intel_overlay_capture_error_state(struct drm_i915_private *dev_priv)
#endif

#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) && defined(I915)
struct intel_overlay_snapshot *
intel_overlay_snapshot_capture(struct intel_display *display);
void intel_overlay_snapshot_print(const struct intel_overlay_snapshot *error,
				  struct drm_printer *p);
#else
static inline struct intel_overlay_snapshot *
intel_overlay_snapshot_capture(struct intel_display *display)
{
	return NULL;
}
static inline void intel_overlay_print_error_state(struct drm_printer *p,
						   struct intel_overlay_error_state *error)
static inline void intel_overlay_snapshot_print(const struct intel_overlay_snapshot *error,
						struct drm_printer *p)
{
}
#endif
Loading