qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 4/6] vfio: Refine GGTT clearing


From: Zhi Wang
Subject: [Qemu-devel] [RFC 4/6] vfio: Refine GGTT clearing
Date: Tue, 30 May 2017 01:30:41 +0800

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 <address@hidden>
Signed-off-by: Zhi Wang <address@hidden>
---
 hw/vfio/pci-quirks.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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),
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]