diff mbox

[RFC,4/6] vfio: Refine GGTT clearing

Message ID 1496079043-26694-12-git-send-email-zhi.a.wang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Zhi A May 29, 2017, 5:30 p.m. UTC
Clear the whole GGTT page tables after the quirk is initialized. Obtain
the total size of GGTT and the entry size of one GGTT entry from
intel_device_info().

Suggested-by: Xiong Zhang <xiong.y.zhang@intel.com>
Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
---
 hw/vfio/pci-quirks.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 5a083c1..618c43c 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1365,7 +1365,7 @@  static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
     const struct intel_device_info *info;
     void *stolen;
     PCIDevice *lpc_bridge;
-    int i, ret;
+    int i, j, ret;
     uint64_t bdsm_size;
     uint32_t gmch;
     uint16_t cmd_orig, cmd;
@@ -1570,9 +1570,11 @@  static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
                      vdev->vbasedev.name);
     }
 
-    for (i = 1; i < vfio_igd_gtt_max(vdev); i += 4) {
-        vfio_region_write(&vdev->bars[4].region, 0, i, 4);
-        vfio_region_write(&vdev->bars[4].region, 4, 0, 4);
+    for (i = 1; i < info->get_gtt_size(gmch); i += info->gtt_entry_size) {
+        for (j = 0; j < info->gtt_entry_size; j += 4) {
+            vfio_region_write(&vdev->bars[4].region, 0, i + j, 4);
+            vfio_region_write(&vdev->bars[4].region, 4, 0, 4);
+        }
     }
 
     if (pwrite(vdev->vbasedev.fd, &cmd_orig, sizeof(cmd_orig),