diff options
author | Changbin Du <changbin.du@intel.com> | 2017-01-12 22:15:58 -0500 |
---|---|---|
committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2017-01-13 02:05:38 -0500 |
commit | 536fc234074b09adae1763d8fb5b2d947847ad1d (patch) | |
tree | 3d75ea85e06c628838d6edcf650480f9d9280f24 | |
parent | b611581b375ce28536ab50be9cd507bb6092fb1e (diff) |
drm/i915/gvt: move cfg space inititation function to cfg_space.c
Move the configuration space inititation function setup_vgpu_cfg_space()
in vgpu.c to dedicated source file cfg_space.c, and rename the function
as intel_vgpu_init_cfg_space().
Signed-off-by: Changbin Du <changbin.du@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
-rw-r--r-- | drivers/gpu/drm/i915/gvt/cfg_space.c | 49 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/gvt/gvt.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/gvt/vgpu.c | 44 |
3 files changed, 52 insertions, 43 deletions
diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c index 711c31c8d8b4..82f449d59884 100644 --- a/drivers/gpu/drm/i915/gvt/cfg_space.c +++ b/drivers/gpu/drm/i915/gvt/cfg_space.c | |||
@@ -282,3 +282,52 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset, | |||
282 | } | 282 | } |
283 | return 0; | 283 | return 0; |
284 | } | 284 | } |
285 | |||
286 | /** | ||
287 | * intel_vgpu_init_cfg_space - init vGPU configuration space when create vGPU | ||
288 | * | ||
289 | * @vgpu: a vGPU | ||
290 | * @primary: is the vGPU presented as primary | ||
291 | * | ||
292 | */ | ||
293 | void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu, | ||
294 | bool primary) | ||
295 | { | ||
296 | struct intel_gvt *gvt = vgpu->gvt; | ||
297 | const struct intel_gvt_device_info *info = &gvt->device_info; | ||
298 | u16 *gmch_ctl; | ||
299 | int i; | ||
300 | |||
301 | memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space, | ||
302 | info->cfg_space_size); | ||
303 | |||
304 | if (!primary) { | ||
305 | vgpu_cfg_space(vgpu)[PCI_CLASS_DEVICE] = | ||
306 | INTEL_GVT_PCI_CLASS_VGA_OTHER; | ||
307 | vgpu_cfg_space(vgpu)[PCI_CLASS_PROG] = | ||
308 | INTEL_GVT_PCI_CLASS_VGA_OTHER; | ||
309 | } | ||
310 | |||
311 | /* Show guest that there isn't any stolen memory.*/ | ||
312 | gmch_ctl = (u16 *)(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_GMCH_CONTROL); | ||
313 | *gmch_ctl &= ~(BDW_GMCH_GMS_MASK << BDW_GMCH_GMS_SHIFT); | ||
314 | |||
315 | intel_vgpu_write_pci_bar(vgpu, PCI_BASE_ADDRESS_2, | ||
316 | gvt_aperture_pa_base(gvt), true); | ||
317 | |||
318 | vgpu_cfg_space(vgpu)[PCI_COMMAND] &= ~(PCI_COMMAND_IO | ||
319 | | PCI_COMMAND_MEMORY | ||
320 | | PCI_COMMAND_MASTER); | ||
321 | /* | ||
322 | * Clear the bar upper 32bit and let guest to assign the new value | ||
323 | */ | ||
324 | memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_1, 0, 4); | ||
325 | memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_3, 0, 4); | ||
326 | memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4); | ||
327 | |||
328 | for (i = 0; i < INTEL_GVT_MAX_BAR_NUM; i++) { | ||
329 | vgpu->cfg_space.bar[i].size = pci_resource_len( | ||
330 | gvt->dev_priv->drm.pdev, i * 2); | ||
331 | vgpu->cfg_space.bar[i].tracked = false; | ||
332 | } | ||
333 | } | ||
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h index 455281d07d75..ab505552d313 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h | |||
@@ -412,6 +412,8 @@ int intel_gvt_ggtt_index_g2h(struct intel_vgpu *vgpu, unsigned long g_index, | |||
412 | int intel_gvt_ggtt_h2g_index(struct intel_vgpu *vgpu, unsigned long h_index, | 412 | int intel_gvt_ggtt_h2g_index(struct intel_vgpu *vgpu, unsigned long h_index, |
413 | unsigned long *g_index); | 413 | unsigned long *g_index); |
414 | 414 | ||
415 | void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu, | ||
416 | bool primary); | ||
415 | int intel_vgpu_emulate_cfg_read(struct intel_vgpu *vgpu, unsigned int offset, | 417 | int intel_vgpu_emulate_cfg_read(struct intel_vgpu *vgpu, unsigned int offset, |
416 | void *p_data, unsigned int bytes); | 418 | void *p_data, unsigned int bytes); |
417 | 419 | ||
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index f0e86123e45b..35c274177da8 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c | |||
@@ -66,48 +66,6 @@ int setup_vgpu_mmio(struct intel_vgpu *vgpu) | |||
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | static void setup_vgpu_cfg_space(struct intel_vgpu *vgpu, | ||
70 | struct intel_vgpu_creation_params *param) | ||
71 | { | ||
72 | struct intel_gvt *gvt = vgpu->gvt; | ||
73 | const struct intel_gvt_device_info *info = &gvt->device_info; | ||
74 | u16 *gmch_ctl; | ||
75 | int i; | ||
76 | |||
77 | memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space, | ||
78 | info->cfg_space_size); | ||
79 | |||
80 | if (!param->primary) { | ||
81 | vgpu_cfg_space(vgpu)[PCI_CLASS_DEVICE] = | ||
82 | INTEL_GVT_PCI_CLASS_VGA_OTHER; | ||
83 | vgpu_cfg_space(vgpu)[PCI_CLASS_PROG] = | ||
84 | INTEL_GVT_PCI_CLASS_VGA_OTHER; | ||
85 | } | ||
86 | |||
87 | /* Show guest that there isn't any stolen memory.*/ | ||
88 | gmch_ctl = (u16 *)(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_GMCH_CONTROL); | ||
89 | *gmch_ctl &= ~(BDW_GMCH_GMS_MASK << BDW_GMCH_GMS_SHIFT); | ||
90 | |||
91 | intel_vgpu_write_pci_bar(vgpu, PCI_BASE_ADDRESS_2, | ||
92 | gvt_aperture_pa_base(gvt), true); | ||
93 | |||
94 | vgpu_cfg_space(vgpu)[PCI_COMMAND] &= ~(PCI_COMMAND_IO | ||
95 | | PCI_COMMAND_MEMORY | ||
96 | | PCI_COMMAND_MASTER); | ||
97 | /* | ||
98 | * Clear the bar upper 32bit and let guest to assign the new value | ||
99 | */ | ||
100 | memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_1, 0, 4); | ||
101 | memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_3, 0, 4); | ||
102 | memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4); | ||
103 | |||
104 | for (i = 0; i < INTEL_GVT_MAX_BAR_NUM; i++) { | ||
105 | vgpu->cfg_space.bar[i].size = pci_resource_len( | ||
106 | gvt->dev_priv->drm.pdev, i * 2); | ||
107 | vgpu->cfg_space.bar[i].tracked = false; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | void populate_pvinfo_page(struct intel_vgpu *vgpu) | 69 | void populate_pvinfo_page(struct intel_vgpu *vgpu) |
112 | { | 70 | { |
113 | /* setup the ballooning information */ | 71 | /* setup the ballooning information */ |
@@ -300,7 +258,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, | |||
300 | vgpu->gvt = gvt; | 258 | vgpu->gvt = gvt; |
301 | bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES); | 259 | bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES); |
302 | 260 | ||
303 | setup_vgpu_cfg_space(vgpu, param); | 261 | intel_vgpu_init_cfg_space(vgpu, param->primary); |
304 | 262 | ||
305 | ret = setup_vgpu_mmio(vgpu); | 263 | ret = setup_vgpu_mmio(vgpu); |
306 | if (ret) | 264 | if (ret) |