summaryrefslogtreecommitdiff
path: root/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c
diff options
context:
space:
mode:
authorWengang Wu <wgw@motorola.com>2014-05-21 09:29:41 -0500
committerWengang Wu <wgw@motorola.com>2014-05-21 09:29:41 -0500
commit53a835f5057367679eb3db728bbdd427aab8aa8a (patch)
tree03e5bbde7d371e885d1c67210b2b0c9bb0130d40 /drivers/gpu/pvr/services4/srvkm/env/linux/mm.c
parent7489b569ffb64cdb998544405b6774bd43aab70b (diff)
downloadolio-linux-3.10-53a835f5057367679eb3db728bbdd427aab8aa8a.tar.xz
olio-linux-3.10-53a835f5057367679eb3db728bbdd427aab8aa8a.zip
IKXCLOCK-1501 Upgrade to TI SGX Android OpenGL 1.12@2701748
Initial codes of TI SGX DDK 1.12@2701748 Change-Id: I75a8f6521968346ea1b2ea9fa54817ba186442ce
Diffstat (limited to 'drivers/gpu/pvr/services4/srvkm/env/linux/mm.c')
-rwxr-xr-x[-rw-r--r--]drivers/gpu/pvr/services4/srvkm/env/linux/mm.c708
1 files changed, 234 insertions, 474 deletions
diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c b/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c
index 0815e464597..c5a9b9b0bf6 100644..100755
--- a/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c
+++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c
@@ -89,12 +89,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "lists.h"
#endif
-/* If there is no explicit definition
- * for the minimum DMM alignment size,
- * then set it to "0" and let ION/DMM
- * set the minimum value. */
-#ifndef CONFIG_TILER_GRANULARITY
-#define CONFIG_TILER_GRANULARITY 0
+/* Decide whether or not DevMem allocs need __GFP_DMA32 */
+#ifndef SGX_FEATURE_36BIT_MMU
+# ifdef CONFIG_ZONE_DMA32
+# if defined CONFIG_X86_PAE || defined CONFIG_ARM_LPAE || defined CONFIG_64BIT
+# define PVR_USE_DMA32_FOR_DEVMEM_ALLOCS
+# endif
+# endif
#endif
/*
@@ -106,7 +107,7 @@ static atomic_t g_sPagePoolEntryCount = ATOMIC_INIT(0);
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
typedef enum {
- DEBUG_MEM_ALLOC_TYPE_KMALLOC,
+ DEBUG_MEM_ALLOC_TYPE_KMALLOC = 0,
DEBUG_MEM_ALLOC_TYPE_VMALLOC,
DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES,
DEBUG_MEM_ALLOC_TYPE_IOREMAP,
@@ -122,11 +123,11 @@ typedef enum {
typedef struct _DEBUG_MEM_ALLOC_REC
{
DEBUG_MEM_ALLOC_TYPE eAllocType;
- IMG_VOID *pvKey; /* Some unique value (private to the eAllocType) */
+ IMG_UINTPTR_T uiKey; /* Some unique value (private to the eAllocType) */
IMG_VOID *pvCpuVAddr;
- IMG_UINT32 ulCpuPAddr;
+ IMG_CPU_PHYADDR sCpuPAddr;
IMG_VOID *pvPrivateData;
- IMG_UINT32 ui32Bytes;
+ IMG_SIZE_T uiBytes;
pid_t pid;
IMG_CHAR *pszFileName;
IMG_UINT32 ui32Line;
@@ -162,20 +163,20 @@ static IMG_UINT32 g_IOMemWaterMark;
static IMG_UINT32 g_IOMemHighWaterMark;
static IMG_VOID DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType,
- IMG_VOID *pvKey,
+ IMG_UINTPTR_T uiKey,
IMG_VOID *pvCpuVAddr,
- IMG_UINT32 ulCpuPAddr,
+ IMG_CPU_PHYADDR sCpuPAddr,
IMG_VOID *pvPrivateData,
- IMG_UINT32 ui32Bytes,
+ IMG_SIZE_T uiBytes,
IMG_CHAR *pszFileName,
IMG_UINT32 ui32Line);
-static IMG_VOID DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_VOID *pvKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line);
+static IMG_VOID DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_UINTPTR_T uiKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line);
static IMG_CHAR *DebugMemAllocRecordTypeToString(DEBUG_MEM_ALLOC_TYPE eAllocType);
-static struct proc_dir_entry *g_SeqFileMemoryRecords;
+static struct pvr_proc_dir_entry *g_SeqFileMemoryRecords;
static void* ProcSeqNextMemoryRecords(struct seq_file *sfile,void* el,loff_t off);
static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el);
static void* ProcSeqOff2ElementMemoryRecords(struct seq_file * sfile, loff_t off);
@@ -209,12 +210,11 @@ static IMG_UINT32 g_LinuxMemAreaWaterMark;
static IMG_UINT32 g_LinuxMemAreaHighWaterMark;
-static struct proc_dir_entry *g_SeqFileMemArea;
+static struct pvr_proc_dir_entry *g_SeqFileMemArea;
static void* ProcSeqNextMemArea(struct seq_file *sfile,void* el,loff_t off);
static void ProcSeqShowMemArea(struct seq_file *sfile,void* el);
static void* ProcSeqOff2ElementMemArea(struct seq_file *sfile, loff_t off);
-
#endif
#if defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
@@ -240,8 +240,8 @@ static LIST_HEAD(g_sPagePoolList);
static int g_iPagePoolMaxEntries;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15))
-static IMG_VOID ReservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length);
-static IMG_VOID UnreservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length);
+static IMG_VOID ReservePages(IMG_VOID *pvAddress, IMG_SIZE_T uiLength);
+static IMG_VOID UnreservePages(IMG_VOID *pvAddress, IMG_SIZE_T uiLength);
#endif
static LinuxMemArea *LinuxMemAreaStructAlloc(IMG_VOID);
@@ -266,19 +266,22 @@ CanFreeToPool(LinuxMemArea *psLinuxMemArea)
}
IMG_VOID *
-_KMallocWrapper(IMG_UINT32 ui32ByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
+_KMallocWrapper(IMG_SIZE_T uiByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
IMG_VOID *pvRet;
- pvRet = kmalloc(ui32ByteSize, uFlags);
+ pvRet = kmalloc(uiByteSize, uFlags);
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
if (pvRet)
{
+ IMG_CPU_PHYADDR sCpuPAddr;
+ sCpuPAddr.uiAddr = 0;
+
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_KMALLOC,
+ (IMG_UINTPTR_T)pvRet,
pvRet,
- pvRet,
- 0,
+ sCpuPAddr,
NULL,
- ui32ByteSize,
+ uiByteSize,
pszFileName,
ui32Line
);
@@ -295,7 +298,11 @@ IMG_VOID
_KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_KMALLOC, pvCpuVAddr, pszFileName, ui32Line);
+ DebugMemAllocRecordRemove(
+ DEBUG_MEM_ALLOC_TYPE_KMALLOC,
+ (IMG_UINTPTR_T)pvCpuVAddr,
+ pszFileName,
+ ui32Line);
#else
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(ui32Line);
@@ -307,33 +314,33 @@ _KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
static IMG_VOID
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType,
- IMG_VOID *pvKey,
+ IMG_UINTPTR_T uiKey,
IMG_VOID *pvCpuVAddr,
- IMG_UINT32 ulCpuPAddr,
+ IMG_CPU_PHYADDR sCpuPAddr,
IMG_VOID *pvPrivateData,
- IMG_UINT32 ui32Bytes,
+ IMG_SIZE_T uiBytes,
IMG_CHAR *pszFileName,
IMG_UINT32 ui32Line)
{
DEBUG_MEM_ALLOC_REC *psRecord;
- LinuxLockMutex(&g_sDebugMutex);
+ LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
psRecord = kmalloc(sizeof(DEBUG_MEM_ALLOC_REC), GFP_KERNEL);
psRecord->eAllocType = eAllocType;
- psRecord->pvKey = pvKey;
+ psRecord->uiKey = uiKey;
psRecord->pvCpuVAddr = pvCpuVAddr;
- psRecord->ulCpuPAddr = ulCpuPAddr;
+ psRecord->sCpuPAddr.uiAddr = sCpuPAddr.uiAddr;
psRecord->pvPrivateData = pvPrivateData;
psRecord->pid = OSGetCurrentProcessIDKM();
- psRecord->ui32Bytes = ui32Bytes;
+ psRecord->uiBytes = uiBytes;
psRecord->pszFileName = pszFileName;
psRecord->ui32Line = ui32Line;
List_DEBUG_MEM_ALLOC_REC_Insert(&g_MemoryRecords, psRecord);
- g_WaterMarkData[eAllocType] += ui32Bytes;
+ g_WaterMarkData[eAllocType] += uiBytes;
if (g_WaterMarkData[eAllocType] > g_HighWaterMarkData[eAllocType])
{
g_HighWaterMarkData[eAllocType] = g_WaterMarkData[eAllocType];
@@ -344,20 +351,20 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType,
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE)
{
- IMG_UINT32 ui32SysRAMTrueWaterMark;
+ IMG_SIZE_T uSysRAMTrueWaterMark;
- g_SysRAMWaterMark += ui32Bytes;
- ui32SysRAMTrueWaterMark = SysRAMTrueWaterMark();
+ g_SysRAMWaterMark += uiBytes;
+ uSysRAMTrueWaterMark = SysRAMTrueWaterMark();
- if (ui32SysRAMTrueWaterMark > g_SysRAMHighWaterMark)
+ if (uSysRAMTrueWaterMark > g_SysRAMHighWaterMark)
{
- g_SysRAMHighWaterMark = ui32SysRAMTrueWaterMark;
+ g_SysRAMHighWaterMark = uSysRAMTrueWaterMark;
}
}
else if (eAllocType == DEBUG_MEM_ALLOC_TYPE_IOREMAP
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_IO)
{
- g_IOMemWaterMark += ui32Bytes;
+ g_IOMemWaterMark += uiBytes;
if (g_IOMemWaterMark > g_IOMemHighWaterMark)
{
g_IOMemHighWaterMark = g_IOMemWaterMark;
@@ -371,28 +378,28 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType,
static IMG_BOOL DebugMemAllocRecordRemove_AnyVaCb(DEBUG_MEM_ALLOC_REC *psCurrentRecord, va_list va)
{
DEBUG_MEM_ALLOC_TYPE eAllocType;
- IMG_VOID *pvKey;
+ IMG_UINTPTR_T uiKey;
eAllocType = va_arg(va, DEBUG_MEM_ALLOC_TYPE);
- pvKey = va_arg(va, IMG_VOID*);
+ uiKey = va_arg(va, IMG_UINTPTR_T);
if (psCurrentRecord->eAllocType == eAllocType
- && psCurrentRecord->pvKey == pvKey)
+ && psCurrentRecord->uiKey == uiKey)
{
eAllocType = psCurrentRecord->eAllocType;
- g_WaterMarkData[eAllocType] -= psCurrentRecord->ui32Bytes;
+ g_WaterMarkData[eAllocType] -= psCurrentRecord->uiBytes;
if (eAllocType == DEBUG_MEM_ALLOC_TYPE_KMALLOC
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_VMALLOC
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE)
{
- g_SysRAMWaterMark -= psCurrentRecord->ui32Bytes;
+ g_SysRAMWaterMark -= psCurrentRecord->uiBytes;
}
else if (eAllocType == DEBUG_MEM_ALLOC_TYPE_IOREMAP
|| eAllocType == DEBUG_MEM_ALLOC_TYPE_IO)
{
- g_IOMemWaterMark -= psCurrentRecord->ui32Bytes;
+ g_IOMemWaterMark -= psCurrentRecord->uiBytes;
}
List_DEBUG_MEM_ALLOC_REC_Remove(psCurrentRecord);
@@ -408,20 +415,20 @@ static IMG_BOOL DebugMemAllocRecordRemove_AnyVaCb(DEBUG_MEM_ALLOC_REC *psCurrent
static IMG_VOID
-DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_VOID *pvKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
+DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_UINTPTR_T uiKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
/* DEBUG_MEM_ALLOC_REC **ppsCurrentRecord;*/
- LinuxLockMutex(&g_sDebugMutex);
+ LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
/* Locate the corresponding allocation entry */
if (!List_DEBUG_MEM_ALLOC_REC_IMG_BOOL_Any_va(g_MemoryRecords,
DebugMemAllocRecordRemove_AnyVaCb,
eAllocType,
- pvKey))
+ uiKey))
{
- PVR_DPF((PVR_DBG_ERROR, "%s: couldn't find an entry for type=%s with pvKey=%p (called from %s, line %d\n",
- __FUNCTION__, DebugMemAllocRecordTypeToString(eAllocType), pvKey,
+ PVR_DPF((PVR_DBG_ERROR, "%s: couldn't find an entry for type=%s with uiKey=" UINTPTR_FMT " (called from %s, line %d\n",
+ __FUNCTION__, DebugMemAllocRecordTypeToString(eAllocType), uiKey,
pszFileName, ui32Line));
}
@@ -439,8 +446,9 @@ DebugMemAllocRecordTypeToString(DEBUG_MEM_ALLOC_TYPE eAllocType)
"IOREMAP",
"IO",
"KMEM_CACHE_ALLOC",
+ "ION",
#if defined(PVR_LINUX_MEM_AREA_USE_VMAP)
- "VMAP"
+ "VMAP",
#endif
};
return apszDebugMemoryRecordTypes[eAllocType];
@@ -478,31 +486,43 @@ AllocFlagsToPGProt(pgprot_t *pPGProtFlags, IMG_UINT32 ui32AllocFlags)
}
IMG_VOID *
-_VMallocWrapper(IMG_UINT32 ui32Bytes,
+_VMallocWrapper(IMG_SIZE_T uiBytes,
IMG_UINT32 ui32AllocFlags,
IMG_CHAR *pszFileName,
IMG_UINT32 ui32Line)
{
pgprot_t PGProtFlags;
IMG_VOID *pvRet;
+ gfp_t gfp_mask;
if (!AllocFlagsToPGProt(&PGProtFlags, ui32AllocFlags))
{
return NULL;
}
+ gfp_mask = GFP_KERNEL;
+
+#if defined(PVR_USE_DMA32_FOR_DEVMEM_ALLOCS)
+ gfp_mask |= __GFP_DMA32;
+#else
+ gfp_mask |= __GFP_HIGHMEM;
+#endif
+
/* Allocate virtually contiguous pages */
- pvRet = __vmalloc(ui32Bytes, GFP_KERNEL | __GFP_HIGHMEM, PGProtFlags);
+ pvRet = __vmalloc(uiBytes, gfp_mask, PGProtFlags);
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
if (pvRet)
{
+ IMG_CPU_PHYADDR sCpuPAddr;
+ sCpuPAddr.uiAddr = 0;
+
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_VMALLOC,
+ (IMG_UINTPTR_T)pvRet,
pvRet,
- pvRet,
- 0,
+ sCpuPAddr,
NULL,
- PAGE_ALIGN(ui32Bytes),
+ PAGE_ALIGN(uiBytes),
pszFileName,
ui32Line
);
@@ -520,7 +540,11 @@ IMG_VOID
_VFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_VMALLOC, pvCpuVAddr, pszFileName, ui32Line);
+ DebugMemAllocRecordRemove(
+ DEBUG_MEM_ALLOC_TYPE_VMALLOC,
+ (IMG_UINTPTR_T)pvCpuVAddr,
+ pszFileName,
+ ui32Line);
#else
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(ui32Line);
@@ -546,10 +570,13 @@ _VMapWrapper(struct page **ppsPageList, IMG_UINT32 ui32NumPages, IMG_UINT32 ui32
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
if (pvRet)
{
+ IMG_CPU_PHYADDR sCpuPAddr;
+ sCpuPAddr.uiAddr = 0;
+
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_VMAP,
+ (IMG_UINTPTR_T)pvRet,
pvRet,
- pvRet,
- 0,
+ sCpuPAddr,
NULL,
PAGES_TO_BYTES(ui32NumPages),
pszFileName,
@@ -565,9 +592,9 @@ _VMapWrapper(struct page **ppsPageList, IMG_UINT32 ui32NumPages, IMG_UINT32 ui32
}
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
-#define VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags) _VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags, __FILE__, __LINE__)
+#define VMapWrapper(ppsPageList, uBytes, ui32AllocFlags) _VMapWrapper(ppsPageList, uBytes, ui32AllocFlags, __FILE__, __LINE__)
#else
-#define VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags) _VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags, NULL, 0)
+#define VMapWrapper(ppsPageList, uBytes, ui32AllocFlags) _VMapWrapper(ppsPageList, uBytes, ui32AllocFlags, NULL, 0)
#endif
@@ -575,7 +602,8 @@ static IMG_VOID
_VUnmapWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_VMAP, pvCpuVAddr, pszFileName, ui32Line);
+ DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_VMAP,
+ (IMG_UINTPTR_T)pvCpuVAddr, pszFileName, ui32Line);
#else
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(ui32Line);
@@ -596,7 +624,11 @@ IMG_VOID
_KMemCacheFreeWrapper(LinuxKMemCache *psCache, IMG_VOID *pvObject, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE, pvObject, pszFileName, ui32Line);
+ DebugMemAllocRecordRemove(
+ DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE,
+ (IMG_UINTPTR_T)pvObject,
+ pszFileName,
+ ui32Line);
#else
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(ui32Line);
@@ -634,13 +666,22 @@ static struct page *
AllocPageFromLinux(void)
{
struct page *psPage;
+ gfp_t gfp_mask;
- psPage = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, 0);
- if (!psPage)
- {
- return NULL;
+ gfp_mask = GFP_KERNEL;
- }
+#if defined(PVR_USE_DMA32_FOR_DEVMEM_ALLOCS)
+ gfp_mask |= __GFP_DMA32;
+#else
+ gfp_mask |= __GFP_HIGHMEM;
+#endif
+
+ psPage = alloc_pages(gfp_mask, 0);
+ if (!psPage)
+ {
+ return NULL;
+
+ }
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15))
/* Reserve those pages to allow them to be re-mapped to user space */
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
@@ -812,7 +853,7 @@ FreePagePool(IMG_VOID)
PagePoolLock();
#if (PVR_LINUX_MEM_AREA_POOL_MAX_PAGES != 0)
- PVR_DPF((PVR_DBG_MESSAGE,"%s: Freeing %d pages from pool", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
+ PVR_TRACE(("%s: Freeing %d pages from pool", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
#else
PVR_ASSERT(atomic_read(&g_sPagePoolEntryCount) == 0);
PVR_ASSERT(list_empty(&g_sPagePoolList));
@@ -848,8 +889,8 @@ ShrinkPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkContr
{
LinuxPagePoolEntry *psPagePoolEntry, *psTempPoolEntry;
- PVR_DPF((PVR_DBG_MESSAGE,"%s: Number to scan: %ld", __FUNCTION__, uNumToScan));
- PVR_DPF((PVR_DBG_MESSAGE,"%s: Pages in pool before scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
+ PVR_TRACE(("%s: Number to scan: %ld", __FUNCTION__, uNumToScan));
+ PVR_TRACE(("%s: Pages in pool before scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
if (!PagePoolTrylock())
{
@@ -877,7 +918,7 @@ ShrinkPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkContr
PagePoolUnlock();
- PVR_DPF((PVR_DBG_MESSAGE,"%s: Pages in pool after scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
+ PVR_TRACE(("%s: Pages in pool after scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
}
return atomic_read(&g_sPagePoolEntryCount);
@@ -893,6 +934,10 @@ AllocPages(IMG_UINT32 ui32AreaFlags, struct page ***pppsPageList, IMG_HANDLE *ph
PVRSRV_ERROR eError;
IMG_BOOL bFromPagePool = IMG_FALSE;
+#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
+ IMG_CPU_PHYADDR sCpuPAddr;
+#endif
+
eError = OSAllocMem(0, sizeof(*ppsPageList) * ui32NumPages, (IMG_VOID **)&ppsPageList, &hBlockPageList,
"Array of pages");
if (eError != PVRSRV_OK)
@@ -915,10 +960,12 @@ AllocPages(IMG_UINT32 ui32AreaFlags, struct page ***pppsPageList, IMG_HANDLE *ph
*phBlockPageList = hBlockPageList;
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
+ sCpuPAddr.uiAddr = 0;
+
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES,
- ppsPageList,
- 0,
+ (IMG_UINTPTR_T)ppsPageList,
0,
+ sCpuPAddr,
NULL,
PAGES_TO_BYTES(ui32NumPages),
"unknown",
@@ -951,7 +998,11 @@ FreePages(IMG_BOOL bToPagePool, struct page **ppsPageList, IMG_HANDLE hBlockPage
}
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, ppsPageList, __FILE__, __LINE__);
+ DebugMemAllocRecordRemove(
+ DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES,
+ (IMG_UINTPTR_T)ppsPageList,
+ __FILE__,
+ __LINE__);
#endif
(IMG_VOID) OSFreeMem(0, sizeof(*ppsPageList) * ui32NumPages, ppsPageList, hBlockPageList);
@@ -959,7 +1010,7 @@ FreePages(IMG_BOOL bToPagePool, struct page **ppsPageList, IMG_HANDLE hBlockPage
LinuxMemArea *
-NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
+NewVMallocLinuxMemArea(IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags)
{
LinuxMemArea *psLinuxMemArea = NULL;
IMG_VOID *pvCpuVAddr;
@@ -977,7 +1028,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
}
#if defined(PVR_LINUX_MEM_AREA_USE_VMAP)
- ui32NumPages = RANGE_TO_PAGES(ui32Bytes);
+ ui32NumPages = RANGE_TO_PAGES(uBytes);
if (!AllocPages(ui32AreaFlags, &ppsPageList, &hBlockPageList, ui32NumPages, &bFromPagePool))
{
@@ -986,7 +1037,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
pvCpuVAddr = VMapWrapper(ppsPageList, ui32NumPages, ui32AreaFlags);
#else /* defined(PVR_LINUX_MEM_AREA_USE_VMAP) */
- pvCpuVAddr = VMallocWrapper(ui32Bytes, ui32AreaFlags);
+ pvCpuVAddr = VMallocWrapper(uBytes, ui32AreaFlags);
if (!pvCpuVAddr)
{
goto failed;
@@ -994,7 +1045,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
/* PG_reserved was deprecated in linux-2.6.15 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15))
/* Reserve those pages to allow them to be re-mapped to user space */
- ReservePages(pvCpuVAddr, ui32Bytes);
+ ReservePages(pvCpuVAddr, uBytes);
#endif
#endif /* defined(PVR_LINUX_MEM_AREA_USE_VMAP) */
@@ -1004,7 +1055,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
psLinuxMemArea->uData.sVmalloc.ppsPageList = ppsPageList;
psLinuxMemArea->uData.sVmalloc.hBlockPageList = hBlockPageList;
#endif
- psLinuxMemArea->ui32ByteSize = ui32Bytes;
+ psLinuxMemArea->uiByteSize = uBytes;
psLinuxMemArea->ui32AreaFlags = ui32AreaFlags;
INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
@@ -1029,7 +1080,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
*/
if (AreaIsUncached(ui32AreaFlags) && !bFromPagePool)
{
- OSInvalidateCPUCacheRangeKM(psLinuxMemArea, 0, pvCpuVAddr, ui32Bytes);
+ OSInvalidateCPUCacheRangeKM(psLinuxMemArea, 0, pvCpuVAddr, uBytes);
}
return psLinuxMemArea;
@@ -1074,7 +1125,7 @@ FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea)
#if defined(PVR_LINUX_MEM_AREA_USE_VMAP)
VUnmapWrapper(psLinuxMemArea->uData.sVmalloc.pvVmallocAddress);
- ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->ui32ByteSize);
+ ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->uiByteSize);
ppsPageList = psLinuxMemArea->uData.sVmalloc.ppsPageList;
hBlockPageList = psLinuxMemArea->uData.sVmalloc.hBlockPageList;
@@ -1083,7 +1134,7 @@ FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea)
/* PG_reserved was deprecated in linux-2.6.15 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15))
UnreservePages(psLinuxMemArea->uData.sVmalloc.pvVmallocAddress,
- psLinuxMemArea->ui32ByteSize);
+ psLinuxMemArea->uiByteSize);
#endif
VFreeWrapper(psLinuxMemArea->uData.sVmalloc.pvVmallocAddress);
@@ -1097,10 +1148,10 @@ FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea)
/* Reserve pages of memory in order that they're not automatically
deallocated after the last user reference dies. */
static IMG_VOID
-ReservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length)
+ReservePages(IMG_VOID *pvAddress, IMG_SIZE_T uLength)
{
IMG_VOID *pvPage;
- IMG_VOID *pvEnd = pvAddress + ui32Length;
+ IMG_VOID *pvEnd = pvAddress + uLength;
for(pvPage = pvAddress; pvPage < pvEnd; pvPage += PAGE_SIZE)
{
@@ -1115,10 +1166,10 @@ ReservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length)
/* Un-reserve pages of memory in order that they can be freed. */
static IMG_VOID
-UnreservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length)
+UnreservePages(IMG_VOID *pvAddress, IMG_SIZE_T uLength)
{
IMG_VOID *pvPage;
- IMG_VOID *pvEnd = pvAddress + ui32Length;
+ IMG_VOID *pvEnd = pvAddress + uLength;
for(pvPage = pvAddress; pvPage < pvEnd; pvPage += PAGE_SIZE)
{
@@ -1134,7 +1185,7 @@ UnreservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length)
IMG_VOID *
_IORemapWrapper(IMG_CPU_PHYADDR BasePAddr,
- IMG_UINT32 ui32Bytes,
+ IMG_SIZE_T uBytes,
IMG_UINT32 ui32MappingFlags,
IMG_CHAR *pszFileName,
IMG_UINT32 ui32Line)
@@ -1144,13 +1195,13 @@ _IORemapWrapper(IMG_CPU_PHYADDR BasePAddr,
switch (ui32MappingFlags & PVRSRV_HAP_CACHETYPE_MASK)
{
case PVRSRV_HAP_CACHED:
- pvIORemapCookie = (IMG_VOID *)IOREMAP(BasePAddr.uiAddr, ui32Bytes);
+ pvIORemapCookie = (IMG_VOID *)IOREMAP(BasePAddr.uiAddr, uBytes);
break;
case PVRSRV_HAP_WRITECOMBINE:
- pvIORemapCookie = (IMG_VOID *)IOREMAP_WC(BasePAddr.uiAddr, ui32Bytes);
+ pvIORemapCookie = (IMG_VOID *)IOREMAP_WC(BasePAddr.uiAddr, uBytes);
break;
case PVRSRV_HAP_UNCACHED:
- pvIORemapCookie = (IMG_VOID *)IOREMAP_UC(BasePAddr.uiAddr, ui32Bytes);
+ pvIORemapCookie = (IMG_VOID *)IOREMAP_UC(BasePAddr.uiAddr, uBytes);
break;
default:
PVR_DPF((PVR_DBG_ERROR, "IORemapWrapper: unknown mapping flags"));
@@ -1161,11 +1212,11 @@ _IORemapWrapper(IMG_CPU_PHYADDR BasePAddr,
if (pvIORemapCookie)
{
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_IOREMAP,
+ (IMG_UINTPTR_T)pvIORemapCookie,
pvIORemapCookie,
- pvIORemapCookie,
- BasePAddr.uiAddr,
+ BasePAddr,
NULL,
- ui32Bytes,
+ uBytes,
pszFileName,
ui32Line
);
@@ -1183,7 +1234,11 @@ IMG_VOID
_IOUnmapWrapper(IMG_VOID *pvIORemapCookie, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
{
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IOREMAP, pvIORemapCookie, pszFileName, ui32Line);
+ DebugMemAllocRecordRemove(
+ DEBUG_MEM_ALLOC_TYPE_IOREMAP,
+ (IMG_UINTPTR_T)pvIORemapCookie,
+ pszFileName,
+ ui32Line);
#else
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(ui32Line);
@@ -1194,7 +1249,7 @@ _IOUnmapWrapper(IMG_VOID *pvIORemapCookie, IMG_CHAR *pszFileName, IMG_UINT32 ui3
LinuxMemArea *
NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr,
- IMG_UINT32 ui32Bytes,
+ IMG_SIZE_T uBytes,
IMG_UINT32 ui32AreaFlags)
{
LinuxMemArea *psLinuxMemArea;
@@ -1206,7 +1261,7 @@ NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr,
return NULL;
}
- pvIORemapCookie = IORemapWrapper(BasePAddr, ui32Bytes, ui32AreaFlags);
+ pvIORemapCookie = IORemapWrapper(BasePAddr, uBytes, ui32AreaFlags);
if (!pvIORemapCookie)
{
LinuxMemAreaStructFree(psLinuxMemArea);
@@ -1216,7 +1271,7 @@ NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr,
psLinuxMemArea->eAreaType = LINUX_MEM_AREA_IOREMAP;
psLinuxMemArea->uData.sIORemap.pvIORemapCookie = pvIORemapCookie;
psLinuxMemArea->uData.sIORemap.CPUPhysAddr = BasePAddr;
- psLinuxMemArea->ui32ByteSize = ui32Bytes;
+ psLinuxMemArea->uiByteSize = uBytes;
psLinuxMemArea->ui32AreaFlags = ui32AreaFlags;
INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
@@ -1255,11 +1310,11 @@ FreeIORemapLinuxMemArea(LinuxMemArea *psLinuxMemArea)
* using memory wrapping, which ends up creating an external KV memory area.
*/
static IMG_BOOL
-TreatExternalPagesAsContiguous(IMG_SYS_PHYADDR *psSysPhysAddr, IMG_UINT32 ui32Bytes, IMG_BOOL bPhysContig)
+TreatExternalPagesAsContiguous(IMG_SYS_PHYADDR *psSysPhysAddr, IMG_SIZE_T uBytes, IMG_BOOL bPhysContig)
{
IMG_UINT32 ui32;
IMG_UINT32 ui32AddrChk;
- IMG_UINT32 ui32NumPages = RANGE_TO_PAGES(ui32Bytes);
+ IMG_UINT32 ui32NumPages = RANGE_TO_PAGES(uBytes);
/*
* If bPhysContig is IMG_TRUE, we must assume psSysPhysAddr points
@@ -1296,7 +1351,7 @@ TreatExternalPagesAsContiguous(IMG_SYS_PHYADDR *psSysPhysAddr, IMG_UINT32 ui32By
}
#endif
-LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_UINT32 ui32Bytes, IMG_BOOL bPhysContig, IMG_UINT32 ui32AreaFlags)
+LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_SIZE_T uBytes, IMG_BOOL bPhysContig, IMG_UINT32 ui32AreaFlags)
{
LinuxMemArea *psLinuxMemArea;
@@ -1310,7 +1365,7 @@ LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *p
psLinuxMemArea->uData.sExternalKV.pvExternalKV = pvCPUVAddr;
psLinuxMemArea->uData.sExternalKV.bPhysContig =
#if !defined(PVR_MAKE_ALL_PFNS_SPECIAL)
- (bPhysContig || TreatExternalPagesAsContiguous(pBasePAddr, ui32Bytes, bPhysContig))
+ (bPhysContig || TreatExternalPagesAsContiguous(pBasePAddr, uBytes, bPhysContig))
? IMG_TRUE : IMG_FALSE;
#else
bPhysContig;
@@ -1323,7 +1378,7 @@ LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *p
{
psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr = pBasePAddr;
}
- psLinuxMemArea->ui32ByteSize = ui32Bytes;
+ psLinuxMemArea->uiByteSize = uBytes;
psLinuxMemArea->ui32AreaFlags = ui32AreaFlags;
INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
@@ -1350,7 +1405,7 @@ FreeExternalKVLinuxMemArea(LinuxMemArea *psLinuxMemArea)
LinuxMemArea *
NewIOLinuxMemArea(IMG_CPU_PHYADDR BasePAddr,
- IMG_UINT32 ui32Bytes,
+ IMG_SIZE_T uBytes,
IMG_UINT32 ui32AreaFlags)
{
LinuxMemArea *psLinuxMemArea = LinuxMemAreaStructAlloc();
@@ -1362,17 +1417,17 @@ NewIOLinuxMemArea(IMG_CPU_PHYADDR BasePAddr,
/* Nothing to activly do. We just keep a record of the physical range. */
psLinuxMemArea->eAreaType = LINUX_MEM_AREA_IO;
psLinuxMemArea->uData.sIO.CPUPhysAddr.uiAddr = BasePAddr.uiAddr;
- psLinuxMemArea->ui32ByteSize = ui32Bytes;
+ psLinuxMemArea->uiByteSize = uBytes;
psLinuxMemArea->ui32AreaFlags = ui32AreaFlags;
INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_IO,
- (IMG_VOID *)BasePAddr.uiAddr,
- 0,
BasePAddr.uiAddr,
+ 0,
+ BasePAddr,
NULL,
- ui32Bytes,
+ uBytes,
"unknown",
0
);
@@ -1397,7 +1452,9 @@ FreeIOLinuxMemArea(LinuxMemArea *psLinuxMemArea)
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IO,
- (IMG_VOID *)psLinuxMemArea->uData.sIO.CPUPhysAddr.uiAddr, __FILE__, __LINE__);
+ psLinuxMemArea->uData.sIO.CPUPhysAddr.uiAddr,
+ __FILE__,
+ __LINE__);
#endif
/* Nothing more to do than free the LinuxMemArea struct */
@@ -1407,7 +1464,7 @@ FreeIOLinuxMemArea(LinuxMemArea *psLinuxMemArea)
LinuxMemArea *
-NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
+NewAllocPagesLinuxMemArea(IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags)
{
LinuxMemArea *psLinuxMemArea;
IMG_UINT32 ui32NumPages;
@@ -1421,7 +1478,7 @@ NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
goto failed_area_alloc;
}
- ui32NumPages = RANGE_TO_PAGES(ui32Bytes);
+ ui32NumPages = RANGE_TO_PAGES(uBytes);
if (!AllocPages(ui32AreaFlags, &ppsPageList, &hBlockPageList, ui32NumPages, &bFromPagePool))
{
@@ -1431,7 +1488,7 @@ NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags)
psLinuxMemArea->eAreaType = LINUX_MEM_AREA_ALLOC_PAGES;
psLinuxMemArea->uData.sPageList.ppsPageList = ppsPageList;
psLinuxMemArea->uData.sPageList.hBlockPageList = hBlockPageList;
- psLinuxMemArea->ui32ByteSize = ui32Bytes;
+ psLinuxMemArea->uiByteSize = uBytes;
psLinuxMemArea->ui32AreaFlags = ui32AreaFlags;
INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
@@ -1467,7 +1524,7 @@ FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea)
DebugLinuxMemAreaRecordRemove(psLinuxMemArea);
#endif
- ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->ui32ByteSize);
+ ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->uiByteSize);
ppsPageList = psLinuxMemArea->uData.sPageList.ppsPageList;
hBlockPageList = psLinuxMemArea->uData.sPageList.hBlockPageList;
@@ -1476,315 +1533,29 @@ FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea)
LinuxMemAreaStructFree(psLinuxMemArea);
}
-#if defined(CONFIG_ION_OMAP)
-
-#include "env_perproc.h"
-
-#include <linux/ion.h>
-#include <linux/omap_ion.h>
-#include <linux/scatterlist.h>
-
-extern struct ion_client *gpsIONClient;
-
-LinuxMemArea *
-NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags,
- IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength)
-{
- const IMG_UINT32 ui32AllocDataLen =
- offsetof(struct omap_ion_tiler_alloc_data, handle);
- struct omap_ion_tiler_alloc_data asAllocData[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES];
- u32 *pu32PageAddrs[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES] = { NULL, NULL, NULL};
- IMG_UINT32 i, j, ui32NumHandlesPerFd;
- IMG_BYTE *pbPrivData = pvPrivData;
- IMG_CPU_PHYADDR *pCPUPhysAddrs;
- IMG_UINT32 iNumPages[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES] = { 0, 0, 0};
- LinuxMemArea *psLinuxMemArea;
- IMG_UINT32 ui32ProcID;
- IMG_UINT32 ui32TotalPagesSizeInBytes = 0, ui32TotalPages = 0;
-
- psLinuxMemArea = LinuxMemAreaStructAlloc();
- if (!psLinuxMemArea)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate LinuxMemArea struct", __func__));
- goto err_out;
- }
-
- /* Depending on the UM config, userspace might give us info for
- * one, two or three ION allocations. Divide the total size of data we
- * were given by this ui32AllocDataLen, and check it's 1 or 2.
- * Otherwise abort.
- */
- BUG_ON(ui32PrivDataLength != ui32AllocDataLen &&
- ui32PrivDataLength != ui32AllocDataLen * 2 &&
- ui32PrivDataLength != ui32AllocDataLen * 3);
- /* This is bad !- change this logic to pass in the size or
- * use uniformed API */
- ui32NumHandlesPerFd = ui32PrivDataLength / ui32AllocDataLen;
-
- ui32ProcID = OSGetCurrentProcessIDKM();
-
- memset(asAllocData, 0x00, sizeof(asAllocData));
-
- /* We do not care about what the first (Y) buffer offset would be,
- * but we do care for the UV buffers to be co-aligned with Y
- * This for SGX to find the UV offset solely based on the height
- * and stride of the YUV buffer.This is very important for OMAP4470
- * and later chipsets, where SGX version is 544. 544 and later use
- * non-shader based YUV to RGB conversion unit that require
- * contiguous GPU virtual space */
- for(i = 0; i < ui32NumHandlesPerFd; i++)
- {
- memcpy(&asAllocData[i], &pbPrivData[i * ui32AllocDataLen], ui32AllocDataLen);
- asAllocData[i].token = ui32ProcID;
-
-#ifndef SGX_DISABLE_DMM_OFFSET_BUFFER_ALLOCATIONS
- if(i == 0)
- {
- /* Tiler API says:
- * Allocate first buffer with the required alignment
- * and an offset of 0 ... */
- asAllocData[i].out_align = CONFIG_TILER_GRANULARITY;
- asAllocData[i].offset = 0;
- }
- else
- { /* .. Then for the second buffer, use the offset from the first
- * buffer with alignment of PAGE_SIZE */
- asAllocData[i].out_align = PAGE_SIZE;
- asAllocData[i].offset = asAllocData[0].offset;
- }
-#else
- asAllocData[i].offset = 0;
- asAllocData[i].out_align = PAGE_SIZE;
-#endif
-
- if(asAllocData[i].fmt == TILER_PIXEL_FMT_PAGE)
- {
- /* 1D DMM Buffers */
- struct scatterlist *sg, *sglist;
- IMG_UINT32 ui32Num1dPages;
-
- asAllocData[i].handle = ion_alloc (gpsIONClient,
- ui32Bytes,
- PAGE_SIZE, (1 << OMAP_ION_HEAP_SYSTEM));
-
- if (asAllocData[i].handle == NULL)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate via ion_alloc",
- __func__));
- goto err_free;
- }
-
- sglist = ion_map_dma (gpsIONClient, asAllocData[i].handle);
- if (sglist == NULL)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to compute pages",
- __func__));
- goto err_free;
- }
-
- ui32Num1dPages = (ui32Bytes >> PAGE_SHIFT);
- pu32PageAddrs[i] = kmalloc (sizeof(u32) * ui32Num1dPages, GFP_KERNEL);
- if (pu32PageAddrs[i] == NULL)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate page array",
- __func__));
- goto err_free;
- }
-
- for_each_sg (sglist, sg, ui32Num1dPages, j)
- {
- pu32PageAddrs[i][j] = sg_phys (sg);
- }
-
- iNumPages[i] = ui32Num1dPages;
- }
- else /* 2D DMM Buffers */
- {
- if (omap_ion_tiler_alloc(gpsIONClient, &asAllocData[i]) < 0)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate via ion_tiler",
- __func__));
- goto err_free;
- }
-
- if (omap_tiler_pages(gpsIONClient, asAllocData[i].handle, &iNumPages[i],
- &pu32PageAddrs[i]) < 0)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to compute tiler pages",
- __func__));
- goto err_free;
- }
- }
- }
-
- /* Basic sanity check on plane co-alignment */
- if((ui32NumHandlesPerFd > 1) &&
- (asAllocData[0].offset != asAllocData[1].offset))
- {
- pr_err("%s: Y and UV offsets do not match for tiler handles "
- "%p,%p: %d != %d \n "
- "Expect issues with SGX544xx and later chipsets\n",
- __func__, asAllocData[0].handle, asAllocData[1].handle,
- (int)asAllocData[0].offset, (int)asAllocData[1].offset);
- }
-
- /* Assume the user-allocator has already done the tiler math and that the
- * number of tiler pages allocated matches any other allocation type.
- */
- for(i = 0; i < ui32NumHandlesPerFd; i++)
- {
- ui32TotalPages += iNumPages[i];
- }
-
- BUG_ON(ui32Bytes != (ui32TotalPages * PAGE_SIZE));
- BUG_ON(sizeof(IMG_CPU_PHYADDR) != sizeof(int));
-
- /* Glue the page lists together */
- pCPUPhysAddrs = vmalloc(sizeof(IMG_CPU_PHYADDR) * ui32TotalPages);
- if (!pCPUPhysAddrs)
- {
- PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate page list", __func__));
- goto err_free;
- }
-
- j = 0;
- for(i = 0; i < ui32NumHandlesPerFd; i++)
- {
- IMG_UINT32 ui32PageIndx;
- for(ui32PageIndx = 0; ui32PageIndx < iNumPages[i]; ui32PageIndx++)
- {
- pCPUPhysAddrs[j++].uiAddr = pu32PageAddrs[i][ui32PageIndx];
- }
-
- psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i] =
- asAllocData[i].handle;
- psLinuxMemArea->uData.sIONTilerAlloc.planeOffsets[i] =
- ui32TotalPagesSizeInBytes + asAllocData[i].offset;
- /* Add the number of pages this plane consists of */
- ui32TotalPagesSizeInBytes += (iNumPages[i] * PAGE_SIZE);
- }
-
- psLinuxMemArea->eAreaType = LINUX_MEM_AREA_ION;
- psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs = pCPUPhysAddrs;
- psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes =
- ui32NumHandlesPerFd;
- psLinuxMemArea->ui32ByteSize = ui32TotalPagesSizeInBytes;
- psLinuxMemArea->ui32AreaFlags = ui32AreaFlags;
- INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
-
- /* We defer the cache flush to the first user mapping of this memory */
- psLinuxMemArea->bNeedsCacheInvalidate = AreaIsUncached(ui32AreaFlags);
-
-#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_ION,
- asAllocData[0].handle,
- 0,
- 0,
- NULL,
- PAGE_ALIGN(ui32Bytes),
- "unknown",
- 0
- );
-#endif
-
-#if defined(DEBUG_LINUX_MEM_AREAS)
- DebugLinuxMemAreaRecordAdd(psLinuxMemArea, ui32AreaFlags);
-#endif
-
-err_out:
- return psLinuxMemArea;
-
-err_free:
- LinuxMemAreaStructFree(psLinuxMemArea);
- psLinuxMemArea = IMG_NULL;
- goto err_out;
-}
-
-IMG_INT32
-GetIONLinuxMemAreaInfo(LinuxMemArea *psLinuxMemArea, IMG_UINT32* pui32AddressOffsets,
- IMG_UINT32* ui32NumAddrOffsets)
-{
- IMG_UINT32 i;
-
- if(!ui32NumAddrOffsets)
- return -1;
-
- if(*ui32NumAddrOffsets < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes)
- {
- *ui32NumAddrOffsets = psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes;
- return -1;
- }
-
- if(!pui32AddressOffsets)
- return -1;
-
- for(i = 0; i < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; i++)
- {
- if(psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i])
- pui32AddressOffsets[i] =
- psLinuxMemArea->uData.sIONTilerAlloc.planeOffsets[i];
- }
-
- *ui32NumAddrOffsets = psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes;
-
- return psLinuxMemArea->ui32ByteSize;
-}
-
-IMG_VOID
-FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea)
-{
- IMG_UINT32 i;
-
-#if defined(DEBUG_LINUX_MEM_AREAS)
- DebugLinuxMemAreaRecordRemove(psLinuxMemArea);
-#endif
-
-#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ION,
- psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[0],
- __FILE__, __LINE__);
-#endif
-
- for(i = 0; i < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; i++)
- {
- if (!psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i])
- break;
- ion_free(gpsIONClient, psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i]);
- psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i] = IMG_NULL;
- }
-
- /* free copy of page list, originals are freed by ion_free */
- vfree(psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs);
- psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs = IMG_NULL;
-
- LinuxMemAreaStructFree(psLinuxMemArea);
-}
-
-#endif /* defined(CONFIG_ION_OMAP) */
-
struct page*
LinuxMemAreaOffsetToPage(LinuxMemArea *psLinuxMemArea,
- IMG_UINT32 ui32ByteOffset)
+ IMG_UINTPTR_T uByteOffset)
{
- IMG_UINT32 ui32PageIndex;
+ IMG_UINTPTR_T uPageIndex;
IMG_CHAR *pui8Addr;
switch (psLinuxMemArea->eAreaType)
{
case LINUX_MEM_AREA_ALLOC_PAGES:
- ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset);
- return psLinuxMemArea->uData.sPageList.ppsPageList[ui32PageIndex];
+ uPageIndex = PHYS_TO_PFN(uByteOffset);
+ return psLinuxMemArea->uData.sPageList.ppsPageList[uPageIndex];
case LINUX_MEM_AREA_VMALLOC:
pui8Addr = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress;
- pui8Addr += ui32ByteOffset;
+ pui8Addr += uByteOffset;
return vmalloc_to_page(pui8Addr);
case LINUX_MEM_AREA_SUB_ALLOC:
/* PRQA S 3670 3 */ /* ignore recursive warning */
return LinuxMemAreaOffsetToPage(psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea,
- psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset
- + ui32ByteOffset);
+ psLinuxMemArea->uData.sSubAlloc.uiByteOffset
+ + uByteOffset);
default:
PVR_DPF((PVR_DBG_ERROR,
"%s: Unsupported request for struct page from LinuxMemArea with type=%s",
@@ -1829,14 +1600,19 @@ _KMemCacheAllocWrapper(LinuxKMemCache *psCache,
IMG_UINT32 ui32Line)
{
IMG_VOID *pvRet;
-
+
+#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
+ IMG_CPU_PHYADDR sCpuPAddr;
+#endif
+
pvRet = kmem_cache_zalloc(psCache, Flags);
#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
+ sCpuPAddr.uiAddr = 0;
DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE,
+ (IMG_UINTPTR_T)pvRet,
pvRet,
- pvRet,
- 0,
+ sCpuPAddr,
psCache,
kmem_cache_size(psCache),
pszFileName,
@@ -1853,12 +1629,12 @@ _KMemCacheAllocWrapper(LinuxKMemCache *psCache,
LinuxMemArea *
NewSubLinuxMemArea(LinuxMemArea *psParentLinuxMemArea,
- IMG_UINT32 ui32ByteOffset,
- IMG_UINT32 ui32Bytes)
+ IMG_UINTPTR_T uiByteOffset,
+ IMG_SIZE_T uBytes)
{
LinuxMemArea *psLinuxMemArea;
- PVR_ASSERT((ui32ByteOffset+ui32Bytes) <= psParentLinuxMemArea->ui32ByteSize);
+ PVR_ASSERT((uiByteOffset + uBytes) <= psParentLinuxMemArea->uiByteSize);
psLinuxMemArea = LinuxMemAreaStructAlloc();
if (!psLinuxMemArea)
@@ -1868,8 +1644,8 @@ NewSubLinuxMemArea(LinuxMemArea *psParentLinuxMemArea,
psLinuxMemArea->eAreaType = LINUX_MEM_AREA_SUB_ALLOC;
psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea = psParentLinuxMemArea;
- psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset = ui32ByteOffset;
- psLinuxMemArea->ui32ByteSize = ui32Bytes;
+ psLinuxMemArea->uData.sSubAlloc.uiByteOffset = uiByteOffset;
+ psLinuxMemArea->uiByteSize = uBytes;
psLinuxMemArea->ui32AreaFlags = psParentLinuxMemArea->ui32AreaFlags;
psLinuxMemArea->bNeedsCacheInvalidate = psParentLinuxMemArea->bNeedsCacheInvalidate;
INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList);
@@ -1949,9 +1725,6 @@ LinuxMemAreaDeepFree(LinuxMemArea *psLinuxMemArea)
case LINUX_MEM_AREA_SUB_ALLOC:
FreeSubLinuxMemArea(psLinuxMemArea);
break;
- case LINUX_MEM_AREA_ION:
- FreeIONLinuxMemArea(psLinuxMemArea);
- break;
default:
PVR_DPF((PVR_DBG_ERROR, "%s: Unknown are type (%d)\n",
__FUNCTION__, psLinuxMemArea->eAreaType));
@@ -1967,11 +1740,11 @@ DebugLinuxMemAreaRecordAdd(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32Flags)
DEBUG_LINUX_MEM_AREA_REC *psNewRecord;
const IMG_CHAR *pi8FlagsString;
- LinuxLockMutex(&g_sDebugMutex);
+ LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_SUB_ALLOC)
{
- g_LinuxMemAreaWaterMark += psLinuxMemArea->ui32ByteSize;
+ g_LinuxMemAreaWaterMark += psLinuxMemArea->uiByteSize;
if (g_LinuxMemAreaWaterMark > g_LinuxMemAreaHighWaterMark)
{
g_LinuxMemAreaHighWaterMark = g_LinuxMemAreaWaterMark;
@@ -2036,7 +1809,7 @@ DebugLinuxMemAreaRecordFind(LinuxMemArea *psLinuxMemArea)
{
DEBUG_LINUX_MEM_AREA_REC *psCurrentRecord;
- LinuxLockMutex(&g_sDebugMutex);
+ LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
psCurrentRecord = List_DEBUG_LINUX_MEM_AREA_REC_Any_va(g_LinuxMemAreaRecords,
MatchLinuxMemArea_AnyVaCb,
psLinuxMemArea);
@@ -2053,11 +1826,11 @@ DebugLinuxMemAreaRecordRemove(LinuxMemArea *psLinuxMemArea)
{
DEBUG_LINUX_MEM_AREA_REC *psCurrentRecord;
- LinuxLockMutex(&g_sDebugMutex);
+ LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_SUB_ALLOC)
{
- g_LinuxMemAreaWaterMark -= psLinuxMemArea->ui32ByteSize;
+ g_LinuxMemAreaWaterMark -= psLinuxMemArea->uiByteSize;
}
g_LinuxMemAreaCount--;
@@ -2101,7 +1874,7 @@ LinuxMemAreaToCpuVAddr(LinuxMemArea *psLinuxMemArea)
{
return NULL;
}
- return pAddr + psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset;
+ return pAddr + psLinuxMemArea->uData.sSubAlloc.uiByteOffset;
}
default:
return NULL;
@@ -2110,7 +1883,7 @@ LinuxMemAreaToCpuVAddr(LinuxMemArea *psLinuxMemArea)
IMG_CPU_PHYADDR
-LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset)
+LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINTPTR_T uiByteOffset)
{
IMG_CPU_PHYADDR CpuPAddr;
@@ -2121,7 +1894,7 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset)
case LINUX_MEM_AREA_IOREMAP:
{
CpuPAddr = psLinuxMemArea->uData.sIORemap.CPUPhysAddr;
- CpuPAddr.uiAddr += ui32ByteOffset;
+ CpuPAddr.uiAddr += uiByteOffset;
break;
}
case LINUX_MEM_AREA_EXTERNAL_KV:
@@ -2129,22 +1902,22 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset)
if (psLinuxMemArea->uData.sExternalKV.bPhysContig)
{
CpuPAddr = SysSysPAddrToCpuPAddr(psLinuxMemArea->uData.sExternalKV.uPhysAddr.SysPhysAddr);
- CpuPAddr.uiAddr += ui32ByteOffset;
+ CpuPAddr.uiAddr += uiByteOffset;
}
else
{
- IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset);
- IMG_SYS_PHYADDR SysPAddr = psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr[ui32PageIndex];
+ IMG_UINTPTR_T uiPageIndex = PHYS_TO_PFN(uiByteOffset);
+ IMG_SYS_PHYADDR SysPAddr = psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr[uiPageIndex];
CpuPAddr = SysSysPAddrToCpuPAddr(SysPAddr);
- CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset);
+ CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(uiByteOffset);
}
break;
}
case LINUX_MEM_AREA_IO:
{
CpuPAddr = psLinuxMemArea->uData.sIO.CPUPhysAddr;
- CpuPAddr.uiAddr += ui32ByteOffset;
+ CpuPAddr.uiAddr += uiByteOffset;
break;
}
case LINUX_MEM_AREA_VMALLOC:
@@ -2152,32 +1925,25 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset)
IMG_CHAR *pCpuVAddr;
pCpuVAddr =
(IMG_CHAR *)psLinuxMemArea->uData.sVmalloc.pvVmallocAddress;
- pCpuVAddr += ui32ByteOffset;
+ pCpuVAddr += uiByteOffset;
CpuPAddr.uiAddr = VMallocToPhys(pCpuVAddr);
break;
}
- case LINUX_MEM_AREA_ION:
- {
- IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset);
- CpuPAddr = psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs[ui32PageIndex];
- CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset);
- break;
- }
case LINUX_MEM_AREA_ALLOC_PAGES:
{
struct page *page;
- IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset);
- page = psLinuxMemArea->uData.sPageList.ppsPageList[ui32PageIndex];
+ IMG_UINTPTR_T uiPageIndex = PHYS_TO_PFN(uiByteOffset);
+ page = psLinuxMemArea->uData.sPageList.ppsPageList[uiPageIndex];
CpuPAddr.uiAddr = page_to_phys(page);
- CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset);
+ CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(uiByteOffset);
break;
}
case LINUX_MEM_AREA_SUB_ALLOC:
{
CpuPAddr =
OSMemHandleToCpuPAddr(psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea,
- psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset
- + ui32ByteOffset);
+ psLinuxMemArea->uData.sSubAlloc.uiByteOffset
+ + uiByteOffset);
break;
}
default:
@@ -2205,7 +1971,6 @@ LinuxMemAreaPhysIsContig(LinuxMemArea *psLinuxMemArea)
case LINUX_MEM_AREA_EXTERNAL_KV:
return psLinuxMemArea->uData.sExternalKV.bPhysContig;
- case LINUX_MEM_AREA_ION:
case LINUX_MEM_AREA_VMALLOC:
case LINUX_MEM_AREA_ALLOC_PAGES:
return IMG_FALSE;
@@ -2243,8 +2008,6 @@ LinuxMemAreaTypeToString(LINUX_MEM_AREA_TYPE eMemAreaType)
return "LINUX_MEM_AREA_SUB_ALLOC";
case LINUX_MEM_AREA_ALLOC_PAGES:
return "LINUX_MEM_AREA_ALLOC_PAGES";
- case LINUX_MEM_AREA_ION:
- return "LINUX_MEM_AREA_ION";
default:
PVR_ASSERT(0);
}
@@ -2258,7 +2021,7 @@ static void ProcSeqStartstopDebugMutex(struct seq_file *sfile, IMG_BOOL start)
{
if (start)
{
- LinuxLockMutex(&g_sDebugMutex);
+ LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
}
else
{
@@ -2350,14 +2113,14 @@ static void ProcSeqShowMemArea(struct seq_file *sfile,void* el)
seq_printf(sfile,
#if !defined(DEBUG_LINUX_XML_PROC_FILES)
- "%8p %-24s %8p %08x %-8d %-5u %08x=(%s)\n",
+ "%p %-24s %p " CPUPADDR_FMT " %" SIZE_T_FMT_LEN "u %-5u %08x=(%s)\n",
#else
"<linux_mem_area>\n"
- "\t<pointer>%8p</pointer>\n"
+ "\t<pointer>%p</pointer>\n"
"\t<type>%s</type>\n"
- "\t<cpu_virtual>%8p</cpu_virtual>\n"
- "\t<cpu_physical>%08x</cpu_physical>\n"
- "\t<bytes>%d</bytes>\n"
+ "\t<cpu_virtual>%p</cpu_virtual>\n"
+ "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n"
+ "\t<bytes>%" SIZE_T_FMT_LEN "d</bytes>\n"
"\t<pid>%u</pid>\n"
"\t<flags>%08x</flags>\n"
"\t<flags_string>%s</flags_string>\n"
@@ -2367,14 +2130,13 @@ static void ProcSeqShowMemArea(struct seq_file *sfile,void* el)
LinuxMemAreaTypeToString(psRecord->psLinuxMemArea->eAreaType),
LinuxMemAreaToCpuVAddr(psRecord->psLinuxMemArea),
LinuxMemAreaToCpuPAddr(psRecord->psLinuxMemArea,0).uiAddr,
- psRecord->psLinuxMemArea->ui32ByteSize,
+ psRecord->psLinuxMemArea->uiByteSize,
psRecord->pid,
psRecord->ui32Flags,
HAPFlagsToString(psRecord->ui32Flags)
);
}
-
#endif /* DEBUG_LINUX_MEM_AREAS */
@@ -2393,7 +2155,6 @@ static IMG_VOID* DecOffMemAllocRec_AnyVaCb(DEBUG_MEM_ALLOC_REC *psNode, va_list
}
}
-
/* seq_file version of generating output, for reference check proc.c:CreateProcReadEntrySeq */
static void* ProcSeqNextMemoryRecords(struct seq_file *sfile,void* el,loff_t off)
{
@@ -2598,13 +2359,13 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el)
{
seq_printf(sfile,
#if !defined(DEBUG_LINUX_XML_PROC_FILES)
- "%-16s %-8p %08x %-10d %-5d %-10s %s:%d\n",
+ "%-16s %p " CPUPADDR_FMT " %" SIZE_T_FMT_LEN "u %-5d %-10s %s:%d\n",
#else
"<allocation>\n"
"\t<type>%s</type>\n"
- "\t<cpu_virtual>%-8p</cpu_virtual>\n"
- "\t<cpu_physical>%08x</cpu_physical>\n"
- "\t<bytes>%d</bytes>\n"
+ "\t<cpu_virtual>%p</cpu_virtual>\n"
+ "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n"
+ "\t<bytes>%" SIZE_T_FMT_LEN "u</bytes>\n"
"\t<pid>%d</pid>\n"
"\t<private>%s</private>\n"
"\t<filename>%s</filename>\n"
@@ -2613,8 +2374,8 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el)
#endif
DebugMemAllocRecordTypeToString(psRecord->eAllocType),
psRecord->pvCpuVAddr,
- psRecord->ulCpuPAddr,
- psRecord->ui32Bytes,
+ psRecord->sCpuPAddr.uiAddr,
+ psRecord->uiBytes,
psRecord->pid,
"NULL",
psRecord->pszFileName,
@@ -2624,13 +2385,13 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el)
{
seq_printf(sfile,
#if !defined(DEBUG_LINUX_XML_PROC_FILES)
- "%-16s %-8p %08x %-10d %-5d %-10s %s:%d\n",
+ "%-16s %p " CPUPADDR_FMT " %" SIZE_T_FMT_LEN "u %-5d %-10s %s:%d\n",
#else
"<allocation>\n"
"\t<type>%s</type>\n"
- "\t<cpu_virtual>%-8p</cpu_virtual>\n"
- "\t<cpu_physical>%08x</cpu_physical>\n"
- "\t<bytes>%d</bytes>\n"
+ "\t<cpu_virtual>%p</cpu_virtual>\n"
+ "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n"
+ "\t<bytes>%" SIZE_T_FMT_LEN "u</bytes>\n"
"\t<pid>%d</pid>\n"
"\t<private>%s</private>\n"
"\t<filename>%s</filename>\n"
@@ -2639,15 +2400,14 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el)
#endif
DebugMemAllocRecordTypeToString(psRecord->eAllocType),
psRecord->pvCpuVAddr,
- psRecord->ulCpuPAddr,
- psRecord->ui32Bytes,
+ psRecord->sCpuPAddr.uiAddr,
+ psRecord->uiBytes,
psRecord->pid,
KMemCacheNameWrapper(psRecord->pvPrivateData),
psRecord->pszFileName,
psRecord->ui32Line);
}
}
-
#endif /* defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) */
@@ -2730,11 +2490,11 @@ static IMG_VOID LinuxMMCleanup_MemAreas_ForEachCb(DEBUG_LINUX_MEM_AREA_REC *psCu
LinuxMemArea *psLinuxMemArea;
psLinuxMemArea = psCurrentRecord->psLinuxMemArea;
- PVR_DPF((PVR_DBG_ERROR, "%s: BUG!: Cleaning up Linux memory area (%p), type=%s, size=%d bytes",
+ PVR_DPF((PVR_DBG_ERROR, "%s: BUG!: Cleaning up Linux memory area (%p), type=%s, size=%"SIZE_T_FMT_LEN"d bytes",
__FUNCTION__,
psCurrentRecord->psLinuxMemArea,
LinuxMemAreaTypeToString(psCurrentRecord->psLinuxMemArea->eAreaType),
- psCurrentRecord->psLinuxMemArea->ui32ByteSize));
+ psCurrentRecord->psLinuxMemArea->uiByteSize));
/* Note this will also remove psCurrentRecord from g_LinuxMemAreaRecords
* but that's ok since we have already got a pointer to the next area. */
LinuxMemAreaDeepFree(psLinuxMemArea);
@@ -2751,12 +2511,12 @@ static IMG_VOID LinuxMMCleanup_MemRecords_ForEachVa(DEBUG_MEM_ALLOC_REC *psCurre
PVR_DPF((PVR_DBG_ERROR, "%s: BUG!: Cleaning up memory: "
"type=%s "
"CpuVAddr=%p "
- "CpuPAddr=0x%08x, "
+ "CpuPAddr=0x" CPUPADDR_FMT ", "
"allocated @ file=%s,line=%d",
__FUNCTION__,
DebugMemAllocRecordTypeToString(psCurrentRecord->eAllocType),
psCurrentRecord->pvCpuVAddr,
- psCurrentRecord->ulCpuPAddr,
+ psCurrentRecord->sCpuPAddr.uiAddr,
psCurrentRecord->pszFileName,
psCurrentRecord->ui32Line));
switch (psCurrentRecord->eAllocType)
@@ -2769,13 +2529,13 @@ static IMG_VOID LinuxMMCleanup_MemRecords_ForEachVa(DEBUG_MEM_ALLOC_REC *psCurre
break;
case DEBUG_MEM_ALLOC_TYPE_IO:
/* Nothing needed except to free the record */
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IO, psCurrentRecord->pvKey, __FILE__, __LINE__);
+ DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IO, psCurrentRecord->uiKey, __FILE__, __LINE__);
break;
case DEBUG_MEM_ALLOC_TYPE_VMALLOC:
VFreeWrapper(psCurrentRecord->pvCpuVAddr);
break;
case DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES:
- DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, psCurrentRecord->pvKey, __FILE__, __LINE__);
+ DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, psCurrentRecord->uiKey, __FILE__, __LINE__);
break;
case DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE:
KMemCacheFreeWrapper(psCurrentRecord->pvPrivateData, psCurrentRecord->pvCpuVAddr);