Skip to contentSkip to conversation

drm/i915/gvt: Change log function of kvmgt to common ones

PATCH In review Shuo Liu 3 participants 6 messages Sep 14, 2017 – Sep 19, 2017

Subsystems (3)
lore
Share & tools
lore

Shuo Liu

author
#0 lore raw

PATCH v3 1/2 drm/i915/gvt: Change log function of kvmgt to common ones

This can remove the dependence of i915 module if we change gvt_dbg_* to function in i915 module.

---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 55 ++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/gvt/kvmgt.c +36 -19
index fd0c85f..c9325e8 100644
@@ -89,6 +89,20 @@ static inline bool handle_valid(unsigned long handle)
 static void intel_vgpu_release_work(struct work_struct *work);
 static bool kvmgt_guest_exit(struct kvmgt_guest_info *info);
 
+static void gvt_kvmgt_dbg(const char *format, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, format);
+	vaf.fmt = format;
+	vaf.va = &args;
+
+	pr_debug("[gvt-mpt:%ps] %pV", __builtin_return_address(0), &vaf);
+
+	va_end(args);
+}
+
 static int gvt_dma_map_iova(struct intel_vgpu *vgpu, kvm_pfn_t pfn,
 		unsigned long *iova)
 {
@@ -443,7 +457,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
 
 	type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj));
 	if (!type) {
-		gvt_vgpu_err("failed to find type %s to create\n",
+		pr_err("failed to find type %s to create\n",
 						kobject_name(kobj));
 		ret = -EINVAL;
 		goto out;
@@ -452,7 +466,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
 	vgpu = intel_gvt_ops->vgpu_create(gvt, type);
 	if (IS_ERR_OR_NULL(vgpu)) {
 		ret = vgpu == NULL ? -EFAULT : PTR_ERR(vgpu);
-		gvt_vgpu_err("failed to create intel vgpu: %d\n", ret);
+		pr_err("failed to create intel vgpu: %d\n", ret);
 		goto out;
 	}
 
@@ -461,8 +475,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
 	vgpu->vdev.mdev = mdev;
 	mdev_set_drvdata(mdev, vgpu);
 
-	gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n",
-		     dev_name(mdev_dev(mdev)));
+	gvt_kvmgt_dbg("succeeded for mdev: %s\n", dev_name(mdev_dev(mdev)));
 	ret = 0;
 
 out:
@@ -532,8 +545,8 @@ static int intel_vgpu_open(struct mdev_device *mdev)
 	ret = vfio_register_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY, &events,
 				&vgpu->vdev.iommu_notifier);
 	if (ret != 0) {
-		gvt_vgpu_err("vfio_register_notifier for iommu failed: %d\n",
-			ret);
+		pr_err("vgpu[%d]: vfio_register_notifier for iommu failed:%d\n",
+			vgpu->id, ret);
 		goto out;
 	}
 
@@ -541,8 +554,8 @@ static int intel_vgpu_open(struct mdev_device *mdev)
 	ret = vfio_register_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY, &events,
 				&vgpu->vdev.group_notifier);
 	if (ret != 0) {
-		gvt_vgpu_err("vfio_register_notifier for group failed: %d\n",
-			ret);
+		pr_err("vgpu[%d]: vfio_register_notifier for group failed:%d\n",
+			vgpu->id, ret);
 		goto undo_iommu;
 	}
 
@@ -647,7 +660,7 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, char *buf,
 
 
 	if (index >= VFIO_PCI_NUM_REGIONS) {
-		gvt_vgpu_err("invalid index: %u\n", index);
+		pr_err("vgpu[%d]: invalid index: %u\n", vgpu->id, index);
 		return -EINVAL;
 	}
 
@@ -681,7 +694,7 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, char *buf,
 	case VFIO_PCI_VGA_REGION_INDEX:
 	case VFIO_PCI_ROM_REGION_INDEX:
 	default:
-		gvt_vgpu_err("unsupported region: %u\n", index);
+		pr_err("vgpu[%d]: unsupported region: %u\n", vgpu->id, index);
 	}
 
 	return ret == 0 ? count : ret;
@@ -873,7 +886,8 @@ static int intel_vgpu_set_msi_trigger(struct intel_vgpu *vgpu,
 
 		trigger = eventfd_ctx_fdget(fd);
 		if (IS_ERR(trigger)) {
-			gvt_vgpu_err("eventfd_ctx_fdget failed\n");
+			pr_err("vgpu[%d]: eventfd_ctx_fdget failed\n",
+					vgpu->id);
 			return PTR_ERR(trigger);
 		}
 		vgpu->vdev.msi_trigger = trigger;
@@ -929,7 +943,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
 	struct intel_vgpu *vgpu = mdev_get_drvdata(mdev);
 	unsigned long minsz;
 
-	gvt_dbg_core("vgpu%d ioctl, cmd: %d\n", vgpu->id, cmd);
+	gvt_kvmgt_dbg("vgpu%d ioctl, cmd: %d\n", vgpu->id, cmd);
 
 	if (cmd == VFIO_DEVICE_GET_INFO) {
 		struct vfio_device_info info;
@@ -1016,12 +1030,12 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
 			info.size = 0;
 
 			info.flags = 0;
-			gvt_dbg_core("get region info bar:%d\n", info.index);
+			gvt_kvmgt_dbg("get region info bar:%d\n", info.index);
 			break;
 
 		case VFIO_PCI_ROM_REGION_INDEX:
 		case VFIO_PCI_VGA_REGION_INDEX:
-			gvt_dbg_core("get region info index:%d\n", info.index);
+			gvt_kvmgt_dbg("get region info index:%d\n", info.index);
 			break;
 		default:
 			{
@@ -1132,7 +1146,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
 			ret = vfio_set_irqs_validate_and_prepare(&hdr, max,
 						VFIO_PCI_NUM_IRQS, &data_size);
 			if (ret) {
-				gvt_vgpu_err("intel:vfio_set_irqs_validate_and_prepare failed\n");
+				pr_err("vgpu[%d]:vfio_set_irqs_validate_and_prepare failed\n",
+						vgpu->id);
 				return -EINVAL;
 			}
 			if (data_size) {
@@ -1354,7 +1369,8 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
 
 	kvm = vgpu->vdev.kvm;
 	if (!kvm || kvm->mm != current->mm) {
-		gvt_vgpu_err("KVM is required to use Intel vGPU\n");
+		pr_err("vgpu[%d]: KVM is required to use Intel vGPU\n",
+				vgpu->id);
 		return -ESRCH;
 	}
 
@@ -1440,14 +1456,15 @@ static unsigned long kvmgt_gfn_to_pfn(unsigned long handle, unsigned long gfn)
 	dev = mdev_dev(info->vgpu->vdev.mdev);
 	rc = vfio_pin_pages(dev, &gfn, 1, IOMMU_READ | IOMMU_WRITE, &pfn);
 	if (rc != 1) {
-		gvt_vgpu_err("vfio_pin_pages failed for gfn 0x%lx: %d\n",
-			gfn, rc);
+		pr_err("vgpu[%d]: vfio_pin_pages failed for gfn 0x%lx: %d\n",
+			vgpu->id, gfn, rc);
 		return INTEL_GVT_INVALID_ADDR;
 	}
 	/* transfer to host iova for GFX to use DMA */
 	rc = gvt_dma_map_iova(info->vgpu, pfn, &iova);
 	if (rc) {
-		gvt_vgpu_err("gvt_dma_map_iova failed for gfn: 0x%lx\n", gfn);
+		pr_err("vgpu[%d]: gvt_dma_map_iova failed for gfn: 0x%lx\n",
+				vgpu->id, gfn);
 		vfio_unpin_pages(dev, &gfn, 1);
 		return INTEL_GVT_INVALID_ADDR;
 	}
Signature · 6 lines
1.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH v3 2/2 drm/i915: Add debug_gvt to classify GVT-g log messages

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

---
 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 ++++++++++++++++++++++++++++----------
 drivers/gpu/drm/i915/i915_params.c | 13 +++++++++++
 drivers/gpu/drm/i915/i915_params.h |  1 +
 6 files changed, 80 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/debug.c
drivers/gpu/drm/i915/Kconfig +8 -0
index a5cd5da..6282a2f 100644
@@ -124,6 +124,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
drivers/gpu/drm/i915/gvt/Makefile +1 -0
index f5486cb9..b1826c2 100644
@@ -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
drivers/gpu/drm/i915/gvt/debug.c new file +24 -0
new file mode 100644
index 0000000..75b4d0c
@@ -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);
+}
drivers/gpu/drm/i915/gvt/debug.h +33 -11

75 lines not on this page · raw message

drivers/gpu/drm/i915/i915_params.c +13 -0
index b6a7e36..7461829 100644
@@ -65,6 +65,7 @@ struct i915_params i915 __read_mostly = {
 	.inject_load_failure = 0,
 	.enable_dpcd_backlight = false,
 	.enable_gvt = false,
+	.debug_gvt = 0,
 };
 
 module_param_named(modeset, i915.modeset, int, 0400);
@@ -253,3 +254,15 @@ struct i915_params i915 __read_mostly = {
 module_param_named(enable_gvt, i915.enable_gvt, bool, 0400);
 MODULE_PARM_DESC(enable_gvt,
 	"Enable support for Intel GVT-g graphics virtualization host support(default:false)");
+
+module_param_named(debug_gvt, i915.debug_gvt, int, 0600);
+MODULE_PARM_DESC(debug_gvt, "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)");
drivers/gpu/drm/i915/i915_params.h +1 -0
index 34148cc..71c7454 100644
@@ -52,6 +52,7 @@
 	func(int, mmio_debug); \
 	func(int, edp_vswing); \
 	func(unsigned int, inject_load_failure); \
+	func(int, debug_gvt); \
 	/* leave bools at the end to not create holes */ \
 	func(bool, alpha_support); \
 	func(bool, enable_cmd_parser); \
Signature · 6 lines
1.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#2 lore raw

Re: [PATCH v3 2/2] drm/i915: Add debug_gvt to classify GVT-g log messages

Quoted 4 lines · Shuo Liu

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

Please split out the i915 related changes to separate patches in the beginning of the series for easier reviewing.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#3 lore raw

Re: [PATCH v3 2/2] drm/i915: Add debug_gvt to classify GVT-g log messages

Quoted 8 lines · Joonas Lahtinen
Quoted 4 lines · Shuo Liu

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

Please split out the i915 related changes to separate patches in the beginning of the series for easier reviewing.

Thanks Joonas for review. I will split i915 params out.

Quoted 6 lines

Regards, Joonas

Signature · 3 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✓ Fi.CI.BAT: success for series starting with [v3,1/2] drm/i915/gvt: Change log function of kvmgt to common ones

In reply to Shuo Liu
== Series Details ==

== Series Details ==

Series: series starting with [v3,1/2] drm/i915/gvt: Change log function of kvmgt to common ones
URL : https://patchwork.freedesktop.org/series/30325/
State : success

== Summary ==

Series 30325v1 series starting with [v3,1/2] drm/i915/gvt: Change log function of kvmgt to common ones
https://patchwork.freedesktop.org/api/1.0/series/30325/revisions/1/mbox/

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215 +1
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                pass       -> SKIP       (fi-skl-x1585l) fdo#101781
Test kms_frontbuffer_tracking:
        Subgroup basic:
                dmesg-warn -> PASS       (fi-bdw-5557u) fdo#102473

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
fdo#102473 https://bugs.freedesktop.org/show_bug.cgi?id=102473

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:449s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:374s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:526s
fi-bwr-2160      total:289  pass:184  dwarn:0   dfail:0   fail:0   skip:105 time:269s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:507s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:498s
fi-byt-n2820     total:289  pass:250  dwarn:1   dfail:0   fail:0   skip:38  time:502s
fi-cfl-s         total:289  pass:223  dwarn:34  dfail:0   fail:0   skip:32  time:546s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:450s
fi-glk-2a        total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:592s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:427s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:405s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:436s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:490s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:463s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:483s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:575s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:580s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:557s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:467s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:517s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:504s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:459s
fi-skl-x1585l    total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:476s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:567s
fi-snb-2600      total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:429s

fd4b78812edddb5118f97329ba04f36483e16e2a drm-tip: 2017y-09m-13d-17h-15m-44s UTC integration manifest 5dd127f04e1b drm/i915: Add debug_gvt to classify GVT-g log messages
9c7178575f13 drm/i915/gvt: Change log function of kvmgt to common ones

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5690/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✓ Fi.CI.IGT: success for series starting with [v3,1/2] drm/i915/gvt: Change log function of kvmgt to common ones

In reply to Shuo Liu
== Series Details ==

== Series Details ==

Series: series starting with [v3,1/2] drm/i915/gvt: Change log function of kvmgt to common ones
URL : https://patchwork.freedesktop.org/series/30325/
State : success

== Summary ==

Test gem_eio:

        Subgroup in-flight:
                fail       -> PASS       (shard-hsw) fdo#102616
Test kms_flip:
        Subgroup wf_vblank-vs-dpms:
                dmesg-warn -> PASS       (shard-hsw)
Test gem_flink_race:
        Subgroup flink_close:
                fail       -> PASS       (shard-hsw) fdo#102655

fdo#102616 https://bugs.freedesktop.org/show_bug.cgi?id=102616
fdo#102655 https://bugs.freedesktop.org/show_bug.cgi?id=102655

shard-hsw total:2313 pass:1245 dwarn:0 dfail:0 fail:13 skip:1055 time:9402s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5690/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx