[PATCH v4 3/3] drm/i915/gvt: Use debug_gvt to classify GVT-g log messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a silimar log mechanism as like drm. Classify GVT-g log messages
as different categories by differnt log functions.

Signed-off-by: Shuo Liu <shuo.a.liu@xxxxxxxxx>
---
 drivers/gpu/drm/i915/Kconfig      |  8 +++++++
 drivers/gpu/drm/i915/gvt/Makefile |  1 +
 drivers/gpu/drm/i915/gvt/debug.c  | 24 +++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/debug.h  | 44 +++++++++++++++++++++++++++++----------
 4 files changed, 66 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/debug.c

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index e9e64e8..bb6ee6e 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -125,6 +125,14 @@ config DRM_I915_GVT_KVMGT
 	  Choose this option if you want to enable KVMGT support for
 	  Intel GVT-g.
 
+config DRM_I915_GVT_DEBUG
+	bool "Enable debug support for Intel GVT-g"
+	depends on DRM_I915_GVT
+	default n
+	help
+	  Choose this option if you want to enable debug support for
+	  Intel GVT-g.
+
 menu "drm/i915 Debugging"
 depends on DRM_I915
 depends on EXPERT
diff --git a/drivers/gpu/drm/i915/gvt/Makefile b/drivers/gpu/drm/i915/gvt/Makefile
index f5486cb9..b1826c2 100644
--- a/drivers/gpu/drm/i915/gvt/Makefile
+++ b/drivers/gpu/drm/i915/gvt/Makefile
@@ -5,4 +5,5 @@ GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \
 
 ccflags-y				+= -I$(src) -I$(src)/$(GVT_DIR)
 i915-y					+= $(addprefix $(GVT_DIR)/, $(GVT_SOURCE))
+i915-$(CONFIG_DRM_I915_GVT_DEBUG)	+= $(GVT_DIR)/debug.o
 obj-$(CONFIG_DRM_I915_GVT_KVMGT)	+= $(GVT_DIR)/kvmgt.o
diff --git a/drivers/gpu/drm/i915/gvt/debug.c b/drivers/gpu/drm/i915/gvt/debug.c
new file mode 100644
index 0000000..75b4d0c
--- /dev/null
+++ b/drivers/gpu/drm/i915/gvt/debug.c
@@ -0,0 +1,24 @@
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include "i915_drv.h"
+#include "debug.h"
+
+void gvt_printk(const char *level, unsigned int category,
+		const char *format, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	if (category != GVT_MSG_NONE && !(i915.debug_gvt & category))
+		return;
+
+	va_start(args, format);
+	vaf.fmt = format;
+	vaf.va = &args;
+
+	printk("%s[gvt:%ps]%s %pV",
+		level, __builtin_return_address(0),
+		strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+
+	va_end(args);
+}
diff --git a/drivers/gpu/drm/i915/gvt/debug.h b/drivers/gpu/drm/i915/gvt/debug.h
index b0cff4d..7a54f82 100644
--- a/drivers/gpu/drm/i915/gvt/debug.h
+++ b/drivers/gpu/drm/i915/gvt/debug.h
@@ -24,42 +24,64 @@
 #ifndef __GVT_DEBUG_H__
 #define __GVT_DEBUG_H__
 
+#define GVT_MSG_NONE		0x00
+#define GVT_MSG_CORE		0x01
+#define GVT_MSG_IRQ		0x02
+#define GVT_MSG_MM		0x04
+#define GVT_MSG_MMIO		0x08
+#define GVT_MSG_DPY		0x10
+#define GVT_MSG_EL		0x20
+#define GVT_MSG_SCHED		0x40
+#define GVT_MSG_RENDER		0x80
+#define GVT_MSG_CMD		0x100
+
+#if IS_ENABLED(CONFIG_DRM_I915_GVT_DEBUG)
+__printf(3, 4)
+void gvt_printk(const char *level, unsigned int category,
+		const char *format, ...);
+#else
+static inline __printf(3, 4)
+void gvt_printk(const char *level, unsigned int category,
+		const char *format, ...) {}
+#endif
+
 #define gvt_err(fmt, args...) \
 	DRM_ERROR("gvt: "fmt, ##args)
 
 #define gvt_vgpu_err(fmt, args...)					\
 do {									\
 	if (IS_ERR_OR_NULL(vgpu))					\
-		DRM_DEBUG_DRIVER("gvt: "fmt, ##args);			\
+		gvt_printk(KERN_WARNING, GVT_MSG_CORE, fmt, ##args);	\
 	else								\
-		DRM_DEBUG_DRIVER("gvt: vgpu %d: "fmt, vgpu->id, ##args);\
+		gvt_printk(KERN_WARNING, GVT_MSG_CORE,			\
+				"vgpu %d: "fmt, vgpu->id, ##args);	\
 } while (0)
 
 #define gvt_dbg_core(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: core: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_CORE, "core: "fmt, ##args)
 
 #define gvt_dbg_irq(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: irq: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_IRQ, "irq: "fmt, ##args)
 
 #define gvt_dbg_mm(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: mm: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_MM, "mm: "fmt, ##args)
 
 #define gvt_dbg_mmio(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: mmio: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_MMIO, "mmio: "fmt, ##args)
 
 #define gvt_dbg_dpy(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: dpy: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_DPY, "dpy: "fmt, ##args)
 
 #define gvt_dbg_el(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: el: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_EL, "el: "fmt, ##args)
 
 #define gvt_dbg_sched(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: sched: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_SCHED, "sched: "fmt, ##args)
 
 #define gvt_dbg_render(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: render: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_RENDER, "render: "fmt, ##args)
 
 #define gvt_dbg_cmd(fmt, args...) \
-	DRM_DEBUG_DRIVER("gvt: cmd: "fmt, ##args)
+	gvt_printk(KERN_DEBUG, GVT_MSG_CMD, "cmd: "fmt, ##args)
 
 #endif
-- 
1.9.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux