diff options
author | Changbin Du <changbin.du@intel.com> | 2017-11-02 01:33:42 -0400 |
---|---|---|
committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2017-12-05 22:24:37 -0500 |
commit | add7e4fc2420e35f200e4aa13764708e62690e2e (patch) | |
tree | 2f477ea4ea398160f4ccb38d5bde113bd176bffc | |
parent | b721b65af4eb46df6a1d9e34b14003225e403565 (diff) |
drm/i915/gvt: Emulate PCI expansion ROM base address register
Our vGPU doesn't have a device ROM, we need follow the PCI spec to
report this info to drivers. Otherwise, we would see below errors.
Inspecting possible rom at 0xfe049000 (vd=8086:1912 bdf=00:10.0)
qemu-system-x86_64: vfio-pci: Cannot read device rom at 00000000-0000-0000-0000-000000000001
Device option ROM contents are probably invalid (check dmesg).
Skip option ROM probe with rombar=0, or load from file with romfile=No option rom signature (got 4860)
I will also send a improvement patch to PCI subsystem related to PCI ROM.
But no idea to omit below error, since no pattern to detect vbios shadow
without touch its content.
0000:00:10.0: Invalid PCI ROM header signature: expecting 0xaa55, got 0x0000
Signed-off-by: Changbin Du <changbin.du@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
(cherry picked from commit c4270d122ccff963a021d1beb893d6192336af96)
-rw-r--r-- | drivers/gpu/drm/i915/gvt/cfg_space.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c index ab19545d59a1..4ce2e6bd0680 100644 --- a/drivers/gpu/drm/i915/gvt/cfg_space.c +++ b/drivers/gpu/drm/i915/gvt/cfg_space.c | |||
@@ -208,6 +208,20 @@ static int emulate_pci_command_write(struct intel_vgpu *vgpu, | |||
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
210 | 210 | ||
211 | static int emulate_pci_rom_bar_write(struct intel_vgpu *vgpu, | ||
212 | unsigned int offset, void *p_data, unsigned int bytes) | ||
213 | { | ||
214 | u32 *pval = (u32 *)(vgpu_cfg_space(vgpu) + offset); | ||
215 | u32 new = *(u32 *)(p_data); | ||
216 | |||
217 | if ((new & PCI_ROM_ADDRESS_MASK) == PCI_ROM_ADDRESS_MASK) | ||
218 | /* We don't have rom, return size of 0. */ | ||
219 | *pval = 0; | ||
220 | else | ||
221 | vgpu_pci_cfg_mem_write(vgpu, offset, p_data, bytes); | ||
222 | return 0; | ||
223 | } | ||
224 | |||
211 | static int emulate_pci_bar_write(struct intel_vgpu *vgpu, unsigned int offset, | 225 | static int emulate_pci_bar_write(struct intel_vgpu *vgpu, unsigned int offset, |
212 | void *p_data, unsigned int bytes) | 226 | void *p_data, unsigned int bytes) |
213 | { | 227 | { |
@@ -300,6 +314,11 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset, | |||
300 | } | 314 | } |
301 | 315 | ||
302 | switch (rounddown(offset, 4)) { | 316 | switch (rounddown(offset, 4)) { |
317 | case PCI_ROM_ADDRESS: | ||
318 | if (WARN_ON(!IS_ALIGNED(offset, 4))) | ||
319 | return -EINVAL; | ||
320 | return emulate_pci_rom_bar_write(vgpu, offset, p_data, bytes); | ||
321 | |||
303 | case PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_5: | 322 | case PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_5: |
304 | if (WARN_ON(!IS_ALIGNED(offset, 4))) | 323 | if (WARN_ON(!IS_ALIGNED(offset, 4))) |
305 | return -EINVAL; | 324 | return -EINVAL; |
@@ -375,6 +394,8 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu, | |||
375 | pci_resource_len(gvt->dev_priv->drm.pdev, 0); | 394 | pci_resource_len(gvt->dev_priv->drm.pdev, 0); |
376 | vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_APERTURE].size = | 395 | vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_APERTURE].size = |
377 | pci_resource_len(gvt->dev_priv->drm.pdev, 2); | 396 | pci_resource_len(gvt->dev_priv->drm.pdev, 2); |
397 | |||
398 | memset(vgpu_cfg_space(vgpu) + PCI_ROM_ADDRESS, 0, 4); | ||
378 | } | 399 | } |
379 | 400 | ||
380 | /** | 401 | /** |