clear-pkgs-linux-iot-lts2018/0617-drm-i915-gvt-get-ready...

102 lines
3.5 KiB
Diff

From af0b9444c11efa03c99f566f66f3101a0e2900f7 Mon Sep 17 00:00:00 2001
From: Pei Zhang <pei.zhang@intel.com>
Date: Fri, 14 Sep 2018 16:10:19 +0800
Subject: [PATCH 617/743] drm/i915/gvt: get ready of memory for pvmmio
To enable pvmmio feature, we need to prepare to regions memory: the mmio
memory whose size is 2M for Gen8/9, and the 4K shared page. GVT creates
them for every vGPU instance, guest i915 driver will map them to virtual
address.
Change-Id: Ifcbd0e55783e19125e98036622cd5d08624d34fa
Signed-off-by: Pei Zhang <pei.zhang@intel.com>
Acknowledged-by: Singh, Satyeshwar <satyeshwar.singh@intel.com>
Reviewed-on:
Reviewed-by: He, Min <min.he@intel.com>
Reviewed-by: Jiang, Fei <fei.jiang@intel.com>
Reviewed-by: Dong, Eddie <eddie.dong@intel.com>
Tested-by: Dong, Eddie <eddie.dong@intel.com>
---
drivers/gpu/drm/i915/gvt/gvt.c | 2 ++
drivers/gpu/drm/i915/gvt/gvt.h | 2 ++
drivers/gpu/drm/i915/gvt/mmio.c | 22 ++++++++++++++++++----
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
index 6261af450ee4..e4a3823e1226 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.c
+++ b/drivers/gpu/drm/i915/gvt/gvt.c
@@ -248,6 +248,8 @@ static void init_device_info(struct intel_gvt *gvt)
info->max_support_vgpus = 8;
info->cfg_space_size = PCI_CFG_SPACE_EXP_SIZE;
info->mmio_size = 2 * 1024 * 1024;
+ /* order of mmio size. assert(2^order == mmio_size) */
+ info->mmio_size_order = 9;
info->mmio_bar = 0;
info->gtt_start_offset = 8 * 1024 * 1024;
info->gtt_entry_size = 8;
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index 64139240207f..ba88f722d602 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -71,6 +71,7 @@ struct intel_gvt_device_info {
u32 max_support_vgpus;
u32 cfg_space_size;
u32 mmio_size;
+ u32 mmio_size_order;
u32 mmio_bar;
unsigned long msi_cap_offset;
u32 gtt_start_offset;
@@ -100,6 +101,7 @@ struct intel_vgpu_fence {
struct intel_vgpu_mmio {
void *vreg;
void *sreg;
+ struct gvt_shared_page *shared_page;
};
#define INTEL_GVT_MAX_BAR_NUM 4
diff --git a/drivers/gpu/drm/i915/gvt/mmio.c b/drivers/gpu/drm/i915/gvt/mmio.c
index 878a8a1f5ff5..4cb3f72ab56a 100644
--- a/drivers/gpu/drm/i915/gvt/mmio.c
+++ b/drivers/gpu/drm/i915/gvt/mmio.c
@@ -311,11 +311,21 @@ int intel_vgpu_init_mmio(struct intel_vgpu *vgpu)
{
const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
- vgpu->mmio.vreg = vzalloc(array_size(info->mmio_size, 2));
+ BUILD_BUG_ON(sizeof(struct gvt_shared_page) != PAGE_SIZE);
+
+ vgpu->mmio.sreg = vzalloc(info->mmio_size);
+ vgpu->mmio.vreg = (void *)__get_free_pages(GFP_KERNEL,
+ info->mmio_size_order);
if (!vgpu->mmio.vreg)
return -ENOMEM;
- vgpu->mmio.sreg = vgpu->mmio.vreg + info->mmio_size;
+ vgpu->mmio.shared_page = (struct gvt_shared_page *) __get_free_pages(
+ GFP_KERNEL, 0);
+ if (!vgpu->mmio.shared_page) {
+ vfree(vgpu->mmio.vreg);
+ vgpu->mmio.vreg = NULL;
+ return -ENOMEM;
+ }
intel_vgpu_reset_mmio(vgpu, true);
@@ -329,6 +339,10 @@ int intel_vgpu_init_mmio(struct intel_vgpu *vgpu)
*/
void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu)
{
- vfree(vgpu->mmio.vreg);
- vgpu->mmio.vreg = vgpu->mmio.sreg = NULL;
+ const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
+
+ vfree(vgpu->mmio.sreg);
+ free_pages((unsigned long) vgpu->mmio.vreg, info->mmio_size_order);
+ free_pages((unsigned long) vgpu->mmio.shared_page, 0);
+ vgpu->mmio.vreg = vgpu->mmio.sreg = vgpu->mmio.shared_page = NULL;
}
--
2.19.2