1 /*************************************************************************/ /*!
3 @Title PVR Bridge Module (kernel side)
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Receives calls from the user portion of services and
6 despatches them to functions in the kernel portion.
7 @License Dual MIT/GPLv2
9 The contents of this file are subject to the MIT license as set out below.
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
33 This License is also included in this distribution in the file called
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
45 #include <linux/mm_types.h>
48 #include "pvr_bridge.h"
49 #include "connection_server.h"
50 #include "syscommon.h"
51 #include "pvr_debug.h"
52 #include "pvr_debugfs.h"
53 #include "private_data.h"
56 #include "rgx_bvnc_defs_km.h"
62 #include "env_connection.h"
63 #include <linux/sched.h>
66 #if defined(SUPPORT_RGX)
67 #include "rgx_bridge.h"
71 #include "common_srvcore_bridge.h"
73 #if defined(SUPPORT_DRM_EXT)
74 #define CAST_BRIDGE_CMD_PTR_TO_PTR(ptr) (ptr)
76 #define CAST_BRIDGE_CMD_PTR_TO_PTR(ptr) (void *)(uintptr_t)(ptr)
79 #if defined(MODULE_TEST)
80 /************************************************************************/
81 // additional includes for services testing
82 /************************************************************************/
83 #include "pvr_test_bridge.h"
84 #include "kern_test.h"
85 /************************************************************************/
86 // end of additional includes
87 /************************************************************************/
91 * The mmap code has its own mutex, to prevent a possible deadlock,
92 * when using gPVRSRVLock.
93 * The Linux kernel takes the mm->mmap_sem before calling the mmap
94 * entry points (PVRMMap, MMapVOpen, MMapVClose), but the ioctl
95 * entry point may take mm->mmap_sem during fault handling, or
96 * before calling get_user_pages. If gPVRSRVLock was used in the
97 * mmap entry points, a deadlock could result, due to the ioctl
98 * and mmap code taking the two locks in different orders.
99 * As a corollary to this, the mmap entry points must not call
100 * any driver code that relies on gPVRSRVLock is held.
102 static DEFINE_MUTEX(g_sMMapMutex);
104 #if defined(DEBUG_BRIDGE_KM)
105 static PVR_DEBUGFS_ENTRY_DATA *gpsPVRDebugFSBridgeStatsEntry = NULL;
106 static struct seq_operations gsBridgeStatsReadOps;
109 /* These will go when full bridge gen comes in */
111 PVRSRV_ERROR InitPDUMPCTRLBridge(void);
112 PVRSRV_ERROR DeinitPDUMPCTRLBridge(void);
113 PVRSRV_ERROR InitPDUMPBridge(void);
114 PVRSRV_ERROR DeinitPDUMPBridge(void);
115 PVRSRV_ERROR InitRGXPDUMPBridge(void);
116 PVRSRV_ERROR DeinitRGXPDUMPBridge(void);
118 #if defined(SUPPORT_DISPLAY_CLASS)
119 PVRSRV_ERROR InitDCBridge(void);
120 PVRSRV_ERROR DeinitDCBridge(void);
122 PVRSRV_ERROR InitMMBridge(void);
123 PVRSRV_ERROR DeinitMMBridge(void);
124 #if !defined(EXCLUDE_CMM_BRIDGE)
125 PVRSRV_ERROR InitCMMBridge(void);
126 PVRSRV_ERROR DeinitCMMBridge(void);
128 PVRSRV_ERROR InitPDUMPMMBridge(void);
129 PVRSRV_ERROR DeinitPDUMPMMBridge(void);
130 PVRSRV_ERROR InitSRVCOREBridge(void);
131 PVRSRV_ERROR DeinitSRVCOREBridge(void);
132 PVRSRV_ERROR InitSYNCBridge(void);
133 PVRSRV_ERROR DeinitSYNCBridge(void);
135 #if defined(SUPPORT_SERVER_SYNC)
136 #if defined(SUPPORT_INSECURE_EXPORT)
137 PVRSRV_ERROR InitSYNCEXPORTBridge(void);
138 PVRSRV_ERROR DeinitSYNCEXPORTBridge(void);
140 #if defined(SUPPORT_SECURE_EXPORT)
141 PVRSRV_ERROR InitSYNCSEXPORTBridge(void);
142 PVRSRV_ERROR DeinitSYNCSEXPORTBridge(void);
144 #endif /* defined(SUPPORT_SERVER_SYNC) */
146 #if defined (SUPPORT_RGX)
147 #if !defined(SUPPORT_KERNEL_SRVINIT)
148 PVRSRV_ERROR InitRGXINITBridge(void);
149 PVRSRV_ERROR DeinitRGXINITBridge(void);
151 PVRSRV_ERROR InitRGXTA3DBridge(void);
152 PVRSRV_ERROR DeinitRGXTA3DBridge(void);
153 PVRSRV_ERROR InitRGXTQBridge(void);
154 PVRSRV_ERROR DeinitRGXTQBridge(void);
155 PVRSRV_ERROR InitRGXTQ2Bridge(void);
156 PVRSRV_ERROR DeinitRGXTQ2Bridge(void);
157 PVRSRV_ERROR InitRGXCMPBridge(void);
158 PVRSRV_ERROR DeinitRGXCMPBridge(void);
159 #if !defined(EXCLUDE_BREAKPOINT_BRIDGE)
160 PVRSRV_ERROR InitBREAKPOINTBridge(void);
161 PVRSRV_ERROR DeinitBREAKPOINTBridge(void);
163 PVRSRV_ERROR InitDEBUGMISCBridge(void);
164 PVRSRV_ERROR DeinitDEBUGMISCBridge(void);
165 PVRSRV_ERROR InitRGXHWPERFBridge(void);
166 PVRSRV_ERROR DeinitRGXHWPERFBridge(void);
167 PVRSRV_ERROR InitRGXRAYBridge(void);
168 PVRSRV_ERROR DeinitRGXRAYBridge(void);
169 #if !defined(EXCLUDE_REGCONFIG_BRIDGE)
170 PVRSRV_ERROR InitREGCONFIGBridge(void);
171 PVRSRV_ERROR DeinitREGCONFIGBridge(void);
173 PVRSRV_ERROR InitTIMERQUERYBridge(void);
174 PVRSRV_ERROR DeinitTIMERQUERYBridge(void);
175 PVRSRV_ERROR InitRGXKICKSYNCBridge(void);
176 PVRSRV_ERROR DeinitRGXKICKSYNCBridge(void);
177 PVRSRV_ERROR InitRGXSIGNALSBridge(void);
178 PVRSRV_ERROR DeinitRGXSIGNALSBridge(void);
179 #endif /* SUPPORT_RGX */
180 PVRSRV_ERROR InitCACHEBridge(void);
181 PVRSRV_ERROR DeinitCACHEBridge(void);
182 #if defined(SUPPORT_SECURE_EXPORT)
183 PVRSRV_ERROR InitSMMBridge(void);
184 PVRSRV_ERROR DeinitSMMBridge(void);
186 #if !defined(EXCLUDE_HTBUFFER_BRIDGE)
187 PVRSRV_ERROR InitHTBUFFERBridge(void);
188 PVRSRV_ERROR DeinitHTBUFFERBridge(void);
190 PVRSRV_ERROR InitPVRTLBridge(void);
191 PVRSRV_ERROR DeinitPVRTLBridge(void);
192 #if defined(PVR_RI_DEBUG)
193 PVRSRV_ERROR InitRIBridge(void);
194 PVRSRV_ERROR DeinitRIBridge(void);
196 #if defined(SUPPORT_PAGE_FAULT_DEBUG)
197 PVRSRV_ERROR InitDEVICEMEMHISTORYBridge(void);
198 PVRSRV_ERROR DeinitDEVICEMEMHISTORYBridge(void);
200 PVRSRV_ERROR InitDMABUFBridge(void);
201 PVRSRV_ERROR DeinitDMABUFBridge(void);
202 #if defined(SUPPORT_VALIDATION_BRIDGE)
203 PVRSRV_ERROR InitVALIDATIONBridge(void);
206 #if defined(PVR_TESTING_UTILS)
207 PVRSRV_ERROR InitTUTILSBridge(void);
208 PVRSRV_ERROR DeinitTUTILSBridge(void);
210 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
211 PVRSRV_ERROR InitSYNCTRACKINGBridge(void);
212 PVRSRV_ERROR DeinitSYNCTRACKINGBridge(void);
214 #if defined(SUPPORT_WRAP_EXTMEM)
215 PVRSRV_ERROR InitMMEXTMEMBridge(void);
216 PVRSRV_ERROR DeinitMMEXTMEMBridge(void);
220 DeviceDepBridgeInit(IMG_UINT64 ui64Features)
224 if(ui64Features & RGX_FEATURE_COMPUTE_BIT_MASK)
226 eError = InitRGXCMPBridge();
227 if (eError != PVRSRV_OK)
234 if(ui64Features & RGX_FEATURE_SIGNAL_SNOOPING_BIT_MASK)
236 eError = InitRGXSIGNALSBridge();
237 if (eError != PVRSRV_OK)
243 if(ui64Features & RGX_FEATURE_RAY_TRACING_BIT_MASK)
245 eError = InitRGXRAYBridge();
246 if (eError != PVRSRV_OK)
252 if(ui64Features & RGX_FEATURE_FASTRENDER_DM_BIT_MASK)
254 eError = InitRGXTQ2Bridge();
255 if (eError != PVRSRV_OK)
266 DeviceDepBridgeDeInit(IMG_UINT64 ui64Features)
270 if(ui64Features & RGX_FEATURE_COMPUTE_BIT_MASK)
272 eError = DeinitRGXCMPBridge();
273 if (eError != PVRSRV_OK)
280 if(ui64Features & RGX_FEATURE_SIGNAL_SNOOPING_BIT_MASK)
282 eError = DeinitRGXSIGNALSBridge();
283 if (eError != PVRSRV_OK)
289 if(ui64Features & RGX_FEATURE_RAY_TRACING_BIT_MASK)
291 eError = DeinitRGXRAYBridge();
292 if (eError != PVRSRV_OK)
298 if(ui64Features & RGX_FEATURE_FASTRENDER_DM_BIT_MASK)
300 eError = DeinitRGXTQ2Bridge();
301 if (eError != PVRSRV_OK)
313 LinuxBridgeInit(void)
316 #if defined(DEBUG_BRIDGE_KM)
319 iResult = PVRDebugFSCreateEntry("bridge_stats",
321 &gsBridgeStatsReadOps,
325 &g_BridgeDispatchTable[0],
326 &gpsPVRDebugFSBridgeStatsEntry);
329 return PVRSRV_ERROR_OUT_OF_MEMORY;
333 BridgeDispatchTableStartOffsetsInit();
335 eError = InitSRVCOREBridge();
336 if (eError != PVRSRV_OK)
341 eError = InitSYNCBridge();
342 if (eError != PVRSRV_OK)
347 #if defined(SUPPORT_SERVER_SYNC)
348 #if defined(SUPPORT_INSECURE_EXPORT)
349 eError = InitSYNCEXPORTBridge();
350 if (eError != PVRSRV_OK)
355 #if defined(SUPPORT_SECURE_EXPORT)
356 eError = InitSYNCSEXPORTBridge();
357 if (eError != PVRSRV_OK)
362 #endif /* defined(SUPPORT_SERVER_SYNC) */
365 eError = InitPDUMPCTRLBridge();
366 if (eError != PVRSRV_OK)
372 eError = InitMMBridge();
373 if (eError != PVRSRV_OK)
377 #if !defined(EXCLUDE_CMM_BRIDGE)
378 eError = InitCMMBridge();
379 if (eError != PVRSRV_OK)
386 eError = InitPDUMPMMBridge();
387 if (eError != PVRSRV_OK)
391 eError = InitPDUMPBridge();
392 if (eError != PVRSRV_OK)
398 eError = InitDMABUFBridge();
399 if (eError != PVRSRV_OK)
404 #if defined(SUPPORT_DISPLAY_CLASS)
405 eError = InitDCBridge();
406 if (eError != PVRSRV_OK)
412 eError = InitCACHEBridge();
413 if (eError != PVRSRV_OK)
418 #if defined(SUPPORT_SECURE_EXPORT)
419 eError = InitSMMBridge();
420 if (eError != PVRSRV_OK)
426 #if !defined(EXCLUDE_HTBUFFER_BRIDGE)
427 eError = InitHTBUFFERBridge();
428 if (eError != PVRSRV_OK)
434 eError = InitPVRTLBridge();
435 if (eError != PVRSRV_OK)
440 #if defined(PVR_RI_DEBUG)
441 eError = InitRIBridge();
442 if (eError != PVRSRV_OK)
448 #if defined(SUPPORT_VALIDATION_BRIDGE)
449 eError = InitVALIDATIONBridge();
450 if (eError != PVRSRV_OK)
456 #if defined(PVR_TESTING_UTILS)
457 eError = InitTUTILSBridge();
458 if (eError != PVRSRV_OK)
464 #if defined(SUPPORT_PAGE_FAULT_DEBUG)
465 eError = InitDEVICEMEMHISTORYBridge();
466 if (eError != PVRSRV_OK)
473 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
474 eError = InitSYNCTRACKINGBridge();
475 if (eError != PVRSRV_OK)
481 #if defined (SUPPORT_RGX)
483 eError = InitRGXTQBridge();
484 if (eError != PVRSRV_OK)
489 #if !defined(SUPPORT_KERNEL_SRVINIT)
490 eError = InitRGXINITBridge();
491 if (eError != PVRSRV_OK)
497 eError = InitRGXTA3DBridge();
498 if (eError != PVRSRV_OK)
503 #if !defined(EXCLUDE_BREAKPOINT_BRIDGE)
504 eError = InitBREAKPOINTBridge();
505 if (eError != PVRSRV_OK)
511 eError = InitDEBUGMISCBridge();
512 if (eError != PVRSRV_OK)
518 eError = InitRGXPDUMPBridge();
519 if (eError != PVRSRV_OK)
525 eError = InitRGXHWPERFBridge();
526 if (eError != PVRSRV_OK)
531 #if !defined(EXCLUDE_REGCONFIG_BRIDGE)
532 eError = InitREGCONFIGBridge();
533 if (eError != PVRSRV_OK)
539 eError = InitTIMERQUERYBridge();
540 if (eError != PVRSRV_OK)
545 eError = InitRGXKICKSYNCBridge();
546 if (eError != PVRSRV_OK)
551 #endif /* SUPPORT_RGX */
553 #if defined(SUPPORT_WRAP_EXTMEM)
554 eError = InitMMEXTMEMBridge();
555 if (eError != PVRSRV_OK)
565 LinuxBridgeDeInit(void)
569 #if defined(SUPPORT_WRAP_EXTMEM)
570 eError = DeinitMMEXTMEMBridge();
571 if (eError != PVRSRV_OK)
577 #if defined(DEBUG_BRIDGE_KM)
578 if (gpsPVRDebugFSBridgeStatsEntry != NULL)
580 PVRDebugFSRemoveEntry(&gpsPVRDebugFSBridgeStatsEntry);
584 eError = DeinitSRVCOREBridge();
585 if (eError != PVRSRV_OK)
590 eError = DeinitSYNCBridge();
591 if (eError != PVRSRV_OK)
596 #if defined(SUPPORT_SERVER_SYNC)
597 #if defined(SUPPORT_INSECURE_EXPORT)
598 eError = DeinitSYNCEXPORTBridge();
599 if (eError != PVRSRV_OK)
604 #if defined(SUPPORT_SECURE_EXPORT)
605 eError = DeinitSYNCSEXPORTBridge();
606 if (eError != PVRSRV_OK)
611 #endif /* defined(SUPPORT_SERVER_SYNC) */
614 eError = DeinitPDUMPCTRLBridge();
615 if (eError != PVRSRV_OK)
621 eError = DeinitMMBridge();
622 if (eError != PVRSRV_OK)
626 #if !defined(EXCLUDE_CMM_BRIDGE)
627 eError = DeinitCMMBridge();
628 if (eError != PVRSRV_OK)
635 eError = DeinitPDUMPMMBridge();
636 if (eError != PVRSRV_OK)
640 eError = DeinitPDUMPBridge();
641 if (eError != PVRSRV_OK)
647 eError = DeinitDMABUFBridge();
648 if (eError != PVRSRV_OK)
653 #if defined(PVR_TESTING_UTILS)
654 eError = DeinitTUTILSBridge();
655 if (eError != PVRSRV_OK)
661 #if defined(SUPPORT_DISPLAY_CLASS)
662 eError = DeinitDCBridge();
663 if (eError != PVRSRV_OK)
669 eError = DeinitCACHEBridge();
670 if (eError != PVRSRV_OK)
675 #if defined(SUPPORT_SECURE_EXPORT)
676 eError = DeinitSMMBridge();
677 if (eError != PVRSRV_OK)
683 #if !defined(EXCLUDE_HTBUFFER_BRIDGE)
684 eError = DeinitHTBUFFERBridge();
685 if (eError != PVRSRV_OK)
691 eError = DeinitPVRTLBridge();
692 if (eError != PVRSRV_OK)
697 #if defined(PVR_RI_DEBUG)
698 eError = DeinitRIBridge();
699 if (eError != PVRSRV_OK)
705 #if defined(SUPPORT_PAGE_FAULT_DEBUG)
706 eError = DeinitDEVICEMEMHISTORYBridge();
707 if (eError != PVRSRV_OK)
714 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
715 eError = DeinitSYNCTRACKINGBridge();
716 if (eError != PVRSRV_OK)
722 #if defined (SUPPORT_RGX)
724 eError = DeinitRGXTQBridge();
725 if (eError != PVRSRV_OK)
731 #if !defined(SUPPORT_KERNEL_SRVINIT)
732 eError = DeinitRGXINITBridge();
733 if (eError != PVRSRV_OK)
739 eError = DeinitRGXTA3DBridge();
740 if (eError != PVRSRV_OK)
745 #if !defined(EXCLUDE_BREAKPOINT_BRIDGE)
746 eError = DeinitBREAKPOINTBridge();
747 if (eError != PVRSRV_OK)
753 eError = DeinitDEBUGMISCBridge();
754 if (eError != PVRSRV_OK)
760 eError = DeinitRGXPDUMPBridge();
761 if (eError != PVRSRV_OK)
767 eError = DeinitRGXHWPERFBridge();
768 if (eError != PVRSRV_OK)
773 #if !defined(EXCLUDE_REGCONFIG_BRIDGE)
774 eError = DeinitREGCONFIGBridge();
775 if (eError != PVRSRV_OK)
781 eError = DeinitTIMERQUERYBridge();
782 if (eError != PVRSRV_OK)
787 eError = DeinitRGXKICKSYNCBridge();
788 if (eError != PVRSRV_OK)
793 #endif /* SUPPORT_RGX */
798 #if defined(DEBUG_BRIDGE_KM)
799 static void *BridgeStatsSeqStart(struct seq_file *psSeqFile, loff_t *puiPosition)
801 PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *psDispatchTable = (PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *)psSeqFile->private;
803 OSAcquireBridgeLock();
805 if (psDispatchTable == NULL || (*puiPosition) > BRIDGE_DISPATCH_TABLE_ENTRY_COUNT)
810 if ((*puiPosition) == 0)
812 return SEQ_START_TOKEN;
815 return &(psDispatchTable[(*puiPosition) - 1]);
818 static void BridgeStatsSeqStop(struct seq_file *psSeqFile, void *pvData)
820 PVR_UNREFERENCED_PARAMETER(psSeqFile);
821 PVR_UNREFERENCED_PARAMETER(pvData);
823 OSReleaseBridgeLock();
826 static void *BridgeStatsSeqNext(struct seq_file *psSeqFile,
830 PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *psDispatchTable = (PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *)psSeqFile->private;
831 loff_t uiItemAskedFor = *puiPosition; /* puiPosition on entry is the index to return */
833 PVR_UNREFERENCED_PARAMETER(pvData);
835 /* Is the item asked for (starts at 0) a valid table index? */
836 if (uiItemAskedFor < BRIDGE_DISPATCH_TABLE_ENTRY_COUNT)
838 (*puiPosition)++; /* on exit it is the next seq index to ask for */
839 return &(psDispatchTable[uiItemAskedFor]);
842 /* Now passed the end of the table to indicate stop */
846 static int BridgeStatsSeqShow(struct seq_file *psSeqFile, void *pvData)
848 if (pvData == SEQ_START_TOKEN)
850 seq_printf(psSeqFile,
851 "Total ioctl call count = %u\n"
852 "Total number of bytes copied via copy_from_user = %u\n"
853 "Total number of bytes copied via copy_to_user = %u\n"
854 "Total number of bytes copied via copy_*_user = %u\n\n"
855 "%3s: %-60s | %-48s | %10s | %20s | %20s | %20s | %20s \n",
856 g_BridgeGlobalStats.ui32IOCTLCount,
857 g_BridgeGlobalStats.ui32TotalCopyFromUserBytes,
858 g_BridgeGlobalStats.ui32TotalCopyToUserBytes,
859 g_BridgeGlobalStats.ui32TotalCopyFromUserBytes + g_BridgeGlobalStats.ui32TotalCopyToUserBytes,
864 "copy_from_user (B)",
869 else if (pvData != NULL)
871 PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *psEntry = ( PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *)pvData;
872 IMG_UINT32 ui32Remainder;
874 seq_printf(psSeqFile,
875 "%3d: %-60s %-48s %-10u %-20u %-20u %-20llu %-20llu\n",
876 (IMG_UINT32)(((size_t)psEntry-(size_t)g_BridgeDispatchTable)/sizeof(*g_BridgeDispatchTable)),
878 (psEntry->pfFunction != NULL) ? psEntry->pszFunctionName : "(null)",
879 psEntry->ui32CallCount,
880 psEntry->ui32CopyFromUserTotalBytes,
881 psEntry->ui32CopyToUserTotalBytes,
882 (unsigned long long) OSDivide64r64(psEntry->ui64TotalTimeNS, 1000, &ui32Remainder),
883 (unsigned long long) OSDivide64r64(psEntry->ui64MaxTimeNS, 1000, &ui32Remainder));
889 static struct seq_operations gsBridgeStatsReadOps =
891 .start = BridgeStatsSeqStart,
892 .stop = BridgeStatsSeqStop,
893 .next = BridgeStatsSeqNext,
894 .show = BridgeStatsSeqShow,
896 #endif /* defined(DEBUG_BRIDGE_KM) */
899 PVRSRV_BridgeDispatchKM(struct drm_device __maybe_unused *dev, void *arg, struct drm_file *pDRMFile)
901 struct drm_pvr_srvkm_cmd *psSrvkmCmd = (struct drm_pvr_srvkm_cmd *) arg;
902 PVRSRV_BRIDGE_PACKAGE sBridgePackageKM = { 0 };
903 CONNECTION_DATA *psConnection = LinuxConnectionFromFile(pDRMFile->filp);
906 if(psConnection == NULL)
908 PVR_DPF((PVR_DBG_ERROR, "%s: Connection is closed", __FUNCTION__));
912 if(OSGetDriverSuspended())
917 PVR_ASSERT(psSrvkmCmd != NULL);
919 DRM_DEBUG("tgid=%d, tgid_connection=%d, bridge_id=%d, func_id=%d",
920 task_tgid_nr(current),
921 ((ENV_CONNECTION_DATA *)PVRSRVConnectionPrivateData(psConnection))->owner,
922 psSrvkmCmd->bridge_id,
923 psSrvkmCmd->bridge_func_id);
925 sBridgePackageKM.ui32BridgeID = psSrvkmCmd->bridge_id;
926 sBridgePackageKM.ui32FunctionID = psSrvkmCmd->bridge_func_id;
927 sBridgePackageKM.ui32Size = sizeof(sBridgePackageKM);
928 sBridgePackageKM.pvParamIn = CAST_BRIDGE_CMD_PTR_TO_PTR(psSrvkmCmd->in_data_ptr);
929 sBridgePackageKM.ui32InBufferSize = psSrvkmCmd->in_data_size;
930 sBridgePackageKM.pvParamOut = CAST_BRIDGE_CMD_PTR_TO_PTR(psSrvkmCmd->out_data_ptr);
931 sBridgePackageKM.ui32OutBufferSize = psSrvkmCmd->out_data_size;
933 error = BridgedDispatchKM(psConnection, &sBridgePackageKM);
934 return OSPVRSRVToNativeError(error);
938 PVRSRV_MMap(struct file *pFile, struct vm_area_struct *ps_vma)
940 CONNECTION_DATA *psConnection = LinuxConnectionFromFile(pFile);
941 IMG_HANDLE hSecurePMRHandle = (IMG_HANDLE)((uintptr_t)ps_vma->vm_pgoff);
945 if(psConnection == NULL)
947 PVR_DPF((PVR_DBG_ERROR, "Invalid connection data"));
952 * The bridge lock used here to protect PVRSRVLookupHandle is replaced
953 * by a specific lock considering that the handle functions have now
954 * their own lock. This change was necessary to solve the lockdep issues
955 * related with the PVRSRV_MMap.
957 mutex_lock(&g_sMMapMutex);
959 eError = PVRSRVLookupHandle(psConnection->psHandleBase,
962 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
964 if (eError != PVRSRV_OK)
969 /* Note: PMRMMapPMR will take a reference on the PMR.
970 * Unref the handle immediately, because we have now done
971 * the required operation on the PMR (whether it succeeded or not)
973 eError = PMRMMapPMR(psPMR, ps_vma);
974 PVRSRVReleaseHandle(psConnection->psHandleBase, hSecurePMRHandle, PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
975 if (eError != PVRSRV_OK)
980 mutex_unlock(&g_sMMapMutex);
988 PVR_DPF((PVR_DBG_ERROR, "Error in mmap critical section"));
990 mutex_unlock(&g_sMMapMutex);
992 PVR_DPF((PVR_DBG_ERROR, "Unable to translate error %d", eError));
993 PVR_ASSERT(eError != PVRSRV_OK);
995 return -ENOENT; // -EAGAIN // or what?