[PATCH] drm/i915/gvt: Add gvt_debug to classify GVT-g log messages
Zhenyu Wang
zhenyuw at linux.intel.com
Thu Aug 31 02:56:11 UTC 2017
On 2017.08.29 20:33:23 +0800, Shuo Liu wrote:
> Add a silimar log mechanism as like drm. Classify GVT-g log messages
> as different categories by differnt log functions.
>
> The reason for split debug code into a module is: i915 module depends
> on kvmgt/xengt module in init code. If put debug code in i915 module,
> i915 and kvmgt/xengt will has loop dependence.
>
> Signed-off-by: Shuo Liu <shuo.a.liu at intel.com>
> ---
> drivers/gpu/drm/i915/Kconfig | 9 ++++++++
> drivers/gpu/drm/i915/gvt/Makefile | 1 +
> drivers/gpu/drm/i915/gvt/debug.h | 45 +++++++++++++++++++++++++++---------
> drivers/gpu/drm/i915/gvt/gvt_debug.c | 41 ++++++++++++++++++++++++++++++++
> 4 files changed, 85 insertions(+), 11 deletions(-)
> create mode 100644 drivers/gpu/drm/i915/gvt/gvt_debug.c
>
> diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
> index a5cd5da..9883061 100644
> --- a/drivers/gpu/drm/i915/Kconfig
> +++ b/drivers/gpu/drm/i915/Kconfig
> @@ -124,6 +124,15 @@ config DRM_I915_GVT_KVMGT
> Choose this option if you want to enable KVMGT support for
> Intel GVT-g.
>
> +config DRM_I915_GVT_DEBUG
> + tristate "Enable debug support for Intel GVT-g"
> + depends on DRM_I915
> + depends on DRM_I915_GVT
just 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..2b5955a 100644
> --- a/drivers/gpu/drm/i915/gvt/Makefile
> +++ b/drivers/gpu/drm/i915/gvt/Makefile
> @@ -6,3 +6,4 @@ 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))
> obj-$(CONFIG_DRM_I915_GVT_KVMGT) += $(GVT_DIR)/kvmgt.o
> +obj-$(CONFIG_DRM_I915_GVT_DEBUG) += $(GVT_DIR)/gvt_debug.o
Let's align file naming, just use "debug.c".
> diff --git a/drivers/gpu/drm/i915/gvt/debug.h b/drivers/gpu/drm/i915/gvt/debug.h
> index b0cff4d..f33a55f 100644
> --- a/drivers/gpu/drm/i915/gvt/debug.h
> +++ b/drivers/gpu/drm/i915/gvt/debug.h
> @@ -24,42 +24,65 @@
> #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
alignment
> +#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, ...);
> +#define gvt_err(fmt, args...) \
> + gvt_printk(KERN_ERR, GVT_MSG_NONE, fmt, ##args)
> +#else
> +static inline __printf(3, 4)
> +void gvt_printk(const char *level, unsigned int category,
> + const char *format, ...) {}
> #define gvt_err(fmt, args...) \
> DRM_ERROR("gvt: "fmt, ##args)
> +#endif
gvt_err() should always print so DRM_ERROR is fine.
GVT_DEBUG should make below vgpu dbg info optional instead, e.g
phrase out all those if !GVT_DEBUG.
oh, looks if !GVT_DEBUG this would just fail to build?
>
> #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
> diff --git a/drivers/gpu/drm/i915/gvt/gvt_debug.c b/drivers/gpu/drm/i915/gvt/gvt_debug.c
> new file mode 100644
> index 0000000..8fe8b2f
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/gvt/gvt_debug.c
> @@ -0,0 +1,41 @@
> +#include <linux/module.h>
> +#include "debug.h"
> +
> +static unsigned int gvt_debug;
> +
> +module_param_named(debug, gvt_debug, int, 0600);
> +MODULE_PARM_DESC(debug, "Enable Gvt-g debug output, where each bit enables a category.\n"
> + "\t\tBit 0 (0x01) will enable CORE messages (GVT-g core message)\n"
> + "\t\tBit 1 (0x02) will enable IRQ messages (GVT-g interrupt message)\n"
> + "\t\tBit 2 (0x04) will enable MM messages (GVT-g memory management message)\n"
> + "\t\tBit 3 (0x08) will enable MMIO messages (GVT-g MMIO message)\n"
> + "\t\tBit 4 (0x10) will enable DPY messages (GVT-g display message)\n"
> + "\t\tBit 5 (0x20) will enable EL messages (GVT-g execlist message)\n"
> + "\t\tBit 6 (0x40) will enable SCHED messages (GVT-g schedule message)\n"
> + "\t\tBit 7 (0x80) will enable RENDER messages (GVT-g render message)\n"
> + "\t\tBit 8 (0x100) will enable CMD messages (GVT-g command message)");
> +
> +void gvt_printk(const char *level, unsigned int category,
> + const char *format, ...)
> +{
> + struct va_format vaf;
> + va_list args;
> +
> + if (category != GVT_MSG_NONE && !(gvt_debug & 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);
> +}
> +EXPORT_SYMBOL_GPL(gvt_printk);
Not required for other module, this is only for gvt internal usage.
> +
> +MODULE_AUTHOR("Intel Corporation");
> +MODULE_DESCRIPTION("GVT-g debug driver");
> +MODULE_LICENSE("GPL");
required?
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170831/97652e06/attachment-0001.sig>
More information about the intel-gvt-dev
mailing list