summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2017-04-10 14:30:56 +0100
committerFrediano Ziglio <fziglio@redhat.com>2017-04-12 09:17:39 +0100
commit1b674d86e206398b730eec830d09f68605c4d13b (patch)
tree0f0ca98829ff988029a197e289039b93536fa5dc
parent8fb1b0a23ef52155db142e0c140b8fc87a60e8a6 (diff)
Compute automatically memory space in FreeMem
This make easier to change allocation of memory using different memory Bars. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
-rwxr-xr-xqxldod/QxlDod.cpp43
-rwxr-xr-xqxldod/QxlDod.h2
2 files changed, 24 insertions, 21 deletions
diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 66e5d21..e747576 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -4052,7 +4052,7 @@ UINT64 QxlDevice::ReleaseOutput(UINT64 output_id)
RELEASE_RES(*now);
}
next = *(UINT64*)output->data;
- FreeMem(MSPACE_TYPE_VRAM, output);
+ FreeMem(output);
DbgPrint(TRACE_LEVEL_VERBOSE, ("<---%s\n", __FUNCTION__));
return next;
}
@@ -4118,24 +4118,27 @@ void *QxlDevice::AllocMem(UINT32 mspace_type, size_t size, BOOL force)
return ptr;
}
-void QxlDevice::FreeMem(UINT32 mspace_type, void *ptr)
+void QxlDevice::FreeMem(void *ptr)
{
PAGED_CODE();
- ASSERT(m_MSInfo[mspace_type]._mspace);
DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
-#ifdef DBG
- if (!((UINT8 *)ptr >= m_MSInfo[mspace_type].mspace_start &&
- (UINT8 *)ptr < m_MSInfo[mspace_type].mspace_end)) {
- DbgPrint(TRACE_LEVEL_ERROR, ("ASSERT failed @ %s, %p not in [%p, %p) (%d)\n", __FUNCTION__,
- ptr, m_MSInfo[mspace_type].mspace_start,
- m_MSInfo[mspace_type].mspace_end, mspace_type));
+ for (const MspaceInfo *info = m_MSInfo; ; ++info)
+ {
+ if (info == m_MSInfo + _countof(m_MSInfo))
+ {
+ DbgPrint(TRACE_LEVEL_ERROR, ("ASSERT failed @ %s, %p not in device memory\n",
+ __FUNCTION__, ptr));
+ break;
+ }
+ if (info->_mspace && ptr >= info->mspace_start && ptr < info->mspace_end)
+ {
+ BOOLEAN locked = WaitForObject(&m_MemLock, NULL);
+ mspace_free(info->_mspace, ptr);
+ ReleaseMutex(&m_MemLock, locked);
+ break;
+ }
}
-#endif
- BOOLEAN locked = FALSE;
- locked = WaitForObject(&m_MemLock, NULL);
- mspace_free(m_MSInfo[mspace_type]._mspace, ptr);
- ReleaseMutex(&m_MemLock, locked);
DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
}
@@ -4258,9 +4261,9 @@ void QxlDevice::FreeClipRects(Resource *res)
while (chunk_phys) {
QXLDataChunk *chunk = (QXLDataChunk *)VA(chunk_phys, m_SurfaceMemSlot);
chunk_phys = chunk->next_chunk;
- FreeMem(MSPACE_TYPE_VRAM, chunk);
+ FreeMem(chunk);
}
- FreeMem(MSPACE_TYPE_VRAM, res);
+ FreeMem(res);
DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
}
@@ -4285,10 +4288,10 @@ void QxlDevice::FreeBitmapImage(Resource *res)
while (chunk_phys) {
QXLDataChunk *chunk = (QXLDataChunk *)VA(chunk_phys, m_SurfaceMemSlot);
chunk_phys = chunk->next_chunk;
- FreeMem(MSPACE_TYPE_VRAM, chunk);
+ FreeMem(chunk);
}
- FreeMem(MSPACE_TYPE_VRAM, res);
+ FreeMem(res);
DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
}
@@ -4310,10 +4313,10 @@ void QxlDevice::FreeCursor(Resource *res)
while (chunk_phys) {
QXLDataChunk *chunk = (QXLDataChunk *)VA(chunk_phys, m_SurfaceMemSlot);
chunk_phys = chunk->next_chunk;
- FreeMem(MSPACE_TYPE_VRAM, chunk);
+ FreeMem(chunk);
}
- FreeMem(MSPACE_TYPE_VRAM, res);
+ FreeMem(res);
DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
}
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index 6e5beee..db7bc8b 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -590,7 +590,7 @@ private:
NTSTATUS InitMonitorConfig();
void InitMspace(UINT32 mspace_type, UINT8 *start, size_t capacity);
void FlushReleaseRing();
- void FreeMem(UINT32 mspace_type, void *ptr);
+ void FreeMem(void *ptr);
UINT64 ReleaseOutput(UINT64 output_id);
void WaitForReleaseRing(void);
void EmptyReleaseRing(void);