[Intel-gfx] [PATCH v4 2/3] drm/i915/gvt: Change log function of kvmgt to common ones
Shuo Liu
shuo.a.liu at intel.com
Tue Sep 19 07:54:44 UTC 2017
This can remove the dependence of i915 module if we change gvt_dbg_* to
function in i915 module.
Signed-off-by: Shuo Liu <shuo.a.liu at intel.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 55 ++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 83e88c7..0dae361 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -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) {
@@ -1371,7 +1386,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;
}
@@ -1457,14 +1473,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;
}
--
1.9.4
More information about the Intel-gfx
mailing list