summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Balagopalakrishnan <anandb@ti.com>2015-02-10 15:31:31 +0300
committerAnand Balagopalakrishnan <anandb@ti.com>2015-02-10 16:22:20 +0300
commit0f3561a47cf7a1b968fb64446a0be10abc9a15d5 (patch)
tree456942eb177e8627fa6e147dfaf1c334100d2d46
parent3b475f4c457e8827ea793c420277a0da69f7988a (diff)
downloadomap5-sgx-ddk-linux-0f3561a47cf7a1b968fb64446a0be10abc9a15d5.tar.xz
km: fix GEM handle memory leakglsdk_7.00.00.04
When memory handles are mapped, a dummy GEM handle is created so that it can be accepted by DRM. However, when the memory handle is unmaped, there is no corresponding delete of the GEM handle. Given that each GEM handle is 4K bytes, this will result in a memory leak that will result in application crash over time. This is not catastrophic to the system since DRM/GEM core will cleanup the GEM handles allocated as part of the proces when it exit. This patch addresses the GEM handle leak in SGX driver. Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
-rw-r--r--eurasia_km/services4/srvkm/env/linux/mm.h1
-rw-r--r--eurasia_km/services4/srvkm/env/linux/mmap.c15
2 files changed, 14 insertions, 2 deletions
diff --git a/eurasia_km/services4/srvkm/env/linux/mm.h b/eurasia_km/services4/srvkm/env/linux/mm.h
index 06b96df..5551077 100644
--- a/eurasia_km/services4/srvkm/env/linux/mm.h
+++ b/eurasia_km/services4/srvkm/env/linux/mm.h
@@ -198,6 +198,7 @@ struct _LinuxMemArea {
#if defined(SUPPORT_DRI_DRM_EXTERNAL)
IMG_HANDLE buf; /* external buffer handle, like a GEM or ION buffer */
+ IMG_UINT32 uiHandle; /* GEM handle */
#endif /* SUPPORT_DRI_DRM_EXTERNAL */
};
diff --git a/eurasia_km/services4/srvkm/env/linux/mmap.c b/eurasia_km/services4/srvkm/env/linux/mmap.c
index bab4c2a..ab9a902 100644
--- a/eurasia_km/services4/srvkm/env/linux/mmap.c
+++ b/eurasia_km/services4/srvkm/env/linux/mmap.c
@@ -517,9 +517,8 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc =
(PVRSRV_ENV_PER_PROCESS_DATA *)PVRSRVProcessPrivateData(psPerProc);
struct drm_gem_object *buf = NULL;
- IMG_UINT32 uiHandle, *puiHandle;
+ IMG_UINT32 *puiHandle;
IMG_UINT32 ret;
- puiHandle = &uiHandle;
#endif /* SUPPORT_DRI_DRM_EXTERNAL */
LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP);
@@ -539,6 +538,7 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
}
psLinuxMemArea = (LinuxMemArea *)hOSMemHandle;
+ puiHandle = &psLinuxMemArea->uiHandle;
/* Sparse mappings have to ask the BM for the virtual size */
if (psLinuxMemArea->hBMHandle)
@@ -715,6 +715,10 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
IMG_HANDLE hOSMemHandle;
PVRSRV_ERROR eError;
IMG_UINT32 ui32PID = OSGetCurrentProcessIDKM();
+#if defined(SUPPORT_DRI_DRM_EXTERNAL)
+ PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc =
+ (PVRSRV_ENV_PER_PROCESS_DATA *)PVRSRVProcessPrivateData(psPerProc);
+#endif /* SUPPORT_DRI_DRM_EXTERNAL */
LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP);
@@ -734,6 +738,13 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
psLinuxMemArea = (LinuxMemArea *)hOSMemHandle;
+#if defined(SUPPORT_DRI_DRM_EXTERNAL)
+ if (psLinuxMemArea->uiHandle) {
+ drm_gem_handle_delete(psEnvPerProc->file, psLinuxMemArea->uiHandle);
+ psLinuxMemArea->uiHandle = 0;
+ }
+#endif
+
psOffsetStruct = FindOffsetStructByPID(psLinuxMemArea, ui32PID);
if (psOffsetStruct)
{