~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to drivers/gpu/pvr/sgx/pb.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**********************************************************************
2
 
 *
3
 
 * Copyright (C) Imagination Technologies Ltd. All rights reserved.
4
 
 * 
5
 
 * This program is free software; you can redistribute it and/or modify it
6
 
 * under the terms and conditions of the GNU General Public License,
7
 
 * version 2, as published by the Free Software Foundation.
8
 
 * 
9
 
 * This program is distributed in the hope it will be useful but, except 
10
 
 * as otherwise stated in writing, without any warranty; without even the 
11
 
 * implied warranty of merchantability or fitness for a particular purpose. 
12
 
 * See the GNU General Public License for more details.
13
 
 * 
14
 
 * You should have received a copy of the GNU General Public License along with
15
 
 * this program; if not, write to the Free Software Foundation, Inc.,
16
 
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17
 
 * 
18
 
 * The full GNU General Public License is included in this distribution in
19
 
 * the file called "COPYING".
20
 
 *
21
 
 * Contact Information:
22
 
 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23
 
 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK 
24
 
 *
25
 
 ******************************************************************************/
26
 
 
27
 
#include <stddef.h>
28
 
 
29
 
#include "services_headers.h"
30
 
#include "sgx_bridge_km.h"
31
 
#include "sgxapi_km.h"
32
 
#include "sgxinfo.h"
33
 
#include "sgxinfokm.h"
34
 
#include "pvr_bridge_km.h"
35
 
#include "pdump_km.h"
36
 
#include "sgxutils.h"
37
 
 
38
 
#ifndef __linux__
39
 
#pragma message("TODO: Review use of OS_PAGEABLE vs OS_NON_PAGEABLE")
40
 
#endif
41
 
 
42
 
#include "lists.h"
43
 
 
44
 
static IMPLEMENT_LIST_INSERT(PVRSRV_STUB_PBDESC)
45
 
static IMPLEMENT_LIST_REMOVE(PVRSRV_STUB_PBDESC)
46
 
 
47
 
static PRESMAN_ITEM psResItemCreateSharedPB = IMG_NULL;
48
 
static PVRSRV_PER_PROCESS_DATA *psPerProcCreateSharedPB = IMG_NULL;
49
 
 
50
 
static PVRSRV_ERROR SGXCleanupSharedPBDescCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy);
51
 
static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy);
52
 
 
53
 
IMG_EXPORT PVRSRV_ERROR
54
 
SGXFindSharedPBDescKM(PVRSRV_PER_PROCESS_DATA   *psPerProc,
55
 
                                          IMG_HANDLE                            hDevCookie,
56
 
                                          IMG_BOOL                              bLockOnFailure,
57
 
                                          IMG_UINT32                            ui32TotalPBSize,
58
 
                                          IMG_HANDLE                            *phSharedPBDesc,
59
 
                                          PVRSRV_KERNEL_MEM_INFO        **ppsSharedPBDescKernelMemInfo,
60
 
                                          PVRSRV_KERNEL_MEM_INFO        **ppsHWPBDescKernelMemInfo,
61
 
                                          PVRSRV_KERNEL_MEM_INFO        **ppsBlockKernelMemInfo,
62
 
                                          PVRSRV_KERNEL_MEM_INFO        **ppsHWBlockKernelMemInfo,
63
 
                                          PVRSRV_KERNEL_MEM_INFO        ***pppsSharedPBDescSubKernelMemInfos,
64
 
                                          IMG_UINT32                            *ui32SharedPBDescSubKernelMemInfosCount)
65
 
{
66
 
        PVRSRV_STUB_PBDESC *psStubPBDesc;
67
 
        PVRSRV_KERNEL_MEM_INFO **ppsSharedPBDescSubKernelMemInfos=IMG_NULL;
68
 
        PVRSRV_SGXDEV_INFO *psSGXDevInfo;
69
 
        PVRSRV_ERROR eError;
70
 
 
71
 
        psSGXDevInfo = ((PVRSRV_DEVICE_NODE *)hDevCookie)->pvDevice;
72
 
 
73
 
        psStubPBDesc = psSGXDevInfo->psStubPBDescListKM;
74
 
        if (psStubPBDesc != IMG_NULL)
75
 
        {
76
 
                IMG_UINT32 i;
77
 
                PRESMAN_ITEM psResItem;
78
 
 
79
 
                if(psStubPBDesc->ui32TotalPBSize != ui32TotalPBSize)
80
 
                {
81
 
                        PVR_DPF((PVR_DBG_WARNING,
82
 
                                        "SGXFindSharedPBDescKM: Shared PB requested with different size (0x%x) from existing shared PB (0x%x) - requested size ignored",
83
 
                                        ui32TotalPBSize, psStubPBDesc->ui32TotalPBSize));
84
 
                }
85
 
 
86
 
                if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
87
 
                                          sizeof(PVRSRV_KERNEL_MEM_INFO *)
88
 
                                                * psStubPBDesc->ui32SubKernelMemInfosCount,
89
 
                                          (IMG_VOID **)&ppsSharedPBDescSubKernelMemInfos,
90
 
                                          IMG_NULL,
91
 
                                          "Array of Kernel Memory Info") != PVRSRV_OK)
92
 
                {
93
 
                        PVR_DPF((PVR_DBG_ERROR, "SGXFindSharedPBDescKM: OSAllocMem failed"));
94
 
 
95
 
                        eError = PVRSRV_ERROR_OUT_OF_MEMORY;
96
 
                        goto ExitNotFound;
97
 
                }
98
 
 
99
 
                psResItem = ResManRegisterRes(psPerProc->hResManContext,
100
 
                                                                          RESMAN_TYPE_SHARED_PB_DESC,
101
 
                                                                          psStubPBDesc,
102
 
                                                                          0,
103
 
                                                                          &SGXCleanupSharedPBDescCallback);
104
 
 
105
 
                if (psResItem == IMG_NULL)
106
 
                {
107
 
                        OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
108
 
                                          sizeof(PVRSRV_KERNEL_MEM_INFO *) * psStubPBDesc->ui32SubKernelMemInfosCount,
109
 
                                          ppsSharedPBDescSubKernelMemInfos,
110
 
                                          0);
111
 
                        
112
 
 
113
 
                        PVR_DPF((PVR_DBG_ERROR, "SGXFindSharedPBDescKM: ResManRegisterRes failed"));
114
 
 
115
 
                        eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE;
116
 
                        goto ExitNotFound;
117
 
                }
118
 
 
119
 
                *ppsSharedPBDescKernelMemInfo = psStubPBDesc->psSharedPBDescKernelMemInfo;
120
 
                *ppsHWPBDescKernelMemInfo = psStubPBDesc->psHWPBDescKernelMemInfo;
121
 
                *ppsBlockKernelMemInfo = psStubPBDesc->psBlockKernelMemInfo;
122
 
                *ppsHWBlockKernelMemInfo = psStubPBDesc->psHWBlockKernelMemInfo;
123
 
 
124
 
                *ui32SharedPBDescSubKernelMemInfosCount =
125
 
                        psStubPBDesc->ui32SubKernelMemInfosCount;
126
 
 
127
 
                *pppsSharedPBDescSubKernelMemInfos = ppsSharedPBDescSubKernelMemInfos;
128
 
 
129
 
                for(i=0; i<psStubPBDesc->ui32SubKernelMemInfosCount; i++)
130
 
                {
131
 
                        ppsSharedPBDescSubKernelMemInfos[i] =
132
 
                                psStubPBDesc->ppsSubKernelMemInfos[i];
133
 
                }
134
 
 
135
 
                psStubPBDesc->ui32RefCount++;
136
 
                *phSharedPBDesc = (IMG_HANDLE)psResItem;
137
 
                return PVRSRV_OK;
138
 
        }
139
 
 
140
 
        eError = PVRSRV_OK;
141
 
        if (bLockOnFailure)
142
 
        {
143
 
                if (psResItemCreateSharedPB == IMG_NULL)
144
 
                {
145
 
                        psResItemCreateSharedPB = ResManRegisterRes(psPerProc->hResManContext,
146
 
                                  RESMAN_TYPE_SHARED_PB_DESC_CREATE_LOCK,
147
 
                                  psPerProc,
148
 
                                  0,
149
 
                                  &SGXCleanupSharedPBDescCreateLockCallback);
150
 
 
151
 
                        if (psResItemCreateSharedPB == IMG_NULL)
152
 
                        {
153
 
                                PVR_DPF((PVR_DBG_ERROR, "SGXFindSharedPBDescKM: ResManRegisterRes failed"));
154
 
 
155
 
                                eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE;
156
 
                                goto ExitNotFound;
157
 
                        }
158
 
                        PVR_ASSERT(psPerProcCreateSharedPB == IMG_NULL);
159
 
                        psPerProcCreateSharedPB = psPerProc;
160
 
                }
161
 
                else
162
 
                {
163
 
                         eError = PVRSRV_ERROR_PROCESSING_BLOCKED;
164
 
                }
165
 
        }
166
 
ExitNotFound:
167
 
        *phSharedPBDesc = IMG_NULL;
168
 
 
169
 
        return eError;
170
 
}
171
 
 
172
 
 
173
 
static PVRSRV_ERROR
174
 
SGXCleanupSharedPBDescKM(PVRSRV_STUB_PBDESC *psStubPBDescIn)
175
 
{
176
 
        
177
 
        IMG_UINT32 i;
178
 
        PVRSRV_DEVICE_NODE *psDeviceNode;
179
 
 
180
 
        psDeviceNode = (PVRSRV_DEVICE_NODE*)psStubPBDescIn->hDevCookie;
181
 
 
182
 
        
183
 
 
184
 
        
185
 
        psStubPBDescIn->ui32RefCount--;
186
 
        if (psStubPBDescIn->ui32RefCount == 0)
187
 
        {
188
 
                IMG_DEV_VIRTADDR sHWPBDescDevVAddr = psStubPBDescIn->sHWPBDescDevVAddr;
189
 
                List_PVRSRV_STUB_PBDESC_Remove(psStubPBDescIn);
190
 
                for(i=0 ; i<psStubPBDescIn->ui32SubKernelMemInfosCount; i++)
191
 
                {
192
 
                        
193
 
                        PVRSRVFreeDeviceMemKM(psStubPBDescIn->hDevCookie,
194
 
                                                                  psStubPBDescIn->ppsSubKernelMemInfos[i]);
195
 
                }
196
 
 
197
 
                OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
198
 
                                  sizeof(PVRSRV_KERNEL_MEM_INFO *) * psStubPBDescIn->ui32SubKernelMemInfosCount,
199
 
                                  psStubPBDescIn->ppsSubKernelMemInfos,
200
 
                                  0);
201
 
                psStubPBDescIn->ppsSubKernelMemInfos = IMG_NULL;
202
 
 
203
 
                PVRSRVFreeSharedSysMemoryKM(psStubPBDescIn->psBlockKernelMemInfo);
204
 
 
205
 
                PVRSRVFreeDeviceMemKM(psStubPBDescIn->hDevCookie, psStubPBDescIn->psHWBlockKernelMemInfo);
206
 
 
207
 
                PVRSRVFreeDeviceMemKM(psStubPBDescIn->hDevCookie, psStubPBDescIn->psHWPBDescKernelMemInfo);
208
 
 
209
 
                PVRSRVFreeSharedSysMemoryKM(psStubPBDescIn->psSharedPBDescKernelMemInfo);
210
 
 
211
 
                OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
212
 
                                  sizeof(PVRSRV_STUB_PBDESC),
213
 
                                  psStubPBDescIn,
214
 
                                  0);
215
 
                
216
 
 
217
 
                
218
 
                SGXCleanupRequest(psDeviceNode,
219
 
                                                  &sHWPBDescDevVAddr,
220
 
                                                  PVRSRV_CLEANUPCMD_PB,
221
 
                                                  CLEANUP_WITH_POLL);
222
 
        }
223
 
        return PVRSRV_OK;
224
 
        
225
 
}
226
 
 
227
 
static PVRSRV_ERROR SGXCleanupSharedPBDescCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy)
228
 
{
229
 
        PVRSRV_STUB_PBDESC *psStubPBDesc = (PVRSRV_STUB_PBDESC *)pvParam;
230
 
 
231
 
        PVR_UNREFERENCED_PARAMETER(ui32Param);
232
 
        PVR_UNREFERENCED_PARAMETER(bDummy);
233
 
 
234
 
        return SGXCleanupSharedPBDescKM(psStubPBDesc);
235
 
}
236
 
 
237
 
static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy)
238
 
{
239
 
#ifdef DEBUG
240
 
        PVRSRV_PER_PROCESS_DATA *psPerProc = (PVRSRV_PER_PROCESS_DATA *)pvParam;
241
 
        PVR_ASSERT(psPerProc == psPerProcCreateSharedPB);
242
 
#else
243
 
        PVR_UNREFERENCED_PARAMETER(pvParam);
244
 
#endif
245
 
 
246
 
        PVR_UNREFERENCED_PARAMETER(ui32Param);
247
 
        PVR_UNREFERENCED_PARAMETER(bDummy);
248
 
 
249
 
        psPerProcCreateSharedPB = IMG_NULL;
250
 
        psResItemCreateSharedPB = IMG_NULL;
251
 
 
252
 
        return PVRSRV_OK;
253
 
}
254
 
 
255
 
 
256
 
IMG_EXPORT PVRSRV_ERROR
257
 
SGXUnrefSharedPBDescKM(IMG_HANDLE hSharedPBDesc)
258
 
{
259
 
        PVR_ASSERT(hSharedPBDesc != IMG_NULL);
260
 
 
261
 
        return ResManFreeResByPtr(hSharedPBDesc, CLEANUP_WITH_POLL);
262
 
}
263
 
 
264
 
 
265
 
IMG_EXPORT PVRSRV_ERROR
266
 
SGXAddSharedPBDescKM(PVRSRV_PER_PROCESS_DATA    *psPerProc,
267
 
                                         IMG_HANDLE                                     hDevCookie,
268
 
                                         PVRSRV_KERNEL_MEM_INFO         *psSharedPBDescKernelMemInfo,
269
 
                                         PVRSRV_KERNEL_MEM_INFO         *psHWPBDescKernelMemInfo,
270
 
                                         PVRSRV_KERNEL_MEM_INFO         *psBlockKernelMemInfo,
271
 
                                         PVRSRV_KERNEL_MEM_INFO         *psHWBlockKernelMemInfo,
272
 
                                         IMG_UINT32                                     ui32TotalPBSize,
273
 
                                         IMG_HANDLE                                     *phSharedPBDesc,
274
 
                                         PVRSRV_KERNEL_MEM_INFO         **ppsSharedPBDescSubKernelMemInfos,
275
 
                                         IMG_UINT32                                     ui32SharedPBDescSubKernelMemInfosCount,
276
 
                                         IMG_DEV_VIRTADDR                       sHWPBDescDevVAddr)
277
 
{
278
 
        PVRSRV_STUB_PBDESC *psStubPBDesc=IMG_NULL;
279
 
        PVRSRV_ERROR eRet = PVRSRV_ERROR_INVALID_PERPROC;
280
 
        IMG_UINT32 i;
281
 
        PVRSRV_SGXDEV_INFO *psSGXDevInfo;
282
 
        PRESMAN_ITEM psResItem;
283
 
 
284
 
        
285
 
        if (psPerProcCreateSharedPB != psPerProc)
286
 
        {
287
 
                goto NoAdd;
288
 
        }
289
 
        else
290
 
        {
291
 
                PVR_ASSERT(psResItemCreateSharedPB != IMG_NULL);
292
 
 
293
 
                ResManFreeResByPtr(psResItemCreateSharedPB, CLEANUP_WITH_POLL);
294
 
 
295
 
                PVR_ASSERT(psResItemCreateSharedPB == IMG_NULL);
296
 
                PVR_ASSERT(psPerProcCreateSharedPB == IMG_NULL);
297
 
        }
298
 
 
299
 
        psSGXDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookie)->pvDevice;
300
 
 
301
 
        psStubPBDesc = psSGXDevInfo->psStubPBDescListKM;
302
 
        if (psStubPBDesc != IMG_NULL)
303
 
        {
304
 
                if(psStubPBDesc->ui32TotalPBSize != ui32TotalPBSize)
305
 
                {
306
 
                        PVR_DPF((PVR_DBG_WARNING,
307
 
                                        "SGXAddSharedPBDescKM: Shared PB requested with different size (0x%x) from existing shared PB (0x%x) - requested size ignored",
308
 
                                        ui32TotalPBSize, psStubPBDesc->ui32TotalPBSize));
309
 
 
310
 
                }
311
 
 
312
 
                
313
 
                psResItem = ResManRegisterRes(psPerProc->hResManContext,
314
 
                                                                          RESMAN_TYPE_SHARED_PB_DESC,
315
 
                                                                          psStubPBDesc,
316
 
                                                                          0,
317
 
                                                                          &SGXCleanupSharedPBDescCallback);
318
 
                if (psResItem == IMG_NULL)
319
 
                {
320
 
                        PVR_DPF((PVR_DBG_ERROR,
321
 
                                "SGXAddSharedPBDescKM: "
322
 
                                "Failed to register existing shared "
323
 
                                "PBDesc with the resource manager"));
324
 
                        goto NoAddKeepPB;
325
 
                }
326
 
 
327
 
                
328
 
                psStubPBDesc->ui32RefCount++;
329
 
 
330
 
                *phSharedPBDesc = (IMG_HANDLE)psResItem;
331
 
                eRet = PVRSRV_OK;
332
 
                goto NoAddKeepPB;
333
 
        }
334
 
 
335
 
        if(OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
336
 
                                  sizeof(PVRSRV_STUB_PBDESC),
337
 
                                  (IMG_VOID **)&psStubPBDesc,
338
 
                                  0,
339
 
                                  "Stub Parameter Buffer Description") != PVRSRV_OK)
340
 
        {
341
 
                PVR_DPF((PVR_DBG_ERROR, "SGXAddSharedPBDescKM: Failed to alloc "
342
 
                                        "StubPBDesc"));
343
 
                eRet = PVRSRV_ERROR_OUT_OF_MEMORY;
344
 
                goto NoAdd;
345
 
        }
346
 
 
347
 
 
348
 
        psStubPBDesc->ppsSubKernelMemInfos = IMG_NULL;
349
 
 
350
 
        if(OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
351
 
                                  sizeof(PVRSRV_KERNEL_MEM_INFO *)
352
 
                                  * ui32SharedPBDescSubKernelMemInfosCount,
353
 
                                  (IMG_VOID **)&psStubPBDesc->ppsSubKernelMemInfos,
354
 
                                  0,
355
 
                                  "Array of Kernel Memory Info") != PVRSRV_OK)
356
 
        {
357
 
                PVR_DPF((PVR_DBG_ERROR, "SGXAddSharedPBDescKM: "
358
 
                                 "Failed to alloc "
359
 
                                 "StubPBDesc->ppsSubKernelMemInfos"));
360
 
                eRet = PVRSRV_ERROR_OUT_OF_MEMORY;
361
 
                goto NoAdd;
362
 
        }
363
 
 
364
 
        if(PVRSRVDissociateMemFromResmanKM(psSharedPBDescKernelMemInfo)
365
 
           != PVRSRV_OK)
366
 
        {
367
 
                goto NoAdd;
368
 
        }
369
 
 
370
 
        if(PVRSRVDissociateMemFromResmanKM(psHWPBDescKernelMemInfo)
371
 
           != PVRSRV_OK)
372
 
        {
373
 
                goto NoAdd;
374
 
        }
375
 
 
376
 
        if(PVRSRVDissociateMemFromResmanKM(psBlockKernelMemInfo)
377
 
           != PVRSRV_OK)
378
 
        {
379
 
                goto NoAdd;
380
 
        }
381
 
 
382
 
        if(PVRSRVDissociateMemFromResmanKM(psHWBlockKernelMemInfo)
383
 
           != PVRSRV_OK)
384
 
        {
385
 
                goto NoAdd;
386
 
        }
387
 
 
388
 
        psStubPBDesc->ui32RefCount = 1;
389
 
        psStubPBDesc->ui32TotalPBSize = ui32TotalPBSize;
390
 
        psStubPBDesc->psSharedPBDescKernelMemInfo = psSharedPBDescKernelMemInfo;
391
 
        psStubPBDesc->psHWPBDescKernelMemInfo = psHWPBDescKernelMemInfo;
392
 
        psStubPBDesc->psBlockKernelMemInfo = psBlockKernelMemInfo;
393
 
        psStubPBDesc->psHWBlockKernelMemInfo = psHWBlockKernelMemInfo;
394
 
 
395
 
        psStubPBDesc->ui32SubKernelMemInfosCount =
396
 
                ui32SharedPBDescSubKernelMemInfosCount;
397
 
        for(i=0; i<ui32SharedPBDescSubKernelMemInfosCount; i++)
398
 
        {
399
 
                psStubPBDesc->ppsSubKernelMemInfos[i] = ppsSharedPBDescSubKernelMemInfos[i];
400
 
                if(PVRSRVDissociateMemFromResmanKM(ppsSharedPBDescSubKernelMemInfos[i])
401
 
                   != PVRSRV_OK)
402
 
                {
403
 
                        PVR_DPF((PVR_DBG_ERROR, "SGXAddSharedPBDescKM: "
404
 
                                         "Failed to dissociate shared PBDesc "
405
 
                                         "from process"));
406
 
                        goto NoAdd;
407
 
                }
408
 
        }
409
 
 
410
 
        psStubPBDesc->sHWPBDescDevVAddr = sHWPBDescDevVAddr;
411
 
 
412
 
        psResItem = ResManRegisterRes(psPerProc->hResManContext,
413
 
                                                                  RESMAN_TYPE_SHARED_PB_DESC,
414
 
                                                                  psStubPBDesc,
415
 
                                                                  0,
416
 
                                                                  &SGXCleanupSharedPBDescCallback);
417
 
        if (psResItem == IMG_NULL)
418
 
        {
419
 
                PVR_DPF((PVR_DBG_ERROR, "SGXAddSharedPBDescKM: "
420
 
                                         "Failed to register shared PBDesc "
421
 
                                         " with the resource manager"));
422
 
                goto NoAdd;
423
 
        }
424
 
        psStubPBDesc->hDevCookie = hDevCookie;
425
 
 
426
 
        
427
 
        List_PVRSRV_STUB_PBDESC_Insert(&(psSGXDevInfo->psStubPBDescListKM),
428
 
                                                                        psStubPBDesc);
429
 
 
430
 
        *phSharedPBDesc = (IMG_HANDLE)psResItem;
431
 
 
432
 
        return PVRSRV_OK;
433
 
 
434
 
NoAdd:
435
 
        if(psStubPBDesc)
436
 
        {
437
 
                if(psStubPBDesc->ppsSubKernelMemInfos)
438
 
                {
439
 
                        OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
440
 
                                          sizeof(PVRSRV_KERNEL_MEM_INFO *) * ui32SharedPBDescSubKernelMemInfosCount,
441
 
                                          psStubPBDesc->ppsSubKernelMemInfos,
442
 
                                          0);
443
 
                        psStubPBDesc->ppsSubKernelMemInfos = IMG_NULL;
444
 
                }
445
 
                OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
446
 
                                  sizeof(PVRSRV_STUB_PBDESC),
447
 
                                  psStubPBDesc,
448
 
                                  0);
449
 
                
450
 
        }
451
 
 
452
 
NoAddKeepPB:
453
 
        for (i = 0; i < ui32SharedPBDescSubKernelMemInfosCount; i++)
454
 
        {
455
 
                PVRSRVFreeDeviceMemKM(hDevCookie, ppsSharedPBDescSubKernelMemInfos[i]);
456
 
        }
457
 
 
458
 
        PVRSRVFreeSharedSysMemoryKM(psSharedPBDescKernelMemInfo);
459
 
        PVRSRVFreeDeviceMemKM(hDevCookie, psHWPBDescKernelMemInfo);
460
 
 
461
 
        PVRSRVFreeSharedSysMemoryKM(psBlockKernelMemInfo);
462
 
        PVRSRVFreeDeviceMemKM(hDevCookie, psHWBlockKernelMemInfo);
463
 
 
464
 
        return eRet;
465
 
}
466