diff options
Diffstat (limited to 'drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c')
-rw-r--r-- | drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c b/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c new file mode 100644 index 000000000000..521b1617adee --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /*************************************************************************/ /*! | ||
2 | @Title Linux specific per process data functions | ||
3 | @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved | ||
4 | @License Dual MIT/GPLv2 | ||
5 | |||
6 | The contents of this file are subject to the MIT license as set out below. | ||
7 | |||
8 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
9 | of this software and associated documentation files (the "Software"), to deal | ||
10 | in the Software without restriction, including without limitation the rights | ||
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
12 | copies of the Software, and to permit persons to whom the Software is | ||
13 | furnished to do so, subject to the following conditions: | ||
14 | |||
15 | The above copyright notice and this permission notice shall be included in | ||
16 | all copies or substantial portions of the Software. | ||
17 | |||
18 | Alternatively, the contents of this file may be used under the terms of | ||
19 | the GNU General Public License Version 2 ("GPL") in which case the provisions | ||
20 | of GPL are applicable instead of those above. | ||
21 | |||
22 | If you wish to allow use of your version of this file only under the terms of | ||
23 | GPL, and not to allow others to use your version of this file under the terms | ||
24 | of the MIT license, indicate your decision by deleting the provisions above | ||
25 | and replace them with the notice and other provisions required by GPL as set | ||
26 | out in the file called "GPL-COPYING" included in this distribution. If you do | ||
27 | not delete the provisions above, a recipient may use your version of this file | ||
28 | under the terms of either the MIT license or GPL. | ||
29 | |||
30 | This License is also included in this distribution in the file called | ||
31 | "MIT-COPYING". | ||
32 | |||
33 | EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS | ||
34 | PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING | ||
35 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
36 | PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR | ||
37 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
38 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
39 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
40 | */ /**************************************************************************/ | ||
41 | |||
42 | #include "services_headers.h" | ||
43 | #include "osperproc.h" | ||
44 | |||
45 | #include "env_perproc.h" | ||
46 | |||
47 | #if defined (SUPPORT_ION) | ||
48 | #include <linux/err.h> | ||
49 | #include "ion.h" | ||
50 | extern struct ion_device *gpsIonDev; | ||
51 | #endif | ||
52 | |||
53 | extern IMG_UINT32 gui32ReleasePID; | ||
54 | |||
55 | PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData) | ||
56 | { | ||
57 | PVRSRV_ERROR eError; | ||
58 | IMG_HANDLE hBlockAlloc; | ||
59 | PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc; | ||
60 | |||
61 | eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, | ||
62 | sizeof(PVRSRV_ENV_PER_PROCESS_DATA), | ||
63 | phOsPrivateData, | ||
64 | &hBlockAlloc, | ||
65 | "Environment per Process Data"); | ||
66 | |||
67 | if (eError != PVRSRV_OK) | ||
68 | { | ||
69 | *phOsPrivateData = IMG_NULL; | ||
70 | |||
71 | PVR_DPF((PVR_DBG_ERROR, "%s: OSAllocMem failed (%d)", __FUNCTION__, eError)); | ||
72 | return eError; | ||
73 | } | ||
74 | |||
75 | psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)*phOsPrivateData; | ||
76 | OSMemSet(psEnvPerProc, 0, sizeof(*psEnvPerProc)); | ||
77 | |||
78 | psEnvPerProc->hBlockAlloc = hBlockAlloc; | ||
79 | |||
80 | /* Linux specific mmap processing */ | ||
81 | LinuxMMapPerProcessConnect(psEnvPerProc); | ||
82 | |||
83 | #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) | ||
84 | /* Linked list of PVRSRV_FILE_PRIVATE_DATA structures */ | ||
85 | INIT_LIST_HEAD(&psEnvPerProc->sDRMAuthListHead); | ||
86 | #endif | ||
87 | |||
88 | #if defined(SUPPORT_ION) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) | ||
89 | OSSNPrintf(psEnvPerProc->azIonClientName, ION_CLIENT_NAME_SIZE, "pvr_ion_client-%d", OSGetCurrentProcessIDKM()); | ||
90 | psEnvPerProc->psIONClient = | ||
91 | ion_client_create(gpsIonDev, | ||
92 | psEnvPerProc->azIonClientName); | ||
93 | |||
94 | if (IS_ERR_OR_NULL(psEnvPerProc->psIONClient)) | ||
95 | { | ||
96 | PVR_DPF((PVR_DBG_ERROR, "OSPerProcessPrivateDataInit: Couldn't create " | ||
97 | "ion client for per process data")); | ||
98 | return PVRSRV_ERROR_OUT_OF_MEMORY; | ||
99 | } | ||
100 | #endif /* defined(SUPPORT_ION) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) */ | ||
101 | return PVRSRV_OK; | ||
102 | } | ||
103 | |||
104 | PVRSRV_ERROR OSPerProcessPrivateDataDeInit(IMG_HANDLE hOsPrivateData) | ||
105 | { | ||
106 | PVRSRV_ERROR eError; | ||
107 | PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc; | ||
108 | |||
109 | if (hOsPrivateData == IMG_NULL) | ||
110 | { | ||
111 | return PVRSRV_OK; | ||
112 | } | ||
113 | |||
114 | psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)hOsPrivateData; | ||
115 | |||
116 | #if defined(SUPPORT_ION) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) | ||
117 | if (psEnvPerProc->psIONClient) | ||
118 | { | ||
119 | ion_client_destroy(psEnvPerProc->psIONClient); | ||
120 | psEnvPerProc->psIONClient = IMG_NULL; | ||
121 | } | ||
122 | #endif /* defined(SUPPORT_ION) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) */ | ||
123 | |||
124 | /* Linux specific mmap processing */ | ||
125 | LinuxMMapPerProcessDisconnect(psEnvPerProc); | ||
126 | |||
127 | /* Remove per process /proc entries */ | ||
128 | RemovePerProcessProcDir(psEnvPerProc); | ||
129 | |||
130 | eError = OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, | ||
131 | sizeof(PVRSRV_ENV_PER_PROCESS_DATA), | ||
132 | hOsPrivateData, | ||
133 | psEnvPerProc->hBlockAlloc); | ||
134 | /*not nulling pointer, copy on stack*/ | ||
135 | |||
136 | if (eError != PVRSRV_OK) | ||
137 | { | ||
138 | PVR_DPF((PVR_DBG_ERROR, "%s: OSFreeMem failed (%d)", __FUNCTION__, eError)); | ||
139 | } | ||
140 | |||
141 | return PVRSRV_OK; | ||
142 | } | ||
143 | |||
144 | PVRSRV_ERROR OSPerProcessSetHandleOptions(PVRSRV_HANDLE_BASE *psHandleBase) | ||
145 | { | ||
146 | return LinuxMMapPerProcessHandleOptions(psHandleBase); | ||
147 | } | ||
148 | |||
149 | IMG_HANDLE LinuxTerminatingProcessPrivateData(IMG_VOID) | ||
150 | { | ||
151 | if(!gui32ReleasePID) | ||
152 | return NULL; | ||
153 | return PVRSRVPerProcessPrivateData(gui32ReleasePID); | ||
154 | } | ||