[PATCH qxl-wddm-dod 3/8] Allocate m_MemSlots statically inside QxlDevice

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

 



There were always 2 slots used so make no sense to allocate
always dynamically.
Also in this way m_MainMemSlot and m_SurfaceMemSlot become
constant making the code slightly smaller.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 qxldod/QxlDod.cpp | 39 ++++++++++++++-------------------------
 qxldod/QxlDod.h   |  7 +++----
 2 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index d29bce8..f8f3e6d 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -3537,24 +3537,14 @@ BOOL QxlDevice::InitMemSlots(void)
     m_SlotGenBits = m_RomHdr->slot_gen_bits;
     m_SlotIdBits = m_RomHdr->slot_id_bits;
     m_VaSlotMask = (~(uint64_t)0) >> (m_SlotIdBits + m_SlotGenBits);
-    size_t size = m_RomHdr->slots_end * sizeof(MemSlot);
-    m_MemSlots = reinterpret_cast<MemSlot*>
-                                (new (PagedPool) BYTE[size]);
-    if (m_MemSlots)
-    {
-        RtlZeroMemory(m_MemSlots, size);
-        return TRUE;
-    }
-    DbgPrint(TRACE_LEVEL_ERROR, ("---> %s Failed to init mem slot\n", __FUNCTION__));
-    return FALSE;
+    RtlZeroMemory(m_MemSlots, sizeof(m_MemSlots));
+    return TRUE;
 }
 
 void QxlDevice::DestroyMemSlots(void)
 {
     PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
-    delete [] reinterpret_cast<BYTE*>(m_MemSlots);
-    m_MemSlots = NULL;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
@@ -3682,7 +3672,7 @@ void QxlDevice::SyncIo(UCHAR  Port, UCHAR Value)
     ReleaseMutex(&m_IoLock, locked);
 }
 
-UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend)
+void QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend)
 {
     PAGED_CODE();
     UINT64 high_bits;
@@ -3691,7 +3681,7 @@ UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 va
 
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     slot_index = m_RomHdr->slots_start + Idx;
-    pSlot = &m_MemSlots[slot_index];
+    pSlot = &m_MemSlots[Idx];
     pSlot->start_phys_addr = pastart;
     pSlot->end_phys_addr = paend;
     pSlot->start_virt_addr = vastart;
@@ -3705,7 +3695,6 @@ UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 va
     high_bits <<= (64 - (m_SlotGenBits + m_SlotIdBits));
     pSlot->high_bits = high_bits;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
-    return slot_index;
 }
 
 BOOL QxlDevice::CreateMemSlots(void)
@@ -3713,17 +3702,17 @@ BOOL QxlDevice::CreateMemSlots(void)
     PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s 3\n", __FUNCTION__));
     UINT64 len = m_RomHdr->surface0_area_size + m_RomHdr->num_pages * PAGE_SIZE;
-    m_MainMemSlot = SetupMemSlot(0,
-                                (UINT64)m_RamPA.QuadPart, 
-                                (UINT64)(m_RamPA.QuadPart + len),
-                                (UINT64)m_RamStart,
-                                (UINT64)(m_RamStart + len));
+    SetupMemSlot(m_MainMemSlot,
+                 (UINT64)m_RamPA.QuadPart,
+                 (UINT64)(m_RamPA.QuadPart + len),
+                 (UINT64)m_RamStart,
+                 (UINT64)(m_RamStart + len));
     len = m_VRamSize;
-    m_SurfaceMemSlot = SetupMemSlot(1,
-                                (UINT64)m_VRamPA.QuadPart,
-                                (UINT64)(m_VRamPA.QuadPart + len),
-                                (UINT64)m_VRamStart,
-                                (UINT64)(m_VRamStart + len));
+    SetupMemSlot(m_SurfaceMemSlot,
+                 (UINT64)m_VRamPA.QuadPart,
+                 (UINT64)(m_VRamPA.QuadPart + len),
+                 (UINT64)m_VRamStart,
+                 (UINT64)(m_VRamStart + len));
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
     return TRUE;
 }
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index 9702314..c8b9873 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -574,7 +574,7 @@ private:
     void CreatePrimarySurface(PVIDEO_MODE_INFORMATION pModeInfo);
     void DestroyPrimarySurface(void);
     void SetupHWSlot(UINT8 Idx, MemSlot *pSlot);
-    UINT8 SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend);
+    void SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend);
     BOOL CreateEvents(void);
     BOOL CreateRings(void);
     UINT64 VA(QXLPHYSICAL paddr, UINT8 slot_id);
@@ -636,9 +636,8 @@ private:
     QXLRom *m_RomHdr;
     ULONG m_RomSize;
 
-    MemSlot *m_MemSlots;
-    UINT8 m_MainMemSlot;
-    UINT8 m_SurfaceMemSlot;
+    MemSlot m_MemSlots[2];
+    enum { m_MainMemSlot = 0, m_SurfaceMemSlot = 1 };
     UINT8 m_SlotIdBits;
     UINT8 m_SlotGenBits;
     QXLPHYSICAL m_VaSlotMask;
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]