clear-pkgs-linux-iot-lts2018/1103-Reduce-the-unnecessary...

71 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zhao Yakui <yakui.zhao@intel.com>
Date: Fri, 17 May 2019 09:22:13 +0800
Subject: [PATCH] Reduce the unnecessary interrupt injection for small time
interval
When the time interval is less than 10000ns(10us), it is unnecessary to
inject the interrupt.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Liu Shuo <shuo.liu@intel.com>
---
drivers/gpu/drm/i915/gvt/gvt.h | 1 +
drivers/gpu/drm/i915/gvt/mpt.h | 14 ++++++++++++++
drivers/gpu/drm/i915/gvt/vgpu.c | 1 +
3 files changed, 16 insertions(+)
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index cf689150dbf7..b0073edbe4a4 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -240,6 +240,7 @@ struct intel_vgpu {
unsigned long long *cached_guest_entry;
bool ge_cache_enable;
bool entire_nonctxmmio_checked;
+ ktime_t vgpu_msi_time;
};
/* validating GM healthy status*/
diff --git a/drivers/gpu/drm/i915/gvt/mpt.h b/drivers/gpu/drm/i915/gvt/mpt.h
index 14fa2ea047fa..6030e41cc6bb 100644
--- a/drivers/gpu/drm/i915/gvt/mpt.h
+++ b/drivers/gpu/drm/i915/gvt/mpt.h
@@ -129,7 +129,21 @@ static inline int intel_gvt_hypervisor_inject_msi(struct intel_vgpu *vgpu)
u16 control, data;
u32 addr;
int ret;
+ ktime_t time_current;
+ time_current = ktime_get_raw();
+
+ if (ktime_before(time_current,
+ ktime_add_ns(vgpu->vgpu_msi_time, 10000))) {
+ /*
+ * vgpu->vpgu_msi_time records the time of last interrupt
+ * injection. when the time interval is too small,
+ * the interrupt injection will be skipped.
+ */
+ return 0;
+ }
+
+ vgpu->vgpu_msi_time = time_current;
control = *(u16 *)(vgpu_cfg_space(vgpu) + MSI_CAP_CONTROL(offset));
addr = *(u32 *)(vgpu_cfg_space(vgpu) + MSI_CAP_ADDRESS(offset));
data = *(u16 *)(vgpu_cfg_space(vgpu) + MSI_CAP_DATA(offset));
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
index 08e99dd14344..b28bc3af3eaf 100644
--- a/drivers/gpu/drm/i915/gvt/vgpu.c
+++ b/drivers/gpu/drm/i915/gvt/vgpu.c
@@ -511,6 +511,7 @@ struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
/* calculate left instance change for types */
intel_gvt_update_vgpu_types(gvt);
mutex_unlock(&gvt->lock);
+ vgpu->vgpu_msi_time = ktime_get_raw();
return vgpu;
}
--
https://clearlinux.org