render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0431-qxl-add-optinal-64bit-vram-bar.patch

Hans de Goede 56753f
From f1e729a041efbd2d562e8202407e927745210bbd Mon Sep 17 00:00:00 2001
Hans de Goede 56753f
From: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede 56753f
Date: Fri, 14 Oct 2011 18:05:48 +0200
Hans de Goede 56753f
Subject: [PATCH 431/434] qxl: add optinal 64bit vram bar
Hans de Goede 56753f
Hans de Goede 56753f
This patch adds an 64bit pci bar for vram.  It is turned off by default.
Hans de Goede 56753f
It can be enabled by setting the size of the 64bit bar to be larger than
Hans de Goede 56753f
the 32bit bar.  Both 32bit and 64bit bar refer to the same memory.  Only
Hans de Goede 56753f
the first part of the memory is available via 32bit bar.
Hans de Goede 56753f
Hans de Goede 56753f
The intention is to allow large vram sizes for 64bit guests, by allowing
Hans de Goede 56753f
the vram bar being mapped above 4G, so we don't have to squeeze it into
Hans de Goede 56753f
the pci I/O window below 4G.
Hans de Goede 56753f
Hans de Goede 56753f
With vram_size_mb=16 and vram64_size_mb=256 it looks like this:
Hans de Goede 56753f
Hans de Goede 56753f
00:02.0 VGA compatible controller: Red Hat, Inc. Device 0100 (rev 02) (prog-if 00 [VGA controller])
Hans de Goede 56753f
        Subsystem: Red Hat, Inc Device 1100
Hans de Goede 56753f
        Physical Slot: 2
Hans de Goede 56753f
        Flags: fast devsel, IRQ 10
Hans de Goede 56753f
        Memory at f8000000 (32-bit, non-prefetchable) [size=64M]
Hans de Goede 56753f
        Memory at fc000000 (32-bit, non-prefetchable) [size=16M]
Hans de Goede 56753f
        Memory at fd020000 (32-bit, non-prefetchable) [size=8K]
Hans de Goede 56753f
        I/O ports at c5a0 [size=32]
Hans de Goede 56753f
        Memory at ffe0000000 (64-bit, prefetchable) [size=256M]
Hans de Goede 56753f
        Expansion ROM at fd000000 [disabled] [size=64K]
Hans de Goede 56753f
Hans de Goede 56753f
[ mapping above 4G needs patched seabios:
Hans de Goede 56753f
  http://www.kraxel.org/cgit/seabios/commit/?h=pci64 ]
Hans de Goede 56753f
Hans de Goede 56753f
Conflicts:
Hans de Goede 56753f
Hans de Goede 56753f
	hw/qxl.c
Hans de Goede 56753f
---
Hans de Goede 56753f
 hw/qxl.c |   51 ++++++++++++++++++++++++++++++++++++++++++++-------
Hans de Goede 56753f
 hw/qxl.h |    7 +++++++
Hans de Goede 56753f
 2 files changed, 51 insertions(+), 7 deletions(-)
Hans de Goede 56753f
Hans de Goede 56753f
diff --git a/hw/qxl.c b/hw/qxl.c
Hans de Goede 56753f
index bcdf274..18f3759 100644
Hans de Goede 56753f
--- a/hw/qxl.c
Hans de Goede 56753f
+++ b/hw/qxl.c
Hans de Goede 56753f
@@ -1002,6 +1002,7 @@ static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
Hans de Goede 56753f
     static const int regions[] = {
Hans de Goede 56753f
         QXL_RAM_RANGE_INDEX,
Hans de Goede 56753f
         QXL_VRAM_RANGE_INDEX,
Hans de Goede 56753f
+        QXL_VRAM64_RANGE_INDEX,
Hans de Goede 56753f
     };
Hans de Goede 56753f
     uint64_t guest_start;
Hans de Goede 56753f
     uint64_t guest_end;
Hans de Goede 56753f
@@ -1046,6 +1047,7 @@ static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
Hans de Goede 56753f
         virt_start = (intptr_t)memory_region_get_ram_ptr(&d->vga.vram);
Hans de Goede 56753f
         break;
Hans de Goede 56753f
     case QXL_VRAM_RANGE_INDEX:
Hans de Goede 56753f
+    case 4 /* vram 64bit */:
Hans de Goede 56753f
         virt_start = (intptr_t)memory_region_get_ram_ptr(&d->vram_bar);
Hans de Goede 56753f
         break;
Hans de Goede 56753f
     default:
Hans de Goede 56753f
@@ -1630,18 +1632,28 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl, uint32_t ram_min_mb)
Hans de Goede 56753f
         qxl->vga.vram_size = ram_min_mb * 1024 * 1024;
Hans de Goede 56753f
     }
Hans de Goede 56753f
 
Hans de Goede 56753f
-    /* vram (surfaces, bar 1) */
Hans de Goede 56753f
+    /* vram32 (surfaces, 32bit, bar 1) */
Hans de Goede 56753f
+    if (qxl->vram32_size_mb != -1) {
Hans de Goede 56753f
+        qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;
Hans de Goede 56753f
+    }
Hans de Goede 56753f
+    if (qxl->vram32_size < 4096) {
Hans de Goede 56753f
+        qxl->vram32_size = 4096;
Hans de Goede 56753f
+    }
Hans de Goede 56753f
+
Hans de Goede 56753f
+    /* vram (surfaces, 64bit, bar 4+5) */
Hans de Goede 56753f
     if (qxl->vram_size_mb != -1) {
Hans de Goede 56753f
         qxl->vram_size = qxl->vram_size_mb * 1024 * 1024;
Hans de Goede 56753f
     }
Hans de Goede 56753f
-    if (qxl->vram_size < 4096) {
Hans de Goede 56753f
-        qxl->vram_size = 4096;
Hans de Goede 56753f
+    if (qxl->vram_size < qxl->vram32_size) {
Hans de Goede 56753f
+        qxl->vram_size = qxl->vram32_size;
Hans de Goede 56753f
     }
Hans de Goede 56753f
+
Hans de Goede 56753f
     if (qxl->revision == 1) {
Hans de Goede 56753f
+        qxl->vram32_size = 4096;
Hans de Goede 56753f
         qxl->vram_size = 4096;
Hans de Goede 56753f
     }
Hans de Goede 56753f
-
Hans de Goede 56753f
     qxl->vga.vram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
Hans de Goede 56753f
+    qxl->vram32_size = msb_mask(qxl->vram32_size * 2 - 1);
Hans de Goede 56753f
     qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);
Hans de Goede 56753f
 }
Hans de Goede 56753f
 
Hans de Goede 56753f
@@ -1683,6 +1695,8 @@ static int qxl_init_common(PCIQXLDevice *qxl)
Hans de Goede 56753f
 
Hans de Goede 56753f
     memory_region_init_ram(&qxl->vram_bar, &qxl->pci.qdev, "qxl.vram",
Hans de Goede 56753f
                            qxl->vram_size);
Hans de Goede 56753f
+    memory_region_init_alias(&qxl->vram32_bar, "qxl.vram32", &qxl->vram_bar,
Hans de Goede 56753f
+                             0, qxl->vram32_size);
Hans de Goede 56753f
 
Hans de Goede 56753f
     io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
Hans de Goede 56753f
     if (qxl->revision == 1) {
Hans de Goede 56753f
@@ -1706,7 +1720,29 @@ static int qxl_init_common(PCIQXLDevice *qxl)
Hans de Goede 56753f
                      PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
Hans de Goede 56753f
 
Hans de Goede 56753f
     pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
Hans de Goede 56753f
-                     PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram_bar);
Hans de Goede 56753f
+                     PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
Hans de Goede 56753f
+
Hans de Goede 56753f
+    if (qxl->vram32_size < qxl->vram_size) {
Hans de Goede 56753f
+        /*
Hans de Goede 56753f
+         * Make the 64bit vram bar show up only in case it is
Hans de Goede 56753f
+         * configured to be larger than the 32bit vram bar.
Hans de Goede 56753f
+         */
Hans de Goede 56753f
+        pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
Hans de Goede 56753f
+                         PCI_BASE_ADDRESS_SPACE_MEMORY |
Hans de Goede 56753f
+                         PCI_BASE_ADDRESS_MEM_TYPE_64 |
Hans de Goede 56753f
+                         PCI_BASE_ADDRESS_MEM_PREFETCH,
Hans de Goede 56753f
+                         &qxl->vram_bar);
Hans de Goede 56753f
+    }
Hans de Goede 56753f
+
Hans de Goede 56753f
+    /* print pci bar details */
Hans de Goede 56753f
+    dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
Hans de Goede 56753f
+           qxl->id == 0 ? "pri" : "sec",
Hans de Goede 56753f
+           qxl->vga.vram_size / (1024*1024));
Hans de Goede 56753f
+    dprint(qxl, 1, "vram/32: %d MB [region 1]\n",
Hans de Goede 56753f
+           qxl->vram32_size / (1024*1024));
Hans de Goede 56753f
+    dprint(qxl, 1, "vram/64: %d MB %s\n",
Hans de Goede 56753f
+           qxl->vram_size / (1024*1024),
Hans de Goede 56753f
+           qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
Hans de Goede 56753f
 
Hans de Goede 56753f
     qxl->ssd.qxl.base.sif = &qxl_interface.base;
Hans de Goede 56753f
     qxl->ssd.qxl.id = qxl->id;
Hans de Goede 56753f
@@ -1918,7 +1954,7 @@ static VMStateDescription qxl_vmstate = {
Hans de Goede 56753f
 static Property qxl_properties[] = {
Hans de Goede 56753f
         DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size,
Hans de Goede 56753f
                            64 * 1024 * 1024),
Hans de Goede 56753f
-        DEFINE_PROP_UINT32("vram_size", PCIQXLDevice, vram_size,
Hans de Goede 56753f
+        DEFINE_PROP_UINT32("vram_size", PCIQXLDevice, vram32_size,
Hans de Goede 56753f
                            64 * 1024 * 1024),
Hans de Goede 56753f
         DEFINE_PROP_UINT32("revision", PCIQXLDevice, revision,
Hans de Goede 56753f
                            QXL_DEFAULT_REVISION),
Hans de Goede 56753f
@@ -1926,7 +1962,8 @@ static Property qxl_properties[] = {
Hans de Goede 56753f
         DEFINE_PROP_UINT32("guestdebug", PCIQXLDevice, guestdebug, 0),
Hans de Goede 56753f
         DEFINE_PROP_UINT32("cmdlog", PCIQXLDevice, cmdlog, 0),
Hans de Goede 56753f
         DEFINE_PROP_UINT32("ram_size_mb",  PCIQXLDevice, ram_size_mb, -1),
Hans de Goede 56753f
-        DEFINE_PROP_UINT32("vram_size_mb", PCIQXLDevice, vram_size_mb, -1),
Hans de Goede 56753f
+        DEFINE_PROP_UINT32("vram_size_mb", PCIQXLDevice, vram32_size_mb, 0),
Hans de Goede 56753f
+        DEFINE_PROP_UINT32("vram64_size_mb", PCIQXLDevice, vram_size_mb, 0),
Hans de Goede 56753f
         DEFINE_PROP_END_OF_LIST(),
Hans de Goede 56753f
 };
Hans de Goede 56753f
 
Hans de Goede 56753f
diff --git a/hw/qxl.h b/hw/qxl.h
Hans de Goede 56753f
index 86e415b..11a0db3 100644
Hans de Goede 56753f
--- a/hw/qxl.h
Hans de Goede 56753f
+++ b/hw/qxl.h
Hans de Goede 56753f
@@ -16,6 +16,10 @@ enum qxl_mode {
Hans de Goede 56753f
     QXL_MODE_NATIVE,
Hans de Goede 56753f
 };
Hans de Goede 56753f
 
Hans de Goede 56753f
+#ifndef QXL_VRAM64_RANGE_INDEX
Hans de Goede 56753f
+#define QXL_VRAM64_RANGE_INDEX 4
Hans de Goede 56753f
+#endif
Hans de Goede 56753f
+
Hans de Goede 56753f
 #define QXL_UNDEFINED_IO UINT32_MAX
Hans de Goede 56753f
 
Hans de Goede 56753f
 #define QXL_NUM_DIRTY_RECTS 64
Hans de Goede 56753f
@@ -88,6 +92,8 @@ typedef struct PCIQXLDevice {
Hans de Goede 56753f
     /* vram pci bar */
Hans de Goede 56753f
     uint32_t           vram_size;
Hans de Goede 56753f
     MemoryRegion       vram_bar;
Hans de Goede 56753f
+    uint32_t           vram32_size;
Hans de Goede 56753f
+    MemoryRegion       vram32_bar;
Hans de Goede 56753f
 
Hans de Goede 56753f
     /* io bar */
Hans de Goede 56753f
     MemoryRegion       io_bar;
Hans de Goede 56753f
@@ -95,6 +101,7 @@ typedef struct PCIQXLDevice {
Hans de Goede 56753f
     /* user-friendly properties (in megabytes) */
Hans de Goede 56753f
     uint32_t          ram_size_mb;
Hans de Goede 56753f
     uint32_t          vram_size_mb;
Hans de Goede 56753f
+    uint32_t          vram32_size_mb;
Hans de Goede 56753f
 
Hans de Goede 56753f
     /* qxl_render_update state */
Hans de Goede 56753f
     int                render_update_cookie_num;
Hans de Goede 56753f
-- 
Hans de Goede 56753f
1.7.10
Hans de Goede 56753f