summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c')
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c588
1 files changed, 588 insertions, 0 deletions
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c
new file mode 100644
index 0000000..fa64b23
--- /dev/null
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c
@@ -0,0 +1,588 @@
1/*************************************************************************/ /*!
2@Title Services reference count debugging
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2
5
6The contents of this file are subject to the MIT license as set out below.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18Alternatively, the contents of this file may be used under the terms of
19the GNU General Public License Version 2 ("GPL") in which case the provisions
20of GPL are applicable instead of those above.
21
22If you wish to allow use of your version of this file only under the terms of
23GPL, and not to allow others to use your version of this file under the terms
24of the MIT license, indicate your decision by deleting the provisions above
25and replace them with the notice and other provisions required by GPL as set
26out in the file called "GPL-COPYING" included in this distribution. If you do
27not delete the provisions above, a recipient may use your version of this file
28under the terms of either the MIT license or GPL.
29
30This License is also included in this distribution in the file called
31"MIT-COPYING".
32
33EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/ /**************************************************************************/
41
42#if defined(PVRSRV_REFCOUNT_DEBUG)
43
44#include "services_headers.h"
45
46#ifndef __linux__
47#warning Reference count debugging is not thread-safe on this platform
48#define PVRSRV_LOCK_CCB()
49#define PVRSRV_UNLOCK_CCB()
50#else /* __linux__ */
51#include <linux/spinlock.h>
52static DEFINE_SPINLOCK(gsCCBLock);
53#define PVRSRV_LOCK_CCB() \
54 { \
55 unsigned long flags; \
56 spin_lock_irqsave(&gsCCBLock, flags);
57#define PVRSRV_UNLOCK_CCB() \
58 spin_unlock_irqrestore(&gsCCBLock, flags); \
59 }
60#endif /* __linux__ */
61
62#define PVRSRV_REFCOUNT_CCB_MAX 512
63#define PVRSRV_REFCOUNT_CCB_MESG_MAX 80
64
65#define PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO (1U << 0)
66#define PVRSRV_REFCOUNT_CCB_DEBUG_MEMINFO (1U << 1)
67#define PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF (1U << 2)
68#define PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF2 (1U << 3)
69#define PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC (1U << 4)
70
71#if defined(__linux__)
72#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 16)
73#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 17)
74#else
75#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP 0
76#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 0
77#endif
78
79#define PVRSRV_REFCOUNT_CCB_DEBUG_ALL ~0U
80
81/*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/
82static const IMG_UINT guiDebugMask =
83 PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO |
84 PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2;
85
86typedef struct
87{
88 const IMG_CHAR *pszFile;
89 IMG_INT iLine;
90 IMG_UINT32 ui32PID;
91 IMG_CHAR pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX];
92}
93PVRSRV_REFCOUNT_CCB;
94
95static PVRSRV_REFCOUNT_CCB gsRefCountCCB[PVRSRV_REFCOUNT_CCB_MAX];
96static IMG_UINT giOffset;
97
98static const IMG_CHAR gszHeader[] =
99 /* 10 20 30 40 50 60 70
100 * 345678901234567890123456789012345678901234567890123456789012345678901
101 */
102 "TYPE SYNCINFO MEMINFO MEMHANDLE OTHER REF REF' SIZE PID";
103 /* NCINFO deadbeef deadbeef deadbeef deadbeef 1234 1234 deadbeef */
104
105#define PVRSRV_REFCOUNT_CCB_FMT_STRING "%8.8s %8p %8p %8p %8p %.4d %.4d %.8x"
106
107IMG_INTERNAL
108void PVRSRVDumpRefCountCCB(void)
109{
110 int i;
111
112 PVRSRV_LOCK_CCB();
113
114 PVR_LOG(("%s", gszHeader));
115
116 for(i = 0; i < PVRSRV_REFCOUNT_CCB_MAX; i++)
117 {
118 PVRSRV_REFCOUNT_CCB *psRefCountCCBEntry =
119 &gsRefCountCCB[(giOffset + i) % PVRSRV_REFCOUNT_CCB_MAX];
120
121 /* Early on, we won't have MAX_REFCOUNT_CCB_SIZE messages */
122 if(!psRefCountCCBEntry->pszFile)
123 break;
124
125 PVR_LOG(("%s %d %s:%d", psRefCountCCBEntry->pcMesg,
126 psRefCountCCBEntry->ui32PID,
127 psRefCountCCBEntry->pszFile,
128 psRefCountCCBEntry->iLine));
129 }
130
131 PVRSRV_UNLOCK_CCB();
132}
133
134IMG_INTERNAL
135void PVRSRVKernelSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
136 PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
137 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
138{
139 IMG_UINT32 ui32RefValue = OSAtomicRead(psKernelSyncInfo->pvRefCount);
140
141 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO))
142 goto skip;
143
144 PVRSRV_LOCK_CCB();
145
146 gsRefCountCCB[giOffset].pszFile = pszFile;
147 gsRefCountCCB[giOffset].iLine = iLine;
148 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
149 snprintf(gsRefCountCCB[giOffset].pcMesg,
150 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
151 PVRSRV_REFCOUNT_CCB_FMT_STRING,
152 "SYNCINFO",
153 psKernelSyncInfo,
154 psKernelMemInfo,
155 NULL,
156 (psKernelMemInfo) ? psKernelMemInfo->sMemBlk.hOSMemHandle : NULL,
157 ui32RefValue,
158 ui32RefValue + 1,
159 (psKernelMemInfo) ? psKernelMemInfo->uAllocSize : 0);
160 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
161 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
162
163 PVRSRV_UNLOCK_CCB();
164
165skip:
166 PVRSRVAcquireSyncInfoKM(psKernelSyncInfo);
167}
168
169IMG_INTERNAL
170void PVRSRVKernelSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
171 PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
172 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
173{
174 IMG_UINT32 ui32RefValue = OSAtomicRead(psKernelSyncInfo->pvRefCount);
175
176 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO))
177 goto skip;
178
179 PVRSRV_LOCK_CCB();
180
181 gsRefCountCCB[giOffset].pszFile = pszFile;
182 gsRefCountCCB[giOffset].iLine = iLine;
183 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
184 snprintf(gsRefCountCCB[giOffset].pcMesg,
185 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
186 PVRSRV_REFCOUNT_CCB_FMT_STRING,
187 "SYNCINFO",
188 psKernelSyncInfo,
189 psKernelMemInfo,
190 (psKernelMemInfo) ? psKernelMemInfo->sMemBlk.hOSMemHandle : NULL,
191 NULL,
192 ui32RefValue,
193 ui32RefValue - 1,
194 (psKernelMemInfo) ? psKernelMemInfo->uAllocSize : 0);
195 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
196 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
197
198 PVRSRV_UNLOCK_CCB();
199
200skip:
201 PVRSRVReleaseSyncInfoKM(psKernelSyncInfo);
202}
203
204IMG_INTERNAL
205void PVRSRVKernelMemInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
206 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
207{
208 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_MEMINFO))
209 goto skip;
210
211 PVRSRV_LOCK_CCB();
212
213 gsRefCountCCB[giOffset].pszFile = pszFile;
214 gsRefCountCCB[giOffset].iLine = iLine;
215 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
216 snprintf(gsRefCountCCB[giOffset].pcMesg,
217 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
218 PVRSRV_REFCOUNT_CCB_FMT_STRING,
219 "MEMINFO",
220 psKernelMemInfo->psKernelSyncInfo,
221 psKernelMemInfo,
222 psKernelMemInfo->sMemBlk.hOSMemHandle,
223 NULL,
224 psKernelMemInfo->ui32RefCount,
225 psKernelMemInfo->ui32RefCount + 1,
226 psKernelMemInfo->uAllocSize);
227 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
228 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
229
230 PVRSRV_UNLOCK_CCB();
231
232skip:
233 psKernelMemInfo->ui32RefCount++;
234}
235
236IMG_INTERNAL
237void PVRSRVKernelMemInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
238 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
239{
240 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_MEMINFO))
241 goto skip;
242
243 PVRSRV_LOCK_CCB();
244
245 gsRefCountCCB[giOffset].pszFile = pszFile;
246 gsRefCountCCB[giOffset].iLine = iLine;
247 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
248 snprintf(gsRefCountCCB[giOffset].pcMesg,
249 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
250 PVRSRV_REFCOUNT_CCB_FMT_STRING,
251 "MEMINFO",
252 psKernelMemInfo->psKernelSyncInfo,
253 psKernelMemInfo,
254 psKernelMemInfo->sMemBlk.hOSMemHandle,
255 NULL,
256 psKernelMemInfo->ui32RefCount,
257 psKernelMemInfo->ui32RefCount - 1,
258 psKernelMemInfo->uAllocSize);
259 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
260 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
261
262 PVRSRV_UNLOCK_CCB();
263
264skip:
265 psKernelMemInfo->ui32RefCount--;
266}
267
268IMG_INTERNAL
269void PVRSRVBMBufIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
270{
271 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF))
272 goto skip;
273
274 PVRSRV_LOCK_CCB();
275
276 gsRefCountCCB[giOffset].pszFile = pszFile;
277 gsRefCountCCB[giOffset].iLine = iLine;
278 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
279 snprintf(gsRefCountCCB[giOffset].pcMesg,
280 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
281 PVRSRV_REFCOUNT_CCB_FMT_STRING,
282 "BM_BUF",
283 NULL,
284 NULL,
285 BM_HandleToOSMemHandle(pBuf),
286 pBuf,
287 pBuf->ui32RefCount,
288 pBuf->ui32RefCount + 1,
289 (pBuf->pMapping) ? pBuf->pMapping->uSize : 0);
290 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
291 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
292
293 PVRSRV_UNLOCK_CCB();
294
295skip:
296 pBuf->ui32RefCount++;
297}
298
299IMG_INTERNAL
300void PVRSRVBMBufDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
301{
302 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF))
303 goto skip;
304
305 PVRSRV_LOCK_CCB();
306
307 gsRefCountCCB[giOffset].pszFile = pszFile;
308 gsRefCountCCB[giOffset].iLine = iLine;
309 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
310 snprintf(gsRefCountCCB[giOffset].pcMesg,
311 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
312 PVRSRV_REFCOUNT_CCB_FMT_STRING,
313 "BM_BUF",
314 NULL,
315 NULL,
316 BM_HandleToOSMemHandle(pBuf),
317 pBuf,
318 pBuf->ui32RefCount,
319 pBuf->ui32RefCount - 1,
320 (pBuf->pMapping) ? pBuf->pMapping->uSize : 0);
321 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
322 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
323
324 PVRSRV_UNLOCK_CCB();
325
326skip:
327 pBuf->ui32RefCount--;
328}
329
330IMG_INTERNAL
331void PVRSRVBMBufIncExport2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
332{
333 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF2))
334 goto skip;
335
336 PVRSRV_LOCK_CCB();
337
338 gsRefCountCCB[giOffset].pszFile = pszFile;
339 gsRefCountCCB[giOffset].iLine = iLine;
340 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
341 snprintf(gsRefCountCCB[giOffset].pcMesg,
342 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
343 PVRSRV_REFCOUNT_CCB_FMT_STRING,
344 "BM_BUF2",
345 NULL,
346 NULL,
347 BM_HandleToOSMemHandle(pBuf),
348 pBuf,
349 pBuf->ui32ExportCount,
350 pBuf->ui32ExportCount + 1,
351 (pBuf->pMapping) ? pBuf->pMapping->uSize : 0);
352 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
353 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
354
355 PVRSRV_UNLOCK_CCB();
356
357skip:
358 pBuf->ui32ExportCount++;
359}
360
361IMG_INTERNAL
362void PVRSRVBMBufDecExport2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
363{
364 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF2))
365 goto skip;
366
367 PVRSRV_LOCK_CCB();
368
369 gsRefCountCCB[giOffset].pszFile = pszFile;
370 gsRefCountCCB[giOffset].iLine = iLine;
371 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
372 snprintf(gsRefCountCCB[giOffset].pcMesg,
373 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
374 PVRSRV_REFCOUNT_CCB_FMT_STRING,
375 "BM_BUF2",
376 NULL,
377 NULL,
378 BM_HandleToOSMemHandle(pBuf),
379 pBuf,
380 pBuf->ui32ExportCount,
381 pBuf->ui32ExportCount - 1,
382 (pBuf->pMapping) ? pBuf->pMapping->uSize : 0);
383 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
384 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
385
386 PVRSRV_UNLOCK_CCB();
387
388skip:
389 pBuf->ui32ExportCount--;
390}
391
392IMG_INTERNAL
393void PVRSRVBMXProcIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index)
394{
395 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC))
396 goto skip;
397
398 PVRSRV_LOCK_CCB();
399
400 gsRefCountCCB[giOffset].pszFile = pszFile;
401 gsRefCountCCB[giOffset].iLine = iLine;
402 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
403 snprintf(gsRefCountCCB[giOffset].pcMesg,
404 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
405 PVRSRV_REFCOUNT_CCB_FMT_STRING,
406 "BM_XPROC",
407 NULL,
408 NULL,
409 gXProcWorkaroundShareData[ui32Index].hOSMemHandle,
410 (IMG_VOID *) ui32Index,
411 gXProcWorkaroundShareData[ui32Index].ui32RefCount,
412 gXProcWorkaroundShareData[ui32Index].ui32RefCount + 1,
413 gXProcWorkaroundShareData[ui32Index].ui32Size);
414 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
415 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
416
417 PVRSRV_UNLOCK_CCB();
418
419skip:
420 gXProcWorkaroundShareData[ui32Index].ui32RefCount++;
421}
422
423IMG_INTERNAL
424void PVRSRVBMXProcDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index)
425{
426 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC))
427 goto skip;
428
429 PVRSRV_LOCK_CCB();
430
431 gsRefCountCCB[giOffset].pszFile = pszFile;
432 gsRefCountCCB[giOffset].iLine = iLine;
433 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
434 snprintf(gsRefCountCCB[giOffset].pcMesg,
435 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
436 PVRSRV_REFCOUNT_CCB_FMT_STRING,
437 "BM_XPROC",
438 NULL,
439 NULL,
440 gXProcWorkaroundShareData[ui32Index].hOSMemHandle,
441 (IMG_VOID *) ui32Index,
442 gXProcWorkaroundShareData[ui32Index].ui32RefCount,
443 gXProcWorkaroundShareData[ui32Index].ui32RefCount - 1,
444 gXProcWorkaroundShareData[ui32Index].ui32Size);
445 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
446 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
447
448 PVRSRV_UNLOCK_CCB();
449
450skip:
451 gXProcWorkaroundShareData[ui32Index].ui32RefCount--;
452}
453
454#if defined(__linux__)
455
456/* mmap refcounting is Linux specific */
457
458IMG_INTERNAL
459void PVRSRVOffsetStructIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
460 PKV_OFFSET_STRUCT psOffsetStruct)
461{
462 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_MMAP))
463 goto skip;
464
465 PVRSRV_LOCK_CCB();
466
467 gsRefCountCCB[giOffset].pszFile = pszFile;
468 gsRefCountCCB[giOffset].iLine = iLine;
469 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
470 snprintf(gsRefCountCCB[giOffset].pcMesg,
471 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
472 PVRSRV_REFCOUNT_CCB_FMT_STRING,
473 "MMAP",
474 NULL,
475 NULL,
476 psOffsetStruct->psLinuxMemArea,
477 psOffsetStruct,
478 psOffsetStruct->ui32RefCount,
479 psOffsetStruct->ui32RefCount + 1,
480 psOffsetStruct->ui32RealByteSize);
481 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
482 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
483
484 PVRSRV_UNLOCK_CCB();
485
486skip:
487 psOffsetStruct->ui32RefCount++;
488}
489
490IMG_INTERNAL
491void PVRSRVOffsetStructDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
492 PKV_OFFSET_STRUCT psOffsetStruct)
493{
494 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_MMAP))
495 goto skip;
496
497 PVRSRV_LOCK_CCB();
498
499 gsRefCountCCB[giOffset].pszFile = pszFile;
500 gsRefCountCCB[giOffset].iLine = iLine;
501 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
502 snprintf(gsRefCountCCB[giOffset].pcMesg,
503 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
504 PVRSRV_REFCOUNT_CCB_FMT_STRING,
505 "MMAP",
506 NULL,
507 NULL,
508 psOffsetStruct->psLinuxMemArea,
509 psOffsetStruct,
510 psOffsetStruct->ui32RefCount,
511 psOffsetStruct->ui32RefCount - 1,
512 psOffsetStruct->ui32RealByteSize);
513 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
514 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
515
516 PVRSRV_UNLOCK_CCB();
517
518skip:
519 psOffsetStruct->ui32RefCount--;
520}
521
522IMG_INTERNAL
523void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
524 PKV_OFFSET_STRUCT psOffsetStruct)
525{
526 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2))
527 goto skip;
528
529 PVRSRV_LOCK_CCB();
530
531 gsRefCountCCB[giOffset].pszFile = pszFile;
532 gsRefCountCCB[giOffset].iLine = iLine;
533 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
534 snprintf(gsRefCountCCB[giOffset].pcMesg,
535 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
536 PVRSRV_REFCOUNT_CCB_FMT_STRING,
537 "MMAP2",
538 NULL,
539 NULL,
540 psOffsetStruct->psLinuxMemArea,
541 psOffsetStruct,
542 psOffsetStruct->ui32Mapped,
543 psOffsetStruct->ui32Mapped + 1,
544 psOffsetStruct->ui32RealByteSize);
545 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
546 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
547
548 PVRSRV_UNLOCK_CCB();
549
550skip:
551 psOffsetStruct->ui32Mapped++;
552}
553
554IMG_INTERNAL
555void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
556 PKV_OFFSET_STRUCT psOffsetStruct)
557{
558 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2))
559 goto skip;
560
561 PVRSRV_LOCK_CCB();
562
563 gsRefCountCCB[giOffset].pszFile = pszFile;
564 gsRefCountCCB[giOffset].iLine = iLine;
565 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
566 snprintf(gsRefCountCCB[giOffset].pcMesg,
567 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
568 PVRSRV_REFCOUNT_CCB_FMT_STRING,
569 "MMAP2",
570 NULL,
571 NULL,
572 psOffsetStruct->psLinuxMemArea,
573 psOffsetStruct,
574 psOffsetStruct->ui32Mapped,
575 psOffsetStruct->ui32Mapped - 1,
576 psOffsetStruct->ui32RealByteSize);
577 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
578 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
579
580 PVRSRV_UNLOCK_CCB();
581
582skip:
583 psOffsetStruct->ui32Mapped--;
584}
585
586#endif /* defined(__linux__) */
587
588#endif /* defined(PVRSRV_REFCOUNT_DEBUG) */