DRI_DRM_STATIC int PVRDRMUnprivCmd(struct drm_device *dev, void *arg, struct drm_file *pFile) { int ret = 0; LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); if (arg == NULL) { ret = -EFAULT; } else { IMG_UINT32 *pui32Args = (IMG_UINT32 *)arg; IMG_UINT32 ui32Cmd = pui32Args[0]; IMG_UINT32 *pui32OutArg = (IMG_UINT32 *)arg; switch (ui32Cmd) { case PVR_DRM_UNPRIV_INIT_SUCCESFUL: *pui32OutArg = PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL) ? 1 : 0; break; default: ret = -EFAULT; } } LinuxUnLockMutex(&gPVRSRVLock); return ret; }
void PVRSRVExportFDToIONHandles(int fd, struct ion_client **client, struct ion_handle *handles[2]) { PVRSRV_FILE_PRIVATE_DATA *psPrivateData; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; LinuxMemArea *psLinuxMemArea; PVRSRV_ERROR eError; struct file *psFile; /* Take the bridge mutex so the handle won't be freed underneath us */ LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); psFile = fget(fd); if(!psFile) goto err_unlock; psPrivateData = psFile->private_data; if(!psPrivateData) { PVR_DPF((PVR_DBG_ERROR, "%s: struct file* has no private_data; " "invalid export handle", __func__)); goto err_fput; } eError = PVRSRVLookupHandle(KERNEL_HANDLE_BASE, (IMG_PVOID *)&psKernelMemInfo, psPrivateData->hKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if(eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "%s: Failed to look up MEM_INFO handle", __func__)); goto err_fput; } psLinuxMemArea = (LinuxMemArea *)psKernelMemInfo->sMemBlk.hOSMemHandle; BUG_ON(psLinuxMemArea == IMG_NULL); if(psLinuxMemArea->eAreaType != LINUX_MEM_AREA_ION) { PVR_DPF((PVR_DBG_ERROR, "%s: Valid handle, but not an ION buffer", __func__)); goto err_fput; } handles[0] = psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[0]; handles[1] = psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[1]; if(client) *client = gpsIONClient; err_fput: fput(psFile); err_unlock: /* Allow PVRSRV clients to communicate with srvkm again */ LinuxUnLockMutex(&gPVRSRVLock); }
static int PVRDRM_Display_ioctl(struct drm_device *dev, void *arg, struct drm_file *pFile) { int res; LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); res = PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(dev, arg, pFile); LinuxUnLockMutex(&gPVRSRVLock); return res; }
static inline void GetBufferLock(unsigned long *pulLockFlags) { #if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) if (USE_SPIN_LOCK) #endif { spin_lock_irqsave(&gsDebugLockIRQ, *pulLockFlags); } #if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) else { LinuxLockMutexNested(&gsDebugMutexNonIRQ, PVRSRV_LOCK_CLASS_PVR_DEBUG); } #endif }