[android-sdk/device-ti-proprietary-open.git] / jacinto6 / sgx_src / eurasia_km / services4 / srvkm / common / refcount.c
1 /*************************************************************************/ /*!
2 @Title Services reference count debugging
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License Dual MIT/GPLv2
6 The contents of this file are subject to the MIT license as set out below.
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:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
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.
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.
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
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 */ /**************************************************************************/
42 #if defined(PVRSRV_REFCOUNT_DEBUG)
44 #include "services_headers.h"
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>
52 static 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__ */
62 #define PVRSRV_REFCOUNT_CCB_MAX 512
63 #define PVRSRV_REFCOUNT_CCB_MESG_MAX 80
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)
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
79 #define PVRSRV_REFCOUNT_CCB_DEBUG_ALL ~0U
81 /*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/
82 static const IMG_UINT guiDebugMask =
83 PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO |
84 PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2;
86 typedef 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 }
93 PVRSRV_REFCOUNT_CCB;
95 static PVRSRV_REFCOUNT_CCB gsRefCountCCB[PVRSRV_REFCOUNT_CCB_MAX];
96 static IMG_UINT giOffset;
98 static 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 */
105 #define PVRSRV_REFCOUNT_CCB_FMT_STRING "%8.8s %8p %8p %8p %8p %.4d %.4d %.8x"
107 IMG_INTERNAL
108 void PVRSRVDumpRefCountCCB(void)
109 {
110 int i;
112 PVRSRV_LOCK_CCB();
114 PVR_LOG(("%s", gszHeader));
116 for(i = 0; i < PVRSRV_REFCOUNT_CCB_MAX; i++)
117 {
118 PVRSRV_REFCOUNT_CCB *psRefCountCCBEntry =
119 &gsRefCountCCB[(giOffset + i) % PVRSRV_REFCOUNT_CCB_MAX];
121 /* Early on, we won't have MAX_REFCOUNT_CCB_SIZE messages */
122 if(!psRefCountCCBEntry->pszFile)
123 break;
125 PVR_LOG(("%s %d %s:%d", psRefCountCCBEntry->pcMesg,
126 psRefCountCCBEntry->ui32PID,
127 psRefCountCCBEntry->pszFile,
128 psRefCountCCBEntry->iLine));
129 }
131 PVRSRV_UNLOCK_CCB();
132 }
134 IMG_INTERNAL
135 void 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);
141 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO))
142 goto skip;
144 PVRSRV_LOCK_CCB();
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;
163 PVRSRV_UNLOCK_CCB();
165 skip:
166 PVRSRVAcquireSyncInfoKM(psKernelSyncInfo);
167 }
169 IMG_INTERNAL
170 void 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);
176 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO))
177 goto skip;
179 PVRSRV_LOCK_CCB();
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;
198 PVRSRV_UNLOCK_CCB();
200 skip:
201 PVRSRVReleaseSyncInfoKM(psKernelSyncInfo);
202 }
204 IMG_INTERNAL
205 void 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;
211 PVRSRV_LOCK_CCB();
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;
230 PVRSRV_UNLOCK_CCB();
232 skip:
233 psKernelMemInfo->ui32RefCount++;
234 }
236 IMG_INTERNAL
237 void 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;
243 PVRSRV_LOCK_CCB();
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;
262 PVRSRV_UNLOCK_CCB();
264 skip:
265 psKernelMemInfo->ui32RefCount--;
266 }
268 IMG_INTERNAL
269 void PVRSRVBMBufIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
270 {
271 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF))
272 goto skip;
274 PVRSRV_LOCK_CCB();
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;
293 PVRSRV_UNLOCK_CCB();
295 skip:
296 pBuf->ui32RefCount++;
297 }
299 IMG_INTERNAL
300 void PVRSRVBMBufDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
301 {
302 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF))
303 goto skip;
305 PVRSRV_LOCK_CCB();
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;
324 PVRSRV_UNLOCK_CCB();
326 skip:
327 pBuf->ui32RefCount--;
328 }
330 IMG_INTERNAL
331 void PVRSRVBMBufIncExport2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
332 {
333 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF2))
334 goto skip;
336 PVRSRV_LOCK_CCB();
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;
355 PVRSRV_UNLOCK_CCB();
357 skip:
358 pBuf->ui32ExportCount++;
359 }
361 IMG_INTERNAL
362 void PVRSRVBMBufDecExport2(const IMG_CHAR *pszFile, IMG_INT iLine, BM_BUF *pBuf)
363 {
364 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF2))
365 goto skip;
367 PVRSRV_LOCK_CCB();
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;
386 PVRSRV_UNLOCK_CCB();
388 skip:
389 pBuf->ui32ExportCount--;
390 }
392 IMG_INTERNAL
393 void PVRSRVBMXProcIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index)
394 {
395 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC))
396 goto skip;
398 PVRSRV_LOCK_CCB();
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;
417 PVRSRV_UNLOCK_CCB();
419 skip:
420 gXProcWorkaroundShareData[ui32Index].ui32RefCount++;
421 }
423 IMG_INTERNAL
424 void PVRSRVBMXProcDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index)
425 {
426 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC))
427 goto skip;
429 PVRSRV_LOCK_CCB();
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;
448 PVRSRV_UNLOCK_CCB();
450 skip:
451 gXProcWorkaroundShareData[ui32Index].ui32RefCount--;
452 }
454 #if defined(__linux__)
456 /* mmap refcounting is Linux specific */
458 IMG_INTERNAL
459 void 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;
465 PVRSRV_LOCK_CCB();
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;
484 PVRSRV_UNLOCK_CCB();
486 skip:
487 psOffsetStruct->ui32RefCount++;
488 }
490 IMG_INTERNAL
491 void 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;
497 PVRSRV_LOCK_CCB();
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;
516 PVRSRV_UNLOCK_CCB();
518 skip:
519 psOffsetStruct->ui32RefCount--;
520 }
522 IMG_INTERNAL
523 void 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;
529 PVRSRV_LOCK_CCB();
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;
548 PVRSRV_UNLOCK_CCB();
550 skip:
551 psOffsetStruct->ui32Mapped++;
552 }
554 IMG_INTERNAL
555 void 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;
561 PVRSRV_LOCK_CCB();
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;
580 PVRSRV_UNLOCK_CCB();
582 skip:
583 psOffsetStruct->ui32Mapped--;
584 }
586 #endif /* defined(__linux__) */
588 #endif /* defined(PVRSRV_REFCOUNT_DEBUG) */