summaryrefslogtreecommitdiff
path: root/debian/dkms/patches/0001-km-fix-failed-mmap-s-of-non-page-aligned-buffers.patch
blob: 8b5a07619228d117a2587018017a03688fc4d91a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From d13f1b816d82ba4dd1d4fd13efbfb78cdf6eac6f Mon Sep 17 00:00:00 2001
From: Rob Clark <rob@ti.com>
Date: Mon, 23 Apr 2012 16:38:37 -0500
Subject: [PATCH] km: fix failed mmap's of non-page aligned buffers

GEM would round up the buffer size to next page boundary, but if the
backing memory is not page aligned to begin w/ the ui32RealByteSize
could actually be rounded up to next+1 page boundary.  Causing an
error to be returned from drm_gem_mmap() later when userspace attempts
to mmap() the buffer.
---
 services4/srvkm/env/linux/mmap.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/services4/srvkm/env/linux/mmap.c b/services4/srvkm/env/linux/mmap.c
index ca38e5d..5835594 100644
--- a/services4/srvkm/env/linux/mmap.c
+++ b/services4/srvkm/env/linux/mmap.c
@@ -420,6 +420,10 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
 
     psLinuxMemArea = (LinuxMemArea *)hOSMemHandle;
 
+    DetermineUsersSizeAndByteOffset(psLinuxMemArea,
+                                   pui32RealByteSize,
+                                   pui32ByteOffset);
+
 #if defined(SUPPORT_DRI_DRM_EXTERNAL)
     /* if we are using DRM/GEM, then let GEM generate the buffer offset..
      * this is done by creating a wrapper object.
@@ -430,7 +434,7 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
         if (!buf)
         {
             buf = create_gem_wrapper(psEnvPerProc->dev,
-                    psLinuxMemArea, 0, psLinuxMemArea->ui32ByteSize);
+                    psLinuxMemArea, 0, *pui32RealByteSize);
             if (!buf)
             {
                 PVR_DPF((PVR_DBG_ERROR, "%s: Screw you guys, I'm going home..", __FUNCTION__));
@@ -442,10 +446,6 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc,
     }
 #endif /* SUPPORT_DRI_DRM_EXTERNAL */
 
-    DetermineUsersSizeAndByteOffset(psLinuxMemArea,
-                                   pui32RealByteSize,
-                                   pui32ByteOffset);
-
     psOffsetStruct = FindOffsetStructByPID(psLinuxMemArea, psPerProc->ui32PID);
     if (psOffsetStruct)
     {
-- 
1.7.4.1