diff options
| author | Wengang Wu <wgw@motorola.com> | 2014-05-21 09:29:41 -0500 |
|---|---|---|
| committer | Wengang Wu <wgw@motorola.com> | 2014-05-21 09:29:41 -0500 |
| commit | 53a835f5057367679eb3db728bbdd427aab8aa8a (patch) | |
| tree | 03e5bbde7d371e885d1c67210b2b0c9bb0130d40 /drivers/gpu | |
| parent | 7489b569ffb64cdb998544405b6774bd43aab70b (diff) | |
| download | olio-linux-3.10-53a835f5057367679eb3db728bbdd427aab8aa8a.tar.xz olio-linux-3.10-53a835f5057367679eb3db728bbdd427aab8aa8a.zip | |
IKXCLOCK-1501 Upgrade to TI SGX Android OpenGL 1.12@2701748
Initial codes of TI SGX DDK 1.12@2701748
Change-Id: I75a8f6521968346ea1b2ea9fa54817ba186442ce
Diffstat (limited to 'drivers/gpu')
215 files changed, 15823 insertions, 12252 deletions
diff --git a/drivers/gpu/pvr/Kconfig b/drivers/gpu/pvr/Kconfig deleted file mode 100644 index 34a122f2f7f..00000000000 --- a/drivers/gpu/pvr/Kconfig +++ /dev/null @@ -1,32 +0,0 @@ -config SGX_OMAP3630 - tristate "PowerVR SGX for OMAP3630" - depends on ARCH_OMAP3 - help - Support for the PowerVR SGX 3D core with OMAP 3630. - -choice - prompt "PowerVR build type" - default SGX_BUILD_RELEASE - -config SGX_BUILD_RELEASE - depends on SGX_OMAP3630 - bool "SGX RELEASE" - help - SGX Release Build. - -config SGX_BUILD_DEBUG - depends on SGX_OMAP3630 - bool "SGX DEBUG" - help - SGX Debug Build. - -endchoice - -config SGX_PDUMP - depends on SGX_OMAP3630 - bool "PowerVR SGX Parameter Dump" - default n - help - This option enables the PDump (Parameter Dump) build to debug - the SGX driver. The user side of the driver must be built with - this option enabled as well. diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile deleted file mode 100644 index 11f512373f8..00000000000 --- a/drivers/gpu/pvr/Makefile +++ /dev/null @@ -1,153 +0,0 @@ -# -ccflags-y = -Idrivers/video/omap2 \ - -Idrivers/gpu/pvr/include4\ - -Idrivers/gpu/pvr/services4/include \ - -Idrivers/gpu/pvr/services4/srvkm/hwdefs \ - -Idrivers/gpu/pvr/services4/srvkm/include \ - -Idrivers/gpu/pvr/services4/srvkm/bridged \ - -Idrivers/gpu/pvr/services4/srvkm/bridged/sgx \ - -Idrivers/gpu/pvr/services4/srvkm/devices/sgx \ - -Idrivers/gpu/pvr/services4/srvkm/env/linux \ - -Idrivers/gpu/pvr/services4/system/include \ - -DLINUX -D__linux__ \ - -DANDROID \ - -DPVR_BUILD_DIR="\"omap3630_android\"" \ - -DSUPPORT_SGX \ - -DTRANSFER_QUEUE \ - -DPVR_SECURE_HANDLES \ - -DDISPLAY_CONTROLLER=omaplfb \ - -DPVR_LINUX_MEM_AREA_POOL_MAX_PAGES=10800 \ - -DPVR_LINUX_MEM_AREA_USE_VMAP \ - -DPVR_LINUX_MEM_AREA_POOL_ALLOW_SHRINK \ - -DSUPPORT_PERCONTEXT_PB \ - -DSUPPORT_HW_RECOVERY \ - -DSUPPORT_ACTIVE_POWER_MANAGEMENT \ - -DSUPPORT_SGX_HWPERF \ - -DSUPPORT_SGX_LOW_LATENCY_SCHEDULING \ - -DSUPPORT_MEMINFO_IDS \ - -DSUPPORT_SGX_NEW_STATUS_VALS \ - -DSUPPORT_DBGDRV_EVENT_OBJECTS \ - -DPVRSRV_USSE_EDM_STATUS_DEBUG \ - -DSGX_DISABLE_VISTEST_SUPPORT \ - -DSYS_USING_INTERRUPTS \ - -DPVRSRV_NEW_PVR_DPF \ - -DSUPPORT_NV12_FROM_2_HWADDRS \ - -DSUPPORT_LINUX_X86_WRITECOMBINE \ - -DSUPPORT_LINUX_X86_PAT \ - -DSGX_DYNAMIC_TIMING_INFO \ - -DSYS_CUSTOM_POWERLOCK_WRAP \ - -DPVR_LINUX_USING_WORKQUEUES \ - -DPVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE \ - -DPVR_LINUX_TIMERS_USING_WORKQUEUES \ - -DLDM_PLATFORM \ - -DPVRSRV_DUMP_MK_TRACE \ - -DSUPPORT_LARGE_GENERAL_HEAP \ - -DPVR_NO_OMAP_TIMER \ - -DSUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED \ - -DPVR_LDM_DRIVER_REGISTRATION_NAME="\"pvrsrvkm\"" \ - -DPVRSRV_MODNAME="\"pvrsrvkm\"" - -#ccflags-y += -Wno-unused-function -Wno-unused-variable - -ccflags-$(CONFIG_SGX_OMAP3630) += \ - -Idrivers/gpu/pvr/services4/system/omap3630 \ - -DSGX530 -DSUPPORT_SGX530 -DSGXCORE=530 \ - -DSGX_CORE_REV=125 \ - -DSKIP_FIRST_FLIP_BUFS=4 - -ccflags-$(CONFIG_SGX_BUILD_RELEASE) += \ - -DPVR_BUILD_TYPE="\"release\"" \ - -DRELEASE - -ccflags-$(CONFIG_SGX_BUILD_DEBUG) += \ - -DPVR_BUILD_TYPE="\"debug\"" \ - -DDEBUG \ - -DDEBUG_LINUX_MEMORY_ALLOCATIONS \ - -DDEBUG_LINUX_MEM_AREAS \ - -DDEBUG_LINUX_MMAP_AREAS \ - -DDEBUG_BRIDGE_KM \ - -DDEBUG_BRIDGE_KM_DISPATCH_TABLE \ - -DDEBUG_TRACE_BRIDGE_KM \ - -DIGNORE_SGX_INIT_COMPATIBILITY_CHECK - -ccflags-$(CONFIG_SGX_PDUMP) += \ - -Idrivers/gpu/pvr/tools/intern/debug/client \ - -DPDUMP - -pvr_bridged-y := \ - services4/srvkm/bridged/bridged_pvr_bridge.o \ - services4/srvkm/bridged/bridged_support.o \ - services4/srvkm/bridged/sgx/bridged_sgx_bridge.o - -pvr_common-y := \ - services4/srvkm/common/buffer_manager.o \ - services4/srvkm/common/deviceclass.o \ - services4/srvkm/common/devicemem.o \ - services4/srvkm/common/handle.o \ - services4/srvkm/common/hash.o \ - services4/srvkm/common/lists.o \ - services4/srvkm/common/mem.o \ - services4/srvkm/common/mem_debug.o \ - services4/srvkm/common/metrics.o \ - services4/srvkm/common/osfunc_common.o \ - services4/srvkm/common/pdump_common.o \ - services4/srvkm/common/perproc.o \ - services4/srvkm/common/power.o \ - services4/srvkm/common/pvrsrv.o \ - services4/srvkm/common/queue.o \ - services4/srvkm/common/ra.o \ - services4/srvkm/common/refcount.o \ - services4/srvkm/common/resman.o \ - services4/srvkm/common/ttrace.o - -pvr_devices-y := \ - services4/srvkm/devices/sgx/mmu.o \ - services4/srvkm/devices/sgx/pb.o \ - services4/srvkm/devices/sgx/sgxinit.o \ - services4/srvkm/devices/sgx/sgxkick.o \ - services4/srvkm/devices/sgx/sgxpower.o \ - services4/srvkm/devices/sgx/sgxreset.o \ - services4/srvkm/devices/sgx/sgxtransfer.o \ - services4/srvkm/devices/sgx/sgxutils.o - -pvr_env-y := \ - services4/srvkm/env/linux/event.o \ - services4/srvkm/env/linux/mmap.o \ - services4/srvkm/env/linux/mm.o \ - services4/srvkm/env/linux/module.o \ - services4/srvkm/env/linux/mutex.o \ - services4/srvkm/env/linux/mutils.o \ - services4/srvkm/env/linux/osfunc.o \ - services4/srvkm/env/linux/osperproc.o \ - services4/srvkm/env/linux/pdump.o \ - services4/srvkm/env/linux/proc.o \ - services4/srvkm/env/linux/pvr_bridge_k.o \ - services4/srvkm/env/linux/pvr_debug.o \ - services4/srvkm/env/linux/sysfs.o - -pvr_omaplfb-y := \ - services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.o \ - services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.o - -pvr_omap3630-$(CONFIG_SGX_OMAP3630) := \ - services4/system/omap3630/sysconfig.o \ - services4/system/omap3630/sysutils.o - -dbgdriv-$(CONFIG_SGX_PDUMP) := \ - tools/intern/debug/dbgdriv/common/dbgdriv.o \ - tools/intern/debug/dbgdriv/common/handle.o \ - tools/intern/debug/dbgdriv/common/hotkey.o \ - tools/intern/debug/dbgdriv/common/ioctl.o \ - tools/intern/debug/dbgdriv/linux/hostfunc.o \ - tools/intern/debug/dbgdriv/linux/main.o - -obj-$(CONFIG_SGX_OMAP3630) := \ - pvr_bridged.o \ - pvr_common.o \ - pvr_devices.o \ - pvr_env.o \ - pvr_omaplfb.o \ - pvr_omap3630.o - -obj-$(CONFIG_SGX_PDUMP) += dbgdriv.o -# diff --git a/drivers/gpu/pvr/include4/dbgdrvif.h b/drivers/gpu/pvr/include4/dbgdrvif.h index 753f8f25cbb..753f8f25cbb 100644..100755 --- a/drivers/gpu/pvr/include4/dbgdrvif.h +++ b/drivers/gpu/pvr/include4/dbgdrvif.h diff --git a/drivers/gpu/pvr/include4/img_defs.h b/drivers/gpu/pvr/include4/img_defs.h index 375ed99510c..bf0c3607439 100644..100755 --- a/drivers/gpu/pvr/include4/img_defs.h +++ b/drivers/gpu/pvr/include4/img_defs.h @@ -147,6 +147,71 @@ typedef char TCHAR, *PTCHAR, *PTSTR; #define IMG_UNDEF (~0UL) #endif +/* + Do the right thing when using printf to output cpu addresses, + depending on architecture. + */ +#if defined (_WIN64) + #define UINTPTR_FMT "%016llX" +#else + #if defined (__x86_64__) + #define UINTPTR_FMT "%016lX" + #else + #define UINTPTR_FMT "%08lX" + #endif +#endif + +/* + Similarly for DEV_ and SYS_ PHYSADDRs, but this is dependent on 32/36-bit MMU + capability, in addition to host architecture. + */ +#if IMG_ADDRSPACE_PHYSADDR_BITS == 32 + #if defined(IMG_UINT32_IS_ULONG) + #define CPUPADDR_FMT "%08lX" + #define DEVPADDR_FMT "%08lX" + #define SYSPADDR_FMT "%08lX" + #else + #define CPUPADDR_FMT "%08X" + #define DEVPADDR_FMT "%08X" + #define SYSPADDR_FMT "%08X" + #endif +#else + #if defined(__x86_64__) + #define CPUPADDR_FMT "%016lX" + #define DEVPADDR_FMT "%016lX" + #define SYSPADDR_FMT "%016lX" + #else + + #define CPUPADDR_FMT "%016llX" + #define DEVPADDR_FMT "%016llX" + #define SYSPADDR_FMT "%016llX" + #endif +#endif + +/* + Define a printf format macro for the length property of the format-specifier + for size_t, that allows avoidance of C99 dependency on compilers that don't + support this, while still ensuring that whatever the size of size_t (eg 32, + 64 bit Linux builds, or Win32/64 builds), a size_t (or IMG_SIZE_T) can be + passed to printf-type functions without a cast. +*/ +#if defined LINUX + /* Use C99 format specifier where possible */ + #define SIZE_T_FMT_LEN "z" +#elif defined _WIN64 + #define SIZE_T_FMT_LEN "I" +#else + #define SIZE_T_FMT_LEN "l" /* May need to be updated as required, for other OSs */ +#endif + + +#if defined (__x86_64__) + #define IMG_UINT64_FMT "l" +#else + #define IMG_UINT64_FMT "ll" /* May need to be updated as required, for other OSs */ +#endif + + #endif /* #if !defined (__IMG_DEFS_H__) */ /***************************************************************************** End of file (IMG_DEFS.H) diff --git a/drivers/gpu/pvr/include4/img_types.h b/drivers/gpu/pvr/include4/img_types.h index 7f5137e798a..3e04e4a8e21 100644..100755 --- a/drivers/gpu/pvr/include4/img_types.h +++ b/drivers/gpu/pvr/include4/img_types.h @@ -75,17 +75,16 @@ typedef signed long IMG_INT32, *IMG_PINT32; #endif #if defined(USE_CODE) - -typedef unsigned __int64 IMG_UINT64, *IMG_PUINT64; -typedef __int64 IMG_INT64, *IMG_PINT64; - + typedef unsigned __int64 IMG_UINT64, *IMG_PUINT64; + typedef __int64 IMG_INT64, *IMG_PINT64; +#elif defined(LINUX) && defined (__x86_64) + typedef unsigned long IMG_UINT64, *IMG_PUINT64; + typedef long IMG_INT64, *IMG_PINT64; +#elif defined(LINUX) || defined(__METAG) || defined (__QNXNTO__) + typedef unsigned long long IMG_UINT64, *IMG_PUINT64; + typedef long long IMG_INT64, *IMG_PINT64; #else - #if defined(LINUX) || defined(__METAG) || defined (__QNXNTO__) - typedef unsigned long long IMG_UINT64, *IMG_PUINT64; - typedef long long IMG_INT64, *IMG_PINT64; - #else - #error("define an OS") - #endif + #error("define an OS") #endif #if !(defined(LINUX) && defined (__KERNEL__)) @@ -107,11 +106,19 @@ typedef IMG_INT32 IMG_RESULT; #if defined(_WIN64) typedef unsigned __int64 IMG_UINTPTR_T; + typedef signed __int64 IMG_INTPTR_T; typedef signed __int64 IMG_PTRDIFF_T; typedef IMG_UINT64 IMG_SIZE_T; #else - typedef unsigned int IMG_UINTPTR_T; - typedef IMG_UINT32 IMG_SIZE_T; + #if defined (__x86_64__) + typedef IMG_UINT64 IMG_SIZE_T; + typedef unsigned long IMG_UINTPTR_T; + typedef signed long IMG_INTPTR_T; + #else + typedef IMG_UINT32 IMG_SIZE_T; + typedef unsigned long IMG_UINTPTR_T; + typedef signed long IMG_INTPTR_T; + #endif #endif typedef IMG_PVOID IMG_HANDLE; @@ -121,9 +128,9 @@ typedef void** IMG_HVOID, * IMG_PHVOID; #define IMG_NULL 0 /* services/stream ID */ -typedef IMG_UINT32 IMG_SID; +typedef IMG_UINTPTR_T IMG_SID; -typedef IMG_UINT32 IMG_EVENTSID; +typedef IMG_UINTPTR_T IMG_EVENTSID; /* * Address types. @@ -184,7 +191,12 @@ typedef IMG_UINT32 IMG_DEVMEM_SIZE_T; typedef struct _IMG_CPU_PHYADDR { /* variable sized type (32,64) */ - IMG_UINTPTR_T uiAddr; +#if IMG_ADDRSPACE_PHYSADDR_BITS == 32 + /* variable sized type (32,64) */ + IMG_UINT32 uiAddr; +#else + IMG_UINT64 uiAddr; +#endif } IMG_CPU_PHYADDR; /* device physical address */ @@ -192,10 +204,9 @@ typedef struct _IMG_DEV_PHYADDR { #if IMG_ADDRSPACE_PHYSADDR_BITS == 32 /* variable sized type (32,64) */ - IMG_UINTPTR_T uiAddr; -#else IMG_UINT32 uiAddr; - IMG_UINT32 uiHighAddr; +#else + IMG_UINT64 uiAddr; #endif } IMG_DEV_PHYADDR; @@ -203,7 +214,12 @@ typedef struct _IMG_DEV_PHYADDR typedef struct _IMG_SYS_PHYADDR { /* variable sized type (32,64) */ - IMG_UINTPTR_T uiAddr; +#if IMG_ADDRSPACE_PHYSADDR_BITS == 32 + /* variable sized type (32,64) */ + IMG_UINT32 uiAddr; +#else + IMG_UINT64 uiAddr; +#endif } IMG_SYS_PHYADDR; #include "img_defs.h" diff --git a/drivers/gpu/pvr/include4/pdumpdefs.h b/drivers/gpu/pvr/include4/pdumpdefs.h index 112e9ee58de..989488bea29 100644..100755 --- a/drivers/gpu/pvr/include4/pdumpdefs.h +++ b/drivers/gpu/pvr/include4/pdumpdefs.h @@ -115,7 +115,7 @@ typedef enum _PDUMP_POLL_OPERATOR PDUMP_POLL_OPERATOR_LESSEQUAL = 2, PDUMP_POLL_OPERATOR_GREATER = 3, PDUMP_POLL_OPERATOR_GREATEREQUAL = 4, - PDUMP_POLL_OPERATOR_NOTEQUAL = 5, + PDUMP_POLL_OPERATOR_NOTEQUAL = 5 } PDUMP_POLL_OPERATOR; diff --git a/drivers/gpu/pvr/include4/pvr_debug.h b/drivers/gpu/pvr/include4/pvr_debug.h index 7e056665f2e..fcc02759788 100644..100755 --- a/drivers/gpu/pvr/include4/pvr_debug.h +++ b/drivers/gpu/pvr/include4/pvr_debug.h @@ -53,16 +53,17 @@ extern "C" { #define PVR_MAX_DEBUG_MESSAGE_LEN (512) /* These are privately used by pvr_debug, use the PVR_DBG_ defines instead */ -#define DBGPRIV_FATAL 0x01UL -#define DBGPRIV_ERROR 0x02UL -#define DBGPRIV_WARNING 0x04UL -#define DBGPRIV_MESSAGE 0x08UL -#define DBGPRIV_VERBOSE 0x10UL -#define DBGPRIV_CALLTRACE 0x20UL -#define DBGPRIV_ALLOC 0x40UL -#define DBGPRIV_DBGDRV_MESSAGE 0x80UL +#define DBGPRIV_FATAL 0x001UL +#define DBGPRIV_ERROR 0x002UL +#define DBGPRIV_WARNING 0x004UL +#define DBGPRIV_MESSAGE 0x008UL +#define DBGPRIV_VERBOSE 0x010UL +#define DBGPRIV_CALLTRACE 0x020UL +#define DBGPRIV_ALLOC 0x040UL +#define DBGPRIV_BUFFERED 0x080UL +#define DBGPRIV_DBGDRV_MESSAGE 0x100UL -#define DBGPRIV_DBGLEVEL_COUNT 8 +#define DBGPRIV_DBGLEVEL_COUNT 9 #if !defined(PVRSRV_NEED_PVR_ASSERT) && defined(DEBUG) #define PVRSRV_NEED_PVR_ASSERT @@ -143,27 +144,29 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugAssertFail(const IMG_CHAR *pszFile, #define PVR_DBG_VERBOSE DBGPRIV_VERBOSE #define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE #define PVR_DBG_ALLOC DBGPRIV_ALLOC + #define PVR_DBG_BUFFERED DBGPRIV_BUFFERED #define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE /* These levels are always on with PVRSRV_NEED_PVR_DPF */ - #define __PVR_DPF_0x01UL(x...) PVRSRVDebugPrintf(DBGPRIV_FATAL, x) - #define __PVR_DPF_0x02UL(x...) PVRSRVDebugPrintf(DBGPRIV_ERROR, x) + #define __PVR_DPF_0x001UL(x...) PVRSRVDebugPrintf(DBGPRIV_FATAL, x) + #define __PVR_DPF_0x002UL(x...) PVRSRVDebugPrintf(DBGPRIV_ERROR, x) + #define __PVR_DPF_0x080UL(x...) PVRSRVDebugPrintf(DBGPRIV_BUFFERED, x) /* Some are compiled out completely in release builds */ #if defined(DEBUG) - #define __PVR_DPF_0x04UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x) - #define __PVR_DPF_0x08UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x) - #define __PVR_DPF_0x10UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x) - #define __PVR_DPF_0x20UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x) - #define __PVR_DPF_0x40UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x) - #define __PVR_DPF_0x80UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x) + #define __PVR_DPF_0x004UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x) + #define __PVR_DPF_0x008UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x) + #define __PVR_DPF_0x010UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x) + #define __PVR_DPF_0x020UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x) + #define __PVR_DPF_0x040UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x) + #define __PVR_DPF_0x100UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x) #else - #define __PVR_DPF_0x04UL(x...) - #define __PVR_DPF_0x08UL(x...) - #define __PVR_DPF_0x10UL(x...) - #define __PVR_DPF_0x20UL(x...) - #define __PVR_DPF_0x40UL(x...) - #define __PVR_DPF_0x80UL(x...) + #define __PVR_DPF_0x004UL(x...) + #define __PVR_DPF_0x008UL(x...) + #define __PVR_DPF_0x010UL(x...) + #define __PVR_DPF_0x020UL(x...) + #define __PVR_DPF_0x040UL(x...) + #define __PVR_DPF_0x100UL(x...) #endif /* Translate the different log levels to separate macros @@ -188,6 +191,7 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugAssertFail(const IMG_CHAR *pszFile, #define PVR_DBG_VERBOSE DBGPRIV_VERBOSE,__FILE__, __LINE__ #define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE,__FILE__, __LINE__ #define PVR_DBG_ALLOC DBGPRIV_ALLOC,__FILE__, __LINE__ + #define PVR_DBG_BUFFERED DBGPRIV_BUFFERED,__FILE__, __LINE__ #define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE, "", 0 #define PVR_DPF(X) PVRSRVDebugPrintf X @@ -200,13 +204,14 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel, const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(4, 5); +IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintfDumpCCB(void); + #else /* defined(PVRSRV_NEED_PVR_DPF) */ #define PVR_DPF(X) #endif /* defined(PVRSRV_NEED_PVR_DPF) */ - /* PVR_TRACE() handling */ #if defined(PVRSRV_NEED_PVR_TRACE) diff --git a/drivers/gpu/pvr/include4/pvr_sync_user.h b/drivers/gpu/pvr/include4/pvr_sync_user.h new file mode 100755 index 00000000000..0220098824d --- /dev/null +++ b/drivers/gpu/pvr/include4/pvr_sync_user.h @@ -0,0 +1,125 @@ +/*************************************************************************/ /*! +@File pvr_sync_user.h +@Title Userspace definitions to use the kernel sync driver +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@Description Version numbers and strings for PVR Consumer services + components. +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#ifndef _PVR_SYNC_USER_H_ +#define _PVR_SYNC_USER_H_ + +#include <linux/ioctl.h> + +#ifdef __KERNEL__ +#include "sgxapi_km.h" +#else +#include "sgxapi.h" +#endif + +#include "servicesext.h" // PVRSRV_SYNC_DATA +#include "img_types.h" + +/* This matches the sw_sync create ioctl data */ +struct PVR_SYNC_CREATE_IOCTL_DATA +{ + /* Input: Name of this sync pt. Passed to base sync driver. */ + char name[32]; + + /* Input: An fd from a previous call to ALLOC ioctl. Cannot be <0. */ + __s32 allocdSyncInfo; + + /* Output: An fd returned from the CREATE ioctl. */ + __s32 fence; +}; + +struct PVR_SYNC_ALLOC_IOCTL_DATA +{ + /* Output: An fd returned from the ALLOC ioctl */ + __s32 fence; + + /* Output: IMG_TRUE if the timeline looked idle at alloc time */ + __u32 bTimelineIdle; +}; + +#define PVR_SYNC_DEBUG_MAX_POINTS 3 + +typedef struct +{ + /* Output: A globally unique stamp/ID for the sync */ + IMG_UINT64 ui64Stamp; + + /* Output: The WOP snapshot for the sync */ + IMG_UINT32 ui32WriteOpsPendingSnapshot; +} +PVR_SYNC_DEBUG; + +struct PVR_SYNC_DEBUG_IOCTL_DATA +{ + /* Input: Fence to acquire debug for */ + int iFenceFD; + + /* Output: Number of points merged into this fence */ + IMG_UINT32 ui32NumPoints; + + struct + { + /* Output: Metadata for sync point */ + PVR_SYNC_DEBUG sMetaData; + + /* Output: 'Live' sync information. */ + PVRSRV_SYNC_DATA sSyncData; + } + sSync[PVR_SYNC_DEBUG_MAX_POINTS]; +}; + +#define PVR_SYNC_IOC_MAGIC 'W' + +#define PVR_SYNC_IOC_CREATE_FENCE \ + _IOWR(PVR_SYNC_IOC_MAGIC, 0, struct PVR_SYNC_CREATE_IOCTL_DATA) + +#define PVR_SYNC_IOC_DEBUG_FENCE \ + _IOWR(PVR_SYNC_IOC_MAGIC, 1, struct PVR_SYNC_DEBUG_IOCTL_DATA) + +#define PVR_SYNC_IOC_ALLOC_FENCE \ + _IOWR(PVR_SYNC_IOC_MAGIC, 2, struct PVR_SYNC_ALLOC_IOCTL_DATA) + +#define PVRSYNC_MODNAME "pvr_sync" + +#endif /* _PVR_SYNC_USER_H_ */ diff --git a/drivers/gpu/pvr/include4/pvrmodule.h b/drivers/gpu/pvr/include4/pvrmodule.h index 267c7b68748..267c7b68748 100644..100755 --- a/drivers/gpu/pvr/include4/pvrmodule.h +++ b/drivers/gpu/pvr/include4/pvrmodule.h diff --git a/drivers/gpu/pvr/include4/pvrversion.h b/drivers/gpu/pvr/include4/pvrversion.h index 820b25a56fc..ed4025f88b2 100644..100755 --- a/drivers/gpu/pvr/include4/pvrversion.h +++ b/drivers/gpu/pvr/include4/pvrversion.h @@ -49,21 +49,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PVR_STR2(X) PVR_STR(X) #define PVRVERSION_MAJ 1 -#define PVRVERSION_MIN 9 -#define PVRVERSION_BRANCH 19 +#define PVRVERSION_MIN 12 #define PVRVERSION_FAMILY "sgxddk" -#define PVRVERSION_BRANCHNAME "1.9" -#define PVRVERSION_BUILD 2166536 -#define PVRVERSION_BSCONTROL "SGX_DDK_Android" +#define PVRVERSION_BRANCHNAME "1.12" +#define PVRVERSION_BUILD 2701748 +#define PVRVERSION_BSCONTROL "SGX_DDK" -#define PVRVERSION_STRING "SGX_DDK_Android sgxddk 19 1.9@" PVR_STR2(PVRVERSION_BUILD) -#define PVRVERSION_STRING_SHORT "1.9@" PVR_STR2(PVRVERSION_BUILD) +#define PVRVERSION_STRING "SGX_DDK sgxddk 1.12@" PVR_STR2(PVRVERSION_BUILD) +#define PVRVERSION_STRING_SHORT "1.12@" PVR_STR2(PVRVERSION_BUILD) "" #define COPYRIGHT_TXT "Copyright (c) Imagination Technologies Ltd. All Rights Reserved." -#define PVRVERSION_BUILD_HI 216 -#define PVRVERSION_BUILD_LO 6536 +#define PVRVERSION_BUILD_HI 270 +#define PVRVERSION_BUILD_LO 1748 #define PVRVERSION_STRING_NUMERIC PVR_STR2(PVRVERSION_MAJ) "." PVR_STR2(PVRVERSION_MIN) "." PVR_STR2(PVRVERSION_BUILD_HI) "." PVR_STR2(PVRVERSION_BUILD_LO) #endif /* _PVRVERSION_H_ */ diff --git a/drivers/gpu/pvr/include4/services.h b/drivers/gpu/pvr/include4/services.h index bfa7fb05097..8828fa98cf3 100644..100755 --- a/drivers/gpu/pvr/include4/services.h +++ b/drivers/gpu/pvr/include4/services.h @@ -105,17 +105,12 @@ extern "C" { #define PVRSRV_HAP_SINGLE_PROCESS (1U<<16) #define PVRSRV_HAP_MULTI_PROCESS (1U<<17) #define PVRSRV_HAP_FROM_EXISTING_PROCESS (1U<<18) -#define PVRSRV_HAP_NO_CPU_VIRTUAL (1U<<19) -#define PVRSRV_MAP_GC_MMU (1UL<<20) -#define PVRSRV_HAP_GPU_PAGEABLE (1U<<21) -#define PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC (1U<<22) +#define PVRSRV_HAP_NO_CPU_VIRTUAL (1U<<19) #define PVRSRV_HAP_MAPTYPE_MASK (PVRSRV_HAP_KERNEL_ONLY \ |PVRSRV_HAP_SINGLE_PROCESS \ |PVRSRV_HAP_MULTI_PROCESS \ - |PVRSRV_HAP_FROM_EXISTING_PROCESS) -#define PVRSRV_HAP_MAPPING_CTRL_MASK (PVRSRV_HAP_NO_CPU_VIRTUAL\ - |PVRSRV_HAP_GPU_PAGEABLE \ - |PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC) + |PVRSRV_HAP_FROM_EXISTING_PROCESS \ + |PVRSRV_HAP_NO_CPU_VIRTUAL) /* Allows user allocations to override heap attributes @@ -137,7 +132,7 @@ extern "C" { */ #define PVRSRV_MAP_NOUSERVIRTUAL (1UL<<27) #define PVRSRV_MEM_XPROC (1U<<28) -#define PVRSRV_MEM_ION (1U<<29) +/* Bit 29 is unused */ #define PVRSRV_MEM_ALLOCATENONCACHEDMEM (1UL<<30) /* @@ -199,9 +194,11 @@ extern "C" { Flags for PVRSRVModifySyncOps WO_INC - Used to increment "WriteOpsPending/complete of sync info" RO_INC - Used to increment "ReadOpsPending/complete of sync info" + RO2_INC - Used to increment "ReadOps2Pending/complete of sync info" */ -#define PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC 0x00000001 -#define PVRSRV_MODIFYSYNCOPS_FLAGS_RO_INC 0x00000002 +#define PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC (1U<<0) +#define PVRSRV_MODIFYSYNCOPS_FLAGS_RO_INC (1U<<1) +#define PVRSRV_MODIFYSYNCOPS_FLAGS_RO2_INC (1U<<2) /* Flags for Services connection. @@ -215,19 +212,6 @@ extern "C" { */ #define PVRSRV_PDUMP_FLAGS_CONTINUOUS 0x1 -/* Number of MM planes supported for the meminfo */ -#define PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES 3 - -/* Invalid Device Virtual Address Value */ -#define PVRSRV_BAD_DEVICE_ADDRESS 0 - -/* Maximum array size of the meminfo's when invoking - * PVRSRVMultiManageDevMem() in shared mode */ -#define PVRSRV_MULTI_MANAGE_DEV_MEM_MAX_SIZE 128 - -/* Maximum array size of the meminfo's when invoking - * PVRSRVMultiManageDevMem() in direct (copy) mode */ -#define PVRSRV_MULTI_MANAGE_DEV_MEM_MAX_DIRECT_SIZE 8 /****************************************************************************** * Enums @@ -294,6 +278,7 @@ typedef enum IMG_OPENCL = 0x0000000F, #endif + IMG_MODULE_UNDEF = 0xFFFFFFFF } IMG_MODULE_ID; @@ -372,11 +357,7 @@ typedef struct _PVRSRV_CONNECTION_ typedef struct _PVRSRV_DEV_DATA_ { IMG_CONST PVRSRV_CONNECTION *psConnection; /*!< Services connection info */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; /*!< Dev cookie */ -#else IMG_HANDLE hDevCookie; /*!< Dev cookie */ -#endif } PVRSRV_DEV_DATA; @@ -445,16 +426,6 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ /* ptr to associated client sync info - NULL if no sync */ struct _PVRSRV_CLIENT_SYNC_INFO_ *psClientSyncInfo; -#if defined (SUPPORT_SID_INTERFACE) - /* handle to client mapping data (OS specific) */ - IMG_SID hMappingInfo; - - /* handle to kernel mem info */ - IMG_SID hKernelMemInfo; - - /* resman handle for UM mapping clean-up */ - IMG_SID hResItem; -#else /* handle to client mapping data (OS specific) */ IMG_HANDLE hMappingInfo; @@ -463,7 +434,6 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ /* resman handle for UM mapping clean-up */ IMG_HANDLE hResItem; -#endif #if defined(SUPPORT_MEMINFO_IDS) #if !defined(USE_CODE) @@ -474,9 +444,9 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ IMG_UINT32 dummy2; #endif /* !defined(USE_CODE) */ #endif /* defined(SUPPORT_MEMINFO_IDS) */ - - /* Sub-system ID that allocated the buffer */ - IMG_UINT64 uiSubSystem; +#if defined(SUPPORT_ION) + IMG_SIZE_T uiIonBufferSize; +#endif /* defined(SUPPORT_ION) */ /* ptr to next mem info @@ -484,68 +454,8 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ */ struct _PVRSRV_CLIENT_MEM_INFO_ *psNext; - /* Device Virtual Addresses for the YUV MM planes */ - IMG_UINT32 planeOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; } PVRSRV_CLIENT_MEM_INFO, *PPVRSRV_CLIENT_MEM_INFO; -/* - Multiple buffer device virtual mapping management -*/ -typedef enum -{ - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_INVALID = 0, - /* We may not have GPU virtual address */ - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_MAP = 1, - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_LOCK_MAP, - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_SWAP_MAP_FROM_PREV, - /* We have GPU virtual address */ - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_UNMAP, - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_UNLOCK_MAP, - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_SWAP_MAP_TO_NEXT, - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_LAST = (IMG_UINT32)-1 -} PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_TYPE; - -typedef struct _PVRSRV_MANAGE_DEV_MEM_REQUEST -{ - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_TYPE eReqType; - IMG_UINT32 ui32FieldSize; /* valid if equal to the size of the structure */ - IMG_HANDLE hKernelMemInfo; - IMG_HANDLE hKernelSyncInfo; - PVRSRV_CLIENT_MEM_INFO *psClientMemInfo; /* Client side reference */ - IMG_UINT32 ui32Hints; - IMG_UINT32 ui32Attribs; - IMG_SIZE_T uSize; - IMG_SIZE_T uAlignment; - IMG_PVOID pvLinAddr; /* CPU Virtual Address */ - IMG_UINT32 ui32CpuMapRefCount; - IMG_DEV_VIRTADDR sDevVAddr; /* Device Virtual Address */ - IMG_UINT32 ui32GpuMapRefCount; - IMG_UINT32 ui32TransferFromToReqSlotIndx; /* Transfer GPU virtual mapping from index */ - IMG_UINT64 uiSubSystem; - PVRSRV_ERROR eError; -}PVRSRV_MANAGE_DEV_MEM_REQUEST; - -typedef PVRSRV_MANAGE_DEV_MEM_REQUEST PVRSRV_MANAGE_DEV_MEM_RESPONSE; - -typedef struct _PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS -{ - IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ - #if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - /* handle to kernel shared memory */ - IMG_SID hKernelMemInfo; - #else - IMG_HANDLE hDevCookie; - /* handle to kernel shared memory*/ - IMG_HANDLE hKernelMemInfo; - #endif - PVRSRV_CLIENT_MEM_INFO *psSharedMemClientMemInfo; /* NULL if direct (not through shared) */ - IMG_UINT32 ui32MaxNumberOfRequests; /* Must be <= PVRSRV_MULTI_MANAGE_DEV_MEM_MAX_DIRECT_SIZE for direct */ - IMG_UINT32 ui32NumberOfValidRequests; /* Must be <= ui32MaxNumberOfRequests */ - IMG_UINT32 ui32CtrlFlags; - IMG_UINT32 ui32StatusFlags; - PVRSRV_MANAGE_DEV_MEM_REQUEST sMemRequests[PVRSRV_MULTI_MANAGE_DEV_MEM_MAX_DIRECT_SIZE]; /* Memory Requests Array */ -}PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS; /*! ****************************************************************************** @@ -555,11 +465,7 @@ typedef struct _PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS typedef struct _PVRSRV_HEAP_INFO_ { IMG_UINT32 ui32HeapID; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap; -#else IMG_HANDLE hDevMemHeap; -#endif IMG_DEV_VIRTADDR sDevVAddrBase; IMG_UINT32 ui32HeapByteSize; IMG_UINT32 ui32Attribs; @@ -577,11 +483,7 @@ typedef struct _PVRSRV_EVENTOBJECT_ /* globally unique name of the event object */ IMG_CHAR szName[EVENTOBJNAME_MAXLENGTH]; /* kernel specific handle for the event object */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hOSEventKM; -#else IMG_HANDLE hOSEventKM; -#endif } PVRSRV_EVENTOBJECT; @@ -607,13 +509,8 @@ typedef struct _PVRSRV_MISC_INFO_ /*!< SOC Timer register */ IMG_VOID *pvSOCTimerRegisterKM; IMG_VOID *pvSOCTimerRegisterUM; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSOCTimerRegisterOSMemHandle; - IMG_SID hSOCTimerRegisterMappingInfo; -#else IMG_HANDLE hSOCTimerRegisterOSMemHandle; IMG_HANDLE hSOCTimerRegisterMappingInfo; -#endif /*!< SOC Clock Gating registers */ IMG_VOID *pvSOCClockGateRegs; @@ -625,11 +522,7 @@ typedef struct _PVRSRV_MISC_INFO_ /* global event object */ PVRSRV_EVENTOBJECT sGlobalEventObject;//FIXME: should be private to services -#if defined (SUPPORT_SID_INTERFACE) - IMG_EVENTSID hOSGlobalEvent; -#else IMG_HANDLE hOSGlobalEvent; -#endif /* Note: add misc. items as required */ IMG_UINT32 aui32DDKVersion[4]; @@ -647,7 +540,6 @@ typedef struct _PVRSRV_MISC_INFO_ * directly in the srvclient PVRSRVGetMiscInfo code, and then convert it * to a kernel meminfo if required. Try to not waste space. */ -#if !defined (SUPPORT_SID_INTERFACE) union { /*!< Input client meminfo (UM side) */ @@ -656,7 +548,6 @@ typedef struct _PVRSRV_MISC_INFO_ /*!< Output kernel meminfo (Bridge+KM side) */ struct _PVRSRV_KERNEL_MEM_INFO_ *psKernelMemInfo; } u; -#endif /*!< Offset in MemInfo to start cache op */ IMG_VOID *pvBaseVAddr; @@ -672,7 +563,6 @@ typedef struct _PVRSRV_MISC_INFO_ * directly in the srvclient PVRSRVGetMiscInfo code, and then convert it * to a kernel meminfo if required. Try to not waste space. */ -#if !defined(SUPPORT_SID_INTERFACE) union { /*!< Input client meminfo (UM side) */ @@ -681,7 +571,6 @@ typedef struct _PVRSRV_MISC_INFO_ /*!< Output kernel meminfo (Bridge+KM side) */ struct _PVRSRV_KERNEL_MEM_INFO_ *psKernelMemInfo; } u; -#endif /*!< Resulting refcount */ IMG_UINT32 ui32RefCount; @@ -701,11 +590,7 @@ typedef struct _PVRSRV_SYNC_TOKEN_ The fields are hidden in sPrivate in order to reinforce this. */ struct { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfo; -#endif IMG_UINT32 ui32ReadOpsPendingSnapshot; IMG_UINT32 ui32WriteOpsPendingSnapshot; IMG_UINT32 ui32ReadOps2PendingSnapshot; @@ -718,7 +603,7 @@ typedef struct _PVRSRV_SYNC_TOKEN_ *****************************************************************************/ typedef enum _PVRSRV_CLIENT_EVENT_ { - PVRSRV_CLIENT_EVENT_HWTIMEOUT = 0, + PVRSRV_CLIENT_EVENT_HWTIMEOUT = 0 } PVRSRV_CLIENT_EVENT; typedef IMG_VOID (*PFN_QUEUE_COMMAND_COMPLETE)(IMG_HANDLE hCallbackData); @@ -754,11 +639,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVReleaseMiscInfo (IMG_CONST PVRSRV_CONNECTION *ps IMG_IMPORT PVRSRV_ERROR PVRSRVPollForValue ( const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hOSEvent, -#else IMG_HANDLE hOSEvent, -#endif volatile IMG_UINT32 *pui32LinMemAddr, IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask, @@ -768,30 +649,18 @@ PVRSRV_ERROR PVRSRVPollForValue ( const PVRSRV_CONNECTION *psConnection, /* memory APIs */ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContext(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phDevMemContext, -#else IMG_HANDLE *phDevMemContext, -#endif IMG_UINT32 *pui32SharedHeapCount, PVRSRV_HEAP_INFO *psHeapInfo); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyDeviceMemContext(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext -#else IMG_HANDLE hDevMemContext -#endif ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfo(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext, -#else IMG_HANDLE hDevMemContext, -#endif IMG_UINT32 *pui32SharedHeapCount, PVRSRV_HEAP_INFO *psHeapInfo); @@ -808,11 +677,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfo(IMG_CONST PVRSRV_DEV_DATA * IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem2(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap, -#else IMG_HANDLE hDevMemHeap, -#endif IMG_UINT32 ui32Attribs, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, @@ -822,11 +687,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem2(IMG_CONST PVRSRV_DEV_DATA *psDev IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap, -#else IMG_HANDLE hDevMemHeap, -#endif IMG_UINT32 ui32Attribs, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, @@ -837,37 +698,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevDa PVRSRV_CLIENT_MEM_INFO *psMemInfo); IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVMultiManageDevMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, - IMG_UINT32 ui32ControlFlags, PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS * psMultiMemDevRequest, - IMG_UINT32 *ui32StatusFlags, IMG_UINT32 *ui32IndexError); - -IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVManageDevMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, - PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_TYPE eReq, PVRSRV_CLIENT_MEM_INFO *psMemInfo, - IMG_UINT32 *ui32StatusFlags); - -IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVManageDevMemSwapGpuVirtAddr(IMG_CONST PVRSRV_DEV_DATA *psDevData, - PVRSRV_CLIENT_MEM_INFO *psMemInfoSourceArray, PVRSRV_CLIENT_MEM_INFO *psMemInfoTargetArray, - IMG_UINT32 ui32NumBuff, IMG_UINT32 *ui32StatusFlags); - -IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, PVRSRV_CLIENT_MEM_INFO *psMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phMemInfo -#else IMG_HANDLE *phMemInfo -#endif ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVReserveDeviceVirtualMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap, -#else IMG_HANDLE hDevMemHeap, -#endif IMG_DEV_VIRTADDR *psDevVAddr, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, @@ -878,13 +716,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceVirtualMem(IMG_CONST PVRSRV_DEV_DATA * IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo, - IMG_SID hDstDevMemHeap, -#else IMG_HANDLE hKernelMemInfo, IMG_HANDLE hDstDevMemHeap, -#endif PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo); IMG_IMPORT @@ -903,11 +736,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapExtMemory (IMG_CONST PVRSRV_DEV_DATA *psDev IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemory(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext, -#else IMG_HANDLE hDevMemContext, -#endif IMG_SIZE_T ui32ByteSize, IMG_SIZE_T ui32PageOffset, IMG_BOOL bPhysContig, @@ -924,20 +753,6 @@ PVRSRV_ERROR PVRSRVChangeDeviceMemoryAttributes(IMG_CONST PVRSRV_DEV_DATA *psD IMG_UINT32 ui32Attribs); IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext, - IMG_SID hDeviceClassBuffer, -#else - IMG_HANDLE hDevMemContext, - IMG_HANDLE hDeviceClassBuffer, -#endif - PVRSRV_CLIENT_MEM_INFO **ppsMemInfo); -IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, - PVRSRV_CLIENT_MEM_INFO *psMemInfo); - -IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapPhysToUserSpace(IMG_CONST PVRSRV_DEV_DATA *psDevData, IMG_SYS_PHYADDR sSysPhysAddr, IMG_UINT32 uiSizeInBytes, @@ -952,9 +767,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapPhysToUserSpace(IMG_CONST PVRSRV_DEV_DATA * #if defined(LINUX) IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVCloseExportedDeviceMemHanle(const PVRSRV_DEV_DATA *psDevData, - IMG_INT i32Fd); -IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem2(IMG_CONST PVRSRV_DEV_DATA *psDevData, PVRSRV_CLIENT_MEM_INFO *psMemInfo, IMG_INT *iFd); @@ -962,23 +774,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem2(IMG_CONST PVRSRV_DEV_DATA *psDe IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory2(IMG_CONST PVRSRV_DEV_DATA *psDevData, IMG_INT iFd, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDstDevMemHeap, -#else IMG_HANDLE hDstDevMemHeap, -#endif PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo); #endif /* defined(LINUX) */ #if defined(SUPPORT_ION) PVRSRV_ERROR PVRSRVMapIonHandle(const PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext, -#else - IMG_HANDLE hDevMemContext, -#endif - IMG_INT32 uiFD, - IMG_UINT32 uiSize, + IMG_HANDLE hDevMemHeap, + IMG_UINT32 ui32NumFDs, + IMG_INT *paiBufferFDs, + IMG_UINT32 ui32ChunkCount, + IMG_SIZE_T *pauiOffset, + IMG_SIZE_T *pauiSize, IMG_UINT32 ui32Attribs, PVRSRV_CLIENT_MEM_INFO **ppsMemInfo); @@ -989,11 +796,7 @@ PVRSRV_ERROR PVRSRVUnmapIonHandle(const PVRSRV_DEV_DATA *psDevData, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMemSparse(const PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap, -#else IMG_HANDLE hDevMemHeap, -#endif IMG_UINT32 ui32Attribs, IMG_SIZE_T uAlignment, IMG_UINT32 ui32ChunkSize, @@ -1009,7 +812,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMemSparse(const PVRSRV_DEV_DATA *psDe typedef enum _PVRSRV_SYNCVAL_MODE_ { PVRSRV_SYNCVAL_READ = IMG_TRUE, - PVRSRV_SYNCVAL_WRITE = IMG_FALSE, + PVRSRV_SYNCVAL_WRITE = IMG_FALSE } PVRSRV_SYNCVAL_MODE, *PPVRSRV_SYNCVAL_MODE; @@ -1036,6 +839,16 @@ IMG_IMPORT IMG_BOOL PVRSRVTestAllOpsNotComplete(PPVRSRV_CLIENT_MEM_INFO psMemInf IMG_IMPORT PVRSRV_SYNCVAL PVRSRVGetPendingOpSyncVal(PPVRSRV_CLIENT_MEM_INFO psMemInfo, PVRSRV_SYNCVAL_MODE eMode); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, + IMG_HANDLE hDevMemContext, + IMG_HANDLE hDeviceClassBuffer, + PVRSRV_CLIENT_MEM_INFO **ppsMemInfo); +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, + PVRSRV_CLIENT_MEM_INFO *psMemInfo); /****************************************************************************** * Common Device Class Enumeration @@ -1069,11 +882,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumDCDims (IMG_HANDLE hDevice, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCSystemBuffer(IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phBuffer -#else IMG_HANDLE *phBuffer -#endif ); IMG_IMPORT @@ -1088,117 +897,69 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDCSwapChain (IMG_HANDLE hDevice, IMG_UINT32 ui32BufferCount, IMG_UINT32 ui32OEMFlags, IMG_UINT32 *pui32SwapChainID, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phSwapChain -#else IMG_HANDLE *phSwapChain -#endif ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyDCSwapChain (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain -#else IMG_HANDLE hSwapChain -#endif ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCDstRect (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain, -#else IMG_HANDLE hSwapChain, -#endif IMG_RECT *psDstRect); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCSrcRect (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain, -#else IMG_HANDLE hSwapChain, -#endif IMG_RECT *psSrcRect); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCDstColourKey (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain, -#else IMG_HANDLE hSwapChain, -#endif IMG_UINT32 ui32CKColour); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCSrcColourKey (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain, -#else IMG_HANDLE hSwapChain, -#endif IMG_UINT32 ui32CKColour); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCBuffers(IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain, - IMG_SID *phBuffer -#else IMG_HANDLE hSwapChain, IMG_HANDLE *phBuffer -#endif ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCBuffers2(IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain, - IMG_SID *phBuffer, -#else IMG_HANDLE hSwapChain, IMG_HANDLE *phBuffer, -#endif IMG_SYS_PHYADDR *psPhyAddr); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCBuffer (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hBuffer, -#else IMG_HANDLE hBuffer, -#endif IMG_UINT32 ui32ClipRectCount, IMG_RECT *psClipRect, IMG_UINT32 ui32SwapInterval, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hPrivateTag -#else IMG_HANDLE hPrivateTag -#endif ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCBuffer2 (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hBuffer, -#else IMG_HANDLE hBuffer, -#endif IMG_UINT32 ui32SwapInterval, PVRSRV_CLIENT_MEM_INFO **ppsMemInfos, - IMG_UINT32 ui32NumMemInfos, + PVRSRV_CLIENT_SYNC_INFO **ppsSyncInfos, + IMG_UINT32 ui32NumMemSyncInfos, IMG_PVOID pvPrivData, - IMG_UINT32 ui32PrivDataLength); + IMG_UINT32 ui32PrivDataLength, + IMG_HANDLE *phFence); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCSystem (IMG_HANDLE hDevice, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain -#else IMG_HANDLE hSwapChain -#endif ); /****************************************************************************** @@ -1219,13 +980,10 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetBCBufferInfo(IMG_HANDLE hDevice, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetBCBuffer(IMG_HANDLE hDevice, IMG_UINT32 ui32BufferIndex, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phBuffer -#else IMG_HANDLE *phBuffer -#endif ); +#endif /* #if defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ /****************************************************************************** * PDUMP Function prototypes... @@ -1241,11 +999,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpStopInitPhase(IMG_CONST PVRSRV_CONNECTION * IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPol(IMG_CONST PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo, -#else PVRSRV_CLIENT_MEM_INFO *psMemInfo, -#endif IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask, @@ -1254,22 +1008,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPol(IMG_CONST PVRSRV_CONNECTION *psConne IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSyncPol(IMG_CONST PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo, -#else PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo, -#endif IMG_BOOL bIsRead, IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSyncPol2(IMG_CONST PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo, -#else PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo, -#endif IMG_BOOL bIsRead); IMG_IMPORT @@ -1321,11 +1067,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpPDDevPAddr(IMG_CONST PVRSRV_CONNECTION *psC #if !defined(USE_CODE) IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPages(IMG_CONST PVRSRV_DEV_DATA *psDevData, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo, -#else IMG_HANDLE hKernelMemInfo, -#endif IMG_DEV_PHYADDR *pPages, IMG_UINT32 ui32NumPages, IMG_DEV_VIRTADDR sDevVAddr, @@ -1378,11 +1120,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpBitmap(IMG_CONST PVRSRV_DEV_DATA *psDevData IMG_UINT32 ui32Height, IMG_UINT32 ui32StrideInBytes, IMG_DEV_VIRTADDR sDevBaseAddr, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext, -#else IMG_HANDLE hDevMemContext, -#endif IMG_UINT32 ui32Size, PDUMP_PIXEL_FORMAT ePixelFormat, PDUMP_MEM_FORMAT eMemFormat, @@ -1437,12 +1175,12 @@ IMG_IMPORT IMG_BOOL IMG_CALLCONV PVRSRVGetAppHint(IMG_VOID *pvHintState, *****************************************************************************/ /* Exported APIs */ -IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVAllocUserModeMem (IMG_SIZE_T ui32Size); -IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVCallocUserModeMem (IMG_SIZE_T ui32Size); -IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMem (IMG_PVOID pvBase, IMG_SIZE_T uNewSize); +IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVAllocUserModeMem (IMG_SIZE_T uiSize); +IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVCallocUserModeMem (IMG_SIZE_T uiSize); +IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMem (IMG_PVOID pvBase, IMG_SIZE_T uiNewSize); IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVFreeUserModeMem (IMG_PVOID pvMem); -IMG_IMPORT IMG_VOID PVRSRVMemCopy(IMG_VOID *pvDst, const IMG_VOID *pvSrc, IMG_SIZE_T ui32Size); -IMG_IMPORT IMG_VOID PVRSRVMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T ui32Size); +IMG_IMPORT IMG_VOID PVRSRVMemCopy(IMG_VOID *pvDst, const IMG_VOID *pvSrc, IMG_SIZE_T uiSize); +IMG_IMPORT IMG_VOID PVRSRVMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T uiSize); struct _PVRSRV_MUTEX_OPAQUE_STRUCT_; typedef struct _PVRSRV_MUTEX_OPAQUE_STRUCT_ *PVRSRV_MUTEX_HANDLE; @@ -1591,11 +1329,7 @@ IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMemTracking(IMG_VOID *pvM *****************************************************************************/ IMG_IMPORT PVRSRV_ERROR PVRSRVEventObjectWait(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_EVENTSID hOSEvent -#else IMG_HANDLE hOSEvent -#endif ); /*! @@ -1608,11 +1342,7 @@ IMG_IMPORT PVRSRV_ERROR PVRSRVEventObjectWait(const PVRSRV_CONNECTION *psConnect ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateSyncInfoModObj(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phKernelSyncInfoModObj -#else IMG_HANDLE *phKernelSyncInfoModObj -#endif ); /*! @@ -1625,11 +1355,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateSyncInfoModObj(const PVRSRV_CONNECTION *ps ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroySyncInfoModObj(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj -#else IMG_HANDLE hKernelSyncInfoModObj -#endif ); @@ -1664,11 +1390,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroySyncInfoModObj(const PVRSRV_CONNECTION *p ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyPendingSyncOps(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj, -#else IMG_HANDLE hKernelSyncInfoModObj, -#endif PVRSRV_CLIENT_SYNC_INFO *psSyncInfo, IMG_UINT32 ui32ModifyFlags, IMG_UINT32 *pui32ReadOpsPending, @@ -1689,11 +1411,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyPendingSyncOps(const PVRSRV_CONNECTION *ps ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyCompleteSyncOps(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj -#else IMG_HANDLE hKernelSyncInfoModObj -#endif ); /*! @@ -1719,11 +1437,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyCompleteSyncOps(const PVRSRV_CONNECTION *p ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsTakeToken(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - const IMG_SID hKernelSyncInfo, -#else const PVRSRV_CLIENT_SYNC_INFO *psSyncInfo, -#endif PVRSRV_SYNC_TOKEN *psSyncToken); /*! ****************************************************************************** @@ -1743,11 +1457,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsTakeToken(const PVRSRV_CONNECTION *psConn ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToToken(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - const IMG_SID hKernelSyncInfo, -#else const PVRSRV_CLIENT_SYNC_INFO *psSyncInfo, -#endif const PVRSRV_SYNC_TOKEN *psSyncToken, IMG_BOOL bWait); /*! @@ -1770,11 +1480,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToToken(const PVRSRV_CONNECTION *psC ******************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToModObj(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj, -#else IMG_HANDLE hKernelSyncInfoModObj, -#endif IMG_BOOL bWait); /*! diff --git a/drivers/gpu/pvr/include4/servicesext.h b/drivers/gpu/pvr/include4/servicesext.h index 80df1177558..a0aff8ca86f 100644..100755 --- a/drivers/gpu/pvr/include4/servicesext.h +++ b/drivers/gpu/pvr/include4/servicesext.h @@ -645,6 +645,9 @@ typedef enum _PVRSRV_PIXEL_FORMAT_ { PVRSRV_PIXEL_FORMAT_RAW512 = 224, PVRSRV_PIXEL_FORMAT_RAW1024 = 225, + /* Same as NV12 but with interleaved VU rather than interleaved UV */ + PVRSRV_PIXEL_FORMAT_NV21 = 226, + PVRSRV_PIXEL_FORMAT_FORCE_I32 = 0x7fffffff } PVRSRV_PIXEL_FORMAT; @@ -657,7 +660,7 @@ typedef enum _PVRSRV_ALPHA_FORMAT_ { PVRSRV_ALPHA_FORMAT_UNKNOWN = 0x00000000, PVRSRV_ALPHA_FORMAT_PRE = 0x00000001, PVRSRV_ALPHA_FORMAT_NONPRE = 0x00000002, - PVRSRV_ALPHA_FORMAT_MASK = 0x0000000F, + PVRSRV_ALPHA_FORMAT_MASK = 0x0000000F } PVRSRV_ALPHA_FORMAT; /*! @@ -668,7 +671,7 @@ typedef enum _PVRSRV_COLOURSPACE_FORMAT_ { PVRSRV_COLOURSPACE_FORMAT_UNKNOWN = 0x00000000, PVRSRV_COLOURSPACE_FORMAT_LINEAR = 0x00010000, PVRSRV_COLOURSPACE_FORMAT_NONLINEAR = 0x00020000, - PVRSRV_COLOURSPACE_FORMAT_MASK = 0x000F0000, + PVRSRV_COLOURSPACE_FORMAT_MASK = 0x000F0000 } PVRSRV_COLOURSPACE_FORMAT; @@ -744,17 +747,10 @@ typedef struct _PVRSRV_CLIENT_SYNC_INFO_ IMG_DEV_VIRTADDR sReadOps2CompleteDevVAddr; /* handle to client mapping data (OS specific) */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMappingInfo; - - /* handle to kernel sync info */ - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hMappingInfo; /* handle to kernel sync info */ IMG_HANDLE hKernelSyncInfo; -#endif } PVRSRV_CLIENT_SYNC_INFO, *PPVRSRV_CLIENT_SYNC_INFO; @@ -803,7 +799,7 @@ typedef struct _IMG_RECT_16_ typedef PVRSRV_ERROR (*PFN_GET_BUFFER_ADDR)(IMG_HANDLE, IMG_HANDLE, IMG_SYS_PHYADDR**, - IMG_SIZE_T*, + IMG_UINT32*, IMG_VOID**, IMG_HANDLE*, IMG_BOOL*, diff --git a/drivers/gpu/pvr/include4/sgx_options.h b/drivers/gpu/pvr/include4/sgx_options.h index b64cd39e616..230e8ada266 100644..100755 --- a/drivers/gpu/pvr/include4/sgx_options.h +++ b/drivers/gpu/pvr/include4/sgx_options.h @@ -87,17 +87,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if defined (SUPPORT_SID_INTERFACE) -#define PVR_SECURE_HANDLES_SET_OFFSET OPTIONS_BIT4 -#define OPTIONS_BIT4 (0x1U << 4) -#else #if defined(PVR_SECURE_HANDLES) || defined (INTERNAL_TEST) #define PVR_SECURE_HANDLES_SET_OFFSET OPTIONS_BIT4 #define OPTIONS_BIT4 (0x1U << 4) #else #define OPTIONS_BIT4 0x0 #endif /* PVR_SECURE_HANDLES */ -#endif #if defined(SGX_BYPASS_SYSTEM_CACHE) || defined (INTERNAL_TEST) #define SGX_BYPASS_SYSTEM_CACHE_SET_OFFSET OPTIONS_BIT5 @@ -206,13 +201,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define OPTIONS_BIT21 0x0 #endif /* SUPPORT_SGX_LOW_LATENCY_SCHEDULING */ -#if defined(USE_SUPPORT_NO_TA3D_OVERLAP) || defined (INTERNAL_TEST) -#define USE_SUPPORT_NO_TA3D_OVERLAP_SET_OFFSET OPTIONS_BIT22 -#define OPTIONS_BIT22 (0x1U << 22) -#else -#define OPTIONS_BIT22 0x0 -#endif /* USE_SUPPORT_NO_TA3D_OVERLAP */ - #if defined(SGX_FEATURE_MP) || defined (INTERNAL_TEST) #if defined(SGX_FEATURE_MP_CORE_COUNT) #define OPTIONS_HIGHBYTE ((SGX_FEATURE_MP_CORE_COUNT-1) << SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET) @@ -253,6 +241,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. OPTIONS_BIT19 |\ OPTIONS_BIT20 |\ OPTIONS_BIT21 |\ - OPTIONS_BIT22 |\ OPTIONS_HIGHBYTE diff --git a/drivers/gpu/pvr/include4/sgxapi_km.h b/drivers/gpu/pvr/include4/sgxapi_km.h index bb8776a8ec7..d001e6f778c 100644..100755 --- a/drivers/gpu/pvr/include4/sgxapi_km.h +++ b/drivers/gpu/pvr/include4/sgxapi_km.h @@ -83,11 +83,8 @@ extern "C" { #if defined(SUPPORT_MEMORY_TILING) #define SGX_VPB_TILED_HEAP_ID 14 #endif -#if defined(SUPPORT_ION) -#define SGX_ION_HEAP_ID 15 -#endif -#define SGX_MAX_HEAP_ID 16 +#define SGX_MAX_HEAP_ID 15 /* * Keep SGX_3DPARAMETERS_HEAP_ID as TQ full custom @@ -119,9 +116,9 @@ extern "C" { /* sync info structure array size */ #define SGX_MAX_SRC_SYNCS_TA 32 #define SGX_MAX_DST_SYNCS_TA 1 -/* note: there is implicitly 1 3D Dst Sync */ -#define SGX_MAX_SRC_SYNCS_TQ 8 -#define SGX_MAX_DST_SYNCS_TQ 1 +/* note: only one dst sync is supported by the 2D paths */ +#define SGX_MAX_SRC_SYNCS_TQ 6 +#define SGX_MAX_DST_SYNCS_TQ 2 #endif @@ -142,6 +139,9 @@ extern "C" { #define PVRSRV_SGX_HWPERF_POWER 0x6 #define PVRSRV_SGX_HWPERF_PERIODIC 0x7 #define PVRSRV_SGX_HWPERF_3DSPM 0x8 +#define PVRSRV_SGX_HWPERF_TA_OCL 0x9 +#define PVRSRV_SGX_HWPERF_3D_OCL 0xA +#define PVRSRV_SGX_HWPERF_3DSPM_OCL 0xB #define PVRSRV_SGX_HWPERF_MK_EVENT 0x101 #define PVRSRV_SGX_HWPERF_MK_TA 0x102 @@ -154,6 +154,7 @@ extern "C" { #define PVRSRV_SGX_HWPERF_MK_TA_LOCKUP 0x109 #define PVRSRV_SGX_HWPERF_MK_3D_LOCKUP 0x10A #define PVRSRV_SGX_HWPERF_MK_2D_LOCKUP 0x10B +#define PVRSRV_SGX_HWPERF_MK_HK 0x10C #define PVRSRV_SGX_HWPERF_TYPE_STARTEND_BIT 28 #define PVRSRV_SGX_HWPERF_TYPE_OP_MASK ((1UL << PVRSRV_SGX_HWPERF_TYPE_STARTEND_BIT) - 1) @@ -173,6 +174,12 @@ extern "C" { #define PVRSRV_SGX_HWPERF_TYPE_PERIODIC (PVRSRV_SGX_HWPERF_PERIODIC) #define PVRSRV_SGX_HWPERF_TYPE_3DSPM_START (PVRSRV_SGX_HWPERF_3DSPM | PVRSRV_SGX_HWPERF_TYPE_OP_START) #define PVRSRV_SGX_HWPERF_TYPE_3DSPM_END (PVRSRV_SGX_HWPERF_3DSPM | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_3DSPM_OCL_START (PVRSRV_SGX_HWPERF_3DSPM_OCL | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_3DSPM_OCL_END (PVRSRV_SGX_HWPERF_3DSPM_OCL | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_TA_OCL_START (PVRSRV_SGX_HWPERF_TA_OCL | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_TA_OCL_END (PVRSRV_SGX_HWPERF_TA_OCL | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_3D_OCL_START (PVRSRV_SGX_HWPERF_3D_OCL | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_3D_OCL_END (PVRSRV_SGX_HWPERF_3D_OCL | PVRSRV_SGX_HWPERF_TYPE_OP_END) #define PVRSRV_SGX_HWPERF_TYPE_MK_TRANSFER_DUMMY_START (PVRSRV_SGX_HWPERF_MK_TRANSFER_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_START) #define PVRSRV_SGX_HWPERF_TYPE_MK_TRANSFER_DUMMY_END (PVRSRV_SGX_HWPERF_MK_TRANSFER_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_END) #define PVRSRV_SGX_HWPERF_TYPE_MK_TA_DUMMY_START (PVRSRV_SGX_HWPERF_MK_TA_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_START) @@ -193,6 +200,9 @@ extern "C" { #define PVRSRV_SGX_HWPERF_TYPE_MK_3D_END (PVRSRV_SGX_HWPERF_MK_3D | PVRSRV_SGX_HWPERF_TYPE_OP_END) #define PVRSRV_SGX_HWPERF_TYPE_MK_2D_START (PVRSRV_SGX_HWPERF_MK_2D | PVRSRV_SGX_HWPERF_TYPE_OP_START) #define PVRSRV_SGX_HWPERF_TYPE_MK_2D_END (PVRSRV_SGX_HWPERF_MK_2D | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_MK_HK_START (PVRSRV_SGX_HWPERF_MK_HK | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_MK_HK_END (PVRSRV_SGX_HWPERF_MK_HK | PVRSRV_SGX_HWPERF_TYPE_OP_END) + #define PVRSRV_SGX_HWPERF_STATUS_OFF (0x0) #define PVRSRV_SGX_HWPERF_STATUS_RESET_COUNTERS (1UL << 0) @@ -236,6 +246,7 @@ typedef struct _CTL_STATUS_ typedef enum _SGX_MISC_INFO_REQUEST_ { SGX_MISC_INFO_REQUEST_CLOCKSPEED = 0, + SGX_MISC_INFO_REQUEST_CLOCKSPEED_SLCSIZE, SGX_MISC_INFO_REQUEST_SGXREV, SGX_MISC_INFO_REQUEST_DRIVER_SGXREV, #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG) @@ -254,6 +265,9 @@ typedef enum _SGX_MISC_INFO_REQUEST_ SGX_MISC_INFO_REQUEST_SPM, SGX_MISC_INFO_REQUEST_ACTIVEPOWER, SGX_MISC_INFO_REQUEST_LOCKUPS, +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + SGX_MISC_INFO_REQUEST_EDM_STATUS_BUFFER_INFO, +#endif SGX_MISC_INFO_REQUEST_FORCE_I16 = 0x7fff } SGX_MISC_INFO_REQUEST; @@ -275,11 +289,24 @@ typedef struct _PVRSRV_SGX_MISCINFO_FEATURES #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG) IMG_UINT32 ui32DeviceMemValue; /*!< device mem value read from ukernel */ #endif +} PVRSRV_SGX_MISCINFO_FEATURES; + +typedef struct _PVRSRV_SGX_MISCINFO_QUERY_CLOCKSPEED_SLCSIZE +{ + IMG_UINT32 ui32SGXClockSpeed; + IMG_UINT32 ui32SGXSLCSize; +} PVRSRV_SGX_MISCINFO_QUERY_CLOCKSPEED_SLCSIZE; + #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) +/****************************************************************************** + * Struct for getting access to the EDM Status Buffer + ******************************************************************************/ +typedef struct _PVRSRV_SGX_MISCINFO_EDM_STATUS_BUFFER_INFO +{ IMG_DEV_VIRTADDR sDevVAEDMStatusBuffer; /*!< DevVAddr of the EDM status buffer */ IMG_PVOID pvEDMStatusBuffer; /*!< CPUVAddr of the EDM status buffer */ +} PVRSRV_SGX_MISCINFO_EDM_STATUS_BUFFER_INFO; #endif -} PVRSRV_SGX_MISCINFO_FEATURES; /****************************************************************************** @@ -389,6 +416,7 @@ typedef struct _SGX_MISC_INFO_ IMG_UINT32 reserved; /*!< Unused: ensures valid code in the case everything else is compiled out */ PVRSRV_SGX_MISCINFO_FEATURES sSGXFeatures; IMG_UINT32 ui32SGXClockSpeed; + PVRSRV_SGX_MISCINFO_QUERY_CLOCKSPEED_SLCSIZE sQueryClockSpeedSLCSize; PVRSRV_SGX_MISCINFO_ACTIVEPOWER sActivePower; PVRSRV_SGX_MISCINFO_LOCKUPS sLockups; PVRSRV_SGX_MISCINFO_SPM sSPM; @@ -396,6 +424,10 @@ typedef struct _SGX_MISC_INFO_ SGX_BREAKPOINT_INFO sSGXBreakpointInfo; #endif PVRSRV_SGX_MISCINFO_SET_HWPERF_STATUS sSetHWPerfStatus; + +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + PVRSRV_SGX_MISCINFO_EDM_STATUS_BUFFER_INFO sEDMStatusBufferInfo; +#endif } uData; } SGX_MISC_INFO; @@ -439,7 +471,6 @@ typedef struct _PVRSRV_SGX_PDUMP_CONTEXT_ } PVRSRV_SGX_PDUMP_CONTEXT; -#if !defined (SUPPORT_SID_INTERFACE) typedef struct _SGX_KICKTA_DUMP_ROFF_ { IMG_HANDLE hKernelMemInfo; /*< Buffer handle */ @@ -448,13 +479,8 @@ typedef struct _SGX_KICKTA_DUMP_ROFF_ IMG_UINT32 ui32Value; /*< Actual value to dump */ IMG_PCHAR pszName; /*< Name of buffer */ } SGX_KICKTA_DUMP_ROFF, *PSGX_KICKTA_DUMP_ROFF; -#endif -#if defined (SUPPORT_SID_INTERFACE) -typedef struct _SGX_KICKTA_DUMP_BUFFER_KM_ -#else typedef struct _SGX_KICKTA_DUMP_BUFFER_ -#endif { IMG_UINT32 ui32SpaceUsed; IMG_UINT32 ui32Start; /*< Byte offset of start to dump */ @@ -475,13 +501,8 @@ typedef struct _SGX_KICKTA_DUMP_BUFFER_ #if defined (__QNXNTO__) IMG_UINT32 ui32NameLength; /*< Number of characters in buffer name */ #endif -#if defined (SUPPORT_SID_INTERFACE) -} SGX_KICKTA_DUMP_BUFFER_KM, *PSGX_KICKTA_DUMP_BUFFER_KM; -#else } SGX_KICKTA_DUMP_BUFFER, *PSGX_KICKTA_DUMP_BUFFER; -#endif -#if !defined (SUPPORT_SID_INTERFACE) #ifdef PDUMP /* PDUMP version of above kick structure @@ -501,7 +522,6 @@ typedef struct _SGX_KICKTA_PDUMP_ IMG_UINT32 ui32ROffArraySize; } SGX_KICKTA_PDUMP, *PSGX_KICKTA_PDUMP; #endif /* PDUMP */ -#endif /* #if !defined (SUPPORT_SID_INTERFACE) */ #if defined(TRANSFER_QUEUE) #if defined(SGX_FEATURE_2D_HARDWARE) diff --git a/drivers/gpu/pvr/include4/sgxscript.h b/drivers/gpu/pvr/include4/sgxscript.h index 46b89d2ea7e..7e663b1e081 100644..100755 --- a/drivers/gpu/pvr/include4/sgxscript.h +++ b/drivers/gpu/pvr/include4/sgxscript.h @@ -42,11 +42,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __SGXSCRIPT_H__ #define __SGXSCRIPT_H__ +#include "sgxfeaturedefs.h" #if defined (__cplusplus) extern "C" { #endif #define SGX_MAX_INIT_COMMANDS 64 +#define SGX_MAX_PRINT_COMMANDS 64 #define SGX_MAX_DEINIT_COMMANDS 16 typedef enum _SGX_INIT_OPERATION @@ -54,6 +56,7 @@ typedef enum _SGX_INIT_OPERATION SGX_INIT_OP_ILLEGAL = 0, SGX_INIT_OP_WRITE_HW_REG, SGX_INIT_OP_READ_HW_REG, + SGX_INIT_OP_PRINT_HW_REG, #if defined(PDUMP) SGX_INIT_OP_PDUMP_HW_REG, #endif @@ -71,6 +74,7 @@ typedef union _SGX_INIT_COMMAND struct { SGX_INIT_OPERATION eOp; IMG_UINT32 ui32Offset; + IMG_UINT32 ui32Value; } sReadHWReg; #if defined(PDUMP) struct { @@ -86,6 +90,10 @@ typedef struct _SGX_INIT_SCRIPTS_ SGX_INIT_COMMAND asInitCommandsPart1[SGX_MAX_INIT_COMMANDS]; SGX_INIT_COMMAND asInitCommandsPart2[SGX_MAX_INIT_COMMANDS]; SGX_INIT_COMMAND asDeinitCommands[SGX_MAX_DEINIT_COMMANDS]; +#if defined(SGX_FEATURE_MP) + SGX_INIT_COMMAND asSGXREGDebugCommandsMaster[SGX_MAX_PRINT_COMMANDS]; +#endif + SGX_INIT_COMMAND asSGXREGDebugCommandsSlave[SGX_MAX_PRINT_COMMANDS]; } SGX_INIT_SCRIPTS; #if defined(__cplusplus) diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/Kbuild.mk b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/Kbuild.mk new file mode 100755 index 00000000000..8f5720e5ce1 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/Kbuild.mk @@ -0,0 +1,45 @@ +########################################################################### ### +#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +#@License Dual MIT/GPLv2 +# +# The contents of this file are subject to the MIT license as set out below. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 2 ("GPL") in which case the provisions +# of GPL are applicable instead of those above. +# +# If you wish to allow use of your version of this file only under the terms of +# GPL, and not to allow others to use your version of this file under the terms +# of the MIT license, indicate your decision by deleting the provisions above +# and replace them with the notice and other provisions required by GPL as set +# out in the file called "GPL-COPYING" included in this distribution. If you do +# not delete the provisions above, a recipient may use your version of this file +# under the terms of either the MIT license or GPL. +# +# This License is also included in this distribution in the file called +# "MIT-COPYING". +# +# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### ########################################################################### +ccflags-y += -I$(TOP)/services4/3rdparty/bufferclass_example + +bc_example-y += \ + services4/3rdparty/bufferclass_example/bufferclass_example.o \ + services4/3rdparty/bufferclass_example/bufferclass_example_linux.o \ + services4/3rdparty/bufferclass_example/bufferclass_example_private.o diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/Linux.mk b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/Linux.mk new file mode 100755 index 00000000000..f2e44a64160 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/Linux.mk @@ -0,0 +1,45 @@ +########################################################################### ### +#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +#@License Dual MIT/GPLv2 +# +# The contents of this file are subject to the MIT license as set out below. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 2 ("GPL") in which case the provisions +# of GPL are applicable instead of those above. +# +# If you wish to allow use of your version of this file only under the terms of +# GPL, and not to allow others to use your version of this file under the terms +# of the MIT license, indicate your decision by deleting the provisions above +# and replace them with the notice and other provisions required by GPL as set +# out in the file called "GPL-COPYING" included in this distribution. If you do +# not delete the provisions above, a recipient may use your version of this file +# under the terms of either the MIT license or GPL. +# +# This License is also included in this distribution in the file called +# "MIT-COPYING". +# +# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### ########################################################################### + +modules := bufferclass_example + +bufferclass_example_type := kernel_module +bufferclass_example_target := bc_example.ko +bufferclass_example_makefile := $(THIS_DIR)/Kbuild.mk diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example.c b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example.c new file mode 100755 index 00000000000..26698889caa --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example.c @@ -0,0 +1,626 @@ +/*************************************************************************/ /*! +@Title bufferclass_example kernel driver +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +/************************************************************************** + The 3rd party driver is a specification of an API to integrate the IMG POWERVR + Services driver with a 3rd Party 'buffer device'. It is NOT a specification for + a 'buffer device' driver, rather a specification to extend the API for a + pre-existing driver for the 'buffer device' hardware. + + The 3rd party driver interface provides IMG POWERVR client drivers (e.g. PVR2D) + with an API abstraction of the system's underlying buffer device hardware, + allowing the client drivers to indirectly control the buffer device hardware + and access its associated memory. + + Functions of the API include + - query buffer device surface attributes (width, height, stride, pixel format, + CPU physical and virtual address) + + Note: having queried surface attributes the client drivers are able to map the + buffer device memory to any IMG POWERVR Services device by calling + PVRSRVMapDeviceClassMemory with the buffer device surface handle. + + This code is intended to be an example of how a pre-existing buffer device + driver may be extended to support the 3rd Party buffer device interface to + POWERVR Services + - IMG is not providing a buffer device driver implementation. + **************************************************************************/ +#if defined(__linux__) +#include <linux/string.h> +#else +#include <string.h> +#endif + +#include "bufferclass_example.h" + + + +#define BUFFERCLASS_DEVICE_NAME "Example Bufferclass Device (SW)" + +/* top level 'hook ptr' */ +static void *gpvAnchor = NULL; +static PFN_BC_GET_PVRJTABLE pfnGetPVRJTable = IMG_NULL; + +/* + Kernel services is a kernel module and must be loaded first. + This driver is also a kernel module and must be loaded after the pvr services module. + This driver should be able to retrieve the + address of the services PVRGetBufferClassJTable from (the already loaded) + kernel services module. +*/ + +/* returns anchor pointer */ +BC_EXAMPLE_DEVINFO * GetAnchorPtr(void) +{ + return (BC_EXAMPLE_DEVINFO *)gpvAnchor; +} + +/* sets anchor pointer */ +static void SetAnchorPtr(BC_EXAMPLE_DEVINFO *psDevInfo) +{ + gpvAnchor = (void *)psDevInfo; +} + + +/* Open device function, called from services */ +static PVRSRV_ERROR OpenBCDevice(IMG_UINT32 ui32DeviceID, IMG_HANDLE *phDevice) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + + /* + bufferclass_example manages only one BufferClass device + therefore there is no need to track ID numbers. + */ + UNREFERENCED_PARAMETER(ui32DeviceID); + + psDevInfo = GetAnchorPtr(); + + /* return handle to the devinfo */ + *phDevice = (IMG_HANDLE)psDevInfo; + + return (PVRSRV_OK); +} + + +/* Close device function, called from services */ +static PVRSRV_ERROR CloseBCDevice(IMG_UINT32 ui32DeviceID, IMG_HANDLE hDevice) +{ + UNREFERENCED_PARAMETER(hDevice); + + return (PVRSRV_OK); +} + +/* Passes in the sync data for a buffer, and returns the handle */ +/* called from services */ +static PVRSRV_ERROR GetBCBuffer(IMG_HANDLE hDevice, + IMG_UINT32 ui32BufferNumber, + PVRSRV_SYNC_DATA *psSyncData, + IMG_HANDLE *phBuffer) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + + if(!hDevice || !phBuffer) + { + return (PVRSRV_ERROR_INVALID_PARAMS); + } + + psDevInfo = (BC_EXAMPLE_DEVINFO*)hDevice; + + if( ui32BufferNumber < psDevInfo->sBufferInfo.ui32BufferCount ) + { + psDevInfo->psSystemBuffer[ui32BufferNumber].psSyncData = psSyncData; + *phBuffer = (IMG_HANDLE)&psDevInfo->psSystemBuffer[ui32BufferNumber]; + } + else + { + return (PVRSRV_ERROR_INVALID_PARAMS); + } + + return (PVRSRV_OK); +} + + +/* get buffer info function, called from services */ +static PVRSRV_ERROR GetBCInfo(IMG_HANDLE hDevice, BUFFER_INFO *psBCInfo) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + + if(!hDevice || !psBCInfo) + { + return (PVRSRV_ERROR_INVALID_PARAMS); + } + + psDevInfo = (BC_EXAMPLE_DEVINFO*)hDevice; + + *psBCInfo = psDevInfo->sBufferInfo; + + return (PVRSRV_OK); +} + + +/* get buffer address function, called from services */ +static PVRSRV_ERROR GetBCBufferAddr(IMG_HANDLE hDevice, + IMG_HANDLE hBuffer, + IMG_SYS_PHYADDR **ppsSysAddr, + IMG_UINT32 *pui32ByteSize, + IMG_VOID **ppvCpuVAddr, + IMG_HANDLE *phOSMapInfo, + IMG_BOOL *pbIsContiguous, + IMG_UINT32 *pui32TilingStride) +{ + BC_EXAMPLE_BUFFER *psBuffer; + + PVR_UNREFERENCED_PARAMETER(pui32TilingStride); + + if(!hDevice || !hBuffer || !ppsSysAddr || !pui32ByteSize) + { + return (PVRSRV_ERROR_INVALID_PARAMS); + } + + psBuffer = (BC_EXAMPLE_BUFFER *) hBuffer; + + *ppvCpuVAddr = psBuffer->sCPUVAddr; + + *phOSMapInfo = IMG_NULL; + *pui32ByteSize = (IMG_UINT32)psBuffer->ulSize; + +#if defined(BC_DISCONTIG_BUFFERS) + *ppsSysAddr = psBuffer->psSysAddr; + *pbIsContiguous = IMG_FALSE; +#else + *ppsSysAddr = &psBuffer->sPageAlignSysAddr; + *pbIsContiguous = IMG_TRUE; +#endif + + return (PVRSRV_OK); +} + + +/* + * Register the device with services module srvkm. + * This should only be done once at boot time. + */ +BCE_ERROR BC_Example_Register(void) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + + /* + - connect to services + - register with services + - allocate and setup private data structure + */ + + + /* + in kernel driver, data structures must be anchored to something for subsequent retrieval + this may be a single global pointer or TLS or something else - up to you + call API to retrieve this ptr + */ + + /* + get the anchor pointer + */ + psDevInfo = GetAnchorPtr(); + + if (psDevInfo == NULL) + { + /* allocate device info. structure */ + psDevInfo = (BC_EXAMPLE_DEVINFO *)BCAllocKernelMem(sizeof(BC_EXAMPLE_DEVINFO)); + + if(!psDevInfo) + { + return (BCE_ERROR_OUT_OF_MEMORY);/* failure */ + } + + /* set the top-level anchor */ + SetAnchorPtr((void*)psDevInfo); + + /* set ref count */ + psDevInfo->ulRefCount = 0; + + + if(BCOpenPVRServices(&psDevInfo->hPVRServices) != BCE_OK) + { + return (BCE_ERROR_INIT_FAILURE);/* failure */ + } + if(BCGetLibFuncAddr (psDevInfo->hPVRServices, "PVRGetBufferClassJTable", &pfnGetPVRJTable) != BCE_OK) + { + return (BCE_ERROR_INIT_FAILURE);/* failure */ + } + + /* got the kernel services function table */ + if(!(*pfnGetPVRJTable)(&psDevInfo->sPVRJTable)) + { + return (BCE_ERROR_INIT_FAILURE);/* failure */ + } + + /* + Setup the devinfo + */ + + psDevInfo->ulNumBuffers = 0; + + psDevInfo->psSystemBuffer = BCAllocKernelMem(sizeof(BC_EXAMPLE_BUFFER) * BC_EXAMPLE_NUM_BUFFERS); + + if(!psDevInfo->psSystemBuffer) + { + return (BCE_ERROR_OUT_OF_MEMORY);/* failure */ + } + + /* Setup Buffer Info */ + psDevInfo->sBufferInfo.pixelformat = PVRSRV_PIXEL_FORMAT_UNKNOWN; + psDevInfo->sBufferInfo.ui32Width = 0; + psDevInfo->sBufferInfo.ui32Height = 0; + psDevInfo->sBufferInfo.ui32ByteStride = 0; + psDevInfo->sBufferInfo.ui32BufferDeviceID = BC_EXAMPLE_DEVICEID; + psDevInfo->sBufferInfo.ui32Flags = 0; + psDevInfo->sBufferInfo.ui32BufferCount = (IMG_UINT32)psDevInfo->ulNumBuffers; + + strncpy(psDevInfo->sBufferInfo.szDeviceName, BUFFERCLASS_DEVICE_NAME, MAX_BUFFER_DEVICE_NAME_SIZE); + + /* + Bsetup the BC Jtable so SRVKM can call into this driver + */ + psDevInfo->sBCJTable.ui32TableSize = sizeof(PVRSRV_BC_SRV2BUFFER_KMJTABLE); + psDevInfo->sBCJTable.pfnOpenBCDevice = OpenBCDevice; + psDevInfo->sBCJTable.pfnCloseBCDevice = CloseBCDevice; + psDevInfo->sBCJTable.pfnGetBCBuffer = GetBCBuffer; + psDevInfo->sBCJTable.pfnGetBCInfo = GetBCInfo; + psDevInfo->sBCJTable.pfnGetBufferAddr = GetBCBufferAddr; + + + /* register device with services and retrieve device index */ + /* This example only registers 1 device, but for multiple buffer streams, register more devices */ + if(psDevInfo->sPVRJTable.pfnPVRSRVRegisterBCDevice (&psDevInfo->sBCJTable, + (IMG_UINT32*)&psDevInfo->ulDeviceID ) != PVRSRV_OK) + { + return (BCE_ERROR_DEVICE_REGISTER_FAILED);/* failure */ + } + } + + /* increment the ref count */ + psDevInfo->ulRefCount++; + + /* return success */ + return (BCE_OK); +} + +/* + * Unregister the device with services module srvkm. + */ +BCE_ERROR BC_Example_Unregister(void) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + + psDevInfo = GetAnchorPtr(); + + /* check DevInfo has been setup */ + if (psDevInfo == NULL) + { + return (BCE_ERROR_GENERIC);/* failure */ + } + /* decrement ref count */ + psDevInfo->ulRefCount--; + + if (psDevInfo->ulRefCount == 0) + { + /* all references gone - de-init device information */ + PVRSRV_BC_BUFFER2SRV_KMJTABLE *psJTable = &psDevInfo->sPVRJTable; + + + /* Remove the device from kernel services device register */ + if (psJTable->pfnPVRSRVRemoveBCDevice(psDevInfo->ulDeviceID) != PVRSRV_OK) + { + return (BCE_ERROR_GENERIC);/* failure */ + } + + if (BCClosePVRServices(psDevInfo->hPVRServices) != BCE_OK) + { + psDevInfo->hPVRServices = NULL; + return (BCE_ERROR_GENERIC);/* failure */ + } + + if (psDevInfo->psSystemBuffer) + { + BCFreeKernelMem(psDevInfo->psSystemBuffer); + } + + /* de-allocate data structure */ + BCFreeKernelMem(psDevInfo); + + /* clear the top-level anchor */ + SetAnchorPtr(NULL); + } + + /* return success */ + return (BCE_OK); +} + + +/* + * Create shared buffers. + */ +BCE_ERROR BC_Example_Buffers_Create(void) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + unsigned long i; +#if !defined(BC_DISCONTIG_BUFFERS) + IMG_CPU_PHYADDR sSystemBufferCPUPAddr; +#endif + PVRSRV_PIXEL_FORMAT pixelformat = BC_EXAMPLE_PIXELFORMAT; + static IMG_UINT32 ui32Width = BC_EXAMPLE_WIDTH; + static IMG_UINT32 ui32Height = BC_EXAMPLE_HEIGHT; + static IMG_UINT32 ui32ByteStride = BC_EXAMPLE_STRIDE; + + IMG_UINT32 ui32MaxWidth = 320 * 4; + + /* + get the anchor pointer + */ + psDevInfo = GetAnchorPtr(); + if (psDevInfo == NULL) + { + /* + * This device was not correctly registered/created. + */ + return (BCE_ERROR_DEVICE_REGISTER_FAILED); + } + if (psDevInfo->ulNumBuffers) + { + /* Buffers already allocated */ + return (BCE_ERROR_GENERIC); + } + + /* Setup Buffer Info */ + psDevInfo->sBufferInfo.pixelformat = BC_EXAMPLE_PIXELFORMAT; + psDevInfo->sBufferInfo.ui32Width = ui32Width; + psDevInfo->sBufferInfo.ui32Height = ui32Height; + psDevInfo->sBufferInfo.ui32ByteStride = ui32ByteStride; + psDevInfo->sBufferInfo.ui32BufferDeviceID = BC_EXAMPLE_DEVICEID; + psDevInfo->sBufferInfo.ui32Flags = PVRSRV_BC_FLAGS_YUVCSC_FULL_RANGE | PVRSRV_BC_FLAGS_YUVCSC_BT601; + + for(i=psDevInfo->ulNumBuffers; i < BC_EXAMPLE_NUM_BUFFERS; i++) + { + unsigned long ulSize = (unsigned long)(ui32Height * ui32ByteStride); + + if(psDevInfo->sBufferInfo.pixelformat == PVRSRV_PIXEL_FORMAT_NV12) + { + /* Second plane is quarter size, but 2bytes per pixel */ + ulSize += ((ui32ByteStride >> 1) * (ui32Height >> 1) << 1); + } + else if(psDevInfo->sBufferInfo.pixelformat == PVRSRV_PIXEL_FORMAT_YV12) + { + /* Second plane is quarter size, but 1byte per pixel */ + ulSize += (ui32ByteStride >> 1) * (ui32Height >> 1); + + /* third plane is quarter size, but 1byte per pixel */ + ulSize += (ui32ByteStride >> 1) * (ui32Height >> 1); + } + +#if defined(BC_DISCONTIG_BUFFERS) + if (BCAllocDiscontigMemory(ulSize, + &psDevInfo->psSystemBuffer[i].hMemHandle, + &psDevInfo->psSystemBuffer[i].sCPUVAddr, + &psDevInfo->psSystemBuffer[i].psSysAddr) != BCE_OK) + { + break; + } +#else + /* Setup system buffer */ + if (BCAllocContigMemory(ulSize, + &psDevInfo->psSystemBuffer[i].hMemHandle, + &psDevInfo->psSystemBuffer[i].sCPUVAddr, + &sSystemBufferCPUPAddr) != BCE_OK) + { + break; + } + psDevInfo->psSystemBuffer[i].sSysAddr = CpuPAddrToSysPAddrBC(sSystemBufferCPUPAddr); + psDevInfo->psSystemBuffer[i].sPageAlignSysAddr.uiAddr = (psDevInfo->psSystemBuffer[i].sSysAddr.uiAddr & 0xFFFFF000); +#endif + + psDevInfo->ulNumBuffers++; + + psDevInfo->psSystemBuffer[i].ulSize = ulSize; + psDevInfo->psSystemBuffer[i].psSyncData = NULL; + } + + psDevInfo->sBufferInfo.ui32BufferCount = (IMG_UINT32)psDevInfo->ulNumBuffers; + + /* + Bsetup the BC Jtable so SRVKM can call into this driver + */ + psDevInfo->sBCJTable.ui32TableSize = sizeof(PVRSRV_BC_SRV2BUFFER_KMJTABLE); + psDevInfo->sBCJTable.pfnOpenBCDevice = OpenBCDevice; + psDevInfo->sBCJTable.pfnCloseBCDevice = CloseBCDevice; + psDevInfo->sBCJTable.pfnGetBCBuffer = GetBCBuffer; + psDevInfo->sBCJTable.pfnGetBCInfo = GetBCInfo; + psDevInfo->sBCJTable.pfnGetBufferAddr = GetBCBufferAddr; + + + + /* Update buffer's parameters for reconfiguration next time */ + if (ui32Width < ui32MaxWidth) + { + switch(pixelformat) + { + case PVRSRV_PIXEL_FORMAT_NV12: + case PVRSRV_PIXEL_FORMAT_YV12: + { + ui32Width += 320; + ui32Height += 160; + ui32ByteStride = ui32Width; + break; + } + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_VYUY: + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_UYVY: + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YUYV: + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YVYU: + { + ui32Width += 320; + ui32Height += 160; + ui32ByteStride = ui32Width*2; + break; + } + case PVRSRV_PIXEL_FORMAT_RGB565: + { + ui32Width += 320; + ui32Height += 160; + ui32ByteStride = ui32Width*2; + break; + } + default: + { + return (BCE_ERROR_INVALID_PARAMS); + } + } + } + else + { + ui32Width = BC_EXAMPLE_WIDTH; + ui32Height = BC_EXAMPLE_HEIGHT; + ui32ByteStride = BC_EXAMPLE_STRIDE; + } + + /* return success */ + return (BCE_OK); +} + + +/* + * Destroy shared buffers. + */ +BCE_ERROR BC_Example_Buffers_Destroy(void) +{ + BC_EXAMPLE_DEVINFO *psDevInfo; + unsigned long i; + + psDevInfo = GetAnchorPtr(); + + /* check DevInfo has been setup */ + if (psDevInfo == NULL) + { + /* + This device was not correctly registered/created. + */ + return (BCE_ERROR_DEVICE_REGISTER_FAILED); + } + + /* + Free all allocated surfaces + */ + for(i = 0; i < psDevInfo->ulNumBuffers; i++) + { +#if defined(BC_DISCONTIG_BUFFERS) + BCFreeDiscontigMemory(psDevInfo->psSystemBuffer[i].ulSize, + psDevInfo->psSystemBuffer[i].hMemHandle, + psDevInfo->psSystemBuffer[i].sCPUVAddr, + psDevInfo->psSystemBuffer[i].psSysAddr); +#else + BCFreeContigMemory(psDevInfo->psSystemBuffer[i].ulSize, + psDevInfo->psSystemBuffer[i].hMemHandle, + psDevInfo->psSystemBuffer[i].sCPUVAddr, + SysPAddrToCpuPAddrBC(psDevInfo->psSystemBuffer[i].sSysAddr)); +#endif + } + psDevInfo->ulNumBuffers = 0; + + /* Reset buffer info */ + psDevInfo->sBufferInfo.pixelformat = PVRSRV_PIXEL_FORMAT_UNKNOWN; + psDevInfo->sBufferInfo.ui32Width = 0; + psDevInfo->sBufferInfo.ui32Height = 0; + psDevInfo->sBufferInfo.ui32ByteStride = 0; + psDevInfo->sBufferInfo.ui32BufferDeviceID = BC_EXAMPLE_DEVICEID; + psDevInfo->sBufferInfo.ui32Flags = 0; + psDevInfo->sBufferInfo.ui32BufferCount = (IMG_UINT32)psDevInfo->ulNumBuffers; + + /* return success */ + return (BCE_OK); +} + + +/* + * This function does both registration and buffer allocation at + * boot time. + */ +BCE_ERROR BC_Example_Init(void) +{ + BCE_ERROR eError; + + eError = BC_Example_Register(); + if (eError != BCE_OK) + { + return eError; + } + + eError = BC_Example_Buffers_Create(); + if (eError != BCE_OK) + { + return eError; + } + + return (BCE_OK); +} + +/* + * Destroy buffers and unregister device. + */ +BCE_ERROR BC_Example_Deinit(void) +{ + BCE_ERROR eError; + + eError = BC_Example_Buffers_Destroy(); + if (eError != BCE_OK) + { + return eError; + } + + eError = BC_Example_Unregister(); + if (eError != BCE_OK) + { + return eError; + } + + return (BCE_OK); +} + +/****************************************************************************** + End of file (bufferclass_example.c) +******************************************************************************/ diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example.h b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example.h new file mode 100755 index 00000000000..4cdeb393948 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example.h @@ -0,0 +1,238 @@ +/*************************************************************************/ /*! +@Title bufferclass_example kernel driver structures and prototypes +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ +#ifndef __BC_EXAMPLE_H__ +#define __BC_EXAMPLE_H__ + +/* IMG services headers */ +#include "img_defs.h" +#include "servicesext.h" +#include "kernelbuffer.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#define BC_EXAMPLE_NUM_BUFFERS 3 + +#define NV12 1 +//#define YV12 1 +//#define YUV422 1 + +#ifdef NV12 + +#define BC_EXAMPLE_WIDTH (320) +#define BC_EXAMPLE_HEIGHT (160) +#define BC_EXAMPLE_STRIDE (320) +#define BC_EXAMPLE_PIXELFORMAT (PVRSRV_PIXEL_FORMAT_NV12) + +#else +#ifdef YV12 + +#define BC_EXAMPLE_WIDTH (320) +#define BC_EXAMPLE_HEIGHT (160) +#define BC_EXAMPLE_STRIDE (320) +#define BC_EXAMPLE_PIXELFORMAT (PVRSRV_PIXEL_FORMAT_YV12) + +#else +#ifdef YUV422 + +#define BC_EXAMPLE_WIDTH (320) +#define BC_EXAMPLE_HEIGHT (160) +#define BC_EXAMPLE_STRIDE (320*2) +#define BC_EXAMPLE_PIXELFORMAT (PVRSRV_PIXEL_FORMAT_FOURCC_ORG_UYVY) + +#else + +#define BC_EXAMPLE_WIDTH (320) +#define BC_EXAMPLE_HEIGHT (160) +#define BC_EXAMPLE_STRIDE (320*2) +#define BC_EXAMPLE_PIXELFORMAT (PVRSRV_PIXEL_FORMAT_RGB565) + +#endif +#endif +#endif + +#define BC_EXAMPLE_DEVICEID 0 + +typedef void * BCE_HANDLE; + +typedef enum tag_bce_bool +{ + BCE_FALSE = 0, + BCE_TRUE = 1, +} BCE_BOOL, *BCE_PBOOL; + +/* BC_NOHW buffer structure */ +typedef struct BC_EXAMPLE_BUFFER_TAG +{ + unsigned long ulSize; + BCE_HANDLE hMemHandle; + + /* IMG structures used, to minimise API function code */ + /* replace with own structures where necessary */ +#if defined(BC_DISCONTIG_BUFFERS) + IMG_SYS_PHYADDR *psSysAddr; +#else + IMG_SYS_PHYADDR sSysAddr; + IMG_SYS_PHYADDR sPageAlignSysAddr; +#endif + IMG_CPU_VIRTADDR sCPUVAddr; + PVRSRV_SYNC_DATA *psSyncData; + + struct BC_EXAMPLE_BUFFER_TAG *psNext; +} BC_EXAMPLE_BUFFER; + + +/* kernel device information structure */ +typedef struct BC_EXAMPLE_DEVINFO_TAG +{ + unsigned long ulDeviceID; + + BC_EXAMPLE_BUFFER *psSystemBuffer; + + /* number of supported buffers */ + unsigned long ulNumBuffers; + + /* jump table into PVR services */ + PVRSRV_BC_BUFFER2SRV_KMJTABLE sPVRJTable; + + /* jump table into BC */ + PVRSRV_BC_SRV2BUFFER_KMJTABLE sBCJTable; + + /* + handle for connection to kernel services + - OS specific - may not be required + */ + BCE_HANDLE hPVRServices; + + /* ref count */ + unsigned long ulRefCount; + + /* IMG structures used, to minimise API function code */ + /* replace with own structures where necessary */ + BUFFER_INFO sBufferInfo; + +} BC_EXAMPLE_DEVINFO; + + +/*! + ***************************************************************************** + * Error values + *****************************************************************************/ +typedef enum _BCE_ERROR_ +{ + BCE_OK = 0, + BCE_ERROR_GENERIC = 1, + BCE_ERROR_OUT_OF_MEMORY = 2, + BCE_ERROR_TOO_FEW_BUFFERS = 3, + BCE_ERROR_INVALID_PARAMS = 4, + BCE_ERROR_INIT_FAILURE = 5, + BCE_ERROR_CANT_REGISTER_CALLBACK = 6, + BCE_ERROR_INVALID_DEVICE = 7, + BCE_ERROR_DEVICE_REGISTER_FAILED = 8, + BCE_ERROR_NO_PRIMARY = 9 +} BCE_ERROR; + + +#ifndef UNREFERENCED_PARAMETER +#define UNREFERENCED_PARAMETER(param) (param) = (param) +#endif + +#ifndef NULL +#define NULL 0 +#endif + +BCE_ERROR BC_Example_Register(void); +BCE_ERROR BC_Example_Unregister(void); +BCE_ERROR BC_Example_Buffers_Create(void); +BCE_ERROR BC_Example_Buffers_Destroy(void); +BCE_ERROR BC_Example_Init(void); +BCE_ERROR BC_Example_Deinit(void); + +/* OS Specific APIs */ +BCE_ERROR BCOpenPVRServices(BCE_HANDLE *phPVRServices); +BCE_ERROR BCClosePVRServices(BCE_HANDLE hPVRServices); + +void *BCAllocKernelMem(unsigned long ulSize); +void BCFreeKernelMem(void *pvMem); +#if defined(BC_DISCONTIG_BUFFERS) +BCE_ERROR BCAllocDiscontigMemory(unsigned long ulSize, + BCE_HANDLE unref__ *phMemHandle, + IMG_CPU_VIRTADDR *pLinAddr, + IMG_SYS_PHYADDR **ppPhysAddr); + +void BCFreeDiscontigMemory(unsigned long ulSize, + BCE_HANDLE unref__ hMemHandle, + IMG_CPU_VIRTADDR LinAddr, + IMG_SYS_PHYADDR *pPhysAddr); + +#else + +BCE_ERROR BCAllocContigMemory(unsigned long ulSize, + BCE_HANDLE *phMemHandle, + IMG_CPU_VIRTADDR *pLinAddr, + IMG_CPU_PHYADDR *pPhysAddr); + +void BCFreeContigMemory(unsigned long ulSize, + BCE_HANDLE hMemHandle, + IMG_CPU_VIRTADDR LinAddr, + IMG_CPU_PHYADDR PhysAddr); +#endif + +IMG_SYS_PHYADDR CpuPAddrToSysPAddrBC(IMG_CPU_PHYADDR cpu_paddr); +IMG_CPU_PHYADDR SysPAddrToCpuPAddrBC(IMG_SYS_PHYADDR sys_paddr); + +void *MapPhysAddr(IMG_SYS_PHYADDR sSysAddr, unsigned long ulSize); +void UnMapPhysAddr(void *pvAddr, unsigned long ulSize); + +BCE_ERROR BCGetLibFuncAddr (BCE_HANDLE hExtDrv, char *szFunctionName, PFN_BC_GET_PVRJTABLE *ppfnFuncTable); +BC_EXAMPLE_DEVINFO * GetAnchorPtr(void); + +#if defined(__cplusplus) +} +#endif + +#endif /* __BC_EXAMPLE_H__ */ + +/****************************************************************************** + End of file (bufferclass_example.h) +******************************************************************************/ + diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_linux.c b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_linux.c new file mode 100755 index 00000000000..fdb8ce3675c --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_linux.c @@ -0,0 +1,610 @@ +/*************************************************************************/ /*! +@Title bufferclass example linux specific implementations +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +/************************************************************************** + The 3rd party driver is a specification of an API to integrate the IMG POWERVR + Services driver with 3rd Party display hardware. It is NOT a specification for + a display controller driver, rather a specification to extend the API for a + pre-existing driver for the display hardware. + + The 3rd party driver interface provides IMG POWERVR client drivers (e.g. PVR2D) + with an API abstraction of the system's underlying display hardware, allowing + the client drivers to indirectly control the display hardware and access its + associated memory. + + Functions of the API include + - query primary surface attributes (width, height, stride, pixel format, CPU + physical and virtual address) + - swap/flip chain creation and subsequent query of surface attributes + - asynchronous display surface flipping, taking account of asynchronous read + (flip) and write (render) operations to the display surface + + Note: having queried surface attributes the client drivers are able to map the + display memory to any IMG POWERVR Services device by calling + PVRSRVMapDeviceClassMemory with the display surface handle. + + This code is intended to be an example of how a pre-existing display driver may + be extended to support the 3rd Party Display interface to POWERVR Services + - IMG is not providing a display driver implementation. + **************************************************************************/ + +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/fs.h> +#include <asm/uaccess.h> +#include <asm/io.h> + +#if defined(LMA) +#include <linux/pci.h> +#else +#include <linux/dma-mapping.h> +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#include <linux/mutex.h> +#endif + +#if defined(BC_DISCONTIG_BUFFERS) +#include <linux/vmalloc.h> +#endif + +#include "bufferclass_example.h" +#include "bufferclass_example_linux.h" +#include "bufferclass_example_private.h" + +#include "pvrmodule.h" + +#define DEVNAME "bc_example" +#define DRVNAME DEVNAME + +#if defined(BCE_USE_SET_MEMORY) +#undef BCE_USE_SET_MEMORY +#endif + +#if (defined(__i386__) || defined(__x86_64__)) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) && defined(SUPPORT_LINUX_X86_PAT) && defined(SUPPORT_LINUX_X86_WRITECOMBINE) +#include <asm/cacheflush.h> +#define BCE_USE_SET_MEMORY +#endif + +MODULE_SUPPORTED_DEVICE(DEVNAME); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +static long BC_Example_Bridge_Unlocked(struct file *file, unsigned int cmd, unsigned long arg); +#else +static int BC_Example_Bridge(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +static DEFINE_MUTEX(sBCExampleBridgeMutex); +#endif + +#if defined(LDM_PLATFORM) || defined(LDM_PCI) +/* + * Device class used for /sys entries (and udev device node creation) + */ +static struct class *psPvrClass; +#endif + +/* + * This is the major number we use for all nodes in /dev. + */ +static int AssignedMajorNumber; + +static struct file_operations bufferclass_example_fops = { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) + .unlocked_ioctl = BC_Example_Bridge_Unlocked +#else + .ioctl = BC_Example_Bridge +#endif +}; + + +#define unref__ __attribute__ ((unused)) + +#if defined(LMA) +#define PVR_BUFFERCLASS_MEMOFFSET (220 * 1024 * 1024) /* Must be after services localmem region */ +#define PVR_BUFFERCLASS_MEMSIZE (4 * 1024 * 1024) /* Must be before displayclass localmem region */ + +unsigned long g_ulMemBase = 0; +unsigned long g_ulMemCurrent = 0; + +/* PVR device vendor ID */ +#define VENDOR_ID_PVR 0x1010 +#define DEVICE_ID_PVR 0x1CF1 + +#define DEVICE_ID1_PVR 0x1CF2 + + +/* PDP mem (including HP mapping) on base register 2 */ +#define PVR_MEM_PCI_BASENUM 2 +#endif + + +/***************************************************************************** + Function Name: BC_Example_ModInit + Description : Insert the driver into the kernel. + + The device major number is allocated by the kernel dynamically + if AssignedMajorNumber is zero on entry. This means that the + device node (nominally /dev/bc_example) may need to be re-made if + the kernel varies the major number it assigns. The number + does seem to stay constant between runs, but I don't think + this is guaranteed. The node is made as root on the shell + with: + + mknod /dev/bc_example c ? 0 + + where ? is the major number reported by the printk() - look + at the boot log using `dmesg' to see this). + + __init places the function in a special memory section that + the kernel frees once the function has been run. Refer also + to module_init() macro call below. + +*****************************************************************************/ +static int __init BC_Example_ModInit(void) +{ +#if defined(LDM_PLATFORM) || defined(LDM_PCI) + struct device *psDev; +#endif + +#if defined(LMA) + struct pci_dev *psPCIDev; + int error; +#endif + +#if defined(LMA) + psPCIDev = pci_get_device(VENDOR_ID_PVR, DEVICE_ID_PVR, NULL); + if (psPCIDev == NULL) + { + /* Try an alternative PCI ID */ + psPCIDev = pci_get_device(VENDOR_ID_PVR, DEVICE_ID1_PVR, NULL); + } + + if (psPCIDev == NULL) + { + printk(KERN_ERR DRVNAME ": BC_Example_ModInit: pci_get_device failed\n"); + + goto ExitError; + } + + if ((error = pci_enable_device(psPCIDev)) != 0) + { + printk(KERN_ERR DRVNAME ": BC_Example_ModInit: pci_enable_device failed (%d)\n", error); + goto ExitError; + } +#endif + + AssignedMajorNumber = register_chrdev(0, DEVNAME, &bufferclass_example_fops); + + if (AssignedMajorNumber <= 0) + { + printk(KERN_ERR DRVNAME ": BC_Example_ModInit: unable to get major number\n"); + + goto ExitDisable; + } + +#if defined(DEBUG) + printk(KERN_ERR DRVNAME ": BC_Example_ModInit: major device %d\n", AssignedMajorNumber); +#endif + +#if defined(LDM_PLATFORM) || defined(LDM_PCI) + /* + * This code (using GPL symbols) facilitates automatic device + * node creation on platforms with udev (or similar). + */ + psPvrClass = class_create(THIS_MODULE, "bc_example"); + + if (IS_ERR(psPvrClass)) + { + printk(KERN_ERR DRVNAME ": BC_Example_ModInit: unable to create class (%ld)", PTR_ERR(psPvrClass)); + goto ExitUnregister; + } + + psDev = device_create(psPvrClass, NULL, MKDEV(AssignedMajorNumber, 0), +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) + NULL, +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */ + DEVNAME); + if (IS_ERR(psDev)) + { + printk(KERN_ERR DRVNAME ": BC_Example_ModInit: unable to create device (%ld)", PTR_ERR(psDev)); + goto ExitDestroyClass; + } +#endif /* defined(LDM_PLATFORM) || defined(LDM_PCI) */ + +#if defined(LMA) + /* + * We don't do a pci_request_region for PVR_MEM_PCI_BASENUM, + * we assume the SGX driver has done this already. + */ + g_ulMemBase = pci_resource_start(psPCIDev, PVR_MEM_PCI_BASENUM) + PVR_BUFFERCLASS_MEMOFFSET; +#endif + + if(BC_Example_Init() != BCE_OK) + { + printk (KERN_ERR DRVNAME ": BC_Example_ModInit: can't init device\n"); + goto ExitUnregister; + } + +#if defined(LMA) + /* + * To prevent possible problems with system suspend/resume, we don't + * keep the device enabled, but rely on the fact that the SGX driver + * will have done a pci_enable_device. + */ + pci_disable_device(psPCIDev); +#endif + + return 0; + +#if defined(LDM_PLATFORM) || defined(LDM_PCI) +ExitDestroyClass: + class_destroy(psPvrClass); +#endif +ExitUnregister: + unregister_chrdev(AssignedMajorNumber, DEVNAME); +ExitDisable: +#if defined(LMA) + pci_disable_device(psPCIDev); +ExitError: +#endif + return -EBUSY; +} /*BC_Example_ModInit*/ + +/***************************************************************************** + Function Name: BC_Example_ModInit + Description : Remove the driver from the kernel. + + __exit places the function in a special memory section that + the kernel frees once the function has been run. Refer also + to module_exit() macro call below. + +*****************************************************************************/ +static void __exit BC_Example_ModCleanup(void) +{ +#if defined(LDM_PLATFORM) || defined(LDM_PCI) + device_destroy(psPvrClass, MKDEV(AssignedMajorNumber, 0)); + class_destroy(psPvrClass); +#endif + + unregister_chrdev(AssignedMajorNumber, DEVNAME); + + if(BC_Example_Deinit() != BCE_OK) + { + printk (KERN_ERR DRVNAME ": BC_Example_ModCleanup: can't deinit device\n"); + } + +} /*BC_Example_ModCleanup*/ + + +void *BCAllocKernelMem(unsigned long ulSize) +{ + return kmalloc(ulSize, GFP_KERNEL); +} + +void BCFreeKernelMem(void *pvMem) +{ + kfree(pvMem); +} + +#if defined(BC_DISCONTIG_BUFFERS) + +#define RANGE_TO_PAGES(range) (((range) + (PAGE_SIZE - 1)) >> PAGE_SHIFT) +#define VMALLOC_TO_PAGE_PHYS(vAddr) page_to_phys(vmalloc_to_page(vAddr)) + +BCE_ERROR BCAllocDiscontigMemory(unsigned long ulSize, + BCE_HANDLE unref__ *phMemHandle, + IMG_CPU_VIRTADDR *pLinAddr, + IMG_SYS_PHYADDR **ppPhysAddr) +{ + unsigned long ulPages = RANGE_TO_PAGES(ulSize); + IMG_SYS_PHYADDR *pPhysAddr; + unsigned long ulPage; + IMG_CPU_VIRTADDR LinAddr; + + LinAddr = __vmalloc(ulSize, GFP_KERNEL | __GFP_HIGHMEM, pgprot_noncached(PAGE_KERNEL)); + if (!LinAddr) + { + return BCE_ERROR_OUT_OF_MEMORY; + } + + pPhysAddr = kmalloc(ulPages * sizeof(IMG_SYS_PHYADDR), GFP_KERNEL); + if (!pPhysAddr) + { + vfree(LinAddr); + return BCE_ERROR_OUT_OF_MEMORY; + } + + *pLinAddr = LinAddr; + + for (ulPage = 0; ulPage < ulPages; ulPage++) + { + pPhysAddr[ulPage].uiAddr = VMALLOC_TO_PAGE_PHYS(LinAddr); + + LinAddr += PAGE_SIZE; + } + + *ppPhysAddr = pPhysAddr; + + return BCE_OK; +} + +void BCFreeDiscontigMemory(unsigned long ulSize, + BCE_HANDLE unref__ hMemHandle, + IMG_CPU_VIRTADDR LinAddr, + IMG_SYS_PHYADDR *pPhysAddr) +{ + kfree(pPhysAddr); + + vfree(LinAddr); +} +#else /* defined(BC_DISCONTIG_BUFFERS) */ + +BCE_ERROR BCAllocContigMemory(unsigned long ulSize, + BCE_HANDLE unref__ *phMemHandle, + IMG_CPU_VIRTADDR *pLinAddr, + IMG_CPU_PHYADDR *pPhysAddr) +{ +#if defined(LMA) + void *pvLinAddr; + + /* Only allowed a certain amount of memory for bufferclass buffers */ + if(g_ulMemCurrent + ulSize >= PVR_BUFFERCLASS_MEMSIZE) + { + return (BCE_ERROR_OUT_OF_MEMORY); + } + + pvLinAddr = ioremap(g_ulMemBase + g_ulMemCurrent, ulSize); + + if(pvLinAddr) + { + pPhysAddr->uiAddr = g_ulMemBase + g_ulMemCurrent; + *pLinAddr = pvLinAddr; + + /* Not a real allocator; just increment the current address */ + g_ulMemCurrent += ulSize; + return (BCE_OK); + } + return (BCE_ERROR_OUT_OF_MEMORY); +#else /* defined(LMA) */ +#if defined(BCE_USE_SET_MEMORY) + void *pvLinAddr; + unsigned long ulAlignedSize = PAGE_ALIGN(ulSize); + int iPages = (int)(ulAlignedSize >> PAGE_SHIFT); + int iError; + + pvLinAddr = kmalloc(ulAlignedSize, GFP_KERNEL); + BUG_ON(((unsigned long)pvLinAddr) & ~PAGE_MASK); + + iError = set_memory_wc((unsigned long)pvLinAddr, iPages); + if (iError != 0) + { + printk(KERN_ERR DRVNAME ": BCAllocContigMemory: set_memory_wc failed (%d)\n", iError); + return (BCE_ERROR_OUT_OF_MEMORY); + } + + pPhysAddr->uiAddr = virt_to_phys(pvLinAddr); + *pLinAddr = pvLinAddr; + + return (BCE_OK); +#else /* BCE_USE_SET_MEMORY */ + dma_addr_t dma; + void *pvLinAddr; + + pvLinAddr = dma_alloc_coherent(NULL, ulSize, &dma, GFP_KERNEL); + if (pvLinAddr == NULL) + { + return (BCE_ERROR_OUT_OF_MEMORY); + } + + pPhysAddr->uiAddr = dma; + *pLinAddr = pvLinAddr; + + return (BCE_OK); +#endif /* BCE_USE_SET_MEMORY */ +#endif /* defined(LMA) */ +} + +void BCFreeContigMemory(unsigned long ulSize, + BCE_HANDLE unref__ hMemHandle, + IMG_CPU_VIRTADDR LinAddr, + IMG_CPU_PHYADDR PhysAddr) +{ +#if defined(LMA) + g_ulMemCurrent -= ulSize; + iounmap(LinAddr); +#else /* defined(LMA) */ +#if defined(BCE_USE_SET_MEMORY) + unsigned long ulAlignedSize = PAGE_ALIGN(ulSize); + int iError; + int iPages = (int)(ulAlignedSize >> PAGE_SHIFT); + + iError = set_memory_wb((unsigned long)LinAddr, iPages); + if (iError != 0) + { + printk(KERN_ERR DRVNAME ": BCFreeContigMemory: set_memory_wb failed (%d)\n", iError); + } + kfree(LinAddr); +#else /* BCE_USE_SET_MEMORY */ + dma_free_coherent(NULL, ulSize, LinAddr, (dma_addr_t)PhysAddr.uiAddr); +#endif /* BCE_USE_SET_MEMORY */ +#endif /* defined(LMA) */ +} +#endif /* defined(BC_DISCONTIG_BUFFERS) */ + +/************************************************************************** + FUNCTION: CpuPAddrToSysPAddrBC + PURPOSE: Compute a system physical address from a cpu physical + address. + PARAMETERS: In: cpu_paddr - cpu physical address. + RETURNS: system physical address. + **************************************************************************/ +IMG_SYS_PHYADDR CpuPAddrToSysPAddrBC(IMG_CPU_PHYADDR cpu_paddr) +{ + IMG_SYS_PHYADDR sys_paddr; + + /* This would only be an inequality if the CPU's MMU did not point to sys address 0, + ie. multi CPU system */ + sys_paddr.uiAddr = cpu_paddr.uiAddr; + return sys_paddr; +} + +/************************************************************************** + FUNCTION: SysPAddrToCpuPAddrBC + PURPOSE: Compute a cpu physical address + from a system physical address. + PARAMETERS: In: cpu_paddr - system physical address. + RETURNS: cpu physical address. + **************************************************************************/ +IMG_CPU_PHYADDR SysPAddrToCpuPAddrBC(IMG_SYS_PHYADDR sys_paddr) +{ + + IMG_CPU_PHYADDR cpu_paddr; + /* This would only be an inequality if the CPU's MMU did not point to sys address 0, + ie. multi CPU system */ + cpu_paddr.uiAddr = sys_paddr.uiAddr; + return cpu_paddr; +} + +BCE_ERROR BCOpenPVRServices (BCE_HANDLE *phPVRServices) +{ + /* Nothing to do - we have already checked services module insertion */ + *phPVRServices = 0; + return (BCE_OK); +} + + +BCE_ERROR BCClosePVRServices (BCE_HANDLE unref__ hPVRServices) +{ + /* Nothing to do */ + return (BCE_OK); +} + +BCE_ERROR BCGetLibFuncAddr (BCE_HANDLE unref__ hExtDrv, char *szFunctionName, PFN_BC_GET_PVRJTABLE *ppfnFuncTable) +{ + if(strcmp("PVRGetBufferClassJTable", szFunctionName) != 0) + { + return (BCE_ERROR_INVALID_PARAMS); + } + + /* Nothing to do - should be exported from pvrsrv.ko */ + *ppfnFuncTable = PVRGetBufferClassJTable; + + return (BCE_OK); +} + + +static int BC_Example_Bridge(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ + int err = -EFAULT; + int command = _IOC_NR(cmd); + BC_Example_ioctl_package sBridge; + + PVR_UNREFERENCED_PARAMETER(inode); + + if (copy_from_user(&sBridge, (void *)arg, sizeof(sBridge)) != 0) + { + return err; + } + + switch(command) + { + case _IOC_NR(BC_Example_ioctl_fill_buffer): + { + if(FillBuffer(sBridge.inputparam) == -1) + { + return err; + } + break; + } + case _IOC_NR(BC_Example_ioctl_get_buffer_count): + { + if(GetBufferCount(&sBridge.outputparam) == -1) + { + return err; + } + break; + } + case _IOC_NR(BC_Example_ioctl_reconfigure_buffer): + { + if(ReconfigureBuffer(&sBridge.outputparam) == -1) + { + return err; + } + break; + } + default: + return err; + } + + if (copy_to_user((void *)arg, &sBridge, sizeof(sBridge)) != 0) + { + return err; + } + + return 0; +} + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +static long BC_Example_Bridge_Unlocked(struct file *file, unsigned int cmd, unsigned long arg) +{ + int res; + + mutex_lock(&sBCExampleBridgeMutex); + res = BC_Example_Bridge(NULL, file, cmd, arg); + mutex_unlock(&sBCExampleBridgeMutex); + + return res; +} +#endif + +/* + These macro calls define the initialisation and removal functions of the + driver. Although they are prefixed `module_', they apply when compiling + statically as well; in both cases they define the function the kernel will + run to start/stop the driver. +*/ +module_init(BC_Example_ModInit); +module_exit(BC_Example_ModCleanup); + diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_linux.h b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_linux.h new file mode 100755 index 00000000000..65d786035f3 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_linux.h @@ -0,0 +1,67 @@ +/*************************************************************************/ /*! +@Title bufferclass_example kernel driver interface +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ +#ifndef __BC_EXAMPLE_LINUX_H__ +#define __BC_EXAMPLE_LINUX_H__ + +#include <linux/ioctl.h> + +typedef struct BC_Example_ioctl_package_TAG +{ + int inputparam; + int outputparam; + +}BC_Example_ioctl_package; + +/*!< Nov 2006: according to ioctl-number.txt 'g' wasn't in use. */ +#define BC_EXAMPLE_IOC_GID 'g' + +#define BC_EXAMPLE_IOWR(INDEX) _IOWR(BC_EXAMPLE_IOC_GID, INDEX, BC_Example_ioctl_package) + +#define BC_Example_ioctl_fill_buffer BC_EXAMPLE_IOWR(0) +#define BC_Example_ioctl_get_buffer_count BC_EXAMPLE_IOWR(1) +#define BC_Example_ioctl_reconfigure_buffer BC_EXAMPLE_IOWR(2) + +#endif /* __BC_EXAMPLE_H__ */ + +/****************************************************************************** + End of file (bufferclass_example.h) +******************************************************************************/ + diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_private.c b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_private.c new file mode 100755 index 00000000000..d9dbfde9ab2 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_private.c @@ -0,0 +1,432 @@ +/*************************************************************************/ /*! +@Title Bufferclass example private functions. +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +/************************************************************************** + The 3rd party driver is a specification of an API to integrate the IMG POWERVR + Services driver with 3rd Party display hardware. It is NOT a specification for + a display controller driver, rather a specification to extend the API for a + pre-existing driver for the display hardware. + + The 3rd party driver interface provides IMG POWERVR client drivers (e.g. PVR2D) + with an API abstraction of the system's underlying display hardware, allowing + the client drivers to indirectly control the display hardware and access its + associated memory. + + Functions of the API include + - query primary surface attributes (width, height, stride, pixel format, CPU + physical and virtual address) + - swap/flip chain creation and subsequent query of surface attributes + - asynchronous display surface flipping, taking account of asynchronous read + (flip) and write (render) operations to the display surface + + Note: having queried surface attributes the client drivers are able to map the + display memory to any IMG POWERVR Services device by calling + PVRSRVMapDeviceClassMemory with the display surface handle. + + This code is intended to be an example of how a pre-existing display driver may + be extended to support the 3rd Party Display interface to POWERVR Services + - IMG is not providing a display driver implementation. + **************************************************************************/ + +#include "bufferclass_example.h" +#include "bufferclass_example_private.h" + +#define MIN(a,b) ((a)<(b)?(a):(b)) + +static void FillNV12Image(void *pvDest, int width, int height, int bytestride) +{ + static int iPhase = 0; + int i, j; + unsigned char u,v,y; + unsigned char *pui8y = (unsigned char *)pvDest; + unsigned short *pui16uv; + unsigned int count = 0; + + for(j=0;j<height;j++) + { + pui8y = (unsigned char *)pvDest + j * bytestride; + count = 0; + + for(i=0;i<width;i++) + { + y = (((i+iPhase)>>6)%(2)==0)? 0x7f:0x00; + + pui8y[count++] = y; + } + } + + for(j=0;j<height;j+=2) + { + pui16uv = (unsigned short *)((unsigned char *)pvDest + height * bytestride + (j / 2) * bytestride); + count = 0; + + for(i=0;i<width;i+=2) + { + u = (j<(height/2))? ((i<(width/2))? 0xFF:0x33) : ((i<(width/2))? 0x33:0xAA); + v = (j<(height/2))? ((i<(width/2))? 0xAC:0x0) : ((i<(width/2))? 0x03:0xEE); + + /* Byte order is VU */ + pui16uv[count++] = (v << 8) | u; + + } + } + + iPhase++; +} + +static void FillYV12Image(void *pvDest, int width, int height, int bytestride) +{ + static int iPhase = 0; + int i, j; + unsigned char u,v,y; + unsigned char *pui8y = (unsigned char *)pvDest; + unsigned char *pui8u, *pui8v; + unsigned int count = 0; + int uvplanestride = bytestride / 2; + int uvplaneheight = height / 2; + + for(j=0;j<height;j++) + { + pui8y = (unsigned char *)pvDest + j * bytestride; + count = 0; + + for(i=0;i<width;i++) + { + y = (((i+iPhase)>>6)%(2)==0)? 0x7f:0x00; + + pui8y[count++] = y; + } + } + + for(j=0;j<height;j+=2) + { + pui8v = (unsigned char *)pvDest + (height * bytestride) + ((j / 2) * uvplanestride); + count = 0; + + for(i=0;i<width;i+=2) + { + v = (j<(height/2))? ((i<(width/2))? 0xAC:0x0) : ((i<(width/2))? 0x03:0xEE); + + pui8v[count++] = v; + } + } + + for(j=0;j<height;j+=2) + { + pui8u = (unsigned char *)pvDest + (height * bytestride) + (uvplaneheight * uvplanestride) + (j / 2) * uvplanestride; + count = 0; + + for(i=0;i<width;i+=2) + { + u = (j<(height/2))? ((i<(width/2))? 0xFF:0x33) : ((i<(width/2))? 0x33:0xAA); + + pui8u[count++] = u; + + } + } + + iPhase++; +} + +static void FillYUV422Image(void *pvDest, int width, int height, int bytestride, PVRSRV_PIXEL_FORMAT pixelformat) +{ + static int iPhase = 0; + int x, y; + unsigned char u,v,y0,y1; + unsigned long *pui32yuv = (unsigned long *)pvDest; + unsigned int count = 0; + + for(y=0;y<height;y++) + { + pui32yuv = (unsigned long *)((unsigned char *)pvDest + y * bytestride); + count = 0; + + for(x=0;x<width; x+=2) + { + u = (y<(height/2))? ((x<(width/2))? 0xFF:0x33) : ((x<(width/2))? 0x33:0xAA); + v = (y<(height/2))? ((x<(width/2))? 0xAA:0x0) : ((x<(width/2))? 0x03:0xEE); + + y0 = y1 = (((x+iPhase)>>6)%(2)==0)? 0x7f:0x00; + + switch(pixelformat) + { + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_VYUY: + pui32yuv[count++] = (y1 << 24) | (u << 16) | (y0 << 8) | v; + break; + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_UYVY: + pui32yuv[count++] = (y1 << 24) | (v << 16) | (y0 << 8) | u; + break; + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YUYV: + pui32yuv[count++] = (v << 24) | (y1 << 16) | (u << 8) | y0; + break; + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YVYU: + pui32yuv[count++] = (u << 24) | (y1 << 16) | (v << 8) | y0; + break; + + default: + break; + + } + + } + } + + iPhase++; +} + +static void FillRGB565Image(void *pvDest, int width, int height, int bytestride) +{ + int i, Count; + unsigned long *pui32Addr = (unsigned long *)pvDest; + unsigned short *pui16Addr = (unsigned short *)pvDest; + unsigned long Colour32; + unsigned short Colour16; + static unsigned char Colour8 = 0;//debug colour + + Colour16 = (Colour8>>3) | ((Colour8>>2)<<5) | ((Colour8>>3)<<11); + Colour32 = Colour16 | Colour16 << 16; + + Count = (height * bytestride)>>2; + + for(i=0; i<Count; i++) + { + pui32Addr[i] = Colour32; + } + + Count = height; + + pui16Addr = (unsigned short *)((unsigned char *)pvDest + (2 * Colour8)); + + for(i=0; i<Count; i++) + { + *pui16Addr = 0xF800U; + + pui16Addr = (unsigned short *)((unsigned char *)pui16Addr + bytestride); + } + Count = bytestride >> 2; + + pui32Addr = (unsigned long *)((unsigned char *)pvDest + (bytestride * (MIN(height - 1, 0xFF) - Colour8))); + + for(i=0; i<Count; i++) + { + pui32Addr[i] = 0x001F001FUL; + } + + /* advance the colour */ + Colour8 = (Colour8 + 1) % MIN(height - 1, 0xFFU); +} + + +/*! +****************************************************************************** + + @Function FillBuffer + + @Description + + Fills pixels into a buffer specified by index + + @Input ui32BufferIndex - buffer index + + @Return 0 - success, -1 - failure + +******************************************************************************/ +int FillBuffer(unsigned int uiBufferIndex) +{ + BC_EXAMPLE_DEVINFO *psDevInfo = GetAnchorPtr(); + BC_EXAMPLE_BUFFER *psBuffer; + BUFFER_INFO *psBufferInfo; + PVRSRV_SYNC_DATA *psSyncData; + + /* check DevInfo has been setup */ + if(psDevInfo == NULL) + { + return -1;/* failure */ + } + + psBuffer = &psDevInfo->psSystemBuffer[uiBufferIndex]; + psBufferInfo = &psDevInfo->sBufferInfo; + + /* This may be NULL, as it is only registered once texture streaming starts. */ + psSyncData = psBuffer->psSyncData; + + if(psSyncData) + { + /* ensure all reads have flushed on the buffer */ + if(psSyncData->ui32ReadOpsPending != psSyncData->ui32ReadOpsComplete) + { + return -1;/* failure */ + } + + /* take a write-lock on the new buffer to capture to */ + psSyncData->ui32WriteOpsPending++; + } + + switch(psBufferInfo->pixelformat) + { + case PVRSRV_PIXEL_FORMAT_RGB565: + default: + { + FillRGB565Image(psBuffer->sCPUVAddr, + psBufferInfo->ui32Width, + psBufferInfo->ui32Height, + psBufferInfo->ui32ByteStride); + break; + } + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_VYUY: + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_UYVY: + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YUYV: + case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YVYU: + { + FillYUV422Image(psBuffer->sCPUVAddr, + psBufferInfo->ui32Width, + psBufferInfo->ui32Height, + psBufferInfo->ui32ByteStride, + psBufferInfo->pixelformat); + break; + } + case PVRSRV_PIXEL_FORMAT_NV12: + { + FillNV12Image(psBuffer->sCPUVAddr, + psBufferInfo->ui32Width, + psBufferInfo->ui32Height, + psBufferInfo->ui32ByteStride); + break; + } + case PVRSRV_PIXEL_FORMAT_YV12: + { + FillYV12Image(psBuffer->sCPUVAddr, + psBufferInfo->ui32Width, + psBufferInfo->ui32Height, + psBufferInfo->ui32ByteStride); + break; + } + } + + /* unlock the buffer, signalling the writes are complete */ + if(psSyncData) + { + psSyncData->ui32WriteOpsComplete++; + + if (NULL != psDevInfo->sPVRJTable.pfnPVRSRVScheduleDevices) + { + (*psDevInfo->sPVRJTable.pfnPVRSRVScheduleDevices)(); + } + } + + return 0; +} + + +/*! +****************************************************************************** + + @Function GetBufferCount + + @Description + + returns buffer count + + @Output pulBufferCount - buffer count + + @Return 0 - success, -1 - failure + +******************************************************************************/ +int GetBufferCount(unsigned int *puiBufferCount) +{ + BC_EXAMPLE_DEVINFO *psDevInfo = GetAnchorPtr(); + + /* check DevInfo has been setup */ + if(psDevInfo == IMG_NULL) + { + return -1;/* failure */ + } + + /* return buffer count */ + *puiBufferCount = (unsigned int)psDevInfo->sBufferInfo.ui32BufferCount; + + return 0; +} + + + +/****************************************************************************** + + @Function ReconfigureBuffer + + @Description + + returns whether reconfiguration succeeds or not + + @Output uiSucceed : 1 - succeeded, 0 - failed + + @Return 0 - success, -1 - failure + +******************************************************************************/ +int ReconfigureBuffer(unsigned int *uiSucceed) +{ + BCE_ERROR eError; + + /* Destroy the shared buffers of the current buffer class device */ + eError = BC_Example_Buffers_Destroy(); + + if (eError != BCE_OK) + { + *uiSucceed = 0; + return -1; + } + + /* No need to un-register and then re-register the device with services module srvkm */ + + + /* Recreate shared buffers with reconfigured parameters */ + eError = BC_Example_Buffers_Create(); + + if (eError != BCE_OK) + { + *uiSucceed = 0; + return -1; + } + + /* return uiSucceed as succeeded 1 */ + *uiSucceed = 1; + return 0; +} diff --git a/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_private.h b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_private.h new file mode 100755 index 00000000000..8d95e2b3386 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/bufferclass_example/bufferclass_example_private.h @@ -0,0 +1,49 @@ +/*************************************************************************/ /*! +@Title Bufferclass example internal interfaces. +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#ifndef _BUFFERCLASS_EXAMPLE_PRIVATE_H_ +#define _BUFFERCLASS_EXAMPLE_PRIVATE_H_ + +int FillBuffer(unsigned int uiBufferIndex); +int GetBufferCount(unsigned int *puiBufferCount); +int ReconfigureBuffer(unsigned int *uiSucceed); + +#endif /* _BUFFERCLASS_EXAMPLE_PRIVATE_H_ */ diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Kbuild.mk b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Kbuild.mk index 4bbcfd0f84a..4bbcfd0f84a 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Kbuild.mk +++ b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Kbuild.mk diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Linux.mk b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Linux.mk index 9bd3e0125ab..9bd3e0125ab 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Linux.mk +++ b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/Linux.mk diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw.h b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw.h index 403361f153b..403361f153b 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw.h +++ b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw.h diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c index d47a1712733..5a6f99f77fa 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c +++ b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c @@ -374,79 +374,90 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, { return (PVRSRV_ERROR_FLIP_CHAIN_EXISTS); } - - /* check the buffer count */ - if(ui32BufferCount > DC_NOHW_MAX_BACKBUFFERS) - { - return (PVRSRV_ERROR_TOOMANYBUFFERS); - } - - /* - verify the DST/SRC attributes - - SRC/DST must match the current display mode config - */ - if(psDstSurfAttrib->pixelformat != psDevInfo->sSysFormat.pixelformat - || psDstSurfAttrib->sDims.ui32ByteStride != psDevInfo->sSysDims.ui32ByteStride - || psDstSurfAttrib->sDims.ui32Width != psDevInfo->sSysDims.ui32Width - || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sSysDims.ui32Height) - { - /* DST doesn't match the current mode */ - return (PVRSRV_ERROR_INVALID_PARAMS); - } - - if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat - || psDstSurfAttrib->sDims.ui32ByteStride != psSrcSurfAttrib->sDims.ui32ByteStride - || psDstSurfAttrib->sDims.ui32Width != psSrcSurfAttrib->sDims.ui32Width - || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) - { - /* DST doesn't match the SRC */ - return (PVRSRV_ERROR_INVALID_PARAMS); - } - - /* INTEGRATION_POINT: check the flags */ - UNREFERENCED_PARAMETER(ui32Flags); - + /* create a swapchain structure */ psSwapChain = (DC_NOHW_SWAPCHAIN*)AllocKernelMem(sizeof(DC_NOHW_SWAPCHAIN)); if(!psSwapChain) { return (PVRSRV_ERROR_OUT_OF_MEMORY); } - - psBuffer = (DC_NOHW_BUFFER*)AllocKernelMem(sizeof(DC_NOHW_BUFFER) * ui32BufferCount); - if(!psBuffer) - { - FreeKernelMem(psSwapChain); - return (PVRSRV_ERROR_OUT_OF_MEMORY); - } - - /* initialise allocations */ + memset(psSwapChain, 0, sizeof(DC_NOHW_SWAPCHAIN)); - memset(psBuffer, 0, sizeof(DC_NOHW_BUFFER) * ui32BufferCount); - - psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; - psSwapChain->psBuffer = psBuffer; - /* link the buffers */ - for(i=0; i<ui32BufferCount-1; i++) + if (ui32BufferCount) { - psBuffer[i].psNext = &psBuffer[i+1]; - } - /* and link last to first */ - psBuffer[i].psNext = &psBuffer[0]; - - /* populate the buffers */ - for(i=0; i<ui32BufferCount; i++) - { - psBuffer[i].psSyncData = ppsSyncData[i]; + + /* check the buffer count */ + if(ui32BufferCount > DC_NOHW_MAX_BACKBUFFERS) + { + return (PVRSRV_ERROR_TOOMANYBUFFERS); + } + + /* + verify the DST/SRC attributes + - SRC/DST must match the current display mode config + */ + if(psDstSurfAttrib->pixelformat != psDevInfo->sSysFormat.pixelformat + || psDstSurfAttrib->sDims.ui32ByteStride != psDevInfo->sSysDims.ui32ByteStride + || psDstSurfAttrib->sDims.ui32Width != psDevInfo->sSysDims.ui32Width + || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sSysDims.ui32Height) + { + /* DST doesn't match the current mode */ + return (PVRSRV_ERROR_INVALID_PARAMS); + } + + if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat + || psDstSurfAttrib->sDims.ui32ByteStride != psSrcSurfAttrib->sDims.ui32ByteStride + || psDstSurfAttrib->sDims.ui32Width != psSrcSurfAttrib->sDims.ui32Width + || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) + { + /* DST doesn't match the SRC */ + return (PVRSRV_ERROR_INVALID_PARAMS); + } + + /* INTEGRATION_POINT: check the flags */ + UNREFERENCED_PARAMETER(ui32Flags); + + + + psBuffer = (DC_NOHW_BUFFER*)AllocKernelMem(sizeof(DC_NOHW_BUFFER) * ui32BufferCount); + if(!psBuffer) + { + FreeKernelMem(psSwapChain); + return (PVRSRV_ERROR_OUT_OF_MEMORY); + } + + /* initialise allocations */ + memset(psBuffer, 0, sizeof(DC_NOHW_BUFFER) * ui32BufferCount); + + psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; + psSwapChain->psBuffer = psBuffer; + + /* link the buffers */ + for(i=0; i<ui32BufferCount-1; i++) + { + psBuffer[i].psNext = &psBuffer[i+1]; + } + /* and link last to first */ + psBuffer[i].psNext = &psBuffer[0]; + + /* populate the buffers */ + for(i=0; i<ui32BufferCount; i++) + { + psBuffer[i].psSyncData = ppsSyncData[i]; #if defined(DC_NOHW_DISCONTIG_BUFFERS) - psBuffer[i].psSysAddr = psDevInfo->asBackBuffers[i].psSysAddr; + psBuffer[i].psSysAddr = psDevInfo->asBackBuffers[i].psSysAddr; #else - psBuffer[i].sSysAddr = psDevInfo->asBackBuffers[i].sSysAddr; + psBuffer[i].sSysAddr = psDevInfo->asBackBuffers[i].sSysAddr; #endif - psBuffer[i].sDevVAddr = psDevInfo->asBackBuffers[i].sDevVAddr; - psBuffer[i].sCPUVAddr = psDevInfo->asBackBuffers[i].sCPUVAddr; - psBuffer[i].hSwapChain = (DC_HANDLE)psSwapChain; + psBuffer[i].sDevVAddr = psDevInfo->asBackBuffers[i].sDevVAddr; + psBuffer[i].sCPUVAddr = psDevInfo->asBackBuffers[i].sCPUVAddr; + psBuffer[i].hSwapChain = (DC_HANDLE)psSwapChain; + } + } + else + { + psSwapChain->psBuffer = NULL; } /* mark swapchain's existence */ @@ -478,7 +489,10 @@ static PVRSRV_ERROR DestroyDCSwapChain(IMG_HANDLE hDevice, psSwapChain = (DC_NOHW_SWAPCHAIN*)hSwapChain; /* free resources */ - FreeKernelMem(psSwapChain->psBuffer); + if (psSwapChain->psBuffer) + { + FreeKernelMem(psSwapChain->psBuffer); + } FreeKernelMem(psSwapChain); /* mark swapchain as not existing */ @@ -598,8 +612,9 @@ static PVRSRV_ERROR SwapToDCBuffer(IMG_HANDLE hDevice, static DC_ERROR Flip(DC_NOHW_DEVINFO *psDevInfo, DC_NOHW_BUFFER *psBuffer) { + UNREFERENCED_PARAMETER(psBuffer); /* check parameters */ - if(!psDevInfo || !psBuffer) + if(!psDevInfo) { return (DC_ERROR_INVALID_PARAMS); } @@ -617,6 +632,8 @@ static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, DISPLAYCLASS_FLIP_COMMAND *psFlipCmd; DC_NOHW_DEVINFO *psDevInfo; DC_NOHW_BUFFER *psBuffer; + + UNREFERENCED_PARAMETER(ui32DataSize); /* check parameters */ if(!hCmdCookie) @@ -626,7 +643,9 @@ static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, /* validate data packet */ psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND*)pvData; - if (psFlipCmd == IMG_NULL || sizeof(DISPLAYCLASS_FLIP_COMMAND) != ui32DataSize) + /* Under android, this may be a DISPLAYCLASS_FLIP_COMMAND2, but the structs + * are compatable for everything used by dc_nohw so it makes no difference */ + if (psFlipCmd == IMG_NULL) { return (IMG_FALSE); } diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_linux.c b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_linux.c index 2f603eab569..2f603eab569 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_linux.c +++ b/drivers/gpu/pvr/services4/3rdparty/dc_nohw/dc_nohw_linux.c diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/3rdparty_dc_drm_shared.h b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/3rdparty_dc_drm_shared.h new file mode 100755 index 00000000000..dc327e37ea9 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/3rdparty_dc_drm_shared.h @@ -0,0 +1,66 @@ +/*************************************************************************/ /*! +@Title OMAP Linux display driver shared DRM structures +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@Description OMAP Linux display driver DRM structures shared between + kernel and user space. +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ +#ifndef __3RDPARTY_DC_DRM_SHARED_H__ +#define __3RDPARTY_DC_DRM_SHARED_H__ +#if defined(SUPPORT_DRI_DRM) + +typedef struct drm_pvr_display_cmd_tag +{ + uint32_t cmd; + uint32_t dev; +} drm_pvr_display_cmd; + +#define PVR_DRM_DISP_CMD_ENTER_VT 1 +#define PVR_DRM_DISP_CMD_LEAVE_VT 2 + +#define PVR_DRM_DISP_CMD_ON 3 +#define PVR_DRM_DISP_CMD_STANDBY 4 +#define PVR_DRM_DISP_CMD_SUSPEND 5 +#define PVR_DRM_DISP_CMD_OFF 6 + +#endif /* defined(SUPPORT_DRI_DRM) */ +#endif /* __3RDPARTY_DC_DRM_SHARED_H__ */ + +/****************************************************************************** + End of file (3rdparty_dc_drm_shared.h) +******************************************************************************/ diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Kbuild.mk b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Kbuild.mk index 7f4fd995561..d442f7903c8 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Kbuild.mk +++ b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Kbuild.mk @@ -40,8 +40,8 @@ ccflags-y += \ -I$(TOP)/services4/3rdparty/dc_omapfb3_linux \ - -I$(KERNELDIR)/drivers/video/omap2 \ - -I$(KERNELDIR)/arch/arm/plat-omap/include + -Idrivers/video/omap2 \ + -Iarch/arm/plat-omap/include omaplfb-y += \ services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.o \ diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Linux.mk b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Linux.mk index 75d11a9ff80..75d11a9ff80 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Linux.mk +++ b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/Linux.mk diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb.h b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb.h index 804695b1c76..5ef52156254 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb.h +++ b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb.h @@ -65,6 +65,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define OMAPLFB_CONSOLE_UNLOCK() release_console_sem() #endif +#if defined(CONFIG_ION_OMAP) +#include <linux/ion.h> +#include <linux/omap_ion.h> +#endif /* defined(CONFIG_ION_OMAP) */ + #define unref__ __attribute__ ((unused)) typedef void * OMAPLFB_HANDLE; @@ -226,6 +231,10 @@ typedef struct OMAPLFB_DEVINFO_TAG OMAPLFB_ATOMIC_BOOL sLeaveVT; #endif +#if defined(CONFIG_ION_OMAP) + struct ion_client *psIONClient; +#endif + } OMAPLFB_DEVINFO; #define OMAPLFB_PAGE_SIZE 4096 @@ -265,7 +274,8 @@ typedef enum _OMAPLFB_UPDATE_MODE_ OMAPLFB_UPDATE_MODE_UNDEFINED = 0, OMAPLFB_UPDATE_MODE_MANUAL = 1, OMAPLFB_UPDATE_MODE_AUTO = 2, - OMAPLFB_UPDATE_MODE_DISABLED = 3 + OMAPLFB_UPDATE_MODE_DISABLED = 3, + OMAPLFB_UPDATE_MODE_VSYNC = 4 } OMAPLFB_UPDATE_MODE; #ifndef UNREFERENCED_PARAMETER diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c index ebca8148c65..7af5703cd67 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c +++ b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c @@ -87,20 +87,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "omaplfb.h" #if defined(CONFIG_DSSCOMP) - -#if !defined(CONFIG_ION_OMAP) +#if defined(CONFIG_ION_OMAP) +extern struct ion_device *omap_ion_device; +#else /* defined(CONFIG_ION_OMAP) */ #error CONFIG_DSSCOMP support requires CONFIG_ION_OMAP +#endif /* defined(CONFIG_ION_OMAP) */ +#if defined(CONFIG_DRM_OMAP_DMM_TILER) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +#include <../drivers/gpu/drm/omapdrm/omap_dmm_tiler.h> +#else +#include <../drivers/staging/omapdrm/omap_dmm_tiler.h> #endif - -#include <linux/ion.h> -#include <linux/omap_ion.h> - -extern struct ion_client *gpsIONClient; - +#include <../drivers/video/omap2/dsscomp/tiler-utils.h> +#elif defined(CONFIG_TI_TILER) #include <mach/tiler.h> +#else /* defined(CONFIG_DRM_OMAP_DMM_TILER) */ +#error CONFIG_DSSCOMP support requires either \ + CONFIG_DRM_OMAP_DMM_TILER or CONFIG_TI_TILER +#endif /* defined(CONFIG_DRM_OMAP_DMM_TILER) */ #include <video/dsscomp.h> #include <plat/dsscomp.h> - #endif /* defined(CONFIG_DSSCOMP) */ #define OMAPLFB_COMMAND_COUNT 1 @@ -117,6 +123,7 @@ static OMAPLFB_DEVINFO *gapsDevInfo[OMAPLFB_MAX_NUM_DEVICES]; /* Top level 'hook ptr' */ static PFN_DC_GET_PVRJTABLE gpfnGetPVRJTable = NULL; +#if !defined(CONFIG_DSSCOMP) /* Round x up to a multiple of y */ static inline unsigned long RoundUpToMultiple(unsigned long x, unsigned long y) { @@ -146,6 +153,7 @@ static unsigned long LCM(unsigned long x, unsigned long y) return (gcd == 0) ? 0 : ((x / gcd) * y); } +#endif unsigned OMAPLFBMaxFBDevIDPlusOne(void) { @@ -210,14 +218,17 @@ static IMG_VOID SetDCState(IMG_HANDLE hDevice, IMG_UINT32 ui32State) switch (ui32State) { case DC_STATE_FLUSH_COMMANDS: + /* Flush out any 'real' operation waiting for another flip. + * In flush state we won't pass any 'real' operations along + * to dsscomp_gralloc_queue(); we'll just CmdComplete them + * immediately. + */ + OMAPLFBFlip(psDevInfo, &psDevInfo->sSystemBuffer); OMAPLFBAtomicBoolSet(&psDevInfo->sFlushCommands, OMAPLFB_TRUE); break; case DC_STATE_NO_FLUSH_COMMANDS: OMAPLFBAtomicBoolSet(&psDevInfo->sFlushCommands, OMAPLFB_FALSE); break; - case DC_STATE_FORCE_SWAP_TO_SYSTEM: - OMAPLFBFlip(psDevInfo, &psDevInfo->sSystemBuffer); - break; default: break; } @@ -233,9 +244,16 @@ static PVRSRV_ERROR OpenDCDevice(IMG_UINT32 uiPVRDevID, { OMAPLFB_DEVINFO *psDevInfo; OMAPLFB_ERROR eError; - unsigned uiMaxFBDevIDPlusOne = OMAPLFBMaxFBDevIDPlusOne(); + unsigned uiMaxFBDevIDPlusOne; unsigned i; + if (!try_module_get(THIS_MODULE)) + { + return PVRSRV_ERROR_UNABLE_TO_OPEN_DC_DEVICE; + } + + uiMaxFBDevIDPlusOne = OMAPLFBMaxFBDevIDPlusOne(); + for (i = 0; i < uiMaxFBDevIDPlusOne; i++) { psDevInfo = OMAPLFBGetDevInfoPtr(i); @@ -248,7 +266,8 @@ static PVRSRV_ERROR OpenDCDevice(IMG_UINT32 uiPVRDevID, { DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: PVR Device %u not found\n", __FUNCTION__, uiPVRDevID)); - return PVRSRV_ERROR_INVALID_DEVICE; + eError = PVRSRV_ERROR_INVALID_DEVICE; + goto ErrorModulePut; } /* store the system surface sync data */ @@ -259,13 +278,19 @@ static PVRSRV_ERROR OpenDCDevice(IMG_UINT32 uiPVRDevID, { DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: Device %u: OMAPLFBUnblankDisplay failed (%d)\n", __FUNCTION__, psDevInfo->uiFBDevID, eError)); - return PVRSRV_ERROR_UNBLANK_DISPLAY_FAILED; + eError = PVRSRV_ERROR_UNBLANK_DISPLAY_FAILED; + goto ErrorModulePut; } /* return handle to the devinfo */ *phDevice = (IMG_HANDLE)psDevInfo; return PVRSRV_OK; + +ErrorModulePut: + module_put(THIS_MODULE); + + return eError; } /* @@ -282,6 +307,8 @@ static PVRSRV_ERROR CloseDCDevice(IMG_HANDLE hDevice) #else UNREFERENCED_PARAMETER(hDevice); #endif + module_put(THIS_MODULE); + return PVRSRV_OK; } @@ -477,15 +504,14 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, IMG_HANDLE *phSwapChain, IMG_UINT32 *pui32SwapChainID) { - OMAPLFB_DEVINFO *psDevInfo; OMAPLFB_SWAPCHAIN *psSwapChain; - OMAPLFB_BUFFER *psBuffer; - IMG_UINT32 i; + OMAPLFB_DEVINFO *psDevInfo; PVRSRV_ERROR eError; - IMG_UINT32 ui32BuffersToSkip; + IMG_UINT32 i; UNREFERENCED_PARAMETER(ui32OEMFlags); - + UNREFERENCED_PARAMETER(ui32Flags); + /* Check parameters */ if(!hDevice || !psDstSurfAttrib @@ -512,60 +538,7 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, eError = PVRSRV_ERROR_FLIP_CHAIN_EXISTS; goto ExitUnLock; } - - /* Check the buffer count */ - if(ui32BufferCount > psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers) - { - eError = PVRSRV_ERROR_TOOMANYBUFFERS; - goto ExitUnLock; - } - - if ((psDevInfo->sFBInfo.ulRoundedBufferSize * (unsigned long)ui32BufferCount) > psDevInfo->sFBInfo.ulFBSize) - { - eError = PVRSRV_ERROR_TOOMANYBUFFERS; - goto ExitUnLock; - } - - /* - * We will allocate the swap chain buffers at the back of the frame - * buffer area. This preserves the front portion, which may be being - * used by other Linux Framebuffer based applications. - */ - ui32BuffersToSkip = psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers - ui32BufferCount; - - /* - * Verify the DST/SRC attributes, - * SRC/DST must match the current display mode config - */ - if(psDstSurfAttrib->pixelformat != psDevInfo->sDisplayFormat.pixelformat - || psDstSurfAttrib->sDims.ui32ByteStride != psDevInfo->sDisplayDim.ui32ByteStride - || psDstSurfAttrib->sDims.ui32Width != psDevInfo->sDisplayDim.ui32Width - || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sDisplayDim.ui32Height) - { - /* DST doesn't match the current mode */ - eError = PVRSRV_ERROR_INVALID_PARAMS; - goto ExitUnLock; - } - - if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat - || psDstSurfAttrib->sDims.ui32ByteStride != psSrcSurfAttrib->sDims.ui32ByteStride - || psDstSurfAttrib->sDims.ui32Width != psSrcSurfAttrib->sDims.ui32Width - || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) - { - /* DST doesn't match the SRC */ - eError = PVRSRV_ERROR_INVALID_PARAMS; - goto ExitUnLock; - } - /* check flags if implementation requires them */ - UNREFERENCED_PARAMETER(ui32Flags); - -#if defined(PVR_OMAPFB3_UPDATE_MODE) - if (!OMAPLFBSetUpdateMode(psDevInfo, PVR_OMAPFB3_UPDATE_MODE)) - { - printk(KERN_WARNING DRIVER_PREFIX ": %s: Device %u: Couldn't set frame buffer update mode %d\n", __FUNCTION__, psDevInfo->uiFBDevID, PVR_OMAPFB3_UPDATE_MODE); - } -#endif /* create a swapchain structure */ psSwapChain = (OMAPLFB_SWAPCHAIN*)OMAPLFBAllocKernelMem(sizeof(OMAPLFB_SWAPCHAIN)); if(!psSwapChain) @@ -574,56 +547,121 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, goto ExitUnLock; } - psBuffer = (OMAPLFB_BUFFER*)OMAPLFBAllocKernelMem(sizeof(OMAPLFB_BUFFER) * ui32BufferCount); - if(!psBuffer) + /* If services asks for a 0-length swap chain, it's probably Android. + * + * This will use only non-display memory posting via PVRSRVSwapToDCBuffers2(), + * and we can skip some useless sanity checking. + */ + if(ui32BufferCount > 0) { - eError = PVRSRV_ERROR_OUT_OF_MEMORY; - goto ErrorFreeSwapChain; - } + IMG_UINT32 ui32BuffersToSkip; - psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; - psSwapChain->psBuffer = psBuffer; - psSwapChain->bNotVSynced = OMAPLFB_TRUE; - psSwapChain->uiFBDevID = psDevInfo->uiFBDevID; + /* Check the buffer count */ + if(ui32BufferCount > psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers) + { + eError = PVRSRV_ERROR_TOOMANYBUFFERS; + goto ErrorFreeSwapChain; + } + + if ((psDevInfo->sFBInfo.ulRoundedBufferSize * (unsigned long)ui32BufferCount) > psDevInfo->sFBInfo.ulFBSize) + { + eError = PVRSRV_ERROR_TOOMANYBUFFERS; + goto ErrorFreeSwapChain; + } - /* Link the buffers */ - for(i=0; i<ui32BufferCount-1; i++) - { - psBuffer[i].psNext = &psBuffer[i+1]; - } - /* and link last to first */ - psBuffer[i].psNext = &psBuffer[0]; + /* + * We will allocate the swap chain buffers at the back of the frame + * buffer area. This preserves the front portion, which may be being + * used by other Linux Framebuffer based applications. + */ + ui32BuffersToSkip = psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers - ui32BufferCount; - /* Configure the swapchain buffers */ - for(i=0; i<ui32BufferCount; i++) - { - IMG_UINT32 ui32SwapBuffer = i + ui32BuffersToSkip; - IMG_UINT32 ui32BufferOffset = ui32SwapBuffer * (IMG_UINT32)psDevInfo->sFBInfo.ulRoundedBufferSize; + /* + * Verify the DST/SRC attributes, + * SRC/DST must match the current display mode config + */ + if(psDstSurfAttrib->pixelformat != psDevInfo->sDisplayFormat.pixelformat + || psDstSurfAttrib->sDims.ui32ByteStride != psDevInfo->sDisplayDim.ui32ByteStride + || psDstSurfAttrib->sDims.ui32Width != psDevInfo->sDisplayDim.ui32Width + || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sDisplayDim.ui32Height) + { + /* DST doesn't match the current mode */ + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto ErrorFreeSwapChain; + } -#if defined(CONFIG_DSSCOMP) - if (psDevInfo->sFBInfo.bIs2D) + if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat + || psDstSurfAttrib->sDims.ui32ByteStride != psSrcSurfAttrib->sDims.ui32ByteStride + || psDstSurfAttrib->sDims.ui32Width != psSrcSurfAttrib->sDims.ui32Width + || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) + { + /* DST doesn't match the SRC */ + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto ErrorFreeSwapChain; + } + + psSwapChain->psBuffer = (OMAPLFB_BUFFER*)OMAPLFBAllocKernelMem(sizeof(OMAPLFB_BUFFER) * ui32BufferCount); + if(!psSwapChain->psBuffer) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + goto ErrorFreeSwapChain; + } + + /* Link the buffers */ + for(i = 0; i < ui32BufferCount - 1; i++) { - ui32BufferOffset = 0; + psSwapChain->psBuffer[i].psNext = &psSwapChain->psBuffer[i + 1]; } + + /* and link last to first */ + psSwapChain->psBuffer[i].psNext = &psSwapChain->psBuffer[0]; + + /* Configure the swapchain buffers */ + for(i = 0; i < ui32BufferCount; i++) + { + IMG_UINT32 ui32SwapBuffer = i + ui32BuffersToSkip; + IMG_UINT32 ui32BufferOffset = ui32SwapBuffer * (IMG_UINT32)psDevInfo->sFBInfo.ulRoundedBufferSize; + +#if defined(CONFIG_DSSCOMP) + if (psDevInfo->sFBInfo.bIs2D) + { + ui32BufferOffset = 0; + } #endif /* defined(CONFIG_DSSCOMP) */ - psBuffer[i].psSyncData = ppsSyncData[i]; + psSwapChain->psBuffer[i].psSyncData = ppsSyncData[i]; - psBuffer[i].sSysAddr.uiAddr = psDevInfo->sFBInfo.sSysAddr.uiAddr + ui32BufferOffset; - psBuffer[i].sCPUVAddr = psDevInfo->sFBInfo.sCPUVAddr + ui32BufferOffset; - psBuffer[i].ulYOffset = ui32BufferOffset / psDevInfo->sFBInfo.ulByteStride; - psBuffer[i].psDevInfo = psDevInfo; + psSwapChain->psBuffer[i].sSysAddr.uiAddr = psDevInfo->sFBInfo.sSysAddr.uiAddr + ui32BufferOffset; + psSwapChain->psBuffer[i].sCPUVAddr = psDevInfo->sFBInfo.sCPUVAddr + ui32BufferOffset; + psSwapChain->psBuffer[i].ulYOffset = ui32BufferOffset / psDevInfo->sFBInfo.ulByteStride; + psSwapChain->psBuffer[i].psDevInfo = psDevInfo; #if defined(CONFIG_DSSCOMP) - if (psDevInfo->sFBInfo.bIs2D) - { - psBuffer[i].sSysAddr.uiAddr += ui32SwapBuffer * - ALIGN((IMG_UINT32)psDevInfo->sFBInfo.ulWidth * psDevInfo->sFBInfo.uiBytesPerPixel, PAGE_SIZE); - } + if (psDevInfo->sFBInfo.bIs2D) + { + psSwapChain->psBuffer[i].sSysAddr.uiAddr += ui32SwapBuffer * + ALIGN((IMG_UINT32)psDevInfo->sFBInfo.ulWidth * psDevInfo->sFBInfo.uiBytesPerPixel, PAGE_SIZE); + } #endif /* defined(CONFIG_DSSCOMP) */ - OMAPLFBInitBufferForSwap(&psBuffer[i]); + OMAPLFBInitBufferForSwap(&psSwapChain->psBuffer[i]); + } } + else + { + psSwapChain->psBuffer = NULL; + } + +#if defined(PVR_OMAPFB3_UPDATE_MODE) + if (!OMAPLFBSetUpdateMode(psDevInfo, PVR_OMAPFB3_UPDATE_MODE)) + { + printk(KERN_WARNING DRIVER_PREFIX ": %s: Device %u: Couldn't set frame buffer update mode %d\n", __FUNCTION__, psDevInfo->uiFBDevID, PVR_OMAPFB3_UPDATE_MODE); + } +#endif /* defined(PVR_OMAPFB3_UPDATE_MODE) */ + + psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; + psSwapChain->bNotVSynced = OMAPLFB_TRUE; + psSwapChain->uiFBDevID = psDevInfo->uiFBDevID; if (OMAPLFBCreateSwapQueue(psSwapChain) != OMAPLFB_OK) { @@ -659,7 +697,10 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, ErrorDestroySwapQueue: OMAPLFBDestroySwapQueue(psSwapChain); ErrorFreeBuffers: - OMAPLFBFreeKernelMem(psBuffer); + if(psSwapChain->psBuffer) + { + OMAPLFBFreeKernelMem(psSwapChain->psBuffer); + } ErrorFreeSwapChain: OMAPLFBFreeKernelMem(psSwapChain); ExitUnLock: @@ -708,7 +749,10 @@ static PVRSRV_ERROR DestroyDCSwapChain(IMG_HANDLE hDevice, } /* Free resources */ - OMAPLFBFreeKernelMem(psSwapChain->psBuffer); + if (psSwapChain->psBuffer) + { + OMAPLFBFreeKernelMem(psSwapChain->psBuffer); + } OMAPLFBFreeKernelMem(psSwapChain); psDevInfo->psSwapChain = NULL; @@ -922,12 +966,16 @@ void OMAPLFBSwapHandler(OMAPLFB_BUFFER *psBuffer) switch(eMode) { case OMAPLFB_UPDATE_MODE_AUTO: + case OMAPLFB_UPDATE_MODE_VSYNC: psSwapChain->bNotVSynced = OMAPLFB_FALSE; if (bPreviouslyNotVSynced || psSwapChain->iBlankEvents != iBlankEvents) { psSwapChain->iBlankEvents = iBlankEvents; - psSwapChain->bNotVSynced = !WaitForVSyncSettle(psDevInfo); + if (eMode == OMAPLFB_UPDATE_MODE_AUTO) + { + psSwapChain->bNotVSynced = !WaitForVSyncSettle(psDevInfo); + } } else if (psBuffer->ulSwapInterval != 0) { psSwapChain->bNotVSynced = !OMAPLFBWaitForVSync(psDevInfo); @@ -972,6 +1020,7 @@ static IMG_BOOL ProcessFlipV1(IMG_HANDLE hCmdCookie, #if defined(CONFIG_DSSCOMP) if (is_tiler_addr(psBuffer->sSysAddr.uiAddr)) { + int res; IMG_UINT32 w = psBuffer->psDevInfo->sDisplayDim.ui32Width; IMG_UINT32 h = psBuffer->psDevInfo->sDisplayDim.ui32Height; struct dsscomp_setup_dispc_data comp = { @@ -995,9 +1044,13 @@ static IMG_BOOL ProcessFlipV1(IMG_HANDLE hCmdCookie, }; struct tiler_pa_info *pas[1] = { NULL }; comp.ovls[0].ba = (u32) psBuffer->sSysAddr.uiAddr; - dsscomp_gralloc_queue(&comp, pas, true, + res = dsscomp_gralloc_queue(&comp, pas, true, (void *) psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete, (void *) psBuffer->hCmdComplete); + if (res != 0) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: Device %u: dsscomp_gralloc_queue failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res)); + } } else #endif /* defined(CONFIG_DSSCOMP) */ @@ -1023,6 +1076,55 @@ static IMG_BOOL ProcessFlipV2(IMG_HANDLE hCmdCookie, { struct tiler_pa_info *apsTilerPAs[5]; IMG_UINT32 i, k; + struct + { + IMG_UINTPTR_T uiAddr; + IMG_UINTPTR_T uiUVAddr; + struct tiler_pa_info *psTilerInfo; + } + asMemInfo[5] = {}; + int res; + + if(!psDssData) + { + if(ui32NumMemInfos == 1) + { + OMAPLFB_BUFFER sBuffer; + IMG_CPU_PHYADDR phyAddr; + + psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[0], 0, &phyAddr); + + /* Fake up an OMAPLFB_BUFFER */ + sBuffer.psNext = NULL; + sBuffer.psDevInfo = psDevInfo; + sBuffer.ulYOffset = 0; + sBuffer.sSysAddr.uiAddr = phyAddr.uiAddr; + sBuffer.sCPUVAddr = 0; + sBuffer.psSyncData = NULL; + sBuffer.hCmdComplete = (OMAPLFB_HANDLE)hCmdCookie; + sBuffer.ulSwapInterval = 0; + + /* If we got a meminfo but no private data, assume the 'null' HWC + * backend is in use, and emulate a swapchain-less ProcessFlipV1. + */ + OMAPLFBFlip(psDevInfo, &sBuffer); + + /* FIXME: Why do this? Shouldn't we use the hCmdCookie correctly, + * like ProcessFlipV1 does? + */ + psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); + } + else + { + printk(KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: WARNING: psDispcData was NULL. " + "The HWC probably has a bug. Silently ignoring.", + __FUNCTION__, psDevInfo->uiFBDevID); + } + + psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); + return IMG_TRUE; + } if(ui32DssDataLength != sizeof(*psDssData)) { @@ -1037,7 +1139,13 @@ static IMG_BOOL ProcessFlipV2(IMG_HANDLE hCmdCookie, return IMG_FALSE; } - for(i = k = 0; i < ui32NumMemInfos && k < ARRAY_SIZE(apsTilerPAs); i++, k++) + if(DontWaitForVSync(psDevInfo)) + { + psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); + return IMG_TRUE; + } + + for(i = k = 0; i < ui32NumMemInfos && k < ARRAY_SIZE(asMemInfo); i++, k++) { struct tiler_pa_info *psTilerInfo; IMG_CPU_VIRTADDR virtAddr; @@ -1049,27 +1157,28 @@ static IMG_BOOL ProcessFlipV2(IMG_HANDLE hCmdCookie, psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetByteSize(ppsMemInfos[i], &uByteSize); ui32NumPages = (uByteSize + PAGE_SIZE - 1) >> PAGE_SHIFT; - apsTilerPAs[k] = NULL; - psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[i], 0, &phyAddr); - /* NV12 buffers are already mapped to tiler */ - if(psDssData->ovls[k].cfg.color_mode == OMAP_DSS_COLOR_NV12) - { - psDssData->ovls[k].ba = (u32)phyAddr.uiAddr; - - psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[i], (uByteSize * 2) / 3, &phyAddr); - psDssData->ovls[k].uv = (u32)phyAddr.uiAddr; - continue; - } - - /* Other kinds of buffer may also already be mapped to tiler */ + /* TILER buffers do not need meminfos */ if(is_tiler_addr((u32)phyAddr.uiAddr)) { - psDssData->ovls[k].ba = (u32)phyAddr.uiAddr; +#ifdef CONFIG_DRM_OMAP_DMM_TILER + enum tiler_fmt fmt; +#endif + asMemInfo[k].uiAddr = phyAddr.uiAddr; +#ifdef CONFIG_DRM_OMAP_DMM_TILER + if(tiler_get_fmt((u32)phyAddr.uiAddr, &fmt) && fmt == TILFMT_8BIT) +#else + if(tiler_fmt((u32)phyAddr.uiAddr) == TILFMT_8BIT) +#endif + { + psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[i], (uByteSize * 2) / 3, &phyAddr); + asMemInfo[k].uiUVAddr = phyAddr.uiAddr; + } continue; } + /* normal gralloc layer */ psTilerInfo = kzalloc(sizeof(*psTilerInfo), GFP_KERNEL); if(!psTilerInfo) { @@ -1085,37 +1194,58 @@ static IMG_BOOL ProcessFlipV2(IMG_HANDLE hCmdCookie, psTilerInfo->num_pg = ui32NumPages; psTilerInfo->memtype = TILER_MEM_USING; - for(j = 0; j < ui32NumPages; j++) { psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[i], j << PAGE_SHIFT, &phyAddr); psTilerInfo->mem[j] = (u32)phyAddr.uiAddr; } - /* Need base address for in-page offset */ + /* need base address for in-page offset */ psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuVAddr(ppsMemInfos[i], &virtAddr); - psDssData->ovls[k].ba = (u32)virtAddr; - apsTilerPAs[k] = psTilerInfo; + asMemInfo[k].uiAddr = (IMG_UINTPTR_T) virtAddr; + asMemInfo[k].psTilerInfo = psTilerInfo; } - /* Set up cloned layer addresses (but don't duplicate tiler_pas) */ - for(i = k; i < psDssData->num_ovls && i < ARRAY_SIZE(apsTilerPAs); i++) + for(i = 0; i < psDssData->num_ovls; i++) { - unsigned int ix = psDssData->ovls[i].ba; - if(ix >= ARRAY_SIZE(apsTilerPAs)) + unsigned int ix; + apsTilerPAs[i] = NULL; + + /* only supporting Post2, cloned and fbmem layers */ + if (psDssData->ovls[i].addressing != OMAP_DSS_BUFADDR_LAYER_IX && + psDssData->ovls[i].addressing != OMAP_DSS_BUFADDR_OVL_IX && + psDssData->ovls[i].addressing != OMAP_DSS_BUFADDR_FB) { - WARN(1, "Invalid clone layer (%u); skipping all cloned layers", ix); - psDssData->num_ovls = k; - break; + psDssData->ovls[i].cfg.enabled = false; + } + + if (psDssData->ovls[i].addressing != OMAP_DSS_BUFADDR_LAYER_IX) + { + continue; + } + + /* Post2 layers */ + ix = psDssData->ovls[i].ba; + if (ix >= k) + { + WARN(1, "Invalid Post2 layer (%u)", ix); + psDssData->ovls[i].cfg.enabled = false; + continue; } - apsTilerPAs[i] = apsTilerPAs[ix]; - psDssData->ovls[i].ba = psDssData->ovls[ix].ba; - psDssData->ovls[i].uv = psDssData->ovls[ix].uv; + + psDssData->ovls[i].addressing = OMAP_DSS_BUFADDR_DIRECT; + psDssData->ovls[i].ba = (u32) asMemInfo[ix].uiAddr; + psDssData->ovls[i].uv = (u32) asMemInfo[ix].uiUVAddr; + apsTilerPAs[i] = asMemInfo[ix].psTilerInfo; } - dsscomp_gralloc_queue(psDssData, apsTilerPAs, false, + res = dsscomp_gralloc_queue(psDssData, apsTilerPAs, false, (void *)psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete, (void *)hCmdCookie); + if (res != 0) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: Device %u: dsscomp_gralloc_queue failed (%d)\n", __FUNCTION__, psDevInfo->uiFBDevID, res)); + } for(i = 0; i < k; i++) { @@ -1194,8 +1324,6 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) struct module *psLINFBOwner; OMAPLFB_FBINFO *psPVRFBInfo = &psDevInfo->sFBInfo; OMAPLFB_ERROR eError = OMAPLFB_ERROR_GENERIC; - unsigned long FBSize; - unsigned long ulLCM; unsigned uiFBDevID = psDevInfo->uiFBDevID; OMAPLFB_CONSOLE_LOCK(); @@ -1207,20 +1335,6 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) goto ErrorRelSem; } - FBSize = (psLINFBInfo->screen_size) != 0 ? - psLINFBInfo->screen_size : - psLINFBInfo->fix.smem_len; - - /* - * Try and filter out invalid FB info structures (a problem - * seen on some OMAP3 systems). - */ - if (FBSize == 0 || psLINFBInfo->fix.line_length == 0) - { - eError = OMAPLFB_ERROR_INVALID_DEVICE; - goto ErrorRelSem; - } - psLINFBOwner = psLINFBInfo->fbops->owner; if (!try_module_get(psLINFBOwner)) { @@ -1246,43 +1360,62 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) psDevInfo->psLINFBInfo = psLINFBInfo; - ulLCM = LCM(psLINFBInfo->fix.line_length, OMAPLFB_PAGE_SIZE); + psPVRFBInfo->ulWidth = psLINFBInfo->var.xres; + psPVRFBInfo->ulHeight = psLINFBInfo->var.yres; + + if (psPVRFBInfo->ulWidth == 0 || psPVRFBInfo->ulHeight == 0) + { + eError = OMAPLFB_ERROR_INVALID_DEVICE; + goto ErrorFBRel; + } + +#if !defined(CONFIG_DSSCOMP) + psPVRFBInfo->ulFBSize = (psLINFBInfo->screen_size) != 0 ? + psLINFBInfo->screen_size : + psLINFBInfo->fix.smem_len; + + /* + * Try and filter out invalid FB info structures (a problem + * seen on some OMAP3 systems). + */ + if (psPVRFBInfo->ulFBSize == 0 || psLINFBInfo->fix.line_length == 0) + { + eError = OMAPLFB_ERROR_INVALID_DEVICE; + goto ErrorFBRel; + } - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX - ": Device %u: Framebuffer physical address: 0x%lx\n", - psDevInfo->uiFBDevID, psLINFBInfo->fix.smem_start)); - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX - ": Device %u: Framebuffer virtual address: 0x%lx\n", - psDevInfo->uiFBDevID, (unsigned long)psLINFBInfo->screen_base)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer size: %lu\n", - psDevInfo->uiFBDevID, FBSize)); + psDevInfo->uiFBDevID, psPVRFBInfo->ulFBSize)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer virtual width: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->var.xres_virtual)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer virtual height: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->var.yres_virtual)); +#endif DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX - ": Device %u: Framebuffer width: %u\n", - psDevInfo->uiFBDevID, psLINFBInfo->var.xres)); - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX - ": Device %u: Framebuffer height: %u\n", - psDevInfo->uiFBDevID, psLINFBInfo->var.yres)); - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX - ": Device %u: Framebuffer stride: %u\n", - psDevInfo->uiFBDevID, psLINFBInfo->fix.line_length)); + ": Device %u: Framebuffer width: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulWidth)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX - ": Device %u: LCM of stride and page size: %lu\n", - psDevInfo->uiFBDevID, ulLCM)); - - /* Additional implementation specific information */ - OMAPLFBPrintInfo(psDevInfo); + ": Device %u: Framebuffer height: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulHeight)); #if defined(CONFIG_DSSCOMP) { - /* for some reason we need at least 3 buffers in the swap chain */ - int n = FBSize / RoundUpToMultiple(psLINFBInfo->fix.line_length * psLINFBInfo->var.yres, ulLCM); +#if defined(SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER) + /* + * Assume we need 3 swap buffers, and a separate system + * buffer. + */ + int n = 4; +#else + /* + * Assume we need just 3 swap buffers, and no separate + * system buffer. + */ + int n = 3; +#endif int res; int i, x, y, w; ion_phys_addr_t phys; @@ -1293,8 +1426,8 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) { /* TILER will align width to 128-bytes */ /* however, SGX must have full page width */ - .w = ALIGN(psLINFBInfo->var.xres, PAGE_SIZE / (psLINFBInfo->var.bits_per_pixel / 8)), - .h = psLINFBInfo->var.yres, + .w = ALIGN(psPVRFBInfo->ulWidth, PAGE_SIZE / (psLINFBInfo->var.bits_per_pixel / 8)), + .h = psPVRFBInfo->ulHeight, .fmt = psLINFBInfo->var.bits_per_pixel == 16 ? TILER_PIXEL_FMT_16BIT : TILER_PIXEL_FMT_32BIT, .flags = 0, }; @@ -1303,43 +1436,43 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) " %s: Device %u: Requesting %d TILER 2D framebuffers\n", __FUNCTION__, uiFBDevID, n); - /* INTEGRATION_POINT: limit to MAX 3 FBs to save TILER container space */ - if (n != 3) - n = 3; - sAllocData.w *= n; psPVRFBInfo->uiBytesPerPixel = psLINFBInfo->var.bits_per_pixel >> 3; psPVRFBInfo->bIs2D = OMAPLFB_TRUE; - res = omap_ion_tiler_alloc(gpsIONClient, &sAllocData); + res = omap_ion_tiler_alloc(psDevInfo->psIONClient, &sAllocData); psPVRFBInfo->psIONHandle = sAllocData.handle; if (res < 0) { printk(KERN_ERR DRIVER_PREFIX " %s: Device %u: Could not allocate 2D framebuffer(%d)\n", __FUNCTION__, uiFBDevID, res); - goto ErrorModPut; + goto ErrorFBRel; } - psLINFBInfo->fix.smem_start = ion_phys(gpsIONClient, sAllocData.handle, &phys, &size); + res = ion_phys(psDevInfo->psIONClient, sAllocData.handle, &phys, &size); + if (res < 0) + { + printk(KERN_ERR DRIVER_PREFIX + " %s: Device %u: Could not get 2D framebufferphysical address (%d)\n", + __FUNCTION__, uiFBDevID, res); + goto ErrorFBRel; + } psPVRFBInfo->sSysAddr.uiAddr = phys; psPVRFBInfo->sCPUVAddr = 0; - psPVRFBInfo->ulWidth = psLINFBInfo->var.xres; - psPVRFBInfo->ulHeight = psLINFBInfo->var.yres; psPVRFBInfo->ulByteStride = PAGE_ALIGN(psPVRFBInfo->ulWidth * psPVRFBInfo->uiBytesPerPixel); w = psPVRFBInfo->ulByteStride >> PAGE_SHIFT; - /* this is an "effective" FB size to get correct number of buffers */ psPVRFBInfo->ulFBSize = sAllocData.h * n * psPVRFBInfo->ulByteStride; psPVRFBInfo->psPageList = kzalloc(w * n * psPVRFBInfo->ulHeight * sizeof(*psPVRFBInfo->psPageList), GFP_KERNEL); if (!psPVRFBInfo->psPageList) { printk(KERN_WARNING DRIVER_PREFIX ": %s: Device %u: Could not allocate page list\n", __FUNCTION__, psDevInfo->uiFBDevID); - ion_free(gpsIONClient, sAllocData.handle); - goto ErrorModPut; + ion_free(psDevInfo->psIONClient, sAllocData.handle); + goto ErrorFBRel; } tilview_create(&view, phys, psDevInfo->sFBInfo.ulWidth, psDevInfo->sFBInfo.ulHeight); @@ -1360,21 +1493,48 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) psPVRFBInfo->sSysAddr.uiAddr = psLINFBInfo->fix.smem_start; psPVRFBInfo->sCPUVAddr = psLINFBInfo->screen_base; - psPVRFBInfo->ulWidth = psLINFBInfo->var.xres; - psPVRFBInfo->ulHeight = psLINFBInfo->var.yres; psPVRFBInfo->ulByteStride = psLINFBInfo->fix.line_length; - psPVRFBInfo->ulFBSize = FBSize; #endif /* defined(CONFIG_DSSCOMP) */ + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer physical address: 0x%x\n", + psDevInfo->uiFBDevID, psPVRFBInfo->sSysAddr.uiAddr)); + + if (psPVRFBInfo->sCPUVAddr != NULL) + { + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer virtual address: %p\n", + psDevInfo->uiFBDevID, psPVRFBInfo->sCPUVAddr)); + } + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer stride: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulByteStride)); + + /* Additional implementation specific information */ + OMAPLFBPrintInfo(psDevInfo); + psPVRFBInfo->ulBufferSize = psPVRFBInfo->ulHeight * psPVRFBInfo->ulByteStride; - /* Round the buffer size up to a multiple of the number of pages - * and the byte stride. - * This is used internally, to ensure buffers start on page - * boundaries, for the benefit of PVR Services. - */ - psPVRFBInfo->ulRoundedBufferSize = RoundUpToMultiple(psPVRFBInfo->ulBufferSize, ulLCM); +#if defined(CONFIG_DSSCOMP) + psPVRFBInfo->ulRoundedBufferSize = psPVRFBInfo->ulBufferSize; +#else + { + unsigned long ulLCM; + ulLCM = LCM(psPVRFBInfo->ulByteStride, OMAPLFB_PAGE_SIZE); + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: LCM of stride and page size: %lu\n", + psDevInfo->uiFBDevID, ulLCM)); + + /* Round the buffer size up to a multiple of the number of pages + * and the byte stride. + * This is used internally, to ensure buffers start on page + * boundaries, for the benefit of PVR Services. + */ + psPVRFBInfo->ulRoundedBufferSize = RoundUpToMultiple(psPVRFBInfo->ulBufferSize, ulLCM); + } +#endif if(psLINFBInfo->var.bits_per_pixel == 16) { if((psLINFBInfo->var.red.length == 5) && @@ -1427,6 +1587,11 @@ static OMAPLFB_ERROR OMAPLFBInitFBDev(OMAPLFB_DEVINFO *psDevInfo) eError = OMAPLFB_OK; goto ErrorRelSem; +ErrorFBRel: + if (psLINFBInfo->fbops->fb_release != NULL) + { + (void) psLINFBInfo->fbops->fb_release(psLINFBInfo, 0); + } ErrorModPut: module_put(psLINFBOwner); ErrorRelSem: @@ -1448,7 +1613,7 @@ static void OMAPLFBDeInitFBDev(OMAPLFB_DEVINFO *psDevInfo) kfree(psPVRFBInfo->psPageList); if (psPVRFBInfo->psIONHandle) { - ion_free(gpsIONClient, psPVRFBInfo->psIONHandle); + ion_free(psDevInfo->psIONClient, psPVRFBInfo->psIONHandle); } } #endif /* defined(CONFIG_DSSCOMP) */ @@ -1493,6 +1658,23 @@ static OMAPLFB_DEVINFO *OMAPLFBInitDev(unsigned uiFBDevID) goto ErrorFreeDevInfo; } +#if defined(CONFIG_ION_OMAP) + psDevInfo->psIONClient = + ion_client_create(omap_ion_device, +#if defined(SUPPORT_OLD_ION_API) + 1 << ION_HEAP_TYPE_CARVEOUT | + 1 << OMAP_ION_HEAP_TYPE_TILER, +#endif + "dc_omapfb3_linux"); + if (IS_ERR_OR_NULL(psDevInfo->psIONClient)) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: Failed to create ion client\n", __FUNCTION__, uiFBDevID); + + goto ErrorFreeDevInfo; + } +#endif /* defined(CONFIG_ION_OMAP) */ + /* Save private fbdev information structure in the dev. info. */ if(OMAPLFBInitFBDev(psDevInfo) != OMAPLFB_OK) { @@ -1502,7 +1684,7 @@ static OMAPLFB_DEVINFO *OMAPLFBInitDev(unsigned uiFBDevID) * there is no Linux framebuffer device corresponding * to the device ID. */ - goto ErrorFreeDevInfo; + goto ErrorIonClientDestroy; } psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers = (IMG_UINT32)(psDevInfo->sFBInfo.ulFBSize / psDevInfo->sFBInfo.ulRoundedBufferSize); @@ -1510,6 +1692,9 @@ static OMAPLFB_DEVINFO *OMAPLFBInitDev(unsigned uiFBDevID) { psDevInfo->sDisplayInfo.ui32MaxSwapChains = 1; psDevInfo->sDisplayInfo.ui32MaxSwapInterval = 1; +#if defined(CONFIG_DSSCOMP) + psDevInfo->sDisplayInfo.ui32MinSwapInterval = 1; +#endif } psDevInfo->sDisplayInfo.ui32PhysicalWidthmm = psDevInfo->sFBInfo.ulPhysicalWidthmm; @@ -1533,6 +1718,10 @@ static OMAPLFB_DEVINFO *OMAPLFBInitDev(unsigned uiFBDevID) OMAPLFBInitBufferForSwap(&psDevInfo->sSystemBuffer); +#if defined(CONFIG_DSSCOMP) && defined(SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER) + OMAPLFBFlip(psDevInfo, &psDevInfo->sSystemBuffer); +#endif + /* Setup the DC Jtable so SRVKM can call into this driver */ @@ -1601,12 +1790,17 @@ static OMAPLFB_DEVINFO *OMAPLFBInitDev(unsigned uiFBDevID) #if defined(SUPPORT_DRI_DRM) OMAPLFBAtomicBoolInit(&psDevInfo->sLeaveVT, OMAPLFB_FALSE); #endif + return psDevInfo; ErrorUnregisterDevice: (void)psDevInfo->sPVRJTable.pfnPVRSRVRemoveDCDevice(psDevInfo->uiPVRDevID); ErrorDeInitFBDev: OMAPLFBDeInitFBDev(psDevInfo); +ErrorIonClientDestroy: +#if defined(CONFIG_ION_OMAP) + ion_client_destroy(psDevInfo->psIONClient); +#endif /* defined(CONFIG_ION_OMAP) */ ErrorFreeDevInfo: OMAPLFBFreeKernelMem(psDevInfo); ErrorExit: @@ -1652,19 +1846,6 @@ static OMAPLFB_BOOL OMAPLFBDeInitDev(OMAPLFB_DEVINFO *psDevInfo) { PVRSRV_DC_DISP2SRV_KMJTABLE *psPVRJTable = &psDevInfo->sPVRJTable; - OMAPLFBCreateSwapChainLockDeInit(psDevInfo); - - OMAPLFBAtomicBoolDeInit(&psDevInfo->sBlanked); - OMAPLFBAtomicIntDeInit(&psDevInfo->sBlankEvents); - OMAPLFBAtomicBoolDeInit(&psDevInfo->sFlushCommands); -#if defined(CONFIG_HAS_EARLYSUSPEND) - OMAPLFBAtomicBoolDeInit(&psDevInfo->sEarlySuspendFlag); -#endif -#if defined(SUPPORT_DRI_DRM) - OMAPLFBAtomicBoolDeInit(&psDevInfo->sLeaveVT); -#endif - psPVRJTable = &psDevInfo->sPVRJTable; - if (psPVRJTable->pfnPVRSRVRemoveCmdProcList (psDevInfo->uiPVRDevID, OMAPLFB_COMMAND_COUNT) != PVRSRV_OK) { printk(KERN_ERR DRIVER_PREFIX @@ -1682,9 +1863,31 @@ static OMAPLFB_BOOL OMAPLFBDeInitDev(OMAPLFB_DEVINFO *psDevInfo) ": %s: Device %u: PVR Device %u: Couldn't remove device from PVR Services\n", __FUNCTION__, psDevInfo->uiFBDevID, psDevInfo->uiPVRDevID); return OMAPLFB_FALSE; } - + +#if defined(CONFIG_DSSCOMP) + /* Disable the overlay, as we will be freeing the display buffers */ + psDevInfo->sSystemBuffer.sSysAddr.uiAddr = 0; + OMAPLFBFlip(psDevInfo, &psDevInfo->sSystemBuffer); +#endif /* defined(CONFIG_DSSCOMP) */ + + OMAPLFBCreateSwapChainLockDeInit(psDevInfo); + + OMAPLFBAtomicBoolDeInit(&psDevInfo->sBlanked); + OMAPLFBAtomicIntDeInit(&psDevInfo->sBlankEvents); + OMAPLFBAtomicBoolDeInit(&psDevInfo->sFlushCommands); +#if defined(CONFIG_HAS_EARLYSUSPEND) + OMAPLFBAtomicBoolDeInit(&psDevInfo->sEarlySuspendFlag); +#endif +#if defined(SUPPORT_DRI_DRM) + OMAPLFBAtomicBoolDeInit(&psDevInfo->sLeaveVT); +#endif + OMAPLFBDeInitFBDev(psDevInfo); +#if defined(CONFIG_ION_OMAP) + ion_client_destroy(psDevInfo->psIONClient); +#endif + OMAPLFBSetDevInfoPtr(psDevInfo->uiFBDevID, NULL); /* De-allocate data structure */ diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c index ce3c8cbd38f..23747841e76 100644..100755 --- a/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c +++ b/drivers/gpu/pvr/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c @@ -93,7 +93,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/mutex.h> #if defined(PVR_OMAPLFB_DRM_FB) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) #include <plat/display.h> +#else +#include <video/omapdss.h> +#endif #include <linux/omap_gpu.h> #else /* defined(PVR_OMAPLFB_DRM_FB) */ /* OmapZoom.org OMAP3 2.6.29 kernel tree - Needs mach/vrfb.h @@ -102,27 +106,30 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * OmapZoom.org OMAP4 2.6.34 kernel tree - Needs plat/vrfb.h * Sholes 2.6.32 kernel tree - Needs plat/vrfb.h */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +#define PVR_OMAPFB3_NEEDS_VIDEO_OMAPVRFB_H +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) #define PVR_OMAPFB3_NEEDS_PLAT_VRFB_H #endif +#if defined(PVR_OMAPFB3_NEEDS_VIDEO_OMAPVRFB_H) +#include <video/omapvrfb.h> +#else #if defined(PVR_OMAPFB3_NEEDS_PLAT_VRFB_H) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) #include <plat/vrfb.h> #else -#include <video/omapvrfb.h> -#endif -#else #if defined(PVR_OMAPFB3_NEEDS_MACH_VRFB_H) #include <mach/vrfb.h> #endif #endif +#endif #if defined(DEBUG) #define PVR_DEBUG DEBUG #undef DEBUG #endif #include <omapfb/omapfb.h> +#undef DBG #if defined(DEBUG) #undef DEBUG #endif @@ -133,7 +140,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif /* defined(PVR_OMAPLFB_DRM_FB) */ #if defined(CONFIG_DSSCOMP) +#if defined(CONFIG_DRM_OMAP_DMM_TILER) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +#include <../drivers/gpu/drm/omapdrm/omap_dmm_tiler.h> +#else +#include <../drivers/staging/omapdrm/omap_dmm_tiler.h> +#endif +#include <../drivers/video/omap2/dsscomp/tiler-utils.h> +#elif defined(CONFIG_TI_TILER) #include <mach/tiler.h> +#else /* defined(CONFIG_DRM_OMAP_DMM_TILER) */ +#error CONFIG_DSSCOMP support requires either \ + CONFIG_DRM_OMAP_DMM_TILER or CONFIG_TI_TILER +#endif /* defined(CONFIG_DRM_OMAP_DMM_TILER) */ #include <video/dsscomp.h> #include <plat/dsscomp.h> #endif /* defined(CONFIG_DSSCOMP) */ @@ -155,19 +174,27 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. MODULE_SUPPORTED_DEVICE(DEVNAME); #if !defined(PVR_OMAPLFB_DRM_FB) +#if defined(PVR_OMAPFB3_OMAP5_UEVM) +#define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_driver *drv = (dev)->driver +#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev)->output->manager +#define WAIT_FOR_VSYNC(man) ((man)->wait_for_vsync) +#else /* defined(PVR_OMAPFB3_OMAP5_UEVM) */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +#define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_driver *drv = (dev)->driver +#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev)->output->manager +#define WAIT_FOR_VSYNC(man) ((man)->wait_for_vsync) +#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) #define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_driver *drv = (dev) != NULL ? (dev)->driver : NULL -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) #define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev) != NULL ? (dev)->manager : NULL -#else -#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev) != NULL ? (dev)->output->manager : NULL -#endif #define WAIT_FOR_VSYNC(man) ((man)->wait_for_vsync) -#else +#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */ #define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_device *drv = (dev) #define OMAP_DSS_MANAGER(man, dev) struct omap_dss_device *man = (dev) #define WAIT_FOR_VSYNC(man) ((man)->wait_vsync) -#endif +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */ +#endif /* defined(PVR_OMAPFB3_OMAP5_UEVM) */ #endif /* !defined(PVR_OMAPLFB_DRM_FB) */ void *OMAPLFBAllocKernelMem(unsigned long ulSize) @@ -333,18 +360,13 @@ void OMAPLFBFlip(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_BUFFER *psBuffer) { struct fb_var_screeninfo sFBVar; int res; - unsigned long ulYResVirtual; -#ifdef SKIP_FIRST_FLIP_BUFS - /* Skip first n numbers of flip buffers to avoid draw blank screen - * that occurred flicker at first time booting up - */ - static unsigned int skip_flips = SKIP_FIRST_FLIP_BUFS; - if (skip_flips) { - --skip_flips; + + if (!lock_fb_info(psDevInfo->psLINFBInfo)) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: Couldn't lock FB info\n", __FUNCTION__, psDevInfo->uiFBDevID)); return; } -#endif - OMAPLFB_CONSOLE_LOCK(); sFBVar = psDevInfo->psLINFBInfo->var; @@ -352,9 +374,26 @@ void OMAPLFBFlip(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_BUFFER *psBuffer) sFBVar.xoffset = 0; sFBVar.yoffset = psBuffer->ulYOffset; - ulYResVirtual = psBuffer->ulYOffset + sFBVar.yres; - #if defined(CONFIG_DSSCOMP) + /* + * If flipping to a NULL buffer, blank the screen to prevent + * warnings/errors from the display subsystem. + */ + if (psBuffer->sSysAddr.uiAddr == 0) + { + struct omap_dss_device *psDSSDev = fb2display(psDevInfo->psLINFBInfo); + OMAP_DSS_MANAGER(psDSSMan, psDSSDev); + + if (psDSSMan != NULL && psDSSMan->blank != NULL) + { + res = psDSSMan->blank(psDSSMan, false); + if (res != 0) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: Device %u: DSS manager blank call failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res)); + } + } + } + { /* * If using DSSCOMP, we need to use dsscomp queuing for normal @@ -382,7 +421,7 @@ void OMAPLFBFlip(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_BUFFER *psBuffer) .width = sFBVar.xres_virtual, .height = sFBVar.yres_virtual, .stride = sFBFix.line_length, - .enabled = 1, + .enabled = (psBuffer->sSysAddr.uiAddr != 0), .global_alpha = 255, }, }, @@ -391,56 +430,71 @@ void OMAPLFBFlip(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_BUFFER *psBuffer) /* do not map buffer into TILER1D as it is contiguous */ struct tiler_pa_info *pas[] = { NULL }; - d.ovls[0].ba = sFBFix.smem_start; + d.ovls[0].ba = (u32) psBuffer->sSysAddr.uiAddr; + omapfb_mode_to_dss_mode(&sFBVar, &d.ovls[0].cfg.color_mode); res = dsscomp_gralloc_queue(&d, pas, true, NULL, NULL); + if (res != 0) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: Device %u: dsscomp_gralloc_queue failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res)); + } } #else /* defined(CONFIG_DSSCOMP) */ - /* - * PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY should be defined to work - * around flipping problems seen with the Taal LCDs on Blaze. - * The work around is safe to use with other types of screen on Blaze - * (e.g. HDMI) and on other platforms (e.g. Panda board). - */ + { + unsigned long ulYResVirtual = psBuffer->ulYOffset + sFBVar.yres; + + /* + * PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY should be defined to + * work around flipping problems seen with the Taal LCDs on + * Blaze. + * The work around is safe to use with other types of screen + * on Blaze (e.g. HDMI) and on other platforms (e.g. Panda + * board). + */ #if !defined(PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY) - /* - * Attempt to change the virtual screen resolution if it is too - * small. Note that fb_set_var also pans the display. - */ - if (sFBVar.xres_virtual != sFBVar.xres || sFBVar.yres_virtual < ulYResVirtual) + /* + * Attempt to change the virtual screen resolution if it is too + * small. Note that fb_set_var also pans the display. + */ + if (sFBVar.xres_virtual != sFBVar.xres || sFBVar.yres_virtual < ulYResVirtual) #endif /* !defined(PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY) */ - { - sFBVar.xres_virtual = sFBVar.xres; - sFBVar.yres_virtual = ulYResVirtual; + { + sFBVar.xres_virtual = sFBVar.xres; + sFBVar.yres_virtual = ulYResVirtual; - sFBVar.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; + sFBVar.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; - res = fb_set_var(psDevInfo->psLINFBInfo, &sFBVar); - if (res != 0) - { - printk(KERN_ERR DRIVER_PREFIX ": %s: Device %u: fb_set_var failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res); + res = fb_set_var(psDevInfo->psLINFBInfo, &sFBVar); + if (res != 0) + { + printk(KERN_ERR DRIVER_PREFIX ": %s: Device %u: fb_set_var failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res); + } } - } #if !defined(PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY) - else - { - res = fb_pan_display(psDevInfo->psLINFBInfo, &sFBVar); - if (res != 0) + else { - printk(KERN_ERR DRIVER_PREFIX ": %s: Device %u: fb_pan_display failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res); + res = fb_pan_display(psDevInfo->psLINFBInfo, &sFBVar); + if (res != 0) + { + printk(KERN_ERR DRIVER_PREFIX ": %s: Device %u: fb_pan_display failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res); + } } - } #endif /* !defined(PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY) */ + } #endif /* defined(CONFIG_DSSCOMP) */ OMAPLFB_CONSOLE_UNLOCK(); + unlock_fb_info(psDevInfo->psLINFBInfo); } /* Newer kernels don't have any update mode capability */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#define PVR_OMAPLFB_HAS_UPDATE_MODE +#endif +#if defined(PVR_OMAPLFB_HAS_UPDATE_MODE) #if !defined(PVR_OMAPLFB_DRM_FB) || defined(DEBUG) static OMAPLFB_BOOL OMAPLFBValidateDSSUpdateMode(enum omap_dss_update_mode eMode) { @@ -536,67 +590,7 @@ static const char *OMAPLFBDSSUpdateModeToString(enum omap_dss_update_mode eMode) return OMAPLFBUpdateModeToString(OMAPLFBFromDSSUpdateMode(eMode)); } - - -#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ - -static const char *OMAPLFBUpdateModeToString(OMAPLFB_UPDATE_MODE eMode) -{ - return "Not supported"; -} - -#if defined(PVR_OMAPLFB_DRM_FB) -static const char *OMAPLFBDSSUpdateModeToString(int eMode) -{ - return "Not supported"; -} -#endif /* defined(PVR_OMAPLFB_DRM_FB) */ - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ - -void OMAPLFBPrintInfo(OMAPLFB_DEVINFO *psDevInfo) -{ -#if defined(PVR_OMAPLFB_DRM_FB) - struct drm_connector *psConnector; - unsigned uConnectors; - unsigned uConnector; - - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: DRM framebuffer\n", psDevInfo->uiFBDevID)); - - for (psConnector = NULL, uConnectors = 0; - (psConnector = omap_fbdev_get_next_connector(psDevInfo->psLINFBInfo, psConnector)) != NULL;) - { - uConnectors++; - } - - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Number of screens (DRM connectors): %u\n", psDevInfo->uiFBDevID, uConnectors)); - - if (uConnectors == 0) - { - return; - } - - for (psConnector = NULL, uConnector = 0; - (psConnector = omap_fbdev_get_next_connector(psDevInfo->psLINFBInfo, psConnector)) != NULL; uConnector++) - { - enum omap_dss_update_mode eMode = omap_connector_get_update_mode(psConnector); - - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Screen %u: %s (%d)\n", psDevInfo->uiFBDevID, uConnector, OMAPLFBDSSUpdateModeToString(eMode), (int)eMode)); - - } -#else /* defined(PVR_OMAPLFB_DRM_FB) */ - OMAPLFB_UPDATE_MODE eMode = OMAPLFBGetUpdateMode(psDevInfo); - - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: non-DRM framebuffer\n", psDevInfo->uiFBDevID)); - - DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: %s\n", psDevInfo->uiFBDevID, OMAPLFBUpdateModeToString(eMode))); -#endif /* defined(PVR_OMAPLFB_DRM_FB) */ -} -#endif /* defined(DEBUG) */ - -/* Newer kernels don't have any update mode capability */ - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#endif /* defined(DEBUG) */ /* * Get display update mode. @@ -752,15 +746,61 @@ OMAPLFB_BOOL OMAPLFBSetUpdateMode(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_UPDATE_MOD return (res == 0); #endif /* defined(PVR_OMAPLFB_DRM_FB) */ } - -#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ +#else /* defined(PVR_OMAPLFB_HAS_UPDATE_MODE) */ OMAPLFB_UPDATE_MODE OMAPLFBGetUpdateMode(OMAPLFB_DEVINFO *psDevInfo) { - return OMAPLFB_UPDATE_MODE_MANUAL; +#if defined(PVR_OMAPFB3_OMAP5_UEVM) + return OMAPLFB_UPDATE_MODE_VSYNC; +#else + return OMAPLFB_UPDATE_MODE_UNDEFINED; +#endif } -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ +#endif /* defined(PVR_OMAPLFB_HAS_UPDATE_MODE) */ + +#if defined(DEBUG) +void OMAPLFBPrintInfo(OMAPLFB_DEVINFO *psDevInfo) +{ +#if defined(PVR_OMAPLFB_DRM_FB) + struct drm_connector *psConnector; + unsigned uConnectors; + unsigned uConnector; + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: DRM framebuffer\n", psDevInfo->uiFBDevID)); + + for (psConnector = NULL, uConnectors = 0; + (psConnector = omap_fbdev_get_next_connector(psDevInfo->psLINFBInfo, psConnector)) != NULL;) + { + uConnectors++; + } + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Number of screens (DRM connectors): %u\n", psDevInfo->uiFBDevID, uConnectors)); + + if (uConnectors == 0) + { + return; + } + + for (psConnector = NULL, uConnector = 0; + (psConnector = omap_fbdev_get_next_connector(psDevInfo->psLINFBInfo, psConnector)) != NULL; uConnector++) + { + enum omap_dss_update_mode eMode = omap_connector_get_update_mode(psConnector); + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Screen %u: %s (%d)\n", psDevInfo->uiFBDevID, uConnector, OMAPLFBDSSUpdateModeToString(eMode), (int)eMode)); + + } +#else /* defined(PVR_OMAPLFB_DRM_FB) */ +#if defined(PVR_OMAPLFB_HAS_UPDATE_MODE) + OMAPLFB_UPDATE_MODE eMode = OMAPLFBGetUpdateMode(psDevInfo); + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: %s\n", psDevInfo->uiFBDevID, OMAPLFBUpdateModeToString(eMode))); +#endif + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: non-DRM framebuffer\n", psDevInfo->uiFBDevID)); + +#endif /* defined(PVR_OMAPLFB_DRM_FB) */ +} +#endif /* defined(DEBUG) */ /* Wait for VSync */ OMAPLFB_BOOL OMAPLFBWaitForVSync(OMAPLFB_DEVINFO *psDevInfo) @@ -897,14 +937,32 @@ static int OMAPLFBFrameBufferEvents(struct notifier_block *psNotif, return 0; } -/* Unblank the screen */ -OMAPLFB_ERROR OMAPLFBUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo) +/* + * Blank or Unblank the screen. To be called where the unblank is being done + * in user context. + */ +static OMAPLFB_ERROR OMAPLFBBlankOrUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo, IMG_BOOL bBlank) { int res; + if (!lock_fb_info(psDevInfo->psLINFBInfo)) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: Couldn't lock FB info\n", __FUNCTION__, psDevInfo->uiFBDevID); + return (OMAPLFB_ERROR_GENERIC); + } + + /* + * FBINFO_MISC_USEREVENT is set to avoid a deadlock resulting from + * fb_blank being called recursively due from within the fb_blank event + * notification. + */ OMAPLFB_CONSOLE_LOCK(); - res = fb_blank(psDevInfo->psLINFBInfo, 0); + psDevInfo->psLINFBInfo->flags |= FBINFO_MISC_USEREVENT; + res = fb_blank(psDevInfo->psLINFBInfo, bBlank ? 1 : 0); + psDevInfo->psLINFBInfo->flags &= ~FBINFO_MISC_USEREVENT; OMAPLFB_CONSOLE_UNLOCK(); + unlock_fb_info(psDevInfo->psLINFBInfo); if (res != 0 && res != -EINVAL) { printk(KERN_ERR DRIVER_PREFIX @@ -915,10 +973,23 @@ OMAPLFB_ERROR OMAPLFBUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo) return (OMAPLFB_OK); } +/* Unblank the screen */ +OMAPLFB_ERROR OMAPLFBUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo) +{ + return OMAPLFBBlankOrUnblankDisplay(psDevInfo, IMG_FALSE); +} + #ifdef CONFIG_HAS_EARLYSUSPEND /* Blank the screen */ -static void OMAPLFBBlankDisplay(OMAPLFB_DEVINFO *psDevInfo) +static void OMAPLFBEarlyUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo) +{ + OMAPLFB_CONSOLE_LOCK(); + fb_blank(psDevInfo->psLINFBInfo, 0); + OMAPLFB_CONSOLE_UNLOCK(); +} + +static void OMAPLFBEarlyBlankDisplay(OMAPLFB_DEVINFO *psDevInfo) { OMAPLFB_CONSOLE_LOCK(); fb_blank(psDevInfo->psLINFBInfo, 1); @@ -937,7 +1008,7 @@ static void OMAPLFBEarlySuspendHandler(struct early_suspend *h) if (psDevInfo != NULL) { OMAPLFBAtomicBoolSet(&psDevInfo->sEarlySuspendFlag, OMAPLFB_TRUE); - OMAPLFBBlankDisplay(psDevInfo); + OMAPLFBEarlyBlankDisplay(psDevInfo); } } } @@ -953,7 +1024,7 @@ static void OMAPLFBEarlyResumeHandler(struct early_suspend *h) if (psDevInfo != NULL) { - OMAPLFBUnblankDisplay(psDevInfo); + OMAPLFBEarlyUnblankDisplay(psDevInfo); OMAPLFBAtomicBoolSet(&psDevInfo->sEarlySuspendFlag, OMAPLFB_FALSE); } } @@ -1049,36 +1120,32 @@ static OMAPLFB_DEVINFO *OMAPLFBPVRDevIDToDevInfo(unsigned uiPVRDevID) int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device unref__ *dev, void *arg, struct drm_file unref__ *pFile) { - uint32_t *puiArgs; - uint32_t uiCmd; - unsigned uiPVRDevID; - int ret = 0; + drm_pvr_display_cmd *psArgs; OMAPLFB_DEVINFO *psDevInfo; + int ret = 0; if (arg == NULL) { return -EFAULT; } - puiArgs = (uint32_t *)arg; - uiCmd = puiArgs[PVR_DRM_DISP_ARG_CMD]; - uiPVRDevID = puiArgs[PVR_DRM_DISP_ARG_DEV]; + psArgs = (drm_pvr_display_cmd *)arg; - psDevInfo = OMAPLFBPVRDevIDToDevInfo(uiPVRDevID); + psDevInfo = OMAPLFBPVRDevIDToDevInfo(psArgs->dev); if (psDevInfo == NULL) { return -EINVAL; } - switch (uiCmd) + switch (psArgs->cmd) { case PVR_DRM_DISP_CMD_LEAVE_VT: case PVR_DRM_DISP_CMD_ENTER_VT: { - OMAPLFB_BOOL bLeaveVT = (uiCmd == PVR_DRM_DISP_CMD_LEAVE_VT); + OMAPLFB_BOOL bLeaveVT = (psArgs->cmd == PVR_DRM_DISP_CMD_LEAVE_VT); DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX ": %s: PVR Device %u: %s\n", - __FUNCTION__, uiPVRDevID, + __FUNCTION__, psArgs->dev, bLeaveVT ? "Leave VT" : "Enter VT")); OMAPLFBCreateSwapChainLock(psDevInfo); @@ -1108,7 +1175,7 @@ int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device unref__ *dev, #if defined(DEBUG) { const char *pszMode; - switch(uiCmd) + switch(psArgs->cmd) { case PVR_DRM_DISP_CMD_ON: pszMode = "On"; @@ -1127,10 +1194,10 @@ int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device unref__ *dev, break; } printk(KERN_WARNING DRIVER_PREFIX ": %s: PVR Device %u: Display %s\n", - __FUNCTION__, uiPVRDevID, pszMode); + __FUNCTION__, psArgs->dev, pszMode); } #endif - switch(uiCmd) + switch(psArgs->cmd) { case PVR_DRM_DISP_CMD_ON: iFBMode = FB_BLANK_UNBLANK; @@ -1155,9 +1222,19 @@ int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device unref__ *dev, flush_workqueue(psDevInfo->psSwapChain->psWorkQueue); } - OMAPLFB_CONSOLE_LOCK(); - ret = fb_blank(psDevInfo->psLINFBInfo, iFBMode); - OMAPLFB_CONSOLE_UNLOCK(); + if (!lock_fb_info(psDevInfo->psLINFBInfo)) + { + ret = -ENODEV; + } + else + { + OMAPLFB_CONSOLE_LOCK(); + psDevInfo->psLINFBInfo->flags |= FBINFO_MISC_USEREVENT; + ret = fb_blank(psDevInfo->psLINFBInfo, iFBMode); + psDevInfo->psLINFBInfo->flags &= ~FBINFO_MISC_USEREVENT; + OMAPLFB_CONSOLE_UNLOCK(); + unlock_fb_info(psDevInfo->psLINFBInfo); + } OMAPLFBCreateSwapChainUnLock(psDevInfo); diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/Kbuild.mk b/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/Kbuild.mk new file mode 100755 index 00000000000..57ef51829a2 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/Kbuild.mk @@ -0,0 +1,46 @@ +########################################################################### ### +#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +#@License Dual MIT/GPLv2 +# +# The contents of this file are subject to the MIT license as set out below. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 2 ("GPL") in which case the provisions +# of GPL are applicable instead of those above. +# +# If you wish to allow use of your version of this file only under the terms of +# GPL, and not to allow others to use your version of this file under the terms +# of the MIT license, indicate your decision by deleting the provisions above +# and replace them with the notice and other provisions required by GPL as set +# out in the file called "GPL-COPYING" included in this distribution. If you do +# not delete the provisions above, a recipient may use your version of this file +# under the terms of either the MIT license or GPL. +# +# This License is also included in this distribution in the file called +# "MIT-COPYING". +# +# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### ########################################################################### + +ccflags-y += \ + -I$(TOP)/services4/3rdparty/dc_sunxi \ + -Idrivers/video + +dc_sunxi-y += \ + services4/3rdparty/dc_sunxi/dc_sunxi_displayclass.o diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/Linux.mk b/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/Linux.mk new file mode 100755 index 00000000000..bcb63567b9b --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/Linux.mk @@ -0,0 +1,45 @@ +########################################################################### ### +#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +#@License Dual MIT/GPLv2 +# +# The contents of this file are subject to the MIT license as set out below. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 2 ("GPL") in which case the provisions +# of GPL are applicable instead of those above. +# +# If you wish to allow use of your version of this file only under the terms of +# GPL, and not to allow others to use your version of this file under the terms +# of the MIT license, indicate your decision by deleting the provisions above +# and replace them with the notice and other provisions required by GPL as set +# out in the file called "GPL-COPYING" included in this distribution. If you do +# not delete the provisions above, a recipient may use your version of this file +# under the terms of either the MIT license or GPL. +# +# This License is also included in this distribution in the file called +# "MIT-COPYING". +# +# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### ########################################################################### + +modules := dc_sunxi + +dc_sunxi_type := kernel_module +dc_sunxi_target := dc_sunxi.ko +dc_sunxi_makefile := $(THIS_DIR)/Kbuild.mk diff --git a/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/dc_sunxi_displayclass.c b/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/dc_sunxi_displayclass.c new file mode 100755 index 00000000000..6af20f6eadc --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/dc_sunxi/dc_sunxi_displayclass.c @@ -0,0 +1,1765 @@ +/*************************************************************************/ /*! +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/console.h> +#include <linux/fb.h> +#include <linux/module.h> +#include <linux/string.h> +#include <linux/notifier.h> + + +#if defined(SUPPORT_DRI_DRM) +#include <drm/drmP.h> +#endif + +/* IMG services headers */ +#include "img_defs.h" +#include "servicesext.h" +#include "kerneldisplay.h" +#include "linux/drv_display.h" + +#if defined(SUPPORT_DRI_DRM) +#include "pvr_drm.h" +#else +#include "pvrmodule.h" +#endif + +#define DC_SUNXI_COMMAND_COUNT 1 + +#define DC_SUNXI_VSYNC_SETTLE_COUNT 5 + +#define DC_SUNXI_MAX_NUM_DEVICES 1 + +//#define DC_SUNXI_DISPC_GRALLOC_QUEUE_IN_V1_PATH + +#if (DC_SUNXI_MAX_NUM_DEVICES > FB_MAX) +#error DC_SUNXI_MAX_NUM_DEVICES must not be greater than FB_MAX +#endif + +/* DEBUG only printk */ +#ifdef DEBUG +#define DEBUG_PRINTK(x) printk x +#else +#define DEBUG_PRINTK(x) +#endif + +#define DISPLAY_DEVICE_NAME "SUNXI Linux Display Driver" +#define DRVNAME "dc_sunxi" +#define DEVNAME DRVNAME +#define DRIVER_PREFIX DRVNAME + +#ifndef UNREFERENCED_PARAMETER +#define UNREFERENCED_PARAMETER(param) (param) = (param) +#endif + +#if !defined(SUPPORT_DRI_DRM) +MODULE_SUPPORTED_DEVICE(DEVNAME); +#endif + +/* DC_SUNXI buffer structure */ +typedef struct DC_SUNXI_BUFFER_TAG +{ + struct DC_SUNXI_BUFFER_TAG *psNext; + struct DC_SUNXI_DEVINFO_TAG *psDevInfo; + + struct work_struct sWork; + + /* Position of this buffer in the virtual framebuffer */ + unsigned long ulYOffset; + + /* IMG structures used, to minimise API function code */ + /* replace with own structures where necessary */ + IMG_SYS_PHYADDR sSysAddr; + IMG_CPU_VIRTADDR sCPUVAddr; + PVRSRV_SYNC_DATA *psSyncData; + + void *hCmdComplete; + unsigned long ulSwapInterval; + +} DC_SUNXI_BUFFER; + +/* DC_SUNXI swapchain structure */ +typedef struct DC_SUNXI_SWAPCHAIN_TAG +{ + /* Swap chain ID */ + unsigned int uiSwapChainID; + + /* number of buffers in swapchain */ + unsigned long ulBufferCount; + + /* list of buffers in the swapchain */ + DC_SUNXI_BUFFER *psBuffer; + + /* Swap chain work queue */ + struct workqueue_struct *psWorkQueue; + + /* + * Set if we didn't manage to wait for VSync on last swap, + * or if we think we need to wait for VSync on the next flip. + * The flag helps to avoid jitter when the screen is + * unblanked, by forcing an extended wait for VSync before + * attempting the next flip. + */ + bool bNotVSynced; + + /* Framebuffer Device ID for messages (e.g. printk) */ + unsigned int uiFBDevID; + +} DC_SUNXI_SWAPCHAIN; + +typedef struct DC_SUNXI_FBINFO_TAG +{ + unsigned long ulFBSize; + unsigned long ulBufferSize; + unsigned long ulRoundedBufferSize; + unsigned long ulWidth; + unsigned long ulHeight; + unsigned long ulByteStride; + unsigned long ulPhysicalWidthmm; + unsigned long ulPhysicalHeightmm; + + /* IMG structures used, to minimise API function code */ + /* replace with own structures where necessary */ + IMG_SYS_PHYADDR sSysAddr; + IMG_CPU_VIRTADDR sCPUVAddr; + + /* pixelformat of system/primary surface */ + PVRSRV_PIXEL_FORMAT ePixelFormat; + +} DC_SUNXI_FBINFO; + +/* kernel device information structure */ +typedef struct DC_SUNXI_DEVINFO_TAG +{ + /* Framebuffer Device ID */ + unsigned int uiFBDevID; + + /* PVR Device ID */ + unsigned int uiPVRDevID; + + /* Swapchain create/destroy mutex */ + struct mutex sCreateSwapChainMutex; + + /* system surface info */ + DC_SUNXI_BUFFER sSystemBuffer; + + /* jump table into PVR services */ + PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable; + + /* jump table into DC */ + PVRSRV_DC_SRV2DISP_KMJTABLE sDCJTable; + + /* fb info structure */ + DC_SUNXI_FBINFO sFBInfo; + + /* Only one swapchain supported by this device so hang it here */ + DC_SUNXI_SWAPCHAIN *psSwapChain; + + /* Swap chain ID */ + unsigned int uiSwapChainID; + + /* True if PVR Services is flushing its command queues */ + atomic_t sFlushCommands; + + /* pointer to linux frame buffer information structure */ + struct fb_info *psLINFBInfo; + + /* IMG structures used, to minimise API function code */ + /* replace with own structures where necessary */ + + DISPLAY_INFO sDisplayInfo; + + /* Display format */ + DISPLAY_FORMAT sDisplayFormat; + + /* Display dimensions */ + DISPLAY_DIMS sDisplayDim; + + /* Number of blank/unblank events */ + atomic_t sBlankEvents; + +} DC_SUNXI_DEVINFO; + +typedef enum _DC_SUNXI_ERROR_ +{ + DC_SUNXI_OK = 0, + DC_SUNXI_ERROR_GENERIC = 1, + DC_SUNXI_ERROR_INIT_FAILURE = 2, + DC_SUNXI_ERROR_INVALID_DEVICE = 3, + +} DC_SUNXI_ERROR; + +static DC_SUNXI_DEVINFO *gapsDevInfo[DC_SUNXI_MAX_NUM_DEVICES]; + +/* Top level 'hook ptr' */ +static PFN_DC_GET_PVRJTABLE gpfnGetPVRJTable; + +/* Don't wait for vertical sync */ +static inline bool DontWaitForVSync(DC_SUNXI_DEVINFO *psDevInfo) +{ + return atomic_read(&psDevInfo->sFlushCommands); +} + +/* + * Called after the screen has unblanked, or after any other occasion + * when we didn't wait for vsync, but now need to. Not doing this after + * unblank leads to screen jitter on some screens. + * Returns true if the screen has been deemed to have settled. + */ +static bool WaitForVSyncSettle(DC_SUNXI_DEVINFO *psDevInfo) +{ + unsigned int i; + for(i = 0; i < DC_SUNXI_VSYNC_SETTLE_COUNT; i++) + { + if (DontWaitForVSync(psDevInfo)) + { + return false; + } + } + + return true; +} + +/* Flip display to given buffer */ +static void DC_SUNXIFlip(DC_SUNXI_DEVINFO *psDevInfo, DC_SUNXI_BUFFER *psBuffer) +{ + struct fb_var_screeninfo sFBVar; + unsigned long ulYResVirtual; + int res; + + console_lock(); + + sFBVar = psDevInfo->psLINFBInfo->var; + + sFBVar.xoffset = 0; + sFBVar.yoffset = psBuffer->ulYOffset; + + ulYResVirtual = psBuffer->ulYOffset + sFBVar.yres; + + res = fb_pan_display(psDevInfo->psLINFBInfo, &sFBVar); + if (res != 0) + { + printk(KERN_ERR DRIVER_PREFIX ": %s: Device %u: fb_pan_display failed (Y Offset: %lu, Error: %d)\n", __FUNCTION__, psDevInfo->uiFBDevID, psBuffer->ulYOffset, res); + } + + console_unlock(); +} + +/* + * Swap handler. + * Called from the swap chain work queue handler. + * There is no need to take the swap chain creation lock in here, or use + * some other method of stopping the swap chain from being destroyed. + * This is because the swap chain creation lock is taken when queueing work, + * and the work queue is flushed before the swap chain is destroyed. + */ +static void DC_SUNXISwapHandler(DC_SUNXI_BUFFER *psBuffer) +{ + DC_SUNXI_DEVINFO *psDevInfo = psBuffer->psDevInfo; + DC_SUNXI_SWAPCHAIN *psSwapChain = psDevInfo->psSwapChain; + bool bPreviouslyNotVSynced; + + DC_SUNXIFlip(psDevInfo, psBuffer); + + bPreviouslyNotVSynced = psSwapChain->bNotVSynced; + psSwapChain->bNotVSynced = true; + + if (!DontWaitForVSync(psDevInfo)) + { + psSwapChain->bNotVSynced = false; + + if (bPreviouslyNotVSynced) + { + psSwapChain->bNotVSynced = !WaitForVSyncSettle(psDevInfo); + } + else if (psBuffer->ulSwapInterval != 0) + { + psSwapChain->bNotVSynced = IMG_FALSE; + } + } + + psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete((IMG_HANDLE)psBuffer->hCmdComplete, IMG_TRUE); +} + +/* Process an item on a swap chain work queue */ +static void WorkQueueHandler(struct work_struct *psWork) +{ + DC_SUNXI_BUFFER *psBuffer = container_of(psWork, DC_SUNXI_BUFFER, sWork); + + DC_SUNXISwapHandler(psBuffer); +} + +/* Create a swap chain work queue */ +static DC_SUNXI_ERROR DC_SUNXICreateSwapQueue(DC_SUNXI_SWAPCHAIN *psSwapChain) +{ + /* + * Calling alloc_ordered_workqueue with the WQ_FREEZABLE and + * WQ_MEM_RECLAIM flags set, (currently) has the same effect as + * calling create_freezable_workqueue. None of the other WQ + * flags are valid. Setting WQ_MEM_RECLAIM should allow the + * workqueue to continue to service the swap chain in low memory + * conditions, preventing the driver from holding on to + * resources longer than it needs to. + */ + psSwapChain->psWorkQueue = alloc_ordered_workqueue(DEVNAME, WQ_FREEZABLE | WQ_MEM_RECLAIM); + if (psSwapChain->psWorkQueue == NULL) + { + printk(KERN_ERR DRIVER_PREFIX ": %s: Device %u: Couldn't create workqueue\n", __FUNCTION__, psSwapChain->uiFBDevID); + + return (DC_SUNXI_ERROR_INIT_FAILURE); + } + + return (DC_SUNXI_OK); +} + +/* Prepare buffer for insertion into a swap chain work queue */ +static void DC_SUNXIInitBufferForSwap(DC_SUNXI_BUFFER *psBuffer) +{ + INIT_WORK(&psBuffer->sWork, WorkQueueHandler); +} + +/* Destroy a swap chain work queue */ +static void DC_SUNXIDestroySwapQueue(DC_SUNXI_SWAPCHAIN *psSwapChain) +{ + destroy_workqueue(psSwapChain->psWorkQueue); +} + +/* Unblank the screen */ +static DC_SUNXI_ERROR DC_SUNXIUnblankDisplay(DC_SUNXI_DEVINFO *psDevInfo) +{ + int res; + + console_lock(); + res = fb_blank(psDevInfo->psLINFBInfo, 0); + console_unlock(); + + if (res != 0 && res != -EINVAL) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: fb_blank failed (%d)\n", __FUNCTION__, psDevInfo->uiFBDevID, res); + return (DC_SUNXI_ERROR_GENERIC); + } + + return (DC_SUNXI_OK); +} + +/* Round x up to a multiple of y */ +static inline unsigned long RoundUpToMultiple(unsigned long x, unsigned long y) +{ + unsigned long div = x / y; + unsigned long rem = x % y; + + return (div + ((rem == 0) ? 0 : 1)) * y; +} + +/* Greatest common divisor of x and y */ +static unsigned long GCD(unsigned long x, unsigned long y) +{ + while (y != 0) + { + unsigned long r = x % y; + x = y; + y = r; + } + + return x; +} + +/* Least common multiple of x and y */ +static unsigned long LCM(unsigned long x, unsigned long y) +{ + unsigned long gcd = GCD(x, y); + + return (gcd == 0) ? 0 : ((x / gcd) * y); +} + +static unsigned DC_SUNXIMaxFBDevIDPlusOne(void) +{ + return DC_SUNXI_MAX_NUM_DEVICES; +} + +/* Returns DevInfo pointer for a given device */ +static DC_SUNXI_DEVINFO *DC_SUNXIGetDevInfoPtr(unsigned uiFBDevID) +{ + WARN_ON(uiFBDevID >= DC_SUNXIMaxFBDevIDPlusOne()); + + if (uiFBDevID >= DC_SUNXI_MAX_NUM_DEVICES) + { + return NULL; + } + + return gapsDevInfo[uiFBDevID]; +} + +/* Sets the DevInfo pointer for a given device */ +static inline void DC_SUNXISetDevInfoPtr(unsigned uiFBDevID, DC_SUNXI_DEVINFO *psDevInfo) +{ + WARN_ON(uiFBDevID >= DC_SUNXI_MAX_NUM_DEVICES); + + if (uiFBDevID < DC_SUNXI_MAX_NUM_DEVICES) + { + gapsDevInfo[uiFBDevID] = psDevInfo; + } +} + +static inline bool SwapChainHasChanged(DC_SUNXI_DEVINFO *psDevInfo, DC_SUNXI_SWAPCHAIN *psSwapChain) +{ + return (psDevInfo->psSwapChain != psSwapChain) || + (psDevInfo->uiSwapChainID != psSwapChain->uiSwapChainID); +} + +extern int dispc_gralloc_queue(setup_dispc_data_t *psDispcData, int ui32DispcDataLength, void (*cb_fn)(void *, int), void *cb_arg); + +static void +QueueBufferImmediate(DC_SUNXI_DEVINFO *psDevInfo, IMG_SYS_PHYADDR sSysAddr, + void (*cb_fn)(void *, int), void *cb_arg) +{ + setup_dispc_data_t sDispcData = + { + .post2_layers = 1, + .primary_display_layer_num = 1, + .layer_info = + { + [0] = + { + .mode = DISP_LAYER_WORK_MODE_NORMAL, + .src_win = + { + .width = psDevInfo->sFBInfo.ulWidth, + .height = psDevInfo->sFBInfo.ulHeight + }, + .scn_win = + { + .width = psDevInfo->sFBInfo.ulWidth, + .height = psDevInfo->sFBInfo.ulHeight + }, + .alpha_en = 1, + .alpha_val = 0xff, + .fb = + { + .mode = DISP_MOD_INTERLEAVED, + .format = DISP_FORMAT_ARGB8888, + .seq = DISP_SEQ_ARGB, + .pre_multiply = 1, + .size = + { + .width = psDevInfo->sFBInfo.ulWidth, + .height = psDevInfo->sFBInfo.ulHeight + }, + .addr[0] = sSysAddr.uiAddr, + }, + }, + }, + }; + + dispc_gralloc_queue(&sDispcData, sizeof(setup_dispc_data_t), cb_fn, cb_arg); +} + +static void dispc_proxy_cmdcomplete(void * cookie, int i) +{ + /* Workaround for bug in sunxi kernel, where it uses the latest cb_fn + * with older cb_arg (they should be used as a pair). + */ + if (cookie == (void *)0xdeadbeef) + return; + + /* XXX: assumes that there is only one display */ + gapsDevInfo[0]->sPVRJTable.pfnPVRSRVCmdComplete(cookie, i); +} + +/* + * SetDCState + * Called from services. + */ +static IMG_VOID SetDCState(IMG_HANDLE hDevice, IMG_UINT32 ui32State) +{ + DC_SUNXI_DEVINFO *psDevInfo = (DC_SUNXI_DEVINFO *)hDevice; + + switch (ui32State) + { + case DC_STATE_FLUSH_COMMANDS: + /* Flush out any 'real' operation waiting for another flip. + * In flush state we won't pass any 'real' operations along + * to dispc_gralloc_queue(); we'll just CmdComplete them + * immediately. + */ + QueueBufferImmediate(psDevInfo, psDevInfo->sSystemBuffer.sSysAddr, + dispc_proxy_cmdcomplete, (void *)0xdeadbeef); + atomic_set(&psDevInfo->sFlushCommands, true); + break; + case DC_STATE_NO_FLUSH_COMMANDS: + atomic_set(&psDevInfo->sFlushCommands, false); + break; + default: + break; + } +} + +/* + * OpenDCDevice + * Called from services. + */ +static PVRSRV_ERROR OpenDCDevice(IMG_UINT32 uiPVRDevID, + IMG_HANDLE *phDevice, + PVRSRV_SYNC_DATA* psSystemBufferSyncData) +{ + DC_SUNXI_DEVINFO *psDevInfo; + DC_SUNXI_ERROR eError; + unsigned int i, uiMaxFBDevIDPlusOne; + + if (!try_module_get(THIS_MODULE)) + { + return PVRSRV_ERROR_UNABLE_TO_OPEN_DC_DEVICE; + } + + uiMaxFBDevIDPlusOne = DC_SUNXIMaxFBDevIDPlusOne(); + + for (i = 0; i < uiMaxFBDevIDPlusOne; i++) + { + psDevInfo = DC_SUNXIGetDevInfoPtr(i); + if (psDevInfo != NULL && psDevInfo->uiPVRDevID == uiPVRDevID) + { + break; + } + } + + if (i == uiMaxFBDevIDPlusOne) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX + ": %s: PVR Device %u not found\n", __FUNCTION__, uiPVRDevID)); + eError = PVRSRV_ERROR_INVALID_DEVICE; + goto ErrorModulePut; + } + + /* store the system surface sync data */ + psDevInfo->sSystemBuffer.psSyncData = psSystemBufferSyncData; + + eError = DC_SUNXIUnblankDisplay(psDevInfo); + if (eError != DC_SUNXI_OK) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: DC_SUNXIUnblankDisplay failed (%d)\n", __FUNCTION__, psDevInfo->uiFBDevID, eError)); + eError = PVRSRV_ERROR_UNBLANK_DISPLAY_FAILED; + goto ErrorModulePut; + } + + /* return handle to the devinfo */ + *phDevice = (IMG_HANDLE)psDevInfo; + + return PVRSRV_OK; + +ErrorModulePut: + module_put(THIS_MODULE); + + return eError; +} + +/* + * CloseDCDevice + * Called from services. + */ +static PVRSRV_ERROR CloseDCDevice(IMG_HANDLE hDevice) +{ + UNREFERENCED_PARAMETER(hDevice); + + module_put(THIS_MODULE); + + return PVRSRV_OK; +} + +/* + * EnumDCFormats + * Called from services. + */ +static PVRSRV_ERROR EnumDCFormats(IMG_HANDLE hDevice, + IMG_UINT32 *pui32NumFormats, + DISPLAY_FORMAT *psFormat) +{ + DC_SUNXI_DEVINFO *psDevInfo; + + if(!hDevice || !pui32NumFormats) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + + *pui32NumFormats = 1; + + if(psFormat) + { + psFormat[0] = psDevInfo->sDisplayFormat; + } + + return PVRSRV_OK; +} + +/* + * EnumDCDims + * Called from services. + */ +static PVRSRV_ERROR EnumDCDims(IMG_HANDLE hDevice, + DISPLAY_FORMAT *psFormat, + IMG_UINT32 *pui32NumDims, + DISPLAY_DIMS *psDim) +{ + DC_SUNXI_DEVINFO *psDevInfo; + + if(!hDevice || !psFormat || !pui32NumDims) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + + *pui32NumDims = 1; + + /* No need to look at psFormat; there is only one */ + if(psDim) + { + psDim[0] = psDevInfo->sDisplayDim; + } + + return PVRSRV_OK; +} + + +/* + * GetDCSystemBuffer + * Called from services. + */ +static PVRSRV_ERROR GetDCSystemBuffer(IMG_HANDLE hDevice, IMG_HANDLE *phBuffer) +{ + DC_SUNXI_DEVINFO *psDevInfo; + + if(!hDevice || !phBuffer) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + + *phBuffer = (IMG_HANDLE)&psDevInfo->sSystemBuffer; + + return PVRSRV_OK; +} + + +/* + * GetDCInfo + * Called from services. + */ +static PVRSRV_ERROR GetDCInfo(IMG_HANDLE hDevice, DISPLAY_INFO *psDCInfo) +{ + DC_SUNXI_DEVINFO *psDevInfo; + + if(!hDevice || !psDCInfo) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + + *psDCInfo = psDevInfo->sDisplayInfo; + + return PVRSRV_OK; +} + +/* + * GetDCBufferAddr + * Called from services. + */ +static PVRSRV_ERROR GetDCBufferAddr(IMG_HANDLE hDevice, + IMG_HANDLE hBuffer, + IMG_SYS_PHYADDR **ppsSysAddr, + IMG_UINT32 *pui32ByteSize, + IMG_VOID **ppvCpuVAddr, + IMG_HANDLE *phOSMapInfo, + IMG_BOOL *pbIsContiguous, + IMG_UINT32 *pui32TilingStride) +{ + DC_SUNXI_DEVINFO *psDevInfo; + DC_SUNXI_BUFFER *psSystemBuffer; + + UNREFERENCED_PARAMETER(pui32TilingStride); + + if(!hDevice) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if(!hBuffer) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if (!ppsSysAddr) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if (!pui32ByteSize) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + + psSystemBuffer = (DC_SUNXI_BUFFER *)hBuffer; + + *ppsSysAddr = &psSystemBuffer->sSysAddr; + + *pui32ByteSize = (IMG_UINT32)psDevInfo->sFBInfo.ulBufferSize; + + if (ppvCpuVAddr) + { + *ppvCpuVAddr = psSystemBuffer->sCPUVAddr; + } + + if (phOSMapInfo) + { + *phOSMapInfo = (IMG_HANDLE)0; + } + + if (pbIsContiguous) + { + *pbIsContiguous = IMG_TRUE; + } + + return PVRSRV_OK; +} + +/* + * CreateDCSwapChain + * Called from services. + */ +static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, + IMG_UINT32 ui32Flags, + DISPLAY_SURF_ATTRIBUTES *psDstSurfAttrib, + DISPLAY_SURF_ATTRIBUTES *psSrcSurfAttrib, + IMG_UINT32 ui32BufferCount, + PVRSRV_SYNC_DATA **ppsSyncData, + IMG_UINT32 ui32OEMFlags, + IMG_HANDLE *phSwapChain, + IMG_UINT32 *pui32SwapChainID) +{ + DC_SUNXI_SWAPCHAIN *psSwapChain; + DC_SUNXI_DEVINFO *psDevInfo; + PVRSRV_ERROR eError; + IMG_UINT32 i; + + UNREFERENCED_PARAMETER(ui32OEMFlags); + UNREFERENCED_PARAMETER(ui32Flags); + + /* Check parameters */ + if(!hDevice + || !psDstSurfAttrib + || !psSrcSurfAttrib + || !ppsSyncData + || !phSwapChain) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + + /* Do we support swap chains? */ + if (psDevInfo->sDisplayInfo.ui32MaxSwapChains == 0) + { + return PVRSRV_ERROR_NOT_SUPPORTED; + } + + mutex_lock(&psDevInfo->sCreateSwapChainMutex); + + /* The driver only supports a single swapchain */ + if(psDevInfo->psSwapChain != NULL) + { + eError = PVRSRV_ERROR_FLIP_CHAIN_EXISTS; + goto ExitUnLock; + } + + /* create a swapchain structure */ + psSwapChain = (DC_SUNXI_SWAPCHAIN*)kmalloc(sizeof(DC_SUNXI_SWAPCHAIN), GFP_KERNEL); + if(!psSwapChain) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + goto ExitUnLock; + } + + /* If services asks for a 0-length swap chain, it's probably Android. + * + * This will use only non-display memory posting via PVRSRVSwapToDCBuffers2(), + * and we can skip some useless sanity checking. + */ + if(ui32BufferCount > 0) + { + IMG_UINT32 ui32BuffersToSkip; + + /* Check the buffer count */ + if(ui32BufferCount > psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers) + { + eError = PVRSRV_ERROR_TOOMANYBUFFERS; + goto ErrorFreeSwapChain; + } + + if ((psDevInfo->sFBInfo.ulRoundedBufferSize * (unsigned long)ui32BufferCount) > psDevInfo->sFBInfo.ulFBSize) + { + eError = PVRSRV_ERROR_TOOMANYBUFFERS; + goto ErrorFreeSwapChain; + } + + /* + * We will allocate the swap chain buffers at the back of the frame + * buffer area. This preserves the front portion, which may be being + * used by other Linux Framebuffer based applications. + */ + ui32BuffersToSkip = psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers - ui32BufferCount; + + /* + * Verify the DST/SRC attributes, + * SRC/DST must match the current display mode config + */ + if(psDstSurfAttrib->pixelformat != psDevInfo->sDisplayFormat.pixelformat + || psDstSurfAttrib->sDims.ui32ByteStride != psDevInfo->sDisplayDim.ui32ByteStride + || psDstSurfAttrib->sDims.ui32Width != psDevInfo->sDisplayDim.ui32Width + || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sDisplayDim.ui32Height) + { + /* DST doesn't match the current mode */ + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto ErrorFreeSwapChain; + } + + if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat + || psDstSurfAttrib->sDims.ui32ByteStride != psSrcSurfAttrib->sDims.ui32ByteStride + || psDstSurfAttrib->sDims.ui32Width != psSrcSurfAttrib->sDims.ui32Width + || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) + { + /* DST doesn't match the SRC */ + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto ErrorFreeSwapChain; + } + + psSwapChain->psBuffer = (DC_SUNXI_BUFFER*)kmalloc(sizeof(DC_SUNXI_BUFFER) * ui32BufferCount, GFP_KERNEL); + if(!psSwapChain->psBuffer) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + goto ErrorFreeSwapChain; + } + + /* Link the buffers */ + for(i = 0; i < ui32BufferCount - 1; i++) + { + psSwapChain->psBuffer[i].psNext = &psSwapChain->psBuffer[i + 1]; + } + + /* and link last to first */ + psSwapChain->psBuffer[i].psNext = &psSwapChain->psBuffer[0]; + + /* Configure the swapchain buffers */ + for(i = 0; i < ui32BufferCount; i++) + { + IMG_UINT32 ui32SwapBuffer = i + ui32BuffersToSkip; + IMG_UINT32 ui32BufferOffset = ui32SwapBuffer * (IMG_UINT32)psDevInfo->sFBInfo.ulRoundedBufferSize; + + psSwapChain->psBuffer[i].psSyncData = ppsSyncData[i]; + + psSwapChain->psBuffer[i].sSysAddr.uiAddr = psDevInfo->sFBInfo.sSysAddr.uiAddr + ui32BufferOffset; + psSwapChain->psBuffer[i].sCPUVAddr = psDevInfo->sFBInfo.sCPUVAddr + ui32BufferOffset; + psSwapChain->psBuffer[i].ulYOffset = ui32BufferOffset / psDevInfo->sFBInfo.ulByteStride; + psSwapChain->psBuffer[i].psDevInfo = psDevInfo; + + DC_SUNXIInitBufferForSwap(&psSwapChain->psBuffer[i]); + } + } + else + { + psSwapChain->psBuffer = NULL; + } + + psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; + psSwapChain->bNotVSynced = true; + psSwapChain->uiFBDevID = psDevInfo->uiFBDevID; + + if (DC_SUNXICreateSwapQueue(psSwapChain) != DC_SUNXI_OK) + { + printk(KERN_WARNING DRIVER_PREFIX ": %s: Device %u: Failed to create workqueue\n", __FUNCTION__, psDevInfo->uiFBDevID); + eError = PVRSRV_ERROR_UNABLE_TO_INSTALL_ISR; + goto ErrorFreeBuffers; + } + + psDevInfo->uiSwapChainID++; + if (psDevInfo->uiSwapChainID == 0) + { + psDevInfo->uiSwapChainID++; + } + + psSwapChain->uiSwapChainID = psDevInfo->uiSwapChainID; + + psDevInfo->psSwapChain = psSwapChain; + + *pui32SwapChainID = psDevInfo->uiSwapChainID; + + *phSwapChain = (IMG_HANDLE)psSwapChain; + + eError = PVRSRV_OK; + goto ExitUnLock; + +ErrorFreeBuffers: + if(psSwapChain->psBuffer) + { + kfree(psSwapChain->psBuffer); + } +ErrorFreeSwapChain: + kfree(psSwapChain); +ExitUnLock: + mutex_unlock(&psDevInfo->sCreateSwapChainMutex); + return eError; +} + +/* + * DestroyDCSwapChain + * Called from services. + */ +static PVRSRV_ERROR DestroyDCSwapChain(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain) +{ + DC_SUNXI_DEVINFO *psDevInfo; + DC_SUNXI_SWAPCHAIN *psSwapChain; + DC_SUNXI_ERROR eError; + + /* Check parameters */ + if(!hDevice || !hSwapChain) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + psSwapChain = (DC_SUNXI_SWAPCHAIN*)hSwapChain; + + mutex_lock(&psDevInfo->sCreateSwapChainMutex); + + if (SwapChainHasChanged(psDevInfo, psSwapChain)) + { + printk(KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: Swap chain mismatch\n", __FUNCTION__, psDevInfo->uiFBDevID); + + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto ExitUnLock; + } + + /* The swap queue is flushed before being destroyed */ + DC_SUNXIDestroySwapQueue(psSwapChain); + + /* Free resources */ + if (psSwapChain->psBuffer) + { + kfree(psSwapChain->psBuffer); + } + kfree(psSwapChain); + + psDevInfo->psSwapChain = NULL; + + DC_SUNXIFlip(psDevInfo, &psDevInfo->sSystemBuffer); + + eError = PVRSRV_OK; + +ExitUnLock: + mutex_unlock(&psDevInfo->sCreateSwapChainMutex); + return eError; +} + +/* + * SetDCDstRect + * Called from services. + */ +static PVRSRV_ERROR SetDCDstRect(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain, + IMG_RECT *psRect) +{ + UNREFERENCED_PARAMETER(hDevice); + UNREFERENCED_PARAMETER(hSwapChain); + UNREFERENCED_PARAMETER(psRect); + + /* Only full display swapchains on this device */ + + return PVRSRV_ERROR_NOT_SUPPORTED; +} + +/* + * SetDCSrcRect + * Called from services. + */ +static PVRSRV_ERROR SetDCSrcRect(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain, + IMG_RECT *psRect) +{ + UNREFERENCED_PARAMETER(hDevice); + UNREFERENCED_PARAMETER(hSwapChain); + UNREFERENCED_PARAMETER(psRect); + + /* Only full display swapchains on this device */ + + return PVRSRV_ERROR_NOT_SUPPORTED; +} + +/* + * SetDCDstColourKey + * Called from services. + */ +static PVRSRV_ERROR SetDCDstColourKey(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain, + IMG_UINT32 ui32CKColour) +{ + UNREFERENCED_PARAMETER(hDevice); + UNREFERENCED_PARAMETER(hSwapChain); + UNREFERENCED_PARAMETER(ui32CKColour); + + /* Don't support DST CK on this device */ + + return PVRSRV_ERROR_NOT_SUPPORTED; +} + +/* + * SetDCSrcColourKey + * Called from services. + */ +static PVRSRV_ERROR SetDCSrcColourKey(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain, + IMG_UINT32 ui32CKColour) +{ + UNREFERENCED_PARAMETER(hDevice); + UNREFERENCED_PARAMETER(hSwapChain); + UNREFERENCED_PARAMETER(ui32CKColour); + + /* Don't support SRC CK on this device */ + + return PVRSRV_ERROR_NOT_SUPPORTED; +} + +/* + * GetDCBuffers + * Called from services. + */ +static PVRSRV_ERROR GetDCBuffers(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain, + IMG_UINT32 *pui32BufferCount, + IMG_HANDLE *phBuffer) +{ + DC_SUNXI_DEVINFO *psDevInfo; + DC_SUNXI_SWAPCHAIN *psSwapChain; + PVRSRV_ERROR eError; + unsigned int i; + + /* Check parameters */ + if(!hDevice + || !hSwapChain + || !pui32BufferCount + || !phBuffer) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)hDevice; + psSwapChain = (DC_SUNXI_SWAPCHAIN*)hSwapChain; + + mutex_lock(&psDevInfo->sCreateSwapChainMutex); + + if (SwapChainHasChanged(psDevInfo, psSwapChain)) + { + printk(KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: Swap chain mismatch\n", __FUNCTION__, psDevInfo->uiFBDevID); + + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto Exit; + } + + /* Return the buffer count */ + *pui32BufferCount = (IMG_UINT32)psSwapChain->ulBufferCount; + + /* Return the buffers */ + for(i=0; i<psSwapChain->ulBufferCount; i++) + { + phBuffer[i] = (IMG_HANDLE)&psSwapChain->psBuffer[i]; + } + + eError = PVRSRV_OK; + +Exit: + mutex_unlock(&psDevInfo->sCreateSwapChainMutex); + return eError; +} + +/* + * SwapToDCBuffer + * Called from services. + */ +static PVRSRV_ERROR SwapToDCBuffer(IMG_HANDLE hDevice, + IMG_HANDLE hBuffer, + IMG_UINT32 ui32SwapInterval, + IMG_HANDLE hPrivateTag, + IMG_UINT32 ui32ClipRectCount, + IMG_RECT *psClipRect) +{ + UNREFERENCED_PARAMETER(hDevice); + UNREFERENCED_PARAMETER(hBuffer); + UNREFERENCED_PARAMETER(ui32SwapInterval); + UNREFERENCED_PARAMETER(hPrivateTag); + UNREFERENCED_PARAMETER(ui32ClipRectCount); + UNREFERENCED_PARAMETER(psClipRect); + + /* * Nothing to do since Services common code does the work */ + + return PVRSRV_OK; +} + +/* Triggered by PVRSRVSwapToDCBuffer */ +static IMG_BOOL ProcessFlipV1(IMG_HANDLE hCmdCookie, + DC_SUNXI_DEVINFO *psDevInfo, + DC_SUNXI_SWAPCHAIN *psSwapChain, + DC_SUNXI_BUFFER *psBuffer, + unsigned long ulSwapInterval) +{ + mutex_lock(&psDevInfo->sCreateSwapChainMutex); + + /* The swap chain has been destroyed */ + if (SwapChainHasChanged(psDevInfo, psSwapChain)) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX + ": %s: Device %u (PVR Device ID %u): The swap chain has been destroyed\n", + __FUNCTION__, psDevInfo->uiFBDevID, psDevInfo->uiPVRDevID)); + } + else + { +#if defined(DC_SUNXI_DISPC_GRALLOC_QUEUE_IN_V1_PATH) + /* Not enabled by default yet until we have a way to CmdComplete + * after vblank rather than after next programming! + */ + QueueBufferImmediate(psDevInfo, psBuffer->sSysAddr, + dispc_proxy_cmdcomplete, (void *)0xdeadbeef); + + /* When dispc_gralloc_queue() can call back after programming, + * this can be removed. + */ + psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); +#else /* DC_SUNXI_DISPC_GRALLOC_QUEUE_IN_V1_PATH */ + int res; + + psBuffer->hCmdComplete = hCmdCookie; + psBuffer->ulSwapInterval = ulSwapInterval; + + res = queue_work(psSwapChain->psWorkQueue, &psBuffer->sWork); + if (res == 0) + { + printk(KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: Buffer already on work queue\n", + __FUNCTION__, psSwapChain->uiFBDevID); + } +#endif /* DC_SUNXI_DISPC_GRALLOC_QUEUE_IN_V1_PATH */ + } + + mutex_unlock(&psDevInfo->sCreateSwapChainMutex); + return IMG_TRUE; +} + +static IMG_BOOL ProcessFlipV2(IMG_HANDLE hCmdCookie, + DC_SUNXI_DEVINFO *psDevInfo, + PDC_MEM_INFO *ppsMemInfos, + IMG_UINT32 ui32NumMemInfos, + setup_dispc_data_t *psDispcData, + IMG_UINT32 ui32DispcDataLength) +{ + int i; + + if(!psDispcData) + { + if(ui32NumMemInfos == 1) + { + IMG_CPU_PHYADDR phyAddr; + IMG_SYS_PHYADDR sSysAddr; + + psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[0], 0, &phyAddr); + sSysAddr.uiAddr = phyAddr.uiAddr; + + /* If we got a meminfo but no private data, assume the 'null' HWC + * backend is in use, and emulate a swapchain-less ProcessFlipV1. + */ + QueueBufferImmediate(psDevInfo, sSysAddr, + dispc_proxy_cmdcomplete, hCmdCookie); + } + else + { + printk(KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: WARNING: psDispcData was NULL. " + "The HWC probably has a bug. Silently ignoring.", + __FUNCTION__, psDevInfo->uiFBDevID); + gapsDevInfo[0]->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); + } + + return IMG_TRUE; + } + + if(ui32DispcDataLength != sizeof(setup_dispc_data_t)) + { + printk(KERN_WARNING DRIVER_PREFIX + ": %s: Device %u: WARNING: Unexpected private data size, %u vs %u.", + __FUNCTION__, psDevInfo->uiFBDevID, ui32DispcDataLength, + sizeof(setup_dispc_data_t)); + gapsDevInfo[0]->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); + return IMG_TRUE; + } + + if(DontWaitForVSync(psDevInfo)) + { + gapsDevInfo[0]->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_TRUE); + return IMG_TRUE; + } + + /* Maximum of 8 layer_infos. Meminfo array is dynamically sized */ + for(i = 0; i < ui32NumMemInfos && i < 8; i++) + { + IMG_CPU_PHYADDR phyAddr; + + psDevInfo->sPVRJTable.pfnPVRSRVDCMemInfoGetCpuPAddr(ppsMemInfos[i], 0, &phyAddr); + + psDispcData->layer_info[i].fb.addr[0] = phyAddr.uiAddr; + } + + dispc_gralloc_queue(psDispcData, ui32DispcDataLength, dispc_proxy_cmdcomplete, (void *)hCmdCookie); + + return IMG_TRUE; +} + +/* Command processing flip handler function. Called from services. */ +static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, + IMG_UINT32 ui32DataSize, + IMG_VOID *pvData) +{ + DISPLAYCLASS_FLIP_COMMAND *psFlipCmd; + DC_SUNXI_DEVINFO *psDevInfo; + + /* Check parameters */ + if(!hCmdCookie || !pvData) + { + return IMG_FALSE; + } + + /* Validate data packet */ + psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND*)pvData; + + if (psFlipCmd == IMG_NULL) + { + return IMG_FALSE; + } + + psDevInfo = (DC_SUNXI_DEVINFO*)psFlipCmd->hExtDevice; + + if(psFlipCmd->hExtBuffer) + { + return ProcessFlipV1(hCmdCookie, + psDevInfo, + psFlipCmd->hExtSwapChain, + psFlipCmd->hExtBuffer, + psFlipCmd->ui32SwapInterval); + } + else + { + DISPLAYCLASS_FLIP_COMMAND2 *psFlipCmd2; + psFlipCmd2 = (DISPLAYCLASS_FLIP_COMMAND2 *)pvData; + return ProcessFlipV2(hCmdCookie, + psDevInfo, + psFlipCmd2->ppsMemInfos, + psFlipCmd2->ui32NumMemInfos, + psFlipCmd2->pvPrivData, + psFlipCmd2->ui32PrivDataLength); + } +} + +static DC_SUNXI_ERROR DC_SUNXIInitFBDev(DC_SUNXI_DEVINFO *psDevInfo) +{ + struct fb_info *psLINFBInfo; + struct module *psLINFBOwner; + DC_SUNXI_FBINFO *psPVRFBInfo = &psDevInfo->sFBInfo; + DC_SUNXI_ERROR eError = DC_SUNXI_ERROR_GENERIC; + unsigned int uiFBDevID = psDevInfo->uiFBDevID; + + console_lock(); + + psLINFBInfo = registered_fb[uiFBDevID]; + if (psLINFBInfo == NULL) + { + eError = DC_SUNXI_ERROR_INVALID_DEVICE; + goto ErrorRelSem; + } + + psLINFBOwner = psLINFBInfo->fbops->owner; + if (!try_module_get(psLINFBOwner)) + { + printk(KERN_INFO DRIVER_PREFIX + ": %s: Device %u: Couldn't get framebuffer module\n", __FUNCTION__, uiFBDevID); + + goto ErrorRelSem; + } + + if (psLINFBInfo->fbops->fb_open != NULL) + { + int res; + + res = psLINFBInfo->fbops->fb_open(psLINFBInfo, 0); + if (res != 0) + { + printk(KERN_INFO DRIVER_PREFIX + " %s: Device %u: Couldn't open framebuffer(%d)\n", __FUNCTION__, uiFBDevID, res); + + goto ErrorModPut; + } + } + + psDevInfo->psLINFBInfo = psLINFBInfo; + + psPVRFBInfo->ulWidth = psLINFBInfo->var.xres; + psPVRFBInfo->ulHeight = psLINFBInfo->var.yres; + + if (psPVRFBInfo->ulWidth == 0 || psPVRFBInfo->ulHeight == 0) + { + eError = DC_SUNXI_ERROR_INVALID_DEVICE; + goto ErrorFBRel; + } + + psPVRFBInfo->ulFBSize = (psLINFBInfo->screen_size) != 0 ? + psLINFBInfo->screen_size : psLINFBInfo->fix.smem_len; + + /* + * Try and filter out invalid FB info structures (a problem + * seen on some systems). + */ + if (psPVRFBInfo->ulFBSize == 0 || psLINFBInfo->fix.line_length == 0) + { + eError = DC_SUNXI_ERROR_INVALID_DEVICE; + goto ErrorFBRel; + } + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer size: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulFBSize)); + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer virtual width: %u\n", + psDevInfo->uiFBDevID, psLINFBInfo->var.xres_virtual)); + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer virtual height: %u\n", + psDevInfo->uiFBDevID, psLINFBInfo->var.yres_virtual)); + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer width: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulWidth)); + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Framebuffer height: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulHeight)); + + /* System Surface */ + psPVRFBInfo->sSysAddr.uiAddr = psLINFBInfo->fix.smem_start; + psPVRFBInfo->sCPUVAddr = psLINFBInfo->screen_base; + + psPVRFBInfo->ulByteStride = psLINFBInfo->fix.line_length; + + printk(KERN_WARNING + "#####: Device %u: Framebuffer physical address: 0x%x\n", + psDevInfo->uiFBDevID, psPVRFBInfo->sSysAddr.uiAddr); + + if (psPVRFBInfo->sCPUVAddr != NULL) + { + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX + ": Device %u: Framebuffer virtual address: %p\n", + psDevInfo->uiFBDevID, psPVRFBInfo->sCPUVAddr)); + } + + DEBUG_PRINTK((KERN_WARNING DRIVER_PREFIX + ": Device %u: Framebuffer stride: %lu\n", + psDevInfo->uiFBDevID, psPVRFBInfo->ulByteStride)); + + psPVRFBInfo->ulBufferSize = psPVRFBInfo->ulHeight * psPVRFBInfo->ulByteStride; + + { + unsigned long ulLCM; + ulLCM = LCM(psPVRFBInfo->ulByteStride, PAGE_SIZE); + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: LCM of stride and page size: %lu\n", + psDevInfo->uiFBDevID, ulLCM)); + + /* Round the buffer size up to a multiple of the number of pages + * and the byte stride. + * This is used internally, to ensure buffers start on page + * boundaries, for the benefit of PVR Services. + */ + psPVRFBInfo->ulRoundedBufferSize = RoundUpToMultiple(psPVRFBInfo->ulBufferSize, ulLCM); + } + + if(psLINFBInfo->var.bits_per_pixel == 16) + { + if((psLINFBInfo->var.red.length == 5) && + (psLINFBInfo->var.green.length == 6) && + (psLINFBInfo->var.blue.length == 5) && + (psLINFBInfo->var.red.offset == 11) && + (psLINFBInfo->var.green.offset == 5) && + (psLINFBInfo->var.blue.offset == 0) && + (psLINFBInfo->var.red.msb_right == 0)) + { + psPVRFBInfo->ePixelFormat = PVRSRV_PIXEL_FORMAT_RGB565; + } + else + { + printk(KERN_INFO DRIVER_PREFIX ": %s: Device %u: Unknown FB format\n", __FUNCTION__, uiFBDevID); + } + } + else if(psLINFBInfo->var.bits_per_pixel == 32) + { + if((psLINFBInfo->var.red.length == 8) && + (psLINFBInfo->var.green.length == 8) && + (psLINFBInfo->var.blue.length == 8) && + (psLINFBInfo->var.red.offset == 16) && + (psLINFBInfo->var.green.offset == 8) && + (psLINFBInfo->var.blue.offset == 0) && + (psLINFBInfo->var.red.msb_right == 0)) + { + psPVRFBInfo->ePixelFormat = PVRSRV_PIXEL_FORMAT_ARGB8888; + } + else + { + printk(KERN_INFO DRIVER_PREFIX ": %s: Device %u: Unknown FB format\n", __FUNCTION__, uiFBDevID); + } + } + else + { + printk(KERN_INFO DRIVER_PREFIX ": %s: Device %u: Unknown FB format\n", __FUNCTION__, uiFBDevID); + } + + psDevInfo->sFBInfo.ulPhysicalWidthmm = + ((int)psLINFBInfo->var.width > 0) ? psLINFBInfo->var.width : 90; + + psDevInfo->sFBInfo.ulPhysicalHeightmm = + ((int)psLINFBInfo->var.height > 0) ? psLINFBInfo->var.height : 54; + + /* System Surface */ + psDevInfo->sFBInfo.sSysAddr.uiAddr = psPVRFBInfo->sSysAddr.uiAddr; + psDevInfo->sFBInfo.sCPUVAddr = psPVRFBInfo->sCPUVAddr; + + eError = DC_SUNXI_OK; + goto ErrorRelSem; + +ErrorFBRel: + if (psLINFBInfo->fbops->fb_release != NULL) + { + (void) psLINFBInfo->fbops->fb_release(psLINFBInfo, 0); + } +ErrorModPut: + module_put(psLINFBOwner); +ErrorRelSem: + console_unlock(); + + return eError; +} + +static void DC_SUNXIDeInitFBDev(DC_SUNXI_DEVINFO *psDevInfo) +{ + struct fb_info *psLINFBInfo = psDevInfo->psLINFBInfo; + struct module *psLINFBOwner; + + console_lock(); + + psLINFBOwner = psLINFBInfo->fbops->owner; + + if (psLINFBInfo->fbops->fb_release != NULL) + { + (void) psLINFBInfo->fbops->fb_release(psLINFBInfo, 0); + } + + module_put(psLINFBOwner); + + console_unlock(); +} + +static DC_SUNXI_DEVINFO *DC_SUNXIInitDev(unsigned uiFBDevID) +{ + PFN_CMD_PROC pfnCmdProcList[DC_SUNXI_COMMAND_COUNT]; + IMG_UINT32 aui32SyncCountList[DC_SUNXI_COMMAND_COUNT][2]; + DC_SUNXI_DEVINFO *psDevInfo = NULL; + + /* Allocate device info. structure */ + psDevInfo = (DC_SUNXI_DEVINFO *)kmalloc(sizeof(DC_SUNXI_DEVINFO), GFP_KERNEL); + + if(psDevInfo == NULL) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: Couldn't allocate device information structure\n", __FUNCTION__, uiFBDevID); + + goto ErrorExit; + } + + /* Any fields not set will be zero */ + memset(psDevInfo, 0, sizeof(DC_SUNXI_DEVINFO)); + + psDevInfo->uiFBDevID = uiFBDevID; + + /* Get the kernel services function table */ + if(!(*gpfnGetPVRJTable)(&psDevInfo->sPVRJTable)) + { + goto ErrorFreeDevInfo; + } + + /* Save private fbdev information structure in the dev. info. */ + if(DC_SUNXIInitFBDev(psDevInfo) != DC_SUNXI_OK) + { + /* + * Leave it to DC_SUNXIInitFBDev to print an error message, if + * required. The function may have failed because + * there is no Linux framebuffer device corresponding + * to the device ID. + */ + goto ErrorIonClientDestroy; + } + + psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers = (IMG_UINT32)(psDevInfo->sFBInfo.ulFBSize / psDevInfo->sFBInfo.ulRoundedBufferSize); + if (psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers != 0) + { + psDevInfo->sDisplayInfo.ui32MaxSwapChains = 1; + psDevInfo->sDisplayInfo.ui32MaxSwapInterval = 1; + } + + psDevInfo->sDisplayInfo.ui32PhysicalWidthmm = psDevInfo->sFBInfo.ulPhysicalWidthmm; + psDevInfo->sDisplayInfo.ui32PhysicalHeightmm = psDevInfo->sFBInfo.ulPhysicalHeightmm; + + strncpy(psDevInfo->sDisplayInfo.szDisplayName, DISPLAY_DEVICE_NAME, MAX_DISPLAY_NAME_SIZE); + + psDevInfo->sDisplayFormat.pixelformat = psDevInfo->sFBInfo.ePixelFormat; + psDevInfo->sDisplayDim.ui32Width = (IMG_UINT32)psDevInfo->sFBInfo.ulWidth; + psDevInfo->sDisplayDim.ui32Height = (IMG_UINT32)psDevInfo->sFBInfo.ulHeight; + psDevInfo->sDisplayDim.ui32ByteStride = (IMG_UINT32)psDevInfo->sFBInfo.ulByteStride; + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX + ": Device %u: Maximum number of swap chain buffers: %u\n", + psDevInfo->uiFBDevID, psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers)); + + /* Setup system buffer */ + psDevInfo->sSystemBuffer.sSysAddr = psDevInfo->sFBInfo.sSysAddr; + psDevInfo->sSystemBuffer.sCPUVAddr = psDevInfo->sFBInfo.sCPUVAddr; + psDevInfo->sSystemBuffer.psDevInfo = psDevInfo; + + DC_SUNXIInitBufferForSwap(&psDevInfo->sSystemBuffer); + + /* + * Setup the DC Jtable so SRVKM can call into this driver + */ + psDevInfo->sDCJTable.ui32TableSize = sizeof(PVRSRV_DC_SRV2DISP_KMJTABLE); + psDevInfo->sDCJTable.pfnOpenDCDevice = OpenDCDevice; + psDevInfo->sDCJTable.pfnCloseDCDevice = CloseDCDevice; + psDevInfo->sDCJTable.pfnEnumDCFormats = EnumDCFormats; + psDevInfo->sDCJTable.pfnEnumDCDims = EnumDCDims; + psDevInfo->sDCJTable.pfnGetDCSystemBuffer = GetDCSystemBuffer; + psDevInfo->sDCJTable.pfnGetDCInfo = GetDCInfo; + psDevInfo->sDCJTable.pfnGetBufferAddr = GetDCBufferAddr; + psDevInfo->sDCJTable.pfnCreateDCSwapChain = CreateDCSwapChain; + psDevInfo->sDCJTable.pfnDestroyDCSwapChain = DestroyDCSwapChain; + psDevInfo->sDCJTable.pfnSetDCDstRect = SetDCDstRect; + psDevInfo->sDCJTable.pfnSetDCSrcRect = SetDCSrcRect; + psDevInfo->sDCJTable.pfnSetDCDstColourKey = SetDCDstColourKey; + psDevInfo->sDCJTable.pfnSetDCSrcColourKey = SetDCSrcColourKey; + psDevInfo->sDCJTable.pfnGetDCBuffers = GetDCBuffers; + psDevInfo->sDCJTable.pfnSwapToDCBuffer = SwapToDCBuffer; + psDevInfo->sDCJTable.pfnSetDCState = SetDCState; + + /* Register device with services and retrieve device index */ + if(psDevInfo->sPVRJTable.pfnPVRSRVRegisterDCDevice( + &psDevInfo->sDCJTable, + &psDevInfo->uiPVRDevID) != PVRSRV_OK) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: PVR Services device registration failed\n", __FUNCTION__, uiFBDevID); + + goto ErrorDeInitFBDev; + } + + DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: PVR Device ID: %u\n", + psDevInfo->uiFBDevID, psDevInfo->uiPVRDevID)); + + /* Setup private command processing function table ... */ + pfnCmdProcList[DC_FLIP_COMMAND] = ProcessFlip; + + /* ... and associated sync count(s) */ + aui32SyncCountList[DC_FLIP_COMMAND][0] = 0; /* writes */ + aui32SyncCountList[DC_FLIP_COMMAND][1] = 10; /* reads */ + + if (psDevInfo->sPVRJTable.pfnPVRSRVRegisterCmdProcList(psDevInfo->uiPVRDevID, + &pfnCmdProcList[0], + aui32SyncCountList, + DC_SUNXI_COMMAND_COUNT) != PVRSRV_OK) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: Couldn't register command processing functions with PVR Services\n", __FUNCTION__, uiFBDevID); + goto ErrorUnregisterDevice; + } + + mutex_init(&psDevInfo->sCreateSwapChainMutex); + + atomic_set(&psDevInfo->sBlankEvents, 0); + atomic_set(&psDevInfo->sFlushCommands, false); + + return psDevInfo; + +ErrorUnregisterDevice: + (void)psDevInfo->sPVRJTable.pfnPVRSRVRemoveDCDevice(psDevInfo->uiPVRDevID); +ErrorDeInitFBDev: + DC_SUNXIDeInitFBDev(psDevInfo); +ErrorIonClientDestroy: +ErrorFreeDevInfo: + kfree(psDevInfo); +ErrorExit: + return NULL; +} + +static DC_SUNXI_ERROR DC_SUNXIInit(void) +{ + unsigned int i, uiMaxFBDevIDPlusOne = DC_SUNXIMaxFBDevIDPlusOne(); + unsigned int uiDevicesFound = 0; + + gpfnGetPVRJTable = PVRGetDisplayClassJTable; + + /* + * We search for frame buffer devices backwards, as the last device + * registered with PVR Services will be the first device enumerated + * by PVR Services. + */ + for(i = uiMaxFBDevIDPlusOne; i-- != 0;) + { + DC_SUNXI_DEVINFO *psDevInfo = DC_SUNXIInitDev(i); + + if (psDevInfo != NULL) + { + /* Set the top-level anchor */ + DC_SUNXISetDevInfoPtr(psDevInfo->uiFBDevID, psDevInfo); + uiDevicesFound++; + } + } + + return (uiDevicesFound != 0) ? DC_SUNXI_OK : DC_SUNXI_ERROR_INIT_FAILURE; +} + +static bool DC_SUNXIDeInitDev(DC_SUNXI_DEVINFO *psDevInfo) +{ + PVRSRV_DC_DISP2SRV_KMJTABLE *psPVRJTable = &psDevInfo->sPVRJTable; + + if (psPVRJTable->pfnPVRSRVRemoveCmdProcList (psDevInfo->uiPVRDevID, DC_SUNXI_COMMAND_COUNT) != PVRSRV_OK) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: PVR Device %u: Couldn't unregister command processing functions\n", __FUNCTION__, psDevInfo->uiFBDevID, psDevInfo->uiPVRDevID); + return false; + } + + if (psPVRJTable->pfnPVRSRVRemoveDCDevice(psDevInfo->uiPVRDevID) != PVRSRV_OK) + { + printk(KERN_ERR DRIVER_PREFIX + ": %s: Device %u: PVR Device %u: Couldn't remove device from PVR Services\n", __FUNCTION__, psDevInfo->uiFBDevID, psDevInfo->uiPVRDevID); + return false; + } + + mutex_destroy(&psDevInfo->sCreateSwapChainMutex); + + DC_SUNXIDeInitFBDev(psDevInfo); + + DC_SUNXISetDevInfoPtr(psDevInfo->uiFBDevID, NULL); + + /* De-allocate data structure */ + kfree(psDevInfo); + + return true; +} + +static DC_SUNXI_ERROR DC_SUNXIDeInit(void) +{ + unsigned int i, uiMaxFBDevIDPlusOne = DC_SUNXIMaxFBDevIDPlusOne(); + bool bError = false; + + for(i = 0; i < uiMaxFBDevIDPlusOne; i++) + { + DC_SUNXI_DEVINFO *psDevInfo = DC_SUNXIGetDevInfoPtr(i); + + if (psDevInfo != NULL) + { + bError |= !DC_SUNXIDeInitDev(psDevInfo); + } + } + + return (bError) ? DC_SUNXI_ERROR_INIT_FAILURE : DC_SUNXI_OK; +} + +#if defined(SUPPORT_DRI_DRM) +int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Init)(struct drm_device unref__ *dev) +#else +static int __init DC_SUNXI_Init(void) +#endif +{ + if(DC_SUNXIInit() != DC_SUNXI_OK) + { + printk(KERN_ERR DRIVER_PREFIX ": %s: DC_SUNXIInit failed\n", __FUNCTION__); + return -ENODEV; + } + + return 0; +} + +#if defined(SUPPORT_DRI_DRM) +void PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Cleanup)(struct drm_device unref__ *dev) +#else +static void __exit DC_SUNXI_Cleanup(void) +#endif +{ + if(DC_SUNXIDeInit() != DC_SUNXI_OK) + { + printk(KERN_ERR DRIVER_PREFIX ": %s: DC_SUNXIDeInit failed\n", __FUNCTION__); + } +} + +#if !defined(SUPPORT_DRI_DRM) +late_initcall(DC_SUNXI_Init); +module_exit(DC_SUNXI_Cleanup); +#endif +/****************************************************************************** + * End of file (dc_sunxi_displayclass.c) + ******************************************************************************/ diff --git a/drivers/gpu/pvr/services4/3rdparty/linux_drm/Kbuild.mk b/drivers/gpu/pvr/services4/3rdparty/linux_drm/Kbuild.mk new file mode 100755 index 00000000000..adee4405639 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/linux_drm/Kbuild.mk @@ -0,0 +1,86 @@ +########################################################################### ### +#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +#@License Dual MIT/GPLv2 +# +# The contents of this file are subject to the MIT license as set out below. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 2 ("GPL") in which case the provisions +# of GPL are applicable instead of those above. +# +# If you wish to allow use of your version of this file only under the terms of +# GPL, and not to allow others to use your version of this file under the terms +# of the MIT license, indicate your decision by deleting the provisions above +# and replace them with the notice and other provisions required by GPL as set +# out in the file called "GPL-COPYING" included in this distribution. If you do +# not delete the provisions above, a recipient may use your version of this file +# under the terms of either the MIT license or GPL. +# +# This License is also included in this distribution in the file called +# "MIT-COPYING". +# +# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### ########################################################################### + +$(call must-be-defined,$(SUPPORT_DRI_DRM)) + +DRM_SOURCE_DIR := drivers/gpu/drm + +ccflags-y += \ + -Iinclude/drm \ + -I$(DRM_SOURCE_DIR) + +drm-y += \ + services4/3rdparty/linux_drm/pvr_drm_stubs.o \ + external/$(DRM_SOURCE_DIR)/drm_auth.o \ + external/$(DRM_SOURCE_DIR)/drm_bufs.o \ + external/$(DRM_SOURCE_DIR)/drm_cache.o \ + external/$(DRM_SOURCE_DIR)/drm_context.o \ + external/$(DRM_SOURCE_DIR)/drm_dma.o \ + external/$(DRM_SOURCE_DIR)/drm_drawable.o \ + external/$(DRM_SOURCE_DIR)/drm_drv.o \ + external/$(DRM_SOURCE_DIR)/drm_fops.o \ + external/$(DRM_SOURCE_DIR)/drm_gem.o \ + external/$(DRM_SOURCE_DIR)/drm_ioctl.o \ + external/$(DRM_SOURCE_DIR)/drm_irq.o \ + external/$(DRM_SOURCE_DIR)/drm_lock.o \ + external/$(DRM_SOURCE_DIR)/drm_memory.o \ + external/$(DRM_SOURCE_DIR)/drm_proc.o \ + external/$(DRM_SOURCE_DIR)/drm_stub.o \ + external/$(DRM_SOURCE_DIR)/drm_vm.o \ + external/$(DRM_SOURCE_DIR)/drm_agpsupport.o \ + external/$(DRM_SOURCE_DIR)/drm_scatter.o \ + external/$(DRM_SOURCE_DIR)/ati_pcigart.o \ + external/$(DRM_SOURCE_DIR)/drm_pci.o \ + external/$(DRM_SOURCE_DIR)/drm_sysfs.o \ + external/$(DRM_SOURCE_DIR)/drm_hashtab.o \ + external/$(DRM_SOURCE_DIR)/drm_sman.o \ + external/$(DRM_SOURCE_DIR)/drm_mm.o \ + external/$(DRM_SOURCE_DIR)/drm_crtc.o \ + external/$(DRM_SOURCE_DIR)/drm_modes.o \ + external/$(DRM_SOURCE_DIR)/drm_edid.o \ + external/$(DRM_SOURCE_DIR)/drm_info.o \ + external/$(DRM_SOURCE_DIR)/drm_debugfs.o \ + external/$(DRM_SOURCE_DIR)/drm_encoder_slave.o + +# extra flags for some files +CFLAGS_pvr_drm_stubs.o := -DCONFIG_PCI +CFLAGS_drm_drv.o := -DCONFIG_PCI +CFLAGS_drm_stub.o := -DCONFIG_PCI +CFLAGS_ati_pcigart.o := -DCONFIG_PCI diff --git a/drivers/gpu/pvr/services4/3rdparty/linux_drm/Linux.mk b/drivers/gpu/pvr/services4/3rdparty/linux_drm/Linux.mk new file mode 100755 index 00000000000..80733c506b3 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/linux_drm/Linux.mk @@ -0,0 +1,45 @@ +########################################################################### ### +#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +#@License Dual MIT/GPLv2 +# +# The contents of this file are subject to the MIT license as set out below. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Alternatively, the contents of this file may be used under the terms of +# the GNU General Public License Version 2 ("GPL") in which case the provisions +# of GPL are applicable instead of those above. +# +# If you wish to allow use of your version of this file only under the terms of +# GPL, and not to allow others to use your version of this file under the terms +# of the MIT license, indicate your decision by deleting the provisions above +# and replace them with the notice and other provisions required by GPL as set +# out in the file called "GPL-COPYING" included in this distribution. If you do +# not delete the provisions above, a recipient may use your version of this file +# under the terms of either the MIT license or GPL. +# +# This License is also included in this distribution in the file called +# "MIT-COPYING". +# +# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### ########################################################################### + +modules := linux_drm + +linux_drm_type := kernel_module +linux_drm_target := drm.ko +linux_drm_makefile := $(THIS_DIR)/Kbuild.mk diff --git a/drivers/gpu/pvr/services4/3rdparty/linux_drm/pvr_drm_mod.h b/drivers/gpu/pvr/services4/3rdparty/linux_drm/pvr_drm_mod.h new file mode 100755 index 00000000000..096f11fdcc7 --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/linux_drm/pvr_drm_mod.h @@ -0,0 +1,49 @@ +/*************************************************************************/ /*! +@Title DRM stub functions +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#ifndef __PVR_DRM_MOD_H__ +#define __PVR_DRM_MOD_H__ + +int drm_pvr_dev_add(void); + +void drm_pvr_dev_remove(void); + +#endif /* __PVR_DRM_MOD_H__ */ diff --git a/drivers/gpu/pvr/services4/3rdparty/linux_drm/pvr_drm_stubs.c b/drivers/gpu/pvr/services4/3rdparty/linux_drm/pvr_drm_stubs.c new file mode 100755 index 00000000000..aad9263188b --- /dev/null +++ b/drivers/gpu/pvr/services4/3rdparty/linux_drm/pvr_drm_stubs.c @@ -0,0 +1,220 @@ +/*************************************************************************/ /*! +@Title DRM stub functions +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +/* + * Emulate enough of the PCI layer to allow the Linux DRM module to be used + * with a non-PCI device. + * Only one device is supported at present. + */ + +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/pci.h> +#include <asm/system.h> + +#include "pvr_drm_mod.h" + +#define DRV_MSG_PREFIX_STR "pvr drm: " + +#define SGX_VENDOR_ID 1 +#define SGX_DEVICE_ID 1 +#define SGX_SUB_VENDOR_ID 1 +#define SGX_SUB_DEVICE_ID 1 + +#if defined(DEBUG) +#define DEBUG_PRINTK(format, args...) printk(format, ## args) +#else +#define DEBUG_PRINTK(format, args...) +#endif + +#define CLEAR_STRUCT(x) memset(&(x), 0, sizeof(x)) + +/* + * Don't specify any initialisers for pvr_pci_bus and pvr_pci_dev, as they + * will be cleared to zero on unregister. This has to be done for + * pvr_pci_dev to prevent a warning from the kernel if the device is + * re-registered without unloading the DRM module. + */ +static struct pci_bus pvr_pci_bus; +static struct pci_dev pvr_pci_dev; + +static bool bDeviceIsRegistered; + +static void +release_device(struct device *dev) +{ +} + +int +drm_pvr_dev_add(void) +{ + int ret; + + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s\n", __FUNCTION__); + + if (bDeviceIsRegistered) + { + DEBUG_PRINTK(KERN_WARNING DRV_MSG_PREFIX_STR "%s: Device already registered\n", __FUNCTION__); + return 0; + } + + /* Set the device ID */ + pvr_pci_dev.vendor = SGX_VENDOR_ID; + pvr_pci_dev.device = SGX_DEVICE_ID; + pvr_pci_dev.subsystem_vendor = SGX_SUB_VENDOR_ID; + pvr_pci_dev.subsystem_device = SGX_SUB_DEVICE_ID; + + /* drm_set_busid needs the bus number */ + pvr_pci_dev.bus = &pvr_pci_bus; + + dev_set_name(&pvr_pci_dev.dev, "%s", "SGX"); + pvr_pci_dev.dev.release = release_device; + + ret = device_register(&pvr_pci_dev.dev); + if (ret != 0) + { + printk(KERN_ERR DRV_MSG_PREFIX_STR "%s: device_register failed (%d)\n", __FUNCTION__, ret); + } + + bDeviceIsRegistered = true; + + return ret; +} +EXPORT_SYMBOL(drm_pvr_dev_add); + +void +drm_pvr_dev_remove(void) +{ + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s\n", __FUNCTION__); + + if (bDeviceIsRegistered) + { + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s: Unregistering device\n", __FUNCTION__); + + device_unregister(&pvr_pci_dev.dev); + bDeviceIsRegistered = false; + + /* Prevent kernel warnings on re-register */ + CLEAR_STRUCT(pvr_pci_dev); + CLEAR_STRUCT(pvr_pci_bus); + } + else + { + DEBUG_PRINTK(KERN_WARNING DRV_MSG_PREFIX_STR "%s: Device not registered\n", __FUNCTION__); + } +} +EXPORT_SYMBOL(drm_pvr_dev_remove); + +void +pci_disable_device(struct pci_dev *dev) +{ +} + +struct pci_dev * +pci_dev_get(struct pci_dev *dev) +{ + return dev; +} + +void +pci_set_master(struct pci_dev *dev) +{ +} + +#define PCI_ID_COMP(field, value) (((value) == PCI_ANY_ID) || \ + ((field) == (value))) + +struct pci_dev * +pci_get_subsys(unsigned int vendor, unsigned int device, + unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) +{ + if (from == NULL && + PCI_ID_COMP(pvr_pci_dev.vendor, vendor) && + PCI_ID_COMP(pvr_pci_dev.device, device) && + PCI_ID_COMP(pvr_pci_dev.subsystem_vendor, ss_vendor) && + PCI_ID_COMP(pvr_pci_dev.subsystem_device, ss_device)) + { + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s: Found %x %x %x %x\n", __FUNCTION__, vendor, device, ss_vendor, ss_device); + + return &pvr_pci_dev; + } + + if (from == NULL) + { + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s: Couldn't find %x %x %x %x\n", __FUNCTION__, vendor, device, ss_vendor, ss_device); + } + + return NULL; +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) +int +pci_set_dma_mask(struct pci_dev *dev, u64 mask) +{ + return 0; +} +#endif + +void +pci_unregister_driver(struct pci_driver *drv) +{ +} + +int +__pci_register_driver(struct pci_driver *drv, struct module *owner, + const char *mod_name) +{ + return 0; +} + +int +pci_enable_device(struct pci_dev *dev) +{ + return 0; +} + +void +__bad_cmpxchg(volatile void *ptr, int size) +{ + printk(KERN_ERR DRV_MSG_PREFIX_STR "%s: ptr %p size %u\n", + __FUNCTION__, ptr, size); +} + diff --git a/drivers/gpu/pvr/services4/include/env/linux/pvr_drm_shared.h b/drivers/gpu/pvr/services4/include/env/linux/pvr_drm_shared.h new file mode 100755 index 00000000000..4b84f6b6d1d --- /dev/null +++ b/drivers/gpu/pvr/services4/include/env/linux/pvr_drm_shared.h @@ -0,0 +1,76 @@ +/*************************************************************************/ /*! +@Title PowerVR drm driver shared definitions +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ +#if !defined(__PVR_DRM_SHARED_H__) +#define __PVR_DRM_SHARED_H__ + +#if defined(SUPPORT_DRI_DRM) + +typedef struct drm_pvr_unpriv_cmd_tag +{ + uint32_t cmd; + uint32_t res; +} drm_pvr_unpriv_cmd; + +/* DRM command numbers, relative to DRM_COMMAND_BASE */ +#if defined(SUPPORT_DRI_DRM_EXT) +#define PVR_DRM_SRVKM_CMD DRM_PVR_RESERVED1 /* Used for PVR Services ioctls */ +#define PVR_DRM_DISP_CMD DRM_PVR_RESERVED2 /* Reserved for display class driver */ +#define PVR_DRM_BC_CMD DRM_PVR_RESERVED3 /* Reserved for buffer class driver */ +#define PVR_DRM_IS_MASTER_CMD DRM_PVR_RESERVED4 /* Are we the DRM master? */ +#define PVR_DRM_UNPRIV_CMD DRM_PVR_RESERVED5 /* PVR driver unprivileged ioctls */ +#define PVR_DRM_DBGDRV_CMD DRM_PVR_RESERVED6 /* Debug driver (PDUMP) ioctls */ +#else /* defined(SUPPORT_DRI_DRM_EXT) */ +#define PVR_DRM_SRVKM_CMD 0 /* Used for PVR Services ioctls */ +#define PVR_DRM_DISP_CMD 1 /* Reserved for display class driver */ +#define PVR_DRM_BC_CMD 2 /* Reserved for buffer class driver */ +#define PVR_DRM_IS_MASTER_CMD 3 /* Are we the DRM master? */ +#define PVR_DRM_UNPRIV_CMD 4 /* PVR driver unprivileged ioctls */ +#define PVR_DRM_DBGDRV_CMD 5 /* Debug driver (PDUMP) ioctls */ +#endif /* defined(SUPPORT_DRI_DRM_EXT) */ + +/* Subcommands of PVR_DRM_UNPRIV_CMD */ +#define PVR_DRM_UNPRIV_INIT_SUCCESFUL 0 /* PVR Services init succesful */ + +#endif + +#endif /* defined(__PVR_DRM_SHARED_H__) */ + + diff --git a/drivers/gpu/pvr/services4/include/kernelbuffer.h b/drivers/gpu/pvr/services4/include/kernelbuffer.h index 6d8aed5fa22..6d8aed5fa22 100644..100755 --- a/drivers/gpu/pvr/services4/include/kernelbuffer.h +++ b/drivers/gpu/pvr/services4/include/kernelbuffer.h diff --git a/drivers/gpu/pvr/services4/include/kerneldisplay.h b/drivers/gpu/pvr/services4/include/kerneldisplay.h index 2efd7b31ef5..048cb439f62 100644..100755 --- a/drivers/gpu/pvr/services4/include/kerneldisplay.h +++ b/drivers/gpu/pvr/services4/include/kerneldisplay.h @@ -44,6 +44,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if !defined (__KERNELDISPLAY_H__) #define __KERNELDISPLAY_H__ +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + #if defined (__cplusplus) extern "C" { #endif @@ -107,7 +109,6 @@ typedef struct PVRSRV_DC_SRV2DISP_KMJTABLE_TAG PFN_GET_DC_BUFFERS pfnGetDCBuffers; PFN_SWAP_TO_DC_BUFFER pfnSwapToDCBuffer; PFN_SET_DC_STATE pfnSetDCState; - PFN_QUERY_SWAP_COMMAND_ID pfnQuerySwapCommandID; } PVRSRV_DC_SRV2DISP_KMJTABLE; @@ -134,9 +135,6 @@ typedef PVRSRV_ERROR (*PFN_DC_MEMINFO_GET_CPU_VADDR)(PDC_MEM_INFO, IMG_CPU_VIRTA typedef PVRSRV_ERROR (*PFN_DC_MEMINFO_GET_CPU_PADDR)(PDC_MEM_INFO, IMG_SIZE_T uByteOffset, IMG_CPU_PHYADDR *pPAddr); typedef PVRSRV_ERROR (*PFN_DC_MEMINFO_GET_BYTE_SIZE)(PDC_MEM_INFO, IMG_SIZE_T *uByteSize); typedef IMG_BOOL (*PFN_DC_MEMINFO_IS_PHYS_CONTIG)(PDC_MEM_INFO); -typedef PVRSRV_ERROR (*PFN_DC_GETBVHANDLE)(PDC_MEM_INFO, IMG_VOID **handle); -typedef IMG_INT32 (*PFN_DC_MEMINFO_GET_MULTI_PLANE_CPU_PADDRS)(PDC_MEM_INFO, IMG_SIZE_T* puByteOffsets, - IMG_CPU_PHYADDR *pPAddrs, IMG_UINT32* pui32NumAddrOffsets); /* Function table for DISPLAY->SRVKM @@ -152,13 +150,10 @@ typedef struct PVRSRV_DC_DISP2SRV_KMJTABLE_TAG PFN_DC_CMD_COMPLETE pfnPVRSRVCmdComplete; PFN_DC_REGISTER_SYS_ISR pfnPVRSRVRegisterSystemISRHandler; PFN_DC_REGISTER_POWER pfnPVRSRVRegisterPowerDevice; - PFN_DC_CMD_COMPLETE pfnPVRSRVFreeCmdCompletePacket; PFN_DC_MEMINFO_GET_CPU_VADDR pfnPVRSRVDCMemInfoGetCpuVAddr; PFN_DC_MEMINFO_GET_CPU_PADDR pfnPVRSRVDCMemInfoGetCpuPAddr; PFN_DC_MEMINFO_GET_BYTE_SIZE pfnPVRSRVDCMemInfoGetByteSize; PFN_DC_MEMINFO_IS_PHYS_CONTIG pfnPVRSRVDCMemInfoIsPhysContig; - PFN_DC_GETBVHANDLE pfnPVRSRVDCMemInfoGetBvHandle; - PFN_DC_MEMINFO_GET_MULTI_PLANE_CPU_PADDRS pfnPVRSRVDCMemInfoGetCpuMultiPlanePAddr; } PVRSRV_DC_DISP2SRV_KMJTABLE, *PPVRSRV_DC_DISP2SRV_KMJTABLE; @@ -223,7 +218,6 @@ typedef struct DISPLAYCLASS_FLIP_COMMAND2_TAG /* States used in PFN_SET_DC_STATE */ #define DC_STATE_NO_FLUSH_COMMANDS 0 #define DC_STATE_FLUSH_COMMANDS 1 -#define DC_STATE_FORCE_SWAP_TO_SYSTEM 2 /* function to retrieve kernel services function table from kernel services */ typedef IMG_BOOL (*PFN_DC_GET_PVRJTABLE)(PPVRSRV_DC_DISP2SRV_KMJTABLE); @@ -236,6 +230,8 @@ IMG_IMPORT IMG_BOOL PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *psJTab } #endif +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + #endif/* #if !defined (__KERNELDISPLAY_H__) */ /****************************************************************************** diff --git a/drivers/gpu/pvr/services4/include/pdump.h b/drivers/gpu/pvr/services4/include/pdump.h index 566a118bc6d..566a118bc6d 100644..100755 --- a/drivers/gpu/pvr/services4/include/pdump.h +++ b/drivers/gpu/pvr/services4/include/pdump.h diff --git a/drivers/gpu/pvr/services4/include/pvr_bridge.h b/drivers/gpu/pvr/services4/include/pvr_bridge.h index 71813c47e2d..cf84f76082f 100644..100755 --- a/drivers/gpu/pvr/services4/include/pvr_bridge.h +++ b/drivers/gpu/pvr/services4/include/pvr_bridge.h @@ -84,9 +84,14 @@ extern "C" { /* * Note *REMEMBER* to update PVRSRV_BRIDGE_LAST_CMD (below) if you add any new * bridge commands! + * The command number of PVRSRV_BRIDGE_UM_KM_COMPAT_CHECK needs to be maintained as 0 across previous ddks, for compatibility check command to execute successfully */ -#define PVRSRV_BRIDGE_CORE_CMD_FIRST 0UL +#define PVRSRV_BRIDGE_UMKM_CMD_FIRST 0UL +#define PVRSRV_BRIDGE_UM_KM_COMPAT_CHECK PVRSRV_IOWR(0) +#define PVRSRV_BRIDGE_UMKM_CMD_LAST (0) + +#define PVRSRV_BRIDGE_CORE_CMD_FIRST (PVRSRV_BRIDGE_UMKM_CMD_LAST + 1) #define PVRSRV_BRIDGE_ENUM_DEVICES PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+0) /*!< enumerate device bridge index */ #define PVRSRV_BRIDGE_ACQUIRE_DEVICEINFO PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+1) /*!< acquire device data bridge index */ #define PVRSRV_BRIDGE_RELEASE_DEVICEINFO PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+2) /*!< release device data bridge index */ @@ -109,27 +114,19 @@ extern "C" { #define PVRSRV_BRIDGE_UNMAP_EXT_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+19) #define PVRSRV_BRIDGE_MAP_DEV_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+20) #define PVRSRV_BRIDGE_UNMAP_DEV_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+21) -#define PVRSRV_BRIDGE_MAP_DEVICECLASS_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+22) -#define PVRSRV_BRIDGE_UNMAP_DEVICECLASS_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+23) -#define PVRSRV_BRIDGE_MAP_MEM_INFO_TO_USER PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+24) -#define PVRSRV_BRIDGE_UNMAP_MEM_INFO_FROM_USER PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+25) -#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+26) -#define PVRSRV_BRIDGE_RELEASE_MMAP_DATA PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+27) -#define PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+28) -#define PVRSRV_BRIDGE_MAP_DEV_MEMORY_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29) -#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30) - -#define PVRSRV_BRIDGE_MULTI_MANAGE_DEV_MEM PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+31) -#define PVRSRV_BRIDGE_CORE_CMD_RESERVED_1 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+32) -#define PVRSRV_BRIDGE_CORE_CMD_RESERVED_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+33) -#define PVRSRV_BRIDGE_CORE_CMD_RESERVED_3 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+34) - +#define PVRSRV_BRIDGE_MAP_MEM_INFO_TO_USER PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+22) +#define PVRSRV_BRIDGE_UNMAP_MEM_INFO_FROM_USER PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+23) +#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+24) +#define PVRSRV_BRIDGE_RELEASE_MMAP_DATA PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+25) +#define PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+26) +#define PVRSRV_BRIDGE_MAP_DEV_MEMORY_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+27) +#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+28) #if defined (SUPPORT_ION) -#define PVRSRV_BRIDGE_MAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+35) -#define PVRSRV_BRIDGE_UNMAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+36) -#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+37) +#define PVRSRV_BRIDGE_MAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29) +#define PVRSRV_BRIDGE_UNMAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30) +#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+30) #else -#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+34) +#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+28) #endif /* SIM */ #define PVRSRV_BRIDGE_SIM_CMD_FIRST (PVRSRV_BRIDGE_CORE_CMD_LAST+1) @@ -202,8 +199,10 @@ extern "C" { /* device class enum */ #define PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST (PVRSRV_BRIDGE_OEM_CMD_LAST+1) -#define PVRSRV_BRIDGE_ENUM_CLASS PVRSRV_IOWR(PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST+0) -#define PVRSRV_BRIDGE_DEVCLASS_CMD_LAST (PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST+0) +#define PVRSRV_BRIDGE_MAP_DEVICECLASS_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST+0) +#define PVRSRV_BRIDGE_UNMAP_DEVICECLASS_MEMORY PVRSRV_IOWR(PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST+1) +#define PVRSRV_BRIDGE_ENUM_CLASS PVRSRV_IOWR(PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST+2) +#define PVRSRV_BRIDGE_DEVCLASS_CMD_LAST (PVRSRV_BRIDGE_DEVCLASS_CMD_FIRST+2) /* display class API */ #define PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST (PVRSRV_BRIDGE_DEVCLASS_CMD_LAST+1) @@ -310,11 +309,7 @@ typedef struct PVRSRV_BRIDGE_PACKAGE_TAG IMG_VOID *pvParamOut; /*!< output data buffer */ IMG_UINT32 ui32OutBufferSize; /*!< size of output data buffer */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelServices; /*!< kernel servcies handle */ -#else IMG_HANDLE hKernelServices; /*!< kernel servcies handle */ -#endif }PVRSRV_BRIDGE_PACKAGE; @@ -360,11 +355,7 @@ typedef struct PVRSRV_BRIDGE_IN_ENUMCLASS_TAG typedef struct PVRSRV_BRIDGE_IN_CLOSE_DISPCLASS_DEVICE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_IN_CLOSE_DISPCLASS_DEVICE; @@ -374,11 +365,7 @@ typedef struct PVRSRV_BRIDGE_IN_CLOSE_DISPCLASS_DEVICE_TAG typedef struct PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_FORMATS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_FORMATS; @@ -388,11 +375,7 @@ typedef struct PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_FORMATS_TAG typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_SYSBUFFER_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_IN_GET_DISPCLASS_SYSBUFFER; @@ -402,11 +385,7 @@ typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_SYSBUFFER_TAG typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_INFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_IN_GET_DISPCLASS_INFO; @@ -416,11 +395,7 @@ typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_INFO_TAG typedef struct PVRSRV_BRIDGE_IN_CLOSE_BUFFERCLASS_DEVICE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_IN_CLOSE_BUFFERCLASS_DEVICE; @@ -430,11 +405,7 @@ typedef struct PVRSRV_BRIDGE_IN_CLOSE_BUFFERCLASS_DEVICE_TAG typedef struct PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_INFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_INFO; @@ -444,11 +415,7 @@ typedef struct PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_INFO_TAG typedef struct PVRSRV_BRIDGE_IN_RELEASE_DEVICEINFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif } PVRSRV_BRIDGE_IN_RELEASE_DEVICEINFO; @@ -471,13 +438,8 @@ typedef struct PVRSRV_BRIDGE_IN_FREE_CLASSDEVICEINFO_TAG typedef struct PVRSRV_BRIDGE_IN_GET_DEVMEM_HEAPINFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; -#endif }PVRSRV_BRIDGE_IN_GET_DEVMEM_HEAPINFO; @@ -488,11 +450,7 @@ typedef struct PVRSRV_BRIDGE_IN_GET_DEVMEM_HEAPINFO_TAG typedef struct PVRSRV_BRIDGE_IN_CREATE_DEVMEMCONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_CREATE_DEVMEMCONTEXT; @@ -503,13 +461,8 @@ typedef struct PVRSRV_BRIDGE_IN_CREATE_DEVMEMCONTEXT_TAG typedef struct PVRSRV_BRIDGE_IN_DESTROY_DEVMEMCONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; -#endif }PVRSRV_BRIDGE_IN_DESTROY_DEVMEMCONTEXT; @@ -520,16 +473,11 @@ typedef struct PVRSRV_BRIDGE_IN_DESTROY_DEVMEMCONTEXT_TAG typedef struct PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemHeap; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemHeap; -#endif IMG_UINT32 ui32Attribs; - IMG_SIZE_T ui32Size; - IMG_SIZE_T ui32Alignment; + IMG_SIZE_T uSize; + IMG_SIZE_T uAlignment; IMG_PVOID pvPrivData; IMG_UINT32 ui32PrivDataLength; @@ -545,11 +493,7 @@ typedef struct PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM_TAG typedef struct PVRSRV_BRIDGE_IN_MAPMEMINFOTOUSER_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif }PVRSRV_BRIDGE_IN_MAPMEMINFOTOUSER; @@ -559,17 +503,9 @@ typedef struct PVRSRV_BRIDGE_IN_MAPMEMINFOTOUSER_TAG typedef struct PVRSRV_BRIDGE_IN_UNMAPMEMINFOFROMUSER_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif IMG_PVOID pvLinAddr; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMappingInfo; -#else IMG_HANDLE hMappingInfo; -#endif }PVRSRV_BRIDGE_IN_UNMAPMEMINFOFROMUSER; @@ -579,13 +515,8 @@ typedef struct PVRSRV_BRIDGE_IN_UNMAPMEMINFOFROMUSER_TAG typedef struct PVRSRV_BRIDGE_IN_FREEDEVICEMEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hDevCookie; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; }PVRSRV_BRIDGE_IN_FREEDEVICEMEM; @@ -596,32 +527,27 @@ typedef struct PVRSRV_BRIDGE_IN_FREEDEVICEMEM_TAG typedef struct PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hDevCookie; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif }PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM; /****************************************************************************** * 'bridge in' map ion handle *****************************************************************************/ +#define ION_IMPORT_MAX_FDS 3 +#define ION_IMPORT_MAX_CHUNK_COUNT 3 typedef struct _PVRSRV_BRIDGE_IN_MAP_ION_HANDLE_ { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ - IMG_HANDLE handle; + IMG_UINT32 ui32NumFDs; + IMG_INT32 ai32BufferFDs[ION_IMPORT_MAX_FDS]; IMG_UINT32 ui32Attribs; - IMG_SIZE_T ui32Size; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else + IMG_UINT32 ui32ChunkCount; + IMG_SIZE_T auiOffset[ION_IMPORT_MAX_CHUNK_COUNT]; + IMG_SIZE_T auiSize[ION_IMPORT_MAX_CHUNK_COUNT]; IMG_HANDLE hDevCookie; - IMG_HANDLE hDevMemContext; -#endif + IMG_HANDLE hDevMemHeap; } PVRSRV_BRIDGE_IN_MAP_ION_HANDLE; /****************************************************************************** @@ -630,11 +556,7 @@ typedef struct _PVRSRV_BRIDGE_IN_MAP_ION_HANDLE_ typedef struct PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif }PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE; /****************************************************************************** @@ -653,12 +575,8 @@ typedef struct PVRSRV_BRIDGE_IN_GETFREEDEVICEMEM_TAG typedef struct PVRSRV_BRIDGE_IN_CREATECOMMANDQUEUE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif - IMG_SIZE_T ui32QueueSize; + IMG_SIZE_T uQueueSize; }PVRSRV_BRIDGE_IN_CREATECOMMANDQUEUE; @@ -669,11 +587,7 @@ typedef struct PVRSRV_BRIDGE_IN_CREATECOMMANDQUEUE_TAG typedef struct PVRSRV_BRIDGE_IN_DESTROYCOMMANDQUEUE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif PVRSRV_QUEUE_INFO *psQueueInfo; }PVRSRV_BRIDGE_IN_DESTROYCOMMANDQUEUE; @@ -685,11 +599,7 @@ typedef struct PVRSRV_BRIDGE_IN_DESTROYCOMMANDQUEUE_TAG typedef struct PVRSRV_BRIDGE_IN_MHANDLE_TO_MMAP_DATA_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMHandle; /* Handle associated with the memory that needs to be mapped */ -#else IMG_HANDLE hMHandle; /* Handle associated with the memory that needs to be mapped */ -#endif } PVRSRV_BRIDGE_IN_MHANDLE_TO_MMAP_DATA; @@ -699,11 +609,7 @@ typedef struct PVRSRV_BRIDGE_IN_MHANDLE_TO_MMAP_DATA_TAG typedef struct PVRSRV_BRIDGE_IN_RELEASE_MMAP_DATA_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMHandle; /* Handle associated with the memory that needs to be mapped */ -#else IMG_HANDLE hMHandle; /* Handle associated with the memory that needs to be mapped */ -#endif } PVRSRV_BRIDGE_IN_RELEASE_MMAP_DATA; @@ -713,14 +619,10 @@ typedef struct PVRSRV_BRIDGE_IN_RELEASE_MMAP_DATA_TAG typedef struct PVRSRV_BRIDGE_IN_RESERVE_DEV_VIRTMEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap; -#else IMG_HANDLE hDevMemHeap; -#endif IMG_DEV_VIRTADDR *psDevVAddr; - IMG_SIZE_T ui32Size; - IMG_SIZE_T ui32Alignment; + IMG_SIZE_T uSize; + IMG_SIZE_T uAlignment; }PVRSRV_BRIDGE_IN_RESERVE_DEV_VIRTMEM; @@ -730,11 +632,7 @@ typedef struct PVRSRV_BRIDGE_IN_RESERVE_DEV_VIRTMEM_TAG typedef struct PVRSRV_BRIDGE_OUT_CONNECT_SERVICES_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelServices; -#else IMG_HANDLE hKernelServices; -#endif }PVRSRV_BRIDGE_OUT_CONNECT_SERVICES; /****************************************************************************** @@ -743,13 +641,8 @@ typedef struct PVRSRV_BRIDGE_OUT_CONNECT_SERVICES_TAG typedef struct PVRSRV_BRIDGE_OUT_RESERVE_DEV_VIRTMEM_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; - IMG_SID hKernelSyncInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -762,11 +655,7 @@ typedef struct PVRSRV_BRIDGE_OUT_RESERVE_DEV_VIRTMEM_TAG typedef struct PVRSRV_BRIDGE_IN_FREE_DEV_VIRTMEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -779,13 +668,8 @@ typedef struct PVRSRV_BRIDGE_IN_FREE_DEV_VIRTMEM_TAG typedef struct PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; - IMG_SID hDstDevMemHeap; -#else IMG_HANDLE hKernelMemInfo; IMG_HANDLE hDstDevMemHeap; -#endif }PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY; @@ -796,11 +680,7 @@ typedef struct PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY_TAG typedef struct PVRSRV_BRIDGE_OUT_MAP_DEV_MEMORY_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDstKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psDstKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sDstClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sDstClientSyncInfo; @@ -813,11 +693,7 @@ typedef struct PVRSRV_BRIDGE_OUT_MAP_DEV_MEMORY_TAG typedef struct PVRSRV_BRIDGE_IN_UNMAP_DEV_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -830,11 +706,7 @@ typedef struct PVRSRV_BRIDGE_IN_UNMAP_DEV_MEMORY_TAG typedef struct PVRSRV_BRIDGE_IN_MAP_EXT_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif IMG_SYS_PHYADDR *psSysPAddr; IMG_UINT32 ui32Flags; @@ -858,13 +730,8 @@ typedef struct PVRSRV_BRIDGE_IN_UNMAP_EXT_MEMORY_TAG typedef struct PVRSRV_BRIDGE_IN_MAP_DEVICECLASS_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceClassBuffer; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDeviceClassBuffer; IMG_HANDLE hDevMemContext; -#endif }PVRSRV_BRIDGE_IN_MAP_DEVICECLASS_MEMORY; @@ -877,13 +744,8 @@ typedef struct PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY_TAG PVRSRV_ERROR eError; PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; - IMG_SID hMappingInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; IMG_HANDLE hMappingInfo; -#endif }PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY; @@ -894,11 +756,7 @@ typedef struct PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY_TAG typedef struct PVRSRV_BRIDGE_IN_UNMAP_DEVICECLASS_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -911,11 +769,7 @@ typedef struct PVRSRV_BRIDGE_IN_UNMAP_DEVICECLASS_MEMORY_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_MEMPOL_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif IMG_UINT32 ui32Offset; IMG_UINT32 ui32Value; IMG_UINT32 ui32Mask; @@ -930,11 +784,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_MEMPOL_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_SYNCPOL_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; -#endif IMG_BOOL bIsRead; IMG_BOOL bUseLastOpDumpVal; IMG_UINT32 ui32Value; @@ -951,11 +801,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPMEM_TAG IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_PVOID pvLinAddr; IMG_PVOID pvAltLinAddr; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif IMG_UINT32 ui32Offset; IMG_UINT32 ui32Bytes; IMG_UINT32 ui32Flags; @@ -970,11 +816,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPSYNC_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_PVOID pvAltLinAddr; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; -#endif IMG_UINT32 ui32Offset; IMG_UINT32 ui32Bytes; @@ -987,11 +829,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPSYNC_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPREG_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif PVRSRV_HWREG sHWReg; IMG_UINT32 ui32Flags; IMG_CHAR szRegRegion[32]; @@ -1004,11 +842,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPREG_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_REGPOL_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif PVRSRV_HWREG sHWReg; IMG_UINT32 ui32Mask; IMG_UINT32 ui32Flags; @@ -1032,13 +866,8 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPPDREG_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_MEMPAGES_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hKernelMemInfo; -#endif IMG_DEV_PHYADDR *pPages; IMG_UINT32 ui32NumPages; IMG_DEV_VIRTADDR sDevVAddr; @@ -1078,22 +907,14 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_SETFRAME_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_BITMAP_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_UINT32 ui32Width; IMG_UINT32 ui32Height; IMG_UINT32 ui32StrideInBytes; IMG_DEV_VIRTADDR sDevBaseAddr; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevMemContext; -#endif IMG_UINT32 ui32Size; PDUMP_PIXEL_FORMAT ePixelFormat; PDUMP_MEM_FORMAT eMemFormat; @@ -1108,11 +929,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_BITMAP_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_READREG_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_UINT32 ui32Address; @@ -1136,11 +953,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DRIVERINFO_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPPDDEVPADDR_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hKernelMemInfo; -#endif IMG_UINT32 ui32Offset; IMG_DEV_PHYADDR sPDDevPAddr; }PVRSRV_BRIDGE_IN_PDUMP_DUMPPDDEVPADDR; @@ -1151,11 +964,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPPDDEVPADDR_TAG typedef struct PVRSRV_BRIDGE_PDUM_IN_CYCLE_COUNT_REG_READ_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_UINT32 ui32RegOffset; IMG_BOOL bLastFrame; }PVRSRV_BRIDGE_IN_PDUMP_CYCLE_COUNT_REG_READ; @@ -1183,11 +992,7 @@ typedef struct PVRSRV_BRIDGE_OUT_ACQUIRE_DEVICEINFO_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif } PVRSRV_BRIDGE_OUT_ACQUIRE_DEVICEINFO; @@ -1211,11 +1016,7 @@ typedef struct PVRSRV_BRIDGE_IN_OPEN_DISPCLASS_DEVICE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_UINT32 ui32DeviceID; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_OPEN_DISPCLASS_DEVICE; @@ -1225,11 +1026,7 @@ typedef struct PVRSRV_BRIDGE_IN_OPEN_DISPCLASS_DEVICE_TAG typedef struct PVRSRV_BRIDGE_OUT_OPEN_DISPCLASS_DEVICE_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif }PVRSRV_BRIDGE_OUT_OPEN_DISPCLASS_DEVICE; @@ -1240,16 +1037,11 @@ typedef struct PVRSRV_BRIDGE_OUT_OPEN_DISPCLASS_DEVICE_TAG typedef struct PVRSRV_BRIDGE_IN_WRAP_EXT_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; -#endif IMG_VOID *pvLinAddr; - IMG_SIZE_T ui32ByteSize; - IMG_SIZE_T ui32PageOffset; + IMG_SIZE_T uByteSize; + IMG_SIZE_T uPageOffset; IMG_BOOL bPhysContig; IMG_UINT32 ui32NumPageTableEntries; IMG_SYS_PHYADDR *psSysPAddr; @@ -1274,11 +1066,7 @@ typedef struct PVRSRV_BRIDGE_OUT_WRAP_EXT_MEMORY_TAG typedef struct PVRSRV_BRIDGE_IN_UNWRAP_EXT_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -1308,11 +1096,7 @@ typedef struct PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_FORMATS_TAG typedef struct PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_DIMS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif DISPLAY_FORMAT sFormat; }PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_DIMS; @@ -1347,11 +1131,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_INFO_TAG typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_SYSBUFFER_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hBuffer; -#else IMG_HANDLE hBuffer; -#endif }PVRSRV_BRIDGE_OUT_GET_DISPCLASS_SYSBUFFER; @@ -1362,11 +1142,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_SYSBUFFER_TAG typedef struct PVRSRV_BRIDGE_IN_CREATE_DISPCLASS_SWAPCHAIN_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif IMG_UINT32 ui32Flags; DISPLAY_SURF_ATTRIBUTES sDstSurfAttrib; DISPLAY_SURF_ATTRIBUTES sSrcSurfAttrib; @@ -1383,11 +1159,7 @@ typedef struct PVRSRV_BRIDGE_IN_CREATE_DISPCLASS_SWAPCHAIN_TAG typedef struct PVRSRV_BRIDGE_OUT_CREATE_DISPCLASS_SWAPCHAIN_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSwapChain; -#else IMG_HANDLE hSwapChain; -#endif IMG_UINT32 ui32SwapChainID; } PVRSRV_BRIDGE_OUT_CREATE_DISPCLASS_SWAPCHAIN; @@ -1399,13 +1171,8 @@ typedef struct PVRSRV_BRIDGE_OUT_CREATE_DISPCLASS_SWAPCHAIN_TAG typedef struct PVRSRV_BRIDGE_IN_DESTROY_DISPCLASS_SWAPCHAIN_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hSwapChain; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; -#endif } PVRSRV_BRIDGE_IN_DESTROY_DISPCLASS_SWAPCHAIN; @@ -1416,13 +1183,8 @@ typedef struct PVRSRV_BRIDGE_IN_DESTROY_DISPCLASS_SWAPCHAIN_TAG typedef struct PVRSRV_BRIDGE_IN_SET_DISPCLASS_RECT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hSwapChain; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; -#endif IMG_RECT sRect; } PVRSRV_BRIDGE_IN_SET_DISPCLASS_RECT; @@ -1434,13 +1196,8 @@ typedef struct PVRSRV_BRIDGE_IN_SET_DISPCLASS_RECT_TAG typedef struct PVRSRV_BRIDGE_IN_SET_DISPCLASS_COLOURKEY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hSwapChain; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; -#endif IMG_UINT32 ui32CKColour; } PVRSRV_BRIDGE_IN_SET_DISPCLASS_COLOURKEY; @@ -1452,13 +1209,8 @@ typedef struct PVRSRV_BRIDGE_IN_SET_DISPCLASS_COLOURKEY_TAG typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_BUFFERS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hSwapChain; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; -#endif } PVRSRV_BRIDGE_IN_GET_DISPCLASS_BUFFERS; @@ -1470,11 +1222,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_BUFFERS_TAG { PVRSRV_ERROR eError; IMG_UINT32 ui32BufferCount; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahBuffer[PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS]; -#else IMG_HANDLE ahBuffer[PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS]; -#endif IMG_SYS_PHYADDR asPhyAddr[PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS]; } PVRSRV_BRIDGE_OUT_GET_DISPCLASS_BUFFERS; @@ -1485,37 +1233,24 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_BUFFERS_TAG typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hBuffer; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hBuffer; -#endif IMG_UINT32 ui32SwapInterval; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hPrivateTag; -#else IMG_HANDLE hPrivateTag; -#endif IMG_UINT32 ui32ClipRectCount; IMG_RECT sClipRect[PVRSRV_MAX_DC_CLIP_RECTS]; } PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER; + /****************************************************************************** - * 'bridge in' swap to buffer + * 'bridge in' swap to buffer 2 *****************************************************************************/ typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hSwapChain; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; -#endif IMG_UINT32 ui32SwapInterval; IMG_UINT32 ui32NumMemInfos; @@ -1527,19 +1262,26 @@ typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2_TAG } PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2; + +/****************************************************************************** + * 'bridge out' swap to buffer 2 + *****************************************************************************/ +typedef struct PVRSRV_BRIDGE_OUT_SWAP_DISPCLASS_TO_BUFFER2_TAG +{ + PVRSRV_ERROR eError; + IMG_HANDLE hFence; + +} PVRSRV_BRIDGE_OUT_SWAP_DISPCLASS_TO_BUFFER2; + + /****************************************************************************** * 'bridge in' swap to system buffer (primary) *****************************************************************************/ typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_SYSTEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; - IMG_SID hSwapChain; -#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; -#endif } PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_SYSTEM; @@ -1551,11 +1293,7 @@ typedef struct PVRSRV_BRIDGE_IN_OPEN_BUFFERCLASS_DEVICE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_UINT32 ui32DeviceID; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif } PVRSRV_BRIDGE_IN_OPEN_BUFFERCLASS_DEVICE; @@ -1566,11 +1304,7 @@ typedef struct PVRSRV_BRIDGE_IN_OPEN_BUFFERCLASS_DEVICE_TAG typedef struct PVRSRV_BRIDGE_OUT_OPEN_BUFFERCLASS_DEVICE_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif } PVRSRV_BRIDGE_OUT_OPEN_BUFFERCLASS_DEVICE; @@ -1592,11 +1326,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_INFO_TAG typedef struct PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_BUFFER_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif IMG_UINT32 ui32BufferIndex; } PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_BUFFER; @@ -1608,11 +1338,7 @@ typedef struct PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_BUFFER_TAG typedef struct PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_BUFFER_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hBuffer; -#else IMG_HANDLE hBuffer; -#endif } PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_BUFFER; @@ -1635,11 +1361,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DEVMEM_HEAPINFO_TAG typedef struct PVRSRV_BRIDGE_OUT_CREATE_DEVMEMCONTEXT_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevMemContext; -#endif IMG_UINT32 ui32ClientHeapCount; PVRSRV_HEAP_INFO sHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; @@ -1652,11 +1374,7 @@ typedef struct PVRSRV_BRIDGE_OUT_CREATE_DEVMEMCONTEXT_TAG typedef struct PVRSRV_BRIDGE_OUT_CREATE_DEVMEMHEAP_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeap; -#else IMG_HANDLE hDevMemHeap; -#endif } PVRSRV_BRIDGE_OUT_CREATE_DEVMEMHEAP; @@ -1667,11 +1385,7 @@ typedef struct PVRSRV_BRIDGE_OUT_CREATE_DEVMEMHEAP_TAG typedef struct PVRSRV_BRIDGE_OUT_ALLOCDEVICEMEM_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -1684,11 +1398,7 @@ typedef struct PVRSRV_BRIDGE_OUT_ALLOCDEVICEMEM_TAG typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMemInfo; -#else IMG_HANDLE hMemInfo; -#endif #if defined(SUPPORT_MEMINFO_IDS) IMG_UINT64 ui64Stamp; #endif @@ -1702,13 +1412,10 @@ typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG typedef struct _PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE_ { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; + IMG_SIZE_T uiIonBufferSize; } PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE; @@ -1720,11 +1427,7 @@ typedef struct PVRSRV_BRIDGE_OUT_MAPMEMINFOTOUSER_TAG { PVRSRV_ERROR eError; IMG_PVOID pvLinAddr; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMappingInfo; -#else IMG_HANDLE hMappingInfo; -#endif }PVRSRV_BRIDGE_OUT_MAPMEMINFOTOUSER; @@ -1735,9 +1438,9 @@ typedef struct PVRSRV_BRIDGE_OUT_MAPMEMINFOTOUSER_TAG typedef struct PVRSRV_BRIDGE_OUT_GETFREEDEVICEMEM_TAG { PVRSRV_ERROR eError; - IMG_SIZE_T ui32Total; - IMG_SIZE_T ui32Free; - IMG_SIZE_T ui32LargestBlock; + IMG_SIZE_T uTotal; + IMG_SIZE_T uFree; + IMG_SIZE_T uLargestBlock; } PVRSRV_BRIDGE_OUT_GETFREEDEVICEMEM; @@ -1754,18 +1457,18 @@ typedef struct PVRSRV_BRIDGE_OUT_MHANDLE_TO_MMAP_DATA_TAG /* This is a the offset you should pass to mmap(2) so that * the driver can look up the full details for the mapping * request. */ - IMG_UINT32 ui32MMapOffset; + IMG_UINTPTR_T uiMMapOffset; /* This is the byte offset you should add to the mapping you * get from mmap */ - IMG_UINT32 ui32ByteOffset; + IMG_UINTPTR_T uiByteOffset; /* This is the real size of the mapping that will be created * which should be passed to mmap _and_ munmap. */ - IMG_UINT32 ui32RealByteSize; + IMG_SIZE_T uiRealByteSize; /* User mode address associated with mapping */ - IMG_UINT32 ui32UserVAddr; + IMG_UINTPTR_T uiUserVAddr; } PVRSRV_BRIDGE_OUT_MHANDLE_TO_MMAP_DATA; @@ -1777,13 +1480,20 @@ typedef struct PVRSRV_BRIDGE_OUT_RELEASE_MMAP_DATA_TAG IMG_BOOL bMUnmap; /* User mode address associated with mapping */ - IMG_UINT32 ui32UserVAddr; + IMG_UINTPTR_T uiUserVAddr; /* Size of mapping */ - IMG_UINT32 ui32RealByteSize; + IMG_SIZE_T uiRealByteSize; } PVRSRV_BRIDGE_OUT_RELEASE_MMAP_DATA; //#endif +typedef struct PVRSRV_BRIDGE_IN_COMPAT_CHECK +{ + IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ + IMG_UINT32 ui32DDKVersion; + IMG_UINT32 ui32DDKBuild; + +} PVRSRV_BRIDGE_IN_COMPAT_CHECK; /****************************************************************************** * 'bridge in' get misc info @@ -1846,8 +1556,8 @@ typedef struct PVRSRV_BRIDGE_OUT_PDUMP_ISCAPTURING_TAG typedef struct PVRSRV_BRIDGE_IN_GET_FB_STATS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ - IMG_SIZE_T ui32Total; - IMG_SIZE_T ui32Available; + IMG_SIZE_T uTotal; + IMG_SIZE_T uAvailable; } PVRSRV_BRIDGE_IN_GET_FB_STATS; @@ -1858,11 +1568,7 @@ typedef struct PVRSRV_BRIDGE_IN_GET_FB_STATS_TAG typedef struct PVRSRV_BRIDGE_IN_MAPPHYSTOUSERSPACE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_SYS_PHYADDR sSysPhysAddr; IMG_UINT32 uiSizeInBytes; @@ -1887,11 +1593,7 @@ typedef struct PVRSRV_BRIDGE_OUT_MAPPHYSTOUSERSPACE_TAG typedef struct PVRSRV_BRIDGE_IN_UNMAPPHYSTOUSERSPACE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_PVOID pvUserAddr; IMG_PVOID pvProcess; @@ -1909,7 +1611,6 @@ typedef struct PVRSRV_BRIDGE_OUT_GETPHYSTOUSERSPACEMAP_TAG } PVRSRV_BRIDGE_OUT_GETPHYSTOUSERSPACEMAP; -#if !defined (SUPPORT_SID_INTERFACE) /****************************************************************************** * 'bridge in' Register RTSIM process thread *****************************************************************************/ @@ -1959,7 +1660,6 @@ typedef struct PVRSRV_BRIDGE_IN_PROCESS_SIMISR_EVENT_TAG PVRSRV_ERROR eError; } PVRSRV_BRIDGE_IN_PROCESS_SIMISR_EVENT; -#endif /* #if !defined (SUPPORT_SID_INTERFACE) */ /****************************************************************************** * 'bridge in' initialisation server disconnect @@ -1975,28 +1675,20 @@ typedef struct PVRSRV_BRIDGE_IN_ALLOC_SHARED_SYS_MEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_UINT32 ui32Flags; - IMG_SIZE_T ui32Size; + IMG_SIZE_T uSize; }PVRSRV_BRIDGE_IN_ALLOC_SHARED_SYS_MEM; typedef struct PVRSRV_BRIDGE_OUT_ALLOC_SHARED_SYS_MEM_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; }PVRSRV_BRIDGE_OUT_ALLOC_SHARED_SYS_MEM; typedef struct PVRSRV_BRIDGE_IN_FREE_SHARED_SYS_MEM_TAG { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; - IMG_SID hMappingInfo; -#else IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; }PVRSRV_BRIDGE_IN_FREE_SHARED_SYS_MEM; @@ -2008,22 +1700,14 @@ typedef struct PVRSRV_BRIDGE_OUT_FREE_SHARED_SYS_MEM_TAG typedef struct PVRSRV_BRIDGE_IN_MAP_MEMINFO_MEM_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hKernelMemInfo; -#endif }PVRSRV_BRIDGE_IN_MAP_MEMINFO_MEM; typedef struct PVRSRV_BRIDGE_OUT_MAP_MEMINFO_MEM_TAG { PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVRSRV_ERROR eError; }PVRSRV_BRIDGE_OUT_MAP_MEMINFO_MEM; @@ -2041,11 +1725,7 @@ typedef struct PVRSRV_BRIDGE_OUT_UNMAP_MEMINFO_MEM_TAG typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_WAI_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hOSEventKM; -#else IMG_HANDLE hOSEventKM; -#endif } PVRSRV_BRIDGE_IN_EVENT_OBJECT_WAIT; typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_OPEN_TAG @@ -2055,56 +1735,35 @@ typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_OPEN_TAG typedef struct PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN_TAG { -#if defined (SUPPORT_SID_INTERFACE) - IMG_UINT32 hOSEvent; -#else IMG_HANDLE hOSEvent; -#endif PVRSRV_ERROR eError; } PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN; typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_CLOSE_TAG { PVRSRV_EVENTOBJECT sEventObject; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hOSEventKM; -#else IMG_HANDLE hOSEventKM; -#endif } PVRSRV_BRIDGE_IN_EVENT_OBJECT_CLOSE; typedef struct PVRSRV_BRIDGE_OUT_CREATE_SYNC_INFO_MOD_OBJ_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj; -#else IMG_HANDLE hKernelSyncInfoModObj; -#endif } PVRSRV_BRIDGE_OUT_CREATE_SYNC_INFO_MOD_OBJ; typedef struct PVRSRV_BRIDGE_IN_DESTROY_SYNC_INFO_MOD_OBJ { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj; -#else IMG_HANDLE hKernelSyncInfoModObj; -#endif } PVRSRV_BRIDGE_IN_DESTROY_SYNC_INFO_MOD_OBJ; typedef struct PVRSRV_BRIDGE_IN_MODIFY_PENDING_SYNC_OPS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj; - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfoModObj; IMG_HANDLE hKernelSyncInfo; -#endif IMG_UINT32 ui32ModifyFlags; } PVRSRV_BRIDGE_IN_MODIFY_PENDING_SYNC_OPS; @@ -2112,11 +1771,7 @@ typedef struct PVRSRV_BRIDGE_IN_MODIFY_PENDING_SYNC_OPS_TAG typedef struct PVRSRV_BRIDGE_IN_MODIFY_COMPLETE_SYNC_OPS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj; -#else IMG_HANDLE hKernelSyncInfoModObj; -#endif } PVRSRV_BRIDGE_IN_MODIFY_COMPLETE_SYNC_OPS; typedef struct PVRSRV_BRIDGE_OUT_MODIFY_PENDING_SYNC_OPS_TAG @@ -2133,11 +1788,7 @@ typedef struct PVRSRV_BRIDGE_OUT_MODIFY_PENDING_SYNC_OPS_TAG typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_TAKE_TOKEN_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfo; -#endif } PVRSRV_BRIDGE_IN_SYNC_OPS_TAKE_TOKEN; @@ -2154,11 +1805,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SYNC_OPS_TAKE_TOKEN_TAG typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_TOKEN_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfo; -#endif IMG_UINT32 ui32ReadOpsPendingSnapshot; IMG_UINT32 ui32WriteOpsPendingSnapshot; IMG_UINT32 ui32ReadOps2PendingSnapshot; @@ -2167,21 +1814,13 @@ typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_TOKEN_TAG typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_MOD_OBJ_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfoModObj; -#else IMG_HANDLE hKernelSyncInfoModObj; -#endif } PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_MOD_OBJ; typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_DELTA_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfo; -#endif IMG_UINT32 ui32Delta; } PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_DELTA; @@ -2189,33 +1828,21 @@ typedef struct PVRSRV_BRIDGE_IN_ALLOC_SYNC_INFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif } PVRSRV_BRIDGE_IN_ALLOC_SYNC_INFO; typedef struct PVRSRV_BRIDGE_OUT_ALLOC_SYNC_INFO_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfo; -#endif } PVRSRV_BRIDGE_OUT_ALLOC_SYNC_INFO; typedef struct PVRSRV_BRIDGE_IN_FREE_SYNC_INFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelSyncInfo; -#else IMG_HANDLE hKernelSyncInfo; -#endif } PVRSRV_BRIDGE_IN_FREE_SYNC_INFO; typedef struct PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS_TAG @@ -2224,24 +1851,6 @@ typedef struct PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS_TAG IMG_UINT32 ui32Attribs; } PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS; -/****************************************************************************** - * 'bridge in' multi manage device memory - *****************************************************************************/ -typedef PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS PVRSRV_BRIDGE_IN_MULTI_MANAGE_DEV_MEM; - -/****************************************************************************** - * 'bridge out' multi manage device memory - *****************************************************************************/ -typedef struct PVRSRV_BRIDGE_OUT_MULTI_MANAGE_DEV_MEM_TAG -{ - IMG_UINT32 ui32NumberOfRequestsProcessed; - IMG_UINT32 ui32CtrlFlags; - IMG_UINT32 ui32StatusFlags; - IMG_UINT32 ui32IndexError; - PVRSRV_ERROR eError; - /* Memory Requests Array - used only with direct (not memory shared( mode */ - PVRSRV_MANAGE_DEV_MEM_RESPONSE sMemResponse[PVRSRV_MULTI_MANAGE_DEV_MEM_MAX_DIRECT_SIZE]; -}PVRSRV_BRIDGE_OUT_MULTI_MANAGE_DEV_MEM; #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/services4/include/pvr_bridge_km.h b/drivers/gpu/pvr/services4/include/pvr_bridge_km.h index 1bf5b9c2cde..d6f7a726155 100644..100755 --- a/drivers/gpu/pvr/services4/include/pvr_bridge_km.h +++ b/drivers/gpu/pvr/services4/include/pvr_bridge_km.h @@ -56,7 +56,14 @@ extern "C" { #if defined(__linux__) PVRSRV_ERROR LinuxBridgeInit(IMG_VOID); IMG_VOID LinuxBridgeDeInit(IMG_VOID); + +#if defined(SUPPORT_MEMINFO_IDS) +extern IMG_UINT64 g_ui64MemInfoID; +#endif + #endif +IMG_IMPORT +IMG_VOID IMG_CALLCONV PVRSRVCompatCheckKM(PVRSRV_BRIDGE_IN_COMPAT_CHECK *psUserModeDDKDetails, PVRSRV_BRIDGE_RETURN *psRetOUT); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevicesKM(IMG_UINT32 *pui32NumDevices, @@ -68,7 +75,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAcquireDeviceDataKM(IMG_UINT32 uiDevIndex, IMG_HANDLE *phDevCookie); IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, +PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize, PVRSRV_QUEUE_INFO **ppsQueueInfo); IMG_IMPORT @@ -76,22 +83,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapsKM(IMG_HANDLE hDevCookie, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *psHeapInfo); -#else PVRSRV_HEAP_INFO *psHeapInfo); -#endif IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCookie, PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE *phDevMemContext, IMG_UINT32 *pui32ClientHeapCount, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *psHeapInfo, -#else PVRSRV_HEAP_INFO *psHeapInfo, -#endif IMG_BOOL *pbCreated, IMG_BOOL *pbShared); @@ -106,11 +105,7 @@ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemContext, IMG_UINT32 *pui32ClientHeapCount, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *psHeapInfo, -#else PVRSRV_HEAP_INFO *psHeapInfo, -#endif IMG_BOOL *pbShared ); @@ -150,24 +145,20 @@ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie, PVRSRV_KERNEL_MEM_INFO *psMemInfo); -IMG_EXPORT -IMG_INT32 IMG_CALLCONV PVRSRVRemapToDevKM(IMG_HANDLE hDevCookie, - PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_DEV_VIRTADDR *psDevVAddr); - -IMG_EXPORT -IMG_INT32 IMG_CALLCONV PVRSRVUnmapFromDevKM(IMG_HANDLE hDevCookie, - PVRSRV_KERNEL_MEM_INFO *psMemInfo); - - #if defined(SUPPORT_ION) IMG_IMPORT PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevCookie, - IMG_HANDLE hDevMemContext, - IMG_HANDLE hIon, + IMG_HANDLE hDevMemHeap, + IMG_UINT32 ui32NumFDs, + IMG_INT32 *pai32BufferFDs, IMG_UINT32 ui32Flags, - IMG_UINT32 ui32Size, - PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo); + IMG_UINT32 ui32ChunkCount, + IMG_SIZE_T *pauiOffset, + IMG_SIZE_T *pauiSize, + IMG_SIZE_T *puiIonBufferSize, + PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo, + IMG_UINT64 *pui64Stamp); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapIonHandleKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); @@ -211,6 +202,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVUnwrapExtMemoryKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + IMG_IMPORT PVRSRV_ERROR PVRSRVEnumerateDCKM(PVRSRV_DEVICE_CLASS DeviceClass, IMG_UINT32 *pui32DevCount, @@ -292,7 +285,8 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, PVRSRV_KERNEL_SYNC_INFO **ppsSyncInfos, IMG_UINT32 ui32NumMemSyncInfos, IMG_PVOID pvPrivData, - IMG_UINT32 ui32PrivDataLength); + IMG_UINT32 ui32PrivDataLength, + IMG_HANDLE *phFence); IMG_IMPORT PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, IMG_HANDLE hSwapChain); @@ -313,7 +307,6 @@ PVRSRV_ERROR PVRSRVGetBCBufferKM(IMG_HANDLE hDeviceKM, IMG_UINT32 ui32BufferIndex, IMG_HANDLE *phBuffer); - IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevMemContext, @@ -321,14 +314,16 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * PVRSRV_KERNEL_MEM_INFO **ppsMemInfo, IMG_HANDLE *phOSMapInfo); +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemoryKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); + +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKernelMemInfo, IMG_UINT32 ui32Attribs); IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemoryKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); - -IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetFreeDeviceMemKM(IMG_UINT32 ui32Flags, IMG_SIZE_T *pui32Total, IMG_SIZE_T *pui32Free, @@ -343,11 +338,7 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVReleaseSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo); IMG_IMPORT -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO_KM *psMiscInfo); -#else PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo); -#endif /*! * ***************************************************************************** diff --git a/drivers/gpu/pvr/services4/include/pvrmmap.h b/drivers/gpu/pvr/services4/include/pvrmmap.h index 1a3930cf3ea..c18c872526f 100644..100755 --- a/drivers/gpu/pvr/services4/include/pvrmmap.h +++ b/drivers/gpu/pvr/services4/include/pvrmmap.h @@ -54,11 +54,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @return PVRSRV_OK, or error code. ***************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRPMapKMem(IMG_HANDLE hModule, IMG_VOID **ppvLinAddr, IMG_VOID *pvLinAddrKM, IMG_SID *phMappingInfo, IMG_SID hMHandle); -#else PVRSRV_ERROR PVRPMapKMem(IMG_HANDLE hModule, IMG_VOID **ppvLinAddr, IMG_VOID *pvLinAddrKM, IMG_HANDLE *phMappingInfo, IMG_HANDLE hMHandle); -#endif /*! @@ -71,11 +67,7 @@ PVRSRV_ERROR PVRPMapKMem(IMG_HANDLE hModule, IMG_VOID **ppvLinAddr, IMG_VOID *pv @return IMG_BOOL indicating success or otherwise. ***************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -IMG_BOOL PVRUnMapKMem(IMG_HANDLE hModule, IMG_SID hMappingInfo, IMG_SID hMHandle); -#else IMG_BOOL PVRUnMapKMem(IMG_HANDLE hModule, IMG_HANDLE hMappingInfo, IMG_HANDLE hMHandle); -#endif #endif /* _PVRMMAP_H_ */ diff --git a/drivers/gpu/pvr/services4/include/pvrsrv_errors.h b/drivers/gpu/pvr/services4/include/pvrsrv_errors.h index 2e95810a528..2e95810a528 100644..100755 --- a/drivers/gpu/pvr/services4/include/pvrsrv_errors.h +++ b/drivers/gpu/pvr/services4/include/pvrsrv_errors.h diff --git a/drivers/gpu/pvr/services4/include/servicesint.h b/drivers/gpu/pvr/services4/include/servicesint.h index 5b39093d352..2ae1a3bc033 100644..100755 --- a/drivers/gpu/pvr/services4/include/servicesint.h +++ b/drivers/gpu/pvr/services4/include/servicesint.h @@ -49,7 +49,6 @@ extern "C" { #include "services.h" #include "sysinfo.h" -#include "sysconfig.h" #define HWREC_DEFAULT_TIMEOUT (500) @@ -87,8 +86,28 @@ typedef enum _PVRSRV_MEMTYPE_ PVRSRV_MEMTYPE_WRAPPED = 3, PVRSRV_MEMTYPE_MAPPED = 4, PVRSRV_MEMTYPE_ION = 5, + PVRSRV_MEMTYPE_ALLOC = 6, + PVRSRV_MEMTYPE_FREE = 7 } PVRSRV_MEMTYPE; +#if defined (MEM_TRACK_INFO_DEBUG) +/* Threshold on number of latest operations to track*/ +#define MAX_MEM_TRACK_OPS 512 +typedef struct _PVRSRV_MEM_TRACK_INFO_ +{ + IMG_DEV_VIRTADDR sDevVAddr; + IMG_SIZE_T uSize; + IMG_UINT32 ui32Pid; + IMG_UINT32 ui32RefCount; + PVRSRV_MEMTYPE eOp; + IMG_UINT32 ui32TimeStampUSecs; + IMG_CHAR asTaskName[128]; + IMG_CHAR heapId[128]; + struct _PVRSRV_MEM_TRACK_INFO_ *next; + struct _PVRSRV_MEM_TRACK_INFO_ *prev; + +} PVRSRV_MEM_TRACK_INFO; +#endif /* Kernel Memory Information structure */ @@ -132,12 +151,9 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_ /* ptr to associated kernel sync info - NULL if no sync */ struct _PVRSRV_KERNEL_SYNC_INFO_ *psKernelSyncInfo; - PVRSRV_MEMTYPE memType; - - IMG_VOID *bvmap_handle; + IMG_HANDLE hIonSyncInfo; - /* Device Virtual Address Offsets for the YUV MM planes */ - IMG_UINT32 planeOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; + PVRSRV_MEMTYPE memType; /* To activate the "share mem workaround", add PVRSRV_MEM_XPROC to @@ -166,6 +182,9 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_ IMG_UINT32 ui32OrigReqSize; IMG_UINT32 ui32OrigReqAlignment; } sShareMemWorkaround; +#if defined (MEM_TRACK_INFO_DEBUG) + IMG_CHAR heapId[128]; +#endif } PVRSRV_KERNEL_MEM_INFO; @@ -199,6 +218,21 @@ typedef struct _PVRSRV_KERNEL_SYNC_INFO_ /* Unique ID of the sync object */ IMG_UINT32 ui32UID; + + /* Pointer for list manager */ + struct _PVRSRV_KERNEL_SYNC_INFO_ *psNext; + struct _PVRSRV_KERNEL_SYNC_INFO_ **ppsThis; + +#if defined(SUPPORT_PER_SYNC_DEBUG) +#define PER_SYNC_HISTORY 10 + IMG_UINT32 ui32OperationMask; + IMG_UINT32 aui32OpInfo[PER_SYNC_HISTORY]; + IMG_UINT32 aui32ReadOpSample[PER_SYNC_HISTORY]; + IMG_UINT32 aui32WriteOpSample[PER_SYNC_HISTORY]; + IMG_UINT32 aui32ReadOp2Sample[PER_SYNC_HISTORY]; + IMG_UINT32 ui32HistoryIndex; +#endif + } PVRSRV_KERNEL_SYNC_INFO; /*! @@ -253,6 +287,11 @@ typedef struct _PVRSRV_COMMAND allocated on back of this structure, i.e. is resident in Q */ PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete; /*!< Command complete callback */ IMG_HANDLE hCallbackData; /*!< Command complete callback data */ + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + IMG_VOID *pvCleanupFence; /*!< Sync fence to 'put' after timeline inc() */ + IMG_VOID *pvTimeline; /*!< Android sync timeline to inc() */ +#endif }PVRSRV_COMMAND, *PPVRSRV_COMMAND; @@ -288,10 +327,10 @@ typedef struct _PVRSRV_QUEUE_INFO_ IMG_VOID *pvLinQueueUM; /*!< Pointer to the command buffer in the user's address space */ - volatile IMG_SIZE_T ui32ReadOffset; /*!< Index into the buffer at which commands are being + volatile IMG_SIZE_T uReadOffset; /*!< Index into the buffer at which commands are being consumed */ - volatile IMG_SIZE_T ui32WriteOffset; /*!< Index into the buffer at which commands are being + volatile IMG_SIZE_T uWriteOffset; /*!< Index into the buffer at which commands are being added */ IMG_UINT32 *pui32KickerAddrKM; /*!< kicker address in the kernel's @@ -300,12 +339,17 @@ typedef struct _PVRSRV_QUEUE_INFO_ IMG_UINT32 *pui32KickerAddrUM; /*!< kicker address in the user's address space */ - IMG_SIZE_T ui32QueueSize; /*!< Size in bytes of the buffer - excluding the safety allocation */ + IMG_SIZE_T uQueueSize; /*!< Size in bytes of the buffer - excluding the safety allocation */ IMG_UINT32 ui32ProcessID; /*!< Process ID required by resource locking */ IMG_HANDLE hMemBlock[2]; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + IMG_UINT32 ui32FenceValue; /*!< 'Target' timeline value when fence signals */ + IMG_VOID *pvTimeline; /*!< Android struct sync_timeline object */ +#endif + struct _PVRSRV_QUEUE_INFO_ *psNextKM; /*!< The next queue in the system */ }PVRSRV_QUEUE_INFO; @@ -434,11 +478,7 @@ typedef struct PVRSRV_DEVICECLASS_BUFFER_TAG */ typedef struct PVRSRV_CLIENT_DEVICECLASS_INFO_TAG { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDeviceKM; -#else IMG_HANDLE hDeviceKM; -#endif IMG_HANDLE hServices; } PVRSRV_CLIENT_DEVICECLASS_INFO; @@ -482,7 +522,7 @@ PVRSRV_ERROR PVRSRVQueueCommand(IMG_HANDLE hQueueInfo, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSharedSysMem(const PVRSRV_CONNECTION *psConnection, IMG_UINT32 ui32Flags, - IMG_SIZE_T ui32Size, + IMG_SIZE_T uSize, PVRSRV_CLIENT_MEM_INFO **ppsClientMemInfo); /*! @@ -538,12 +578,13 @@ PVRSRVUnrefSharedSysMem(const PVRSRV_CONNECTION *psConnection, ********************************************************************************/ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapMemInfoMem(const PVRSRV_CONNECTION *psConnection, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo, -#else IMG_HANDLE hKernelMemInfo, -#endif PVRSRV_CLIENT_MEM_INFO **ppsClientMemInfo); +#if defined(MEM_TRACK_INFO_DEBUG) +IMG_IMPORT IMG_VOID PVRSRVPrintMemTrackInfo(IMG_UINT32 ui32FaultAddr); +IMG_IMPORT IMG_VOID PVRSRVAddMemTrackInfo(PVRSRV_MEM_TRACK_INFO *psMemTrackInfo); +IMG_IMPORT IMG_VOID PVRSRVFreeMemOps(IMG_VOID); +#endif #if defined (__cplusplus) diff --git a/drivers/gpu/pvr/services4/include/sgx_bridge.h b/drivers/gpu/pvr/services4/include/sgx_bridge.h index 33b27e3f250..ab1593ff132 100644..100755 --- a/drivers/gpu/pvr/services4/include/sgx_bridge.h +++ b/drivers/gpu/pvr/services4/include/sgx_bridge.h @@ -43,11 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if !defined(__SGX_BRIDGE_H__) #define __SGX_BRIDGE_H__ -#if defined (SUPPORT_SID_INTERFACE) -#include "sgxapi.h" -#else #include "sgxapi_km.h" -#endif #include "sgxinfo.h" #include "pvr_bridge.h" @@ -150,13 +146,8 @@ typedef struct PVRSRV_BRIDGE_OUT_GETPHYSPAGEADDR typedef struct PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ - #if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hHWTransferContext; - #else IMG_HANDLE hDevCookie; IMG_HANDLE hHWTransferContext; - #endif IMG_UINT32 ui32Priority; IMG_UINT32 ui32OffsetOfPriorityField; }PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY; @@ -168,13 +159,8 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hHWRenderContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hHWRenderContext; -#endif IMG_UINT32 ui32Priority; IMG_UINT32 ui32OffsetOfPriorityField; }PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY; @@ -186,11 +172,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY_TAG typedef struct PVRSRV_BRIDGE_IN_GETCLIENTINFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_GETCLIENTINFO; /*! @@ -210,11 +192,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GETINTERNALDEVINFO_TAG typedef struct PVRSRV_BRIDGE_IN_GETINTERNALDEVINFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_GETINTERNALDEVINFO; /*! @@ -234,11 +212,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GETCLIENTINFO_TAG typedef struct PVRSRV_BRIDGE_IN_RELEASECLIENTINFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif SGX_CLIENT_INFO sClientInfo; }PVRSRV_BRIDGE_IN_RELEASECLIENTINFO; @@ -249,11 +223,7 @@ typedef struct PVRSRV_BRIDGE_IN_RELEASECLIENTINFO_TAG typedef struct PVRSRV_BRIDGE_IN_ISPBREAKPOLL_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_ISPBREAKPOLL; /*! @@ -263,11 +233,7 @@ typedef struct PVRSRV_BRIDGE_IN_ISPBREAKPOLL_TAG typedef struct PVRSRV_BRIDGE_IN_DOKICK_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif SGX_CCB_KICK sCCBKick; }PVRSRV_BRIDGE_IN_DOKICK; @@ -278,11 +244,7 @@ typedef struct PVRSRV_BRIDGE_IN_DOKICK_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES; @@ -294,11 +256,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES_TAG typedef struct PVRSRV_BRIDGE_IN_SUBMITTRANSFER_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif PVRSRV_TRANSFER_SGX_KICK sKick; }PVRSRV_BRIDGE_IN_SUBMITTRANSFER; @@ -310,11 +268,7 @@ typedef struct PVRSRV_BRIDGE_IN_SUBMITTRANSFER_TAG typedef struct PVRSRV_BRIDGE_IN_SUBMIT2D_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif PVRSRV_2D_SGX_KICK sKick; } PVRSRV_BRIDGE_IN_SUBMIT2D; #endif @@ -327,11 +281,7 @@ typedef struct PVRSRV_BRIDGE_IN_SUBMIT2D_TAG typedef struct PVRSRV_BRIDGE_IN_READREGDWORD_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_PCHAR pszKey; IMG_PCHAR pszValue; }PVRSRV_BRIDGE_IN_READREGDWORD; @@ -354,11 +304,7 @@ typedef struct PVRSRV_BRIDGE_OUT_READREGDWORD_TAG typedef struct PVRSRV_BRIDGE_IN_SGXGETMISCINFO_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif SGX_MISC_INFO *psMiscInfo; }PVRSRV_BRIDGE_IN_SGXGETMISCINFO; @@ -369,11 +315,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGXGETMISCINFO_TAG typedef struct PVRSRV_BRIDGE_IN_SGXINFO_FOR_SRVINIT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif }PVRSRV_BRIDGE_IN_SGXINFO_FOR_SRVINIT; /*! @@ -393,11 +335,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXINFO_FOR_SRVINIT_TAG typedef struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif SGX_BRIDGE_INIT_INFO sInitInfo; }PVRSRV_BRIDGE_IN_SGXDEVINITPART2; @@ -419,13 +357,8 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXDEVINITPART2_TAG typedef struct PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hKernSyncInfo; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hKernSyncInfo; -#endif IMG_BOOL bWaitForComplete; }PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE; @@ -435,26 +368,13 @@ typedef struct PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE_TAG typedef struct PVRSRV_BRIDGE_IN_SGXFINDSHAREDPBDESC_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_BOOL bLockOnFailure; IMG_UINT32 ui32TotalPBSize; }PVRSRV_BRIDGE_IN_SGXFINDSHAREDPBDESC; typedef struct PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC_TAG { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; - IMG_SID hSharedPBDesc; - IMG_SID hSharedPBDescKernelMemInfoHandle; - IMG_SID hHWPBDescKernelMemInfoHandle; - IMG_SID hBlockKernelMemInfoHandle; - IMG_SID hHWBlockKernelMemInfoHandle; - IMG_SID ahSharedPBDescSubKernelMemInfoHandles[PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS]; -#else IMG_HANDLE hKernelMemInfo; IMG_HANDLE hSharedPBDesc; IMG_HANDLE hSharedPBDescKernelMemInfoHandle; @@ -462,7 +382,6 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC_TAG IMG_HANDLE hBlockKernelMemInfoHandle; IMG_HANDLE hHWBlockKernelMemInfoHandle; IMG_HANDLE ahSharedPBDescSubKernelMemInfoHandles[PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS]; -#endif IMG_UINT32 ui32SharedPBDescSubKernelMemInfoHandlesCount; PVRSRV_ERROR eError; }PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC; @@ -470,11 +389,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC_TAG typedef struct PVRSRV_BRIDGE_IN_SGXUNREFSHAREDPBDESC_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSharedPBDesc; -#else IMG_HANDLE hSharedPBDesc; -#endif }PVRSRV_BRIDGE_IN_SGXUNREFSHAREDPBDESC; typedef struct PVRSRV_BRIDGE_OUT_SGXUNREFSHAREDPBDESC_TAG @@ -487,21 +402,12 @@ typedef struct PVRSRV_BRIDGE_IN_SGXADDSHAREDPBDESC_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_UINT32 ui32TotalPBSize; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hSharedPBDescKernelMemInfo; - IMG_SID hHWPBDescKernelMemInfo; - IMG_SID hBlockKernelMemInfo; - IMG_SID hHWBlockKernelMemInfo; - IMG_SID *phKernelMemInfoHandles; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hSharedPBDescKernelMemInfo; IMG_HANDLE hHWPBDescKernelMemInfo; IMG_HANDLE hBlockKernelMemInfo; IMG_HANDLE hHWBlockKernelMemInfo; IMG_HANDLE *phKernelMemInfoHandles; -#endif IMG_UINT32 ui32KernelMemInfoHandlesCount; IMG_DEV_VIRTADDR sHWPBDescDevVAddr; }PVRSRV_BRIDGE_IN_SGXADDSHAREDPBDESC; @@ -509,11 +415,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGXADDSHAREDPBDESC_TAG typedef struct PVRSRV_BRIDGE_OUT_SGXADDSHAREDPBDESC_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hSharedPBDesc; -#else IMG_HANDLE hSharedPBDesc; -#endif }PVRSRV_BRIDGE_OUT_SGXADDSHAREDPBDESC; @@ -529,13 +431,8 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_BUFFER_ARRAY_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; -#endif IMG_UINT32 ui32DumpFrameNum; IMG_BOOL bLastFrame; IMG_UINT32 *pui32Registers; @@ -545,11 +442,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMPCOUNTER_REGISTERS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_UINT32 ui32DumpFrameNum; IMG_BOOL bLastFrame; IMG_UINT32 *pui32Registers; @@ -559,11 +452,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMPCOUNTER_REGISTERS_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_TA_SIGNATURE_REGISTERS_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_UINT32 ui32DumpFrameNum; IMG_UINT32 ui32TAKickCount; IMG_BOOL bLastFrame; @@ -574,13 +463,8 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_TA_SIGNATURE_REGISTERS_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_HWPERFCB_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; -#endif IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_UINT32 ui32PDumpFlags; @@ -590,19 +474,12 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_HWPERFCB_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hDevMemContext; -#else IMG_HANDLE hDevCookie; -#endif IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_DEV_VIRTADDR sDevVAddr; IMG_UINT32 ui32Size; -#if !defined (SUPPORT_SID_INTERFACE) IMG_HANDLE hDevMemContext; -#endif IMG_UINT32 ui32PDumpFlags; }PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM; @@ -612,11 +489,7 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_CPU_VIRTADDR pHWRenderContextCpuVAddr; IMG_UINT32 ui32HWRenderContextSize; IMG_UINT32 ui32OffsetToPDDevPAddr; @@ -626,11 +499,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT_TAG typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHWRenderContext; -#else IMG_HANDLE hHWRenderContext; -#endif IMG_DEV_VIRTADDR sHWRenderContextDevVAddr; }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT; @@ -638,23 +507,14 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_RENDER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_BOOL bForceCleanup; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hHWRenderContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hHWRenderContext; -#endif }PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_RENDER_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_CPU_VIRTADDR pHWTransferContextCpuVAddr; IMG_UINT32 ui32HWTransferContextSize; IMG_UINT32 ui32OffsetToPDDevPAddr; @@ -664,11 +524,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHWTransferContext; -#else IMG_HANDLE hHWTransferContext; -#endif IMG_DEV_VIRTADDR sHWTransferContextDevVAddr; }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT; @@ -676,23 +532,14 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_TRANSFER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_BOOL bForceCleanup; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hHWTransferContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hHWTransferContext; -#endif }PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_TRANSFER_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_DEV_VIRTADDR sHWRTDataSetDevVAddr; }PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET; @@ -704,11 +551,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_CPU_VIRTADDR pHW2DContextCpuVAddr; IMG_UINT32 ui32HW2DContextSize; IMG_UINT32 ui32OffsetToPDDevPAddr; @@ -718,11 +561,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT_TAG typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT_TAG { PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHW2DContext; -#else IMG_HANDLE hHW2DContext; -#endif IMG_DEV_VIRTADDR sHW2DContextDevVAddr; }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT; @@ -730,13 +569,8 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ IMG_BOOL bForceCleanup; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; - IMG_SID hHW2DContext; -#else IMG_HANDLE hDevCookie; IMG_HANDLE hHW2DContext; -#endif }PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT; #define SGX2D_MAX_BLT_CMD_SIZ 256 /* Maximum size of a blit command, in bytes */ @@ -750,11 +584,7 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_READ_HWPERF_CB_TAG { IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevCookie; -#else IMG_HANDLE hDevCookie; -#endif IMG_UINT32 ui32ArraySize; PVRSRV_SGX_HWPERF_CB_ENTRY *psHWPerfCBData; } PVRSRV_BRIDGE_IN_SGX_READ_HWPERF_CB; diff --git a/drivers/gpu/pvr/services4/include/sgx_mkif_km.h b/drivers/gpu/pvr/services4/include/sgx_mkif_km.h index 3a9866f6b9c..baab80d140a 100644..100755 --- a/drivers/gpu/pvr/services4/include/sgx_mkif_km.h +++ b/drivers/gpu/pvr/services4/include/sgx_mkif_km.h @@ -139,11 +139,8 @@ typedef struct _SGXMKIF_HOST_CTL_ IMG_UINT32 ui32PerfGroup; /*!< Specifies the HW's active group */ #endif /* SGX_FEATURE_EXTENDED_PERF_COUNTERS */ -#if defined(FIX_HW_BRN_31939) - IMG_UINT32 ui32BRN31939Mem; -#endif - IMG_UINT32 ui32OpenCLDelayCount; /* Counter to keep track OpenCL task completion time in units of regular task time out events */ + IMG_UINT32 ui32InterruptCount; } SGXMKIF_HOST_CTL; /* @@ -268,6 +265,9 @@ typedef struct _SGXMKIF_2DCMD_SHARED_ { /* need to be able to check reads and writes on 2D ops, and update writes */ PVRSRV_DEVICE_SYNC_OBJECT s3DSyncData; + + IMG_UINT32 ui32NumStatusVals; + CTL_STATUS sCtlStatusInfo[SGXTQ_MAX_STATUS]; } SGXMKIF_2DCMD_SHARED, *PSGXMKIF_2DCMD_SHARED; #endif /* SGX_FEATURE_2D_HARDWARE */ diff --git a/drivers/gpu/pvr/services4/include/sgx_ukernel_status_codes.h b/drivers/gpu/pvr/services4/include/sgx_ukernel_status_codes.h index dc8f2f3c78e..e8c16265c0e 100644..100755 --- a/drivers/gpu/pvr/services4/include/sgx_ukernel_status_codes.h +++ b/drivers/gpu/pvr/services4/include/sgx_ukernel_status_codes.h @@ -239,6 +239,14 @@ MKTC_ST(MKTC_KICKTA_TACMD_DEBUG) MKTC_ST(MKTC_KICKTA_FREECONTEXT) #define MKTC_KICKTA_PIM_PATCHING 0xAD00080C MKTC_ST(MKTC_KICKTA_PIM_PATCHING) +#define MKTC_KICKTA_TPC_CHECK_START 0xAD00080D +MKTC_ST(MKTC_KICKTA_TPC_CHECK_START) +#define MKTC_KICKTA_TPC_CHECK_END 0xAD00080E +MKTC_ST(MKTC_KICKTA_TPC_CHECK_END) +#define MKTC_KICKTA_TPC_CHECK_CORE 0xAD00080F +MKTC_ST(MKTC_KICKTA_TPC_CHECK_CORE) +#define MKTC_KICKTA_TPC_CHECK_FAIL 0xAD000810 +MKTC_ST(MKTC_KICKTA_TPC_CHECK_FAIL) #define MKTC_KICKTA_CHKPT_START_DUMMY_CS 0xAD0008A1 MKTC_ST(MKTC_KICKTA_CHKPT_START_DUMMY_CS) @@ -397,6 +405,7 @@ MKTC_ST(MKTC_FINDTA_SRC_WRITEOPSBLOCKED) #define MKTC_FINDTA_READOPS2BLOCKED 0xAD000E0F MKTC_ST(MKTC_FINDTA_READOPS2BLOCKED) + #define MKTC_CTRL_SRCREADOPSBLOCKED 0xAD000F00 MKTC_ST(MKTC_CTRL_SRCREADOPSBLOCKED) #define MKTC_CTRL_SRCWRITEOPSBLOCKED 0xAD000F01 @@ -517,6 +526,10 @@ MKTC_ST(MKTC_OOM_SPM_DEADLOCK_MEM_ADDED) MKTC_ST(MKTC_RESET) #define MKTC_SPM_INVALID_ZLSCONFIG 0xAD001226 MKTC_ST(MKTC_SPM_INVALID_ZLSCONFIG) +#define MKTC_SPM_DEADLOCK_RENDER_FINISHED 0xAD001227 +MKTC_ST(MKTC_SPM_DEADLOCK_RENDER_FINISHED) +#define MKTC_OOM_BLOCKEDRTDATA 0xAD001228 +MKTC_ST(MKTC_OOM_BLOCKEDRTDATA) #define MKTC_OOM_TYPE_MT 0xAD00122A MKTC_ST(MKTC_OOM_TYPE_MT) @@ -659,7 +672,7 @@ MKTC_ST(MKTC_TAFINISHED_TERM_COMPLETE_START) #define MKTC_TAFINISHED_TERM_COMPLETE_END 0xAD001711 MKTC_ST(MKTC_TAFINISHED_TERM_COMPLETE_END) -#define MKTC_TAFINISHED_DPMPAGERECYCLING 0xAD001720 +#define MKTC_TAFINISHED_DPMPAGERECYCLING 0xAD001720 MKTC_ST(MKTC_TAFINISHED_DPMPAGERECYCLING) #define MKTC_2DEVENT_2DCOMPLETE 0xAD001800 @@ -712,11 +725,21 @@ MKTC_ST(MKTC_FIND2D_ADDR_SPACE_DIFFERENT) MKTC_ST(MKTC_FTD_3DOPSBLOCKED) #define MKTC_FTD_DSTREADOPS2BLOCKED 0xAD001818 MKTC_ST(MKTC_FTD_DSTREADOPS2BLOCKED) +#define MKTC_U2DSO_UPDATESTATUSVALS 0xAD001819 +MKTC_ST(MKTC_U2DSO_UPDATESTATUSVALS) +#define MKTC_U2DSO_UPDATESTATUSVALS_DONE 0xAD00181A +MKTC_ST(MKTC_U2DSO_UPDATESTATUSVALS_DONE) #define MKTC_FCM_START 0xAD001900 MKTC_ST(MKTC_FCM_START) #define MKTC_FCM_END 0xAD001901 MKTC_ST(MKTC_FCM_END) +#define MKTC_FCM_PB_SAME 0xAD001902 +MKTC_ST(MKTC_FCM_PB_SAME) +#define MKTC_FCM_TQ_IN_PROGESS 0xAD001903 +MKTC_ST(MKTC_FCM_TQ_IN_PROGESS) +#define MKTC_FCM_TQ_MEMCONTEXT_DIFFERENT 0xAD001904 +MKTC_ST(MKTC_FCM_TQ_MEMCONTEXT_DIFFERENT) #define MKTC_TIMER_ACTIVE_POWER 0xAD001A00 MKTC_ST(MKTC_TIMER_ACTIVE_POWER) @@ -781,6 +804,10 @@ MKTC_ST(MKTC_RTA_CHECK_NEXT_SA_PROG) MKTC_ST(MKTC_RTA_CORE_COMPLETED) #define MKTC_RTA_DEBUG_SAS 0xAD001F07 MKTC_ST(MKTC_RTA_DEBUG_SAS) +#define MKTC_RTA_MTE_STATE_RESTORE_TASK 0xAD001F08 +MKTC_ST(MKTC_RTA_MTE_STATE_RESTORE_TASK) +#define MKTC_RTA_SA_STATE_RESTORE_TASK 0xAD001F09 +MKTC_ST(MKTC_RTA_SA_STATE_RESTORE_TASK) #define MKTC_RESUMETA_END 0xAD001F0F MKTC_ST(MKTC_RESUMETA_END) diff --git a/drivers/gpu/pvr/services4/include/sgxinfo.h b/drivers/gpu/pvr/services4/include/sgxinfo.h index 17f6d95dc4f..7ffdbc7fb37 100644..100755 --- a/drivers/gpu/pvr/services4/include/sgxinfo.h +++ b/drivers/gpu/pvr/services4/include/sgxinfo.h @@ -45,9 +45,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sgxscript.h" #include "servicesint.h" #include "services.h" -#if !defined (SUPPORT_SID_INTERFACE) #include "sgxapi_km.h" -#endif #include "sgx_mkif_km.h" @@ -84,17 +82,6 @@ typedef enum _SGXMKIF_CMD_TYPE_ typedef struct _SGX_BRIDGE_INIT_INFO_ { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelCCBMemInfo; - IMG_SID hKernelCCBCtlMemInfo; - IMG_SID hKernelCCBEventKickerMemInfo; - IMG_SID hKernelSGXHostCtlMemInfo; - IMG_SID hKernelSGXTA3DCtlMemInfo; -#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) - IMG_SID hKernelSGXPTLAWriteBackMemInfo; -#endif - IMG_SID hKernelSGXMiscMemInfo; -#else IMG_HANDLE hKernelCCBMemInfo; IMG_HANDLE hKernelCCBCtlMemInfo; IMG_HANDLE hKernelCCBEventKickerMemInfo; @@ -104,7 +91,6 @@ typedef struct _SGX_BRIDGE_INIT_INFO_ IMG_HANDLE hKernelSGXPTLAWriteBackMemInfo; #endif IMG_HANDLE hKernelSGXMiscMemInfo; -#endif IMG_UINT32 aui32HostKickAddr[SGXMKIF_CMD_MAX]; @@ -114,53 +100,16 @@ typedef struct _SGX_BRIDGE_INIT_INFO_ SGX_MISCINFO_STRUCT_SIZES sSGXStructSizes; #if defined(SGX_SUPPORT_HWPROFILING) -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelHWProfilingMemInfo; -#else IMG_HANDLE hKernelHWProfilingMemInfo; #endif -#endif #if defined(SUPPORT_SGX_HWPERF) -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelHWPerfCBMemInfo; -#else IMG_HANDLE hKernelHWPerfCBMemInfo; #endif -#endif -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelTASigBufferMemInfo; - IMG_SID hKernel3DSigBufferMemInfo; -#else IMG_HANDLE hKernelTASigBufferMemInfo; IMG_HANDLE hKernel3DSigBufferMemInfo; -#endif -#if defined(FIX_HW_BRN_29702) -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelCFIMemInfo; -#else - IMG_HANDLE hKernelCFIMemInfo; -#endif -#endif -#if defined(FIX_HW_BRN_29823) -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelDummyTermStreamMemInfo; -#else - IMG_HANDLE hKernelDummyTermStreamMemInfo; -#endif -#endif #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513) -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelClearClipWAVDMStreamMemInfo; - IMG_SID hKernelClearClipWAIndexStreamMemInfo; - IMG_SID hKernelClearClipWAPDSMemInfo; - IMG_SID hKernelClearClipWAUSEMemInfo; - IMG_SID hKernelClearClipWAParamMemInfo; - IMG_SID hKernelClearClipWAPMPTMemInfo; - IMG_SID hKernelClearClipWATPCMemInfo; - IMG_SID hKernelClearClipWAPSGRgnHdrMemInfo; -#else IMG_HANDLE hKernelClearClipWAVDMStreamMemInfo; IMG_HANDLE hKernelClearClipWAIndexStreamMemInfo; IMG_HANDLE hKernelClearClipWAPDSMemInfo; @@ -170,23 +119,14 @@ typedef struct _SGX_BRIDGE_INIT_INFO_ IMG_HANDLE hKernelClearClipWATPCMemInfo; IMG_HANDLE hKernelClearClipWAPSGRgnHdrMemInfo; #endif -#endif -#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559) - IMG_HANDLE hKernelVDMSnapShotBufferMemInfo; - IMG_HANDLE hKernelVDMCtrlStreamBufferMemInfo; -#endif #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) IMG_HANDLE hKernelVDMStateUpdateBufferMemInfo; #endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelEDMStatusBufferMemInfo; -#else IMG_HANDLE hKernelEDMStatusBufferMemInfo; #endif -#endif IMG_UINT32 ui32EDMTaskReg0; IMG_UINT32 ui32EDMTaskReg1; @@ -205,11 +145,7 @@ typedef struct _SGX_BRIDGE_INIT_INFO_ IMG_UINT32 ui32CacheControl; IMG_UINT32 asInitDevData[SGX_MAX_DEV_DATA]; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID asInitMemHandles[SGX_MAX_INIT_MEM_HANDLES]; -#else IMG_HANDLE asInitMemHandles[SGX_MAX_INIT_MEM_HANDLES]; -#endif } SGX_BRIDGE_INIT_INFO; @@ -218,11 +154,7 @@ typedef struct _SGX_DEVICE_SYNC_LIST_ { PSGXMKIF_HWDEVICE_SYNC_LIST psHWDeviceSyncList; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelHWSyncListMemInfo; -#else IMG_HANDLE hKernelHWSyncListMemInfo; -#endif PVRSRV_CLIENT_MEM_INFO *psHWDeviceSyncListClientMemInfo; PVRSRV_CLIENT_MEM_INFO *psAccessResourceClientMemInfo; @@ -232,47 +164,27 @@ typedef struct _SGX_DEVICE_SYNC_LIST_ /* Must be the last variable in the structure */ IMG_UINT32 ui32NumSyncObjects; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahSyncHandles[1]; -#else IMG_HANDLE ahSyncHandles[1]; -#endif } SGX_DEVICE_SYNC_LIST, *PSGX_DEVICE_SYNC_LIST; typedef struct _SGX_INTERNEL_STATUS_UPDATE_ { CTL_STATUS sCtlStatus; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hKernelMemInfo; -#endif } SGX_INTERNEL_STATUS_UPDATE; typedef struct _SGX_CCB_KICK_ { SGXMKIF_COMMAND sCommand; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hCCBKernelMemInfo; -#else IMG_HANDLE hCCBKernelMemInfo; -#endif IMG_UINT32 ui32NumDstSyncObjects; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelHWSyncListMemInfo; -#else IMG_HANDLE hKernelHWSyncListMemInfo; -#endif /* DST syncs */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *pahDstSyncHandles; -#else IMG_HANDLE *pahDstSyncHandles; -#endif IMG_UINT32 ui32NumTAStatusVals; IMG_UINT32 ui32Num3DStatusVals; @@ -281,14 +193,9 @@ typedef struct _SGX_CCB_KICK_ SGX_INTERNEL_STATUS_UPDATE asTAStatusUpdate[SGX_MAX_TA_STATUS_VALS]; SGX_INTERNEL_STATUS_UPDATE as3DStatusUpdate[SGX_MAX_3D_STATUS_VALS]; #else -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahTAStatusSyncInfo[SGX_MAX_TA_STATUS_VALS]; - IMG_SID ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]; -#else IMG_HANDLE ahTAStatusSyncInfo[SGX_MAX_TA_STATUS_VALS]; IMG_HANDLE ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]; #endif -#endif IMG_BOOL bFirstKickOrResume; #if defined(NO_HARDWARE) || defined(PDUMP) @@ -302,46 +209,23 @@ typedef struct _SGX_CCB_KICK_ #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) /* SRC and DST syncs */ IMG_UINT32 ui32NumTASrcSyncs; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS]; -#else IMG_HANDLE ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS]; -#endif IMG_UINT32 ui32NumTADstSyncs; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS]; -#else IMG_HANDLE ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS]; -#endif IMG_UINT32 ui32Num3DSrcSyncs; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS]; -#else IMG_HANDLE ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS]; -#endif #else /* SRC syncs */ IMG_UINT32 ui32NumSrcSyncs; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS_TA]; -#else IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS_TA]; #endif -#endif /* TA/3D dependency data */ IMG_BOOL bTADependency; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hTA3DSyncInfo; - - IMG_SID hTASyncInfo; - IMG_SID h3DSyncInfo; -#else IMG_HANDLE hTA3DSyncInfo; IMG_HANDLE hTASyncInfo; IMG_HANDLE h3DSyncInfo; -#endif #if defined(PDUMP) IMG_UINT32 ui32CCBDumpWOff; #endif @@ -349,6 +233,12 @@ typedef struct _SGX_CCB_KICK_ IMG_UINT32 ui32WriteOpsPendingVal; #endif IMG_HANDLE hDevMemContext; + IMG_DEV_VIRTADDR sHWRTDataSetDevAddr; + IMG_DEV_VIRTADDR sHWRTDataDevAddr; + IMG_UINT32 ui32FrameNum; +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + IMG_BOOL bIsFirstKick; +#endif } SGX_CCB_KICK; @@ -380,11 +270,7 @@ typedef struct _SGX_CLIENT_INFO_ typedef struct _SGX_INTERNAL_DEVINFO_ { IMG_UINT32 ui32Flags; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHostCtlKernelMemInfoHandle; -#else IMG_HANDLE hHostCtlKernelMemInfoHandle; -#endif IMG_BOOL bForcePTOff; } SGX_INTERNAL_DEVINFO; @@ -400,36 +286,19 @@ typedef struct _SGX_INTERNAL_DEVINFO_KM_ #if defined(TRANSFER_QUEUE) typedef struct _PVRSRV_TRANSFER_SGX_KICK_ { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hCCBMemInfo; -#else IMG_HANDLE hCCBMemInfo; -#endif IMG_UINT32 ui32SharedCmdCCBOffset; IMG_DEV_VIRTADDR sHWTransferContextDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hTASyncInfo; - IMG_SID h3DSyncInfo; -#else IMG_HANDLE hTASyncInfo; IMG_HANDLE h3DSyncInfo; -#endif IMG_UINT32 ui32NumSrcSync; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahSrcSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; -#else IMG_HANDLE ahSrcSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; -#endif IMG_UINT32 ui32NumDstSync; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahDstSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; -#else IMG_HANDLE ahDstSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; -#endif IMG_UINT32 ui32Flags; @@ -438,33 +307,21 @@ typedef struct _PVRSRV_TRANSFER_SGX_KICK_ IMG_UINT32 ui32CCBDumpWOff; #endif IMG_HANDLE hDevMemContext; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + /* Android >JB MR1 doesn't use ahSrcSyncInfo for synchronization */ + IMG_INT iFenceFd; +#endif } PVRSRV_TRANSFER_SGX_KICK, *PPVRSRV_TRANSFER_SGX_KICK; #if defined(SGX_FEATURE_2D_HARDWARE) typedef struct _PVRSRV_2D_SGX_KICK_ { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hCCBMemInfo; -#else IMG_HANDLE hCCBMemInfo; -#endif IMG_UINT32 ui32SharedCmdCCBOffset; IMG_DEV_VIRTADDR sHW2DContextDevVAddr; IMG_UINT32 ui32NumSrcSync; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID ahSrcSyncInfo[SGX_MAX_2D_SRC_SYNC_OPS]; - - /* need to be able to check reads and writes on dest, and update writes */ - IMG_SID hDstSyncInfo; - - /* need to be able to check reads and writes on TA ops, and update writes */ - IMG_SID hTASyncInfo; - - /* need to be able to check reads and writes on 2D ops, and update writes */ - IMG_SID h3DSyncInfo; -#else IMG_HANDLE ahSrcSyncInfo[SGX_MAX_2D_SRC_SYNC_OPS]; /* need to be able to check reads and writes on dest, and update writes */ @@ -475,13 +332,16 @@ typedef struct _PVRSRV_2D_SGX_KICK_ /* need to be able to check reads and writes on 2D ops, and update writes */ IMG_HANDLE h3DSyncInfo; -#endif IMG_UINT32 ui32PDumpFlags; #if defined(PDUMP) IMG_UINT32 ui32CCBDumpWOff; #endif IMG_HANDLE hDevMemContext; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + /* Android >JB MR1 doesn't use ahSrcSyncInfo for synchronization */ + IMG_INT iFenceFd; +#endif } PVRSRV_2D_SGX_KICK, *PPVRSRV_2D_SGX_KICK; #endif /* defined(SGX_FEATURE_2D_HARDWARE) */ #endif /* defined(TRANSFER_QUEUE) */ diff --git a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.c b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.c index d98a71c2c2d..2321a69b66e 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.c @@ -80,12 +80,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #include "env_data.h" +#include "ttrace.h" +#include "ttrace_tokens.h" #if defined (__linux__) || defined(__QNXNTO__) #include "mmap.h" #endif +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include <linux/file.h> +#include <linux/version.h> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) +#include <linux/sync.h> +#else +#include <../drivers/staging/android/sync.h> +#endif +#endif + #include "srvkm.h" /* FIXME: we should include an OS specific header here to allow configuration of @@ -106,7 +118,7 @@ PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_E PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats; #endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) static IMG_BOOL abSharedDeviceMemHeap[PVRSRV_MAX_CLIENT_HEAPS]; static IMG_BOOL *pbSharedDeviceMemHeap = abSharedDeviceMemHeap; #else @@ -202,9 +214,6 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, IMG_HANDLE hDevMemContextInt; IMG_UINT32 i; IMG_BOOL bCreated; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_CREATE_DEVMEMCONTEXT); @@ -229,11 +238,7 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, psPerProc, &hDevMemContextInt, &psCreateDevMemContextOUT->ui32ClientHeapCount, -#if defined (SUPPORT_SID_INTERFACE) - &asHeapInfo[0], -#else &psCreateDevMemContextOUT->sHeapInfo[0], -#endif &bCreated, pbSharedDeviceMemHeap); @@ -270,13 +275,9 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, for(i = 0; i < psCreateDevMemContextOUT->ui32ClientHeapCount; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeapExt; -#else IMG_HANDLE hDevMemHeapExt; -#endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) if(abSharedDeviceMemHeap[i]) #endif { @@ -287,20 +288,12 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, * driver, hence, we use shared handles for these * heaps. */ -#if defined (SUPPORT_SID_INTERFACE) - PVRSRVAllocHandleNR(psPerProc->psHandleBase, - &hDevMemHeapExt, - asHeapInfo[i].hDevMemHeap, - PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, - PVRSRV_HANDLE_ALLOC_FLAG_SHARED); -#else PVRSRVAllocHandleNR(psPerProc->psHandleBase, &hDevMemHeapExt, psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); -#endif } -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) else { /* @@ -311,31 +304,18 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, */ if(bCreated) { -#if defined (SUPPORT_SID_INTERFACE) - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &hDevMemHeapExt, - asHeapInfo[i].hDevMemHeap, - PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psCreateDevMemContextOUT->hDevMemContext); -#else PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &hDevMemHeapExt, psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, PVRSRV_HANDLE_ALLOC_FLAG_NONE, psCreateDevMemContextOUT->hDevMemContext); -#endif } else { psCreateDevMemContextOUT->eError = PVRSRVFindHandle(psPerProc->psHandleBase, &hDevMemHeapExt, -#if defined (SUPPORT_SID_INTERFACE) - asHeapInfo[i].hDevMemHeap, -#else psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, -#endif PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); if(psCreateDevMemContextOUT->eError != PVRSRV_OK) { @@ -345,13 +325,6 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, } #endif psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap = hDevMemHeapExt; -#if defined (SUPPORT_SID_INTERFACE) - psCreateDevMemContextOUT->sHeapInfo[i].ui32HeapID = asHeapInfo[i].ui32HeapID; - psCreateDevMemContextOUT->sHeapInfo[i].sDevVAddrBase = asHeapInfo[i].sDevVAddrBase; - psCreateDevMemContextOUT->sHeapInfo[i].ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize; - psCreateDevMemContextOUT->sHeapInfo[i].ui32Attribs = asHeapInfo[i].ui32Attribs; - psCreateDevMemContextOUT->sHeapInfo[i].ui32XTileStride = asHeapInfo[i].ui32XTileStride; -#endif } COMMIT_HANDLE_BATCH_OR_ERROR(psCreateDevMemContextOUT->eError, psPerProc) @@ -420,9 +393,6 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, IMG_HANDLE hDevCookieInt; IMG_HANDLE hDevMemContextInt; IMG_UINT32 i; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GET_DEVMEM_HEAPINFO); @@ -452,11 +422,7 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, PVRSRVGetDeviceMemHeapInfoKM(hDevCookieInt, hDevMemContextInt, &psGetDevMemHeapInfoOUT->ui32ClientHeapCount, -#if defined (SUPPORT_SID_INTERFACE) - &asHeapInfo[0], -#else &psGetDevMemHeapInfoOUT->sHeapInfo[0], -#endif pbSharedDeviceMemHeap); if(psGetDevMemHeapInfoOUT->eError != PVRSRV_OK) @@ -466,13 +432,9 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, for(i = 0; i < psGetDevMemHeapInfoOUT->ui32ClientHeapCount; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hDevMemHeapExt; -#else IMG_HANDLE hDevMemHeapExt; -#endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) if(abSharedDeviceMemHeap[i]) #endif { @@ -483,20 +445,12 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, * driver, hence, we use shared handles for these * heaps. */ -#if defined (SUPPORT_SID_INTERFACE) - PVRSRVAllocHandleNR(psPerProc->psHandleBase, - &hDevMemHeapExt, - asHeapInfo[i].hDevMemHeap, - PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, - PVRSRV_HANDLE_ALLOC_FLAG_SHARED); -#else PVRSRVAllocHandleNR(psPerProc->psHandleBase, &hDevMemHeapExt, psGetDevMemHeapInfoOUT->sHeapInfo[i].hDevMemHeap, PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); -#endif } -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) else { /* @@ -508,11 +462,7 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, psGetDevMemHeapInfoOUT->eError = PVRSRVFindHandle(psPerProc->psHandleBase, &hDevMemHeapExt, -#if defined (SUPPORT_SID_INTERFACE) - asHeapInfo[i].hDevMemHeap, -#else psGetDevMemHeapInfoOUT->sHeapInfo[i].hDevMemHeap, -#endif PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); if(psGetDevMemHeapInfoOUT->eError != PVRSRV_OK) { @@ -521,13 +471,6 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, } #endif psGetDevMemHeapInfoOUT->sHeapInfo[i].hDevMemHeap = hDevMemHeapExt; -#if defined (SUPPORT_SID_INTERFACE) - psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32HeapID = asHeapInfo[i].ui32HeapID; - psGetDevMemHeapInfoOUT->sHeapInfo[i].sDevVAddrBase = asHeapInfo[i].sDevVAddrBase; - psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize; - psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32Attribs = asHeapInfo[i].ui32Attribs; - psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32XTileStride = asHeapInfo[i].ui32XTileStride; -#endif } COMMIT_HANDLE_BATCH_OR_ERROR(psGetDevMemHeapInfoOUT->eError, psPerProc) @@ -672,8 +615,8 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, psPerProc, hDevMemHeapInt, psAllocDeviceMemIN->ui32Attribs, - psAllocDeviceMemIN->ui32Size, - psAllocDeviceMemIN->ui32Alignment, + psAllocDeviceMemIN->uSize, + psAllocDeviceMemIN->uAlignment, psAllocDeviceMemIN->pvPrivData, psAllocDeviceMemIN->ui32PrivDataLength, psAllocDeviceMemIN->ui32ChunkSize, @@ -683,12 +626,6 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, &psMemInfo, "" /*FIXME: add something meaningful*/); - /* Allow mapping this buffer to the GC MMU only on allocation time, if - * this buffer is mapped into another process context we don't want the - * GC MMU mapping to happen. - */ - psAllocDeviceMemIN->ui32Attribs &= ~PVRSRV_MAP_GC_MMU; - if (bUseShareMemWorkaround) { PVR_ASSERT(ui32ShareIndex != 7654321); @@ -707,8 +644,8 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, psMemInfo->sShareMemWorkaround.ui32ShareIndex = ui32ShareIndex; psMemInfo->sShareMemWorkaround.hDevCookieInt = hDevCookieInt; psMemInfo->sShareMemWorkaround.ui32OrigReqAttribs = psAllocDeviceMemIN->ui32Attribs; - psMemInfo->sShareMemWorkaround.ui32OrigReqSize = (IMG_UINT32)psAllocDeviceMemIN->ui32Size; - psMemInfo->sShareMemWorkaround.ui32OrigReqAlignment = (IMG_UINT32)psAllocDeviceMemIN->ui32Alignment; + psMemInfo->sShareMemWorkaround.ui32OrigReqSize = (IMG_UINT32)psAllocDeviceMemIN->uSize; + psMemInfo->sShareMemWorkaround.ui32OrigReqAlignment = (IMG_UINT32)psAllocDeviceMemIN->uAlignment; } OSMemSet(&psAllocDeviceMemOUT->sClientMemInfo, @@ -726,13 +663,7 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, psAllocDeviceMemOUT->sClientMemInfo.sDevVAddr = psMemInfo->sDevVAddr; psAllocDeviceMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; psAllocDeviceMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; - OSMemCopy(psAllocDeviceMemOUT->sClientMemInfo.planeOffsets, psMemInfo->planeOffsets, - sizeof(psMemInfo->planeOffsets)); -#if defined (SUPPORT_SID_INTERFACE) - /* see below */ -#else psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; -#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo, @@ -740,23 +671,6 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, PVRSRV_HANDLE_TYPE_MEM_INFO, PVRSRV_HANDLE_ALLOC_FLAG_NONE); -#if defined (SUPPORT_SID_INTERFACE) - PVR_ASSERT(psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo != 0); - - if (psMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo, - psMemInfo->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo = 0; - } -#endif if(psAllocDeviceMemIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ) { @@ -780,25 +694,9 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, psAllocDeviceMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = psMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - if (psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psAllocDeviceMemOUT->sClientSyncInfo.hMappingInfo, - psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_SYNC_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psAllocDeviceMemOUT->sClientSyncInfo.hMappingInfo = 0; - } -#else psAllocDeviceMemOUT->sClientSyncInfo.hMappingInfo = psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; #endif -#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psAllocDeviceMemOUT->sClientSyncInfo.hKernelSyncInfo, @@ -842,11 +740,7 @@ PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvKernelMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psFreeDeviceMemIN->hKernelMemInfo, -#else psFreeDeviceMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -863,11 +757,7 @@ PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - psFreeDeviceMemIN->hKernelMemInfo, -#else psFreeDeviceMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; @@ -875,228 +765,13 @@ PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, static IMG_INT -PVRSRVMultiManageDevMemBW(IMG_UINT32 ui32BridgeID, - PVRSRV_BRIDGE_IN_MULTI_MANAGE_DEV_MEM *psMultiMemDevRequestIN, - PVRSRV_BRIDGE_OUT_MULTI_MANAGE_DEV_MEM *psMultiMemDevRequestOUT, - PVRSRV_PER_PROCESS_DATA *psPerProc) -{ - IMG_HANDLE hDevCookieInt; - PVRSRV_KERNEL_MEM_INFO *psSharedBuffKernelMemInfo = NULL; - PVRSRV_MANAGE_DEV_MEM_REQUEST* pRequestsArray; - PVRSRV_MANAGE_DEV_MEM_RESPONSE* pResponseArray; - IMG_UINT32 reqNum; - - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_MULTI_MANAGE_DEV_MEM); - - psMultiMemDevRequestOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, - psMultiMemDevRequestIN->hDevCookie, - PVRSRV_HANDLE_TYPE_DEV_NODE); - - if(psMultiMemDevRequestOUT->eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"%s: invalid hDevCookie", __FUNCTION__)); - return 0; - } - - if(psMultiMemDevRequestIN->hKernelMemInfo) - { - PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS* psMultiMemDevRequest; - psMultiMemDevRequestOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - (IMG_VOID **)&psSharedBuffKernelMemInfo, - #if defined (SUPPORT_SID_INTERFACE) - psMultiMemDevRequestIN->hKernelMemInfo, - #else - psMultiMemDevRequestIN->hKernelMemInfo, - #endif - PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); - - if(psMultiMemDevRequestOUT->eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"%s: invalid shared memory hKernelMemInfo", __FUNCTION__)); - return 0; - } - - psMultiMemDevRequest = (PVRSRV_MULTI_MANAGE_DEV_MEM_REQUESTS*)psSharedBuffKernelMemInfo->pvLinAddrKM; - if( (psMultiMemDevRequest->psSharedMemClientMemInfo != psMultiMemDevRequestIN->psSharedMemClientMemInfo ) || - (psMultiMemDevRequest->ui32MaxNumberOfRequests != psMultiMemDevRequestIN->ui32MaxNumberOfRequests) || - psMultiMemDevRequest->ui32NumberOfValidRequests != psMultiMemDevRequestIN->ui32NumberOfValidRequests || - psMultiMemDevRequest->ui32CtrlFlags != psMultiMemDevRequestIN->ui32CtrlFlags) - { - psMultiMemDevRequestOUT->eError = PVRSRV_ERROR_BAD_MAPPING; - return 0; - } - pRequestsArray = psMultiMemDevRequest->sMemRequests; - pResponseArray = psMultiMemDevRequest->sMemRequests; - } - else - { - pRequestsArray = psMultiMemDevRequestIN->sMemRequests; - pResponseArray = psMultiMemDevRequestOUT->sMemResponse; - } - - PVR_DPF((PVR_DBG_MESSAGE, "\n%s: %s %d Number of request/s, Control flag = 0x%08x\n", - __FUNCTION__, - (psMultiMemDevRequestIN->hKernelMemInfo ? "Shared" : "Direct"), - psMultiMemDevRequestIN->ui32NumberOfValidRequests, - psMultiMemDevRequestIN->ui32CtrlFlags)); - - for(reqNum = 0; reqNum < psMultiMemDevRequestIN->ui32NumberOfValidRequests; reqNum++) - { - PVRSRV_MANAGE_DEV_MEM_REQUEST *pRequest = &pRequestsArray[reqNum]; - PVRSRV_MANAGE_DEV_MEM_REQUEST *pResponse = &pResponseArray[reqNum]; - PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo = NULL; - - /* At the kernel size, psClientMemInfo only works as a verification token */ - if(psMultiMemDevRequestIN->hKernelMemInfo == NULL) - { - pResponse->psClientMemInfo = pRequest->psClientMemInfo; - pResponse->eReqType = pRequest->eReqType; - } - - PVR_DPF((PVR_DBG_MESSAGE, "%s: Request %d for ClientMemInfo %p\n" - "DevVirtAddr 0x%08x, GpuRefCount %d " - "CpuVirtAddr %p, CpuRefCount %d, Kernel Handle %p, sync %p\n" - "Size %d, Attrib 0x%08x, Align %d, Subsystem 0x%llx, Hints 0x%08x " - "transfer slot %d\n", - __FUNCTION__, pResponse->eReqType, - pRequest->psClientMemInfo, - pRequest->sDevVAddr.uiAddr, - pRequest->ui32GpuMapRefCount, - pRequest->pvLinAddr, - pRequest->ui32CpuMapRefCount, - pRequest->hKernelMemInfo, - pRequest->hKernelSyncInfo, - pRequest->uSize, - pRequest->ui32Attribs, - pRequest->uAlignment, - pRequest->uiSubSystem, - pRequest->ui32Hints, - pRequest->ui32TransferFromToReqSlotIndx)); - - pResponse->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - (IMG_PVOID *)&psKernelMemInfo, - #if defined (SUPPORT_SID_INTERFACE) - pRequest->hKernelMemInfo, - #else - pRequest->hKernelMemInfo, - #endif - PVRSRV_HANDLE_TYPE_MEM_INFO); - if(pResponse->eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"%s: invalid hKernelMemInfo for slot %d", - __FUNCTION__, reqNum)); - continue; - } - - PVR_DPF((PVR_DBG_MESSAGE, "%s: KernelMemInfo %p -%s SHARED\n" - "DevVirtAddr 0x%08x, RefCount %d " - "Size %d, Flags 0x%08x, OrigAlign %d, Subsystem 0x%llx, Hints 0x%08x\n", - __FUNCTION__, psKernelMemInfo, - (psKernelMemInfo->sShareMemWorkaround.bInUse ? "" : "NOT"), - psKernelMemInfo->sDevVAddr.uiAddr, - psKernelMemInfo->ui32RefCount, - psKernelMemInfo->uAllocSize, - psKernelMemInfo->ui32Flags, - psKernelMemInfo->sShareMemWorkaround.ui32OrigReqAlignment, - (IMG_UINT64)0, 0)); - - if(psKernelMemInfo->sDevVAddr.uiAddr != pRequest->sDevVAddr.uiAddr) - { - PVR_DPF((PVR_DBG_WARNING, "%s: Kernel and Client MemInfo's " - "virtual addresses are not equal\n" - "Kernel DevVirtAddr 0x%08x != Client DevVirtAddr 0x%08x", - __FUNCTION__, - psKernelMemInfo->sDevVAddr.uiAddr, pRequest->sDevVAddr.uiAddr)); - } - - switch(pResponse->eReqType) - { - case PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_MAP: - case PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_LOCK_MAP: - { - IMG_INT32 result = PVRSRVRemapToDevKM(hDevCookieInt, - psKernelMemInfo, &pResponse->sDevVAddr); - - if(result < 0) - { - pResponse->eError = -result; - PVR_DPF((PVR_DBG_ERROR, "Request for GPU Virtual " - "memory mapping had failed " - "with error %d", - pResponse->eError)); - } - else - { - pResponse->ui32GpuMapRefCount = result; - pResponse->eError = PVRSRV_OK; - } - } - break; - case PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_SWAP_MAP_TO_NEXT: - pResponse->eError = PVRSRV_OK; - pResponse->ui32GpuMapRefCount = 1; - pResponse->sDevVAddr = psKernelMemInfo->sDevVAddr; - break; - case PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_UNMAP: - case PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_UNLOCK_MAP: - { - IMG_INT32 result = PVRSRVUnmapFromDevKM(hDevCookieInt, psKernelMemInfo); - if(result < 0) - { - pResponse->eError = -result; - PVR_DPF((PVR_DBG_ERROR, "Request for GPU Virtual memory " - "un-mapping had failed " - "with error %d", - pResponse->eError)); - } - else - { - pResponse->ui32GpuMapRefCount = result; - pResponse->eError = PVRSRV_OK; - } - pResponse->sDevVAddr = psKernelMemInfo->sDevVAddr; - } - break; - case PVRSRV_MULTI_MANAGE_DEV_MEM_RQST_SWAP_MAP_FROM_PREV: - pResponse->eError = PVRSRV_OK; - pResponse->ui32GpuMapRefCount = 1; - pResponse->sDevVAddr = psKernelMemInfo->sDevVAddr; - break; - default: - pResponse->eError = PVRSRV_ERROR_INVALID_PARAMS; - break; - } - - PVR_DPF((PVR_DBG_MESSAGE, "%s: RETURN: ClientMemInfo %p " - "DevVirtAddr 0x%08x, GpuMapRefCount %d, err %d\n", - __FUNCTION__, pRequest->psClientMemInfo, - pResponse->sDevVAddr.uiAddr, - pResponse->ui32GpuMapRefCount, - pResponse->eError)); - } - - if(psMultiMemDevRequestIN->hKernelMemInfo == NULL) - psMultiMemDevRequestOUT->ui32CtrlFlags = psMultiMemDevRequestIN->ui32CtrlFlags; - /* No status implemented yet */ - psMultiMemDevRequestOUT->ui32StatusFlags = 0; - - return 0; -} - -static IMG_INT PVRSRVExportDeviceMemBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM *psExportDeviceMemIN, PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM *psExportDeviceMemOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo = IMG_NULL; -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; -#endif PVR_ASSERT(ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_EXPORT_DEVICEMEM) || ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2)); @@ -1119,11 +794,7 @@ PVRSRVExportDeviceMemBW(IMG_UINT32 ui32BridgeID, psExportDeviceMemOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_PVOID *)&psKernelMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psExportDeviceMemIN->hKernelMemInfo, -#else psExportDeviceMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psExportDeviceMemOUT->eError != PVRSRV_OK) @@ -1205,19 +876,6 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, { PVR_DPF((PVR_DBG_MESSAGE, "using the mem wrap workaround.")); - /* Check the XPROC mapping count -if it is "0", - * then the object is about to go away - do not allow mapping */ - if(BM_XProcGetShareDataRefCount(psSrcKernelMemInfo->sShareMemWorkaround.ui32ShareIndex) < 1) - { - psMapDevMemOUT->eError = PVRSRV_ERROR_MAPPING_NOT_FOUND; - PVR_DPF((PVR_DBG_WARNING, "%s: Can't map buffer with slot %d, size %d " - "and refcount %d\n\t Invalid XPROC refcount of %d", - __FUNCTION__, psSrcKernelMemInfo->sShareMemWorkaround.ui32ShareIndex, - psSrcKernelMemInfo->uAllocSize, psSrcKernelMemInfo->ui32RefCount, - BM_XProcGetShareDataRefCount(psSrcKernelMemInfo->sShareMemWorkaround.ui32ShareIndex))); - return 0; - } - /* Ensure we get the same ID for this allocation, such that it inherits the same physical block. Rather than add a lot of plumbing to several APIs, we call into buffer manager directly @@ -1294,13 +952,7 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevMemOUT->sDstClientMemInfo.sDevVAddr = psDstKernelMemInfo->sDevVAddr; psMapDevMemOUT->sDstClientMemInfo.ui32Flags = psDstKernelMemInfo->ui32Flags; psMapDevMemOUT->sDstClientMemInfo.uAllocSize = psDstKernelMemInfo->uAllocSize; - OSMemCopy(psMapDevMemOUT->sDstClientMemInfo.planeOffsets, psDstKernelMemInfo->planeOffsets, - sizeof(psDstKernelMemInfo->planeOffsets)); -#if defined (SUPPORT_SID_INTERFACE) - /* see below */ -#else psMapDevMemOUT->sDstClientMemInfo.hMappingInfo = psDstKernelMemInfo->sMemBlk.hOSMemHandle; -#endif /* allocate handle to the DST kernel meminfo */ PVRSRVAllocHandleNR(psPerProc->psHandleBase, @@ -1310,22 +962,6 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRV_HANDLE_ALLOC_FLAG_NONE); psMapDevMemOUT->sDstClientSyncInfo.hKernelSyncInfo = IMG_NULL; -#if defined (SUPPORT_SID_INTERFACE) - /* alloc subhandle for the mapping info */ - if (psDstKernelMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapDevMemOUT->sDstClientMemInfo.hMappingInfo, - psDstKernelMemInfo->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psMapDevMemOUT->sDstClientMemInfo.hKernelMemInfo); - } - else - { - psMapDevMemOUT->sDstClientMemInfo.hMappingInfo = 0; - } -#endif /* and setup the sync info */ if(psDstKernelMemInfo->psKernelSyncInfo) @@ -1340,26 +976,9 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevMemOUT->sDstClientSyncInfo.sReadOps2CompleteDevVAddr = psDstKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - /* alloc subhandle for the mapping info */ - if (psDstKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapDevMemOUT->sDstClientSyncInfo.hMappingInfo, - psDstKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psMapDevMemOUT->sDstClientMemInfo.hKernelMemInfo); - } - else - { - psMapDevMemOUT->sDstClientSyncInfo.hMappingInfo = 0; - } -#else psMapDevMemOUT->sDstClientSyncInfo.hMappingInfo = psDstKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; #endif -#endif psMapDevMemOUT->sDstClientMemInfo.psClientSyncInfo = &psMapDevMemOUT->sDstClientSyncInfo; /* @@ -1393,11 +1012,7 @@ PVRSRVUnmapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psKernelMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psUnmapDevMemIN->hKernelMemInfo, -#else psUnmapDevMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -1423,17 +1038,13 @@ PVRSRVUnmapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, } psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - psUnmapDevMemIN->hKernelMemInfo, -#else psUnmapDevMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; } - +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) static IMG_INT PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, @@ -1482,7 +1093,7 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, /* Having looked up the handle, now check its type */ switch(eHandleType) { -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) case PVRSRV_HANDLE_TYPE_DISP_BUFFER: case PVRSRV_HANDLE_TYPE_BUF_BUFFER: #else @@ -1519,23 +1130,7 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevClassMemOUT->sClientMemInfo.sDevVAddr = psMemInfo->sDevVAddr; psMapDevClassMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; psMapDevClassMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; -#if defined (SUPPORT_SID_INTERFACE) - if (psMemInfo->sMemBlk.hOSMemHandle != 0) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapDevClassMemOUT->sClientMemInfo.hMappingInfo, - psMemInfo->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psMapDevClassMemIN->hDeviceClassBuffer); - } - else - { - psMapDevClassMemOUT->sClientMemInfo.hMappingInfo = 0; - } -#else psMapDevClassMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; -#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psMapDevClassMemOUT->sClientMemInfo.hKernelMemInfo, @@ -1559,25 +1154,9 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevClassMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = psMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - if (psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != 0) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapDevClassMemOUT->sClientSyncInfo.hMappingInfo, - psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_SYNC_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_MULTI, - psMapDevClassMemOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psMapDevClassMemOUT->sClientSyncInfo.hMappingInfo = 0; - } -#else psMapDevClassMemOUT->sClientSyncInfo.hMappingInfo = psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; #endif -#endif psMapDevClassMemOUT->sClientMemInfo.psClientSyncInfo = &psMapDevClassMemOUT->sClientSyncInfo; /* @@ -1611,11 +1190,7 @@ PVRSRVUnmapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvKernelMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psUnmapDevClassMemIN->hKernelMemInfo, -#else psUnmapDevClassMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -1631,16 +1206,14 @@ PVRSRVUnmapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - psUnmapDevClassMemIN->hKernelMemInfo, -#else psUnmapDevClassMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + #if defined(OS_PVRSRV_WRAP_EXT_MEM_BW) IMG_INT @@ -1716,8 +1289,8 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRVWrapExtMemoryKM(hDevCookieInt, psPerProc, hDevMemContextInt, - psWrapExtMemIN->ui32ByteSize, - psWrapExtMemIN->ui32PageOffset, + psWrapExtMemIN->uByteSize, + psWrapExtMemIN->uPageOffset, psWrapExtMemIN->bPhysContig, psSysPAddr, psWrapExtMemIN->pvLinAddr, @@ -1745,11 +1318,7 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, psWrapExtMemOUT->sClientMemInfo.sDevVAddr = psMemInfo->sDevVAddr; psWrapExtMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; psWrapExtMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; -#if defined (SUPPORT_SID_INTERFACE) -/* see below */ -#else psWrapExtMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; -#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psWrapExtMemOUT->sClientMemInfo.hKernelMemInfo, @@ -1757,22 +1326,6 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRV_HANDLE_TYPE_MEM_INFO, PVRSRV_HANDLE_ALLOC_FLAG_NONE); -#if defined (SUPPORT_SID_INTERFACE) - /* alloc subhandle for the mapping info */ - if (psMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psWrapExtMemOUT->sClientMemInfo.hMappingInfo, - psMemInfo->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psWrapExtMemOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psWrapExtMemOUT->sClientMemInfo.hMappingInfo = 0; - } -#endif /* setup the sync info */ #if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) @@ -1785,26 +1338,9 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, psWrapExtMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = psMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - /* alloc subhandle for the mapping info */ - if (psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psWrapExtMemOUT->sClientSyncInfo.hMappingInfo, - psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psWrapExtMemOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psWrapExtMemOUT->sClientSyncInfo.hMappingInfo = 0; - } -#else psWrapExtMemOUT->sClientSyncInfo.hMappingInfo = psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; #endif -#endif psWrapExtMemOUT->sClientMemInfo.psClientSyncInfo = &psWrapExtMemOUT->sClientSyncInfo; @@ -1864,6 +1400,7 @@ PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + IMG_UINT64 ui64Stamp; psMapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &psMapIonIN->hDevCookie, @@ -1876,9 +1413,9 @@ PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID, } psMapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - &psMapIonIN->hDevMemContext, - psMapIonIN->hDevMemContext, - PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + &psMapIonIN->hDevMemHeap, + psMapIonIN->hDevMemHeap, + PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); if (psMapIonOUT->eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup memory context handle", __FUNCTION__)); @@ -1887,11 +1424,16 @@ PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID, psMapIonOUT->eError = PVRSRVMapIonHandleKM(psPerProc, psMapIonIN->hDevCookie, - psMapIonIN->hDevMemContext, - psMapIonIN->handle, + psMapIonIN->hDevMemHeap, + psMapIonIN->ui32NumFDs, + psMapIonIN->ai32BufferFDs, psMapIonIN->ui32Attribs, - psMapIonIN->ui32Size, - &psKernelMemInfo); + psMapIonIN->ui32ChunkCount, + psMapIonIN->auiOffset, + psMapIonIN->auiSize, + &psMapIonOUT->uiIonBufferSize, + &psKernelMemInfo, + &ui64Stamp); if (psMapIonOUT->eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "%s: Failed to map ion handle", __FUNCTION__)); @@ -1913,6 +1455,9 @@ PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID, /* No mapping info, we map through ion */ psMapIonOUT->sClientMemInfo.hMappingInfo = IMG_NULL; +#if defined(SUPPORT_MEMINFO_IDS) + psMapIonOUT->sClientMemInfo.ui64Stamp = ui64Stamp; +#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psMapIonOUT->sClientMemInfo.hKernelMemInfo, @@ -1941,25 +1486,9 @@ PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID, psMapIonOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - if (psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapIonOUT->sClientSyncInfo.hMappingInfo, - psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_SYNC_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE, - psMapIonOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psMapIonOUT->sClientSyncInfo.hMappingInfo = 0; - } -#else psMapIonOUT->sClientSyncInfo.hMappingInfo = psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; #endif -#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psMapIonOUT->sClientSyncInfo.hKernelSyncInfo, @@ -1987,11 +1516,7 @@ PVRSRVUnmapIonHandleBW(IMG_UINT32 ui32BridgeID, psUnmapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvKernelMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psUnmapIonIN->hKernelMemInfo, -#else psUnmapIonIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psUnmapIonOUT->eError != PVRSRV_OK) @@ -2008,11 +1533,7 @@ PVRSRVUnmapIonHandleBW(IMG_UINT32 ui32BridgeID, psUnmapIonOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - psUnmapIonIN->hKernelMemInfo, -#else psUnmapIonIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; @@ -2031,9 +1552,9 @@ PVRSRVGetFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, psGetFreeDeviceMemOUT->eError = PVRSRVGetFreeDeviceMemKM(psGetFreeDeviceMemIN->ui32Flags, - &psGetFreeDeviceMemOUT->ui32Total, - &psGetFreeDeviceMemOUT->ui32Free, - &psGetFreeDeviceMemOUT->ui32LargestBlock); + &psGetFreeDeviceMemOUT->uTotal, + &psGetFreeDeviceMemOUT->uFree, + &psGetFreeDeviceMemOUT->uLargestBlock); return 0; } @@ -2050,10 +1571,10 @@ PVRMMapOSMemHandleToMMapDataBW(IMG_UINT32 ui32BridgeID, psMMapDataOUT->eError = PVRMMapOSMemHandleToMMapData(psPerProc, psMMapDataIN->hMHandle, - &psMMapDataOUT->ui32MMapOffset, - &psMMapDataOUT->ui32ByteOffset, - &psMMapDataOUT->ui32RealByteSize, - &psMMapDataOUT->ui32UserVAddr); + &psMMapDataOUT->uiMMapOffset, + &psMMapDataOUT->uiByteOffset, + &psMMapDataOUT->uiRealByteSize, + &psMMapDataOUT->uiUserVAddr); #else PVR_UNREFERENCED_PARAMETER(psPerProc); PVR_UNREFERENCED_PARAMETER(psMMapDataIN); @@ -2077,8 +1598,8 @@ PVRMMapReleaseMMapDataBW(IMG_UINT32 ui32BridgeID, PVRMMapReleaseMMapData(psPerProc, psMMapDataIN->hMHandle, &psMMapDataOUT->bMUnmap, - &psMMapDataOUT->ui32RealByteSize, - &psMMapDataOUT->ui32UserVAddr); + &psMMapDataOUT->uiRealByteSize, + &psMMapDataOUT->uiUserVAddr); #else PVR_UNREFERENCED_PARAMETER(psPerProc); @@ -2090,34 +1611,6 @@ PVRMMapReleaseMMapDataBW(IMG_UINT32 ui32BridgeID, } -#if defined (SUPPORT_SID_INTERFACE) -static IMG_INT -PVRSRVChangeDeviceMemoryAttributesBW(IMG_UINT32 ui32BridgeID, - PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS *psChgMemAttribIN, - PVRSRV_BRIDGE_RETURN *psRetOUT, - PVRSRV_PER_PROCESS_DATA *psPerProc) -{ - IMG_HANDLE hKernelMemInfo; - - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS); - - psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - &hKernelMemInfo, - psChgMemAttribIN->hKernelMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - - if(psRetOUT->eError != PVRSRV_OK) - { - return 0; - } - - psRetOUT->eError = - PVRSRVChangeDeviceMemoryAttributesKM(hKernelMemInfo, psChgMemAttribIN->ui32Attribs); - - return 0; -} -#else static IMG_INT PVRSRVChangeDeviceMemoryAttributesBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS *psChgMemAttribIN, @@ -2131,7 +1624,6 @@ PVRSRVChangeDeviceMemoryAttributesBW(IMG_UINT32 ui32BridgeID, return 0; } -#endif #ifdef PDUMP static IMG_INT @@ -2251,11 +1743,7 @@ PDumpMemPolBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psPDumpMemPolIN->hKernelMemInfo, -#else psPDumpMemPolIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -2287,11 +1775,7 @@ PDumpMemBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psPDumpMemDumpIN->hKernelMemInfo, -#else psPDumpMemDumpIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -2442,11 +1926,7 @@ PDumpSyncDumpBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvSyncInfo, -#if defined (SUPPORT_SID_INTERFACE) - psPDumpSyncDumpIN->hKernelSyncInfo, -#else psPDumpSyncDumpIN->psKernelSyncInfo, -#endif PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -2482,11 +1962,7 @@ PDumpSyncPolBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvSyncInfo, -#if defined (SUPPORT_SID_INTERFACE) - psPDumpSyncPolIN->hKernelSyncInfo, -#else psPDumpSyncPolIN->psKernelSyncInfo, -#endif PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -2630,30 +2106,13 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_OUT_GET_MISC_INFO *psGetMiscInfoOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_MISC_INFO_KM sMiscInfo = {0}; -#endif PVRSRV_ERROR eError; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GET_MISC_INFO); -#if defined (SUPPORT_SID_INTERFACE) - sMiscInfo.ui32StateRequest = psGetMiscInfoIN->sMiscInfo.ui32StateRequest; - sMiscInfo.ui32StatePresent = psGetMiscInfoIN->sMiscInfo.ui32StatePresent; - sMiscInfo.ui32MemoryStrLen = psGetMiscInfoIN->sMiscInfo.ui32MemoryStrLen; - sMiscInfo.pszMemoryStr = psGetMiscInfoIN->sMiscInfo.pszMemoryStr; - - OSMemCopy(&sMiscInfo.sCacheOpCtl, - &psGetMiscInfoIN->sMiscInfo.sCacheOpCtl, - sizeof(sMiscInfo.sCacheOpCtl)); - OSMemCopy(&sMiscInfo.sGetRefCountCtl, - &psGetMiscInfoIN->sMiscInfo.sGetRefCountCtl, - sizeof(sMiscInfo.sGetRefCountCtl)); -#else OSMemCopy(&psGetMiscInfoOUT->sMiscInfo, &psGetMiscInfoIN->sMiscInfo, sizeof(PVRSRV_MISC_INFO)); -#endif if (((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_MEMSTATS_PRESENT) != 0) && ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_DDKVERSION_PRESENT) != 0) && @@ -2670,20 +2129,6 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) != 0)) { /* Alloc kernel side buffer to write into */ -#if defined (SUPPORT_SID_INTERFACE) - ASSIGN_AND_EXIT_ON_ERROR(psGetMiscInfoOUT->eError, - OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen, - (IMG_VOID **)&sMiscInfo.pszMemoryStr, 0, - "Output string buffer")); - psGetMiscInfoOUT->eError = PVRSRVGetMiscInfoKM(&sMiscInfo); - - /* Copy result to user */ - eError = CopyToUserWrapper(psPerProc, ui32BridgeID, - psGetMiscInfoIN->sMiscInfo.pszMemoryStr, - sMiscInfo.pszMemoryStr, - sMiscInfo.ui32MemoryStrLen); -#else ASSIGN_AND_EXIT_ON_ERROR(psGetMiscInfoOUT->eError, OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen, @@ -2697,18 +2142,11 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, psGetMiscInfoIN->sMiscInfo.pszMemoryStr, psGetMiscInfoOUT->sMiscInfo.pszMemoryStr, psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen); -#endif /* Free kernel side buffer again */ -#if defined (SUPPORT_SID_INTERFACE) - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, - sMiscInfo.ui32MemoryStrLen, - (IMG_VOID *)sMiscInfo.pszMemoryStr, 0); -#else OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen, (IMG_VOID *)psGetMiscInfoOUT->sMiscInfo.pszMemoryStr, 0); -#endif /* Replace output buffer pointer with input pointer, as both are expected * to point to the same userspace memory. @@ -2726,11 +2164,7 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, } else { -#if defined (SUPPORT_SID_INTERFACE) - psGetMiscInfoOUT->eError = PVRSRVGetMiscInfoKM(&sMiscInfo); -#else psGetMiscInfoOUT->eError = PVRSRVGetMiscInfoKM(&psGetMiscInfoOUT->sMiscInfo); -#endif } /* Return on error so exit status of PVRSRVGetMiscInfoKM is propagated to client. @@ -2746,19 +2180,11 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, * (a shared handle is allocated at most once), and there is no * resource allocation to undo if the handle allocation fails. */ -#if defined (SUPPORT_SID_INTERFACE) - if (sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT) -#else if (psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT) -#endif { psGetMiscInfoOUT->eError = PVRSRVAllocHandle(psPerProc->psHandleBase, &psGetMiscInfoOUT->sMiscInfo.sGlobalEventObject.hOSEventKM, -#if defined (SUPPORT_SID_INTERFACE) - sMiscInfo.sGlobalEventObject.hOSEventKM, -#else psGetMiscInfoOUT->sMiscInfo.sGlobalEventObject.hOSEventKM, -#endif PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); @@ -2767,27 +2193,14 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.sGlobalEventObject.szName, - sMiscInfo.sGlobalEventObject.szName, - EVENTOBJNAME_MAXLENGTH); -#endif } -#if defined (SUPPORT_SID_INTERFACE) - if (sMiscInfo.hSOCTimerRegisterOSMemHandle) -#else if (psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle) -#endif { /* Allocate handle for SOC OSMemHandle */ psGetMiscInfoOUT->eError = PVRSRVAllocHandle(psPerProc->psHandleBase, &psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle, -#if defined (SUPPORT_SID_INTERFACE) - sMiscInfo.hSOCTimerRegisterOSMemHandle, -#else psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle, -#endif PVRSRV_HANDLE_TYPE_SOC_TIMER, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); @@ -2796,32 +2209,6 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, return 0; } } -#if defined (SUPPORT_SID_INTERFACE) - else - { - psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle = 0; - } - - /* copy data from local sMiscInfo to OUT */ - psGetMiscInfoOUT->sMiscInfo.ui32StateRequest = sMiscInfo.ui32StateRequest; - psGetMiscInfoOUT->sMiscInfo.ui32StatePresent = sMiscInfo.ui32StatePresent; - - psGetMiscInfoOUT->sMiscInfo.pvSOCTimerRegisterKM = sMiscInfo.pvSOCTimerRegisterKM; - psGetMiscInfoOUT->sMiscInfo.pvSOCTimerRegisterUM = sMiscInfo.pvSOCTimerRegisterUM; - psGetMiscInfoOUT->sMiscInfo.pvSOCClockGateRegs = sMiscInfo.pvSOCClockGateRegs; - - psGetMiscInfoOUT->sMiscInfo.ui32SOCClockGateRegsSize = sMiscInfo.ui32SOCClockGateRegsSize; - - OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.aui32DDKVersion, - &sMiscInfo.aui32DDKVersion, - sizeof(psGetMiscInfoOUT->sMiscInfo.aui32DDKVersion)); - OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.sCacheOpCtl, - &sMiscInfo.sCacheOpCtl, - sizeof(psGetMiscInfoOUT->sMiscInfo.sCacheOpCtl)); - OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.sGetRefCountCtl, - &sMiscInfo.sGetRefCountCtl, - sizeof(psGetMiscInfoOUT->sMiscInfo.sGetRefCountCtl)); -#endif return 0; } @@ -2882,6 +2269,8 @@ PVRSRVDisconnectBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + static IMG_INT PVRSRVEnumerateDCBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_ENUMCLASS *psEnumDispClassIN, @@ -3369,9 +2758,6 @@ PVRSRVGetDCBuffersBW(IMG_UINT32 ui32BridgeID, IMG_VOID *pvDispClassInfo; IMG_VOID *pvSwapChain; IMG_UINT32 i; -#if defined (SUPPORT_SID_INTERFACE) - IMG_HANDLE *pahBuffer; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GET_DISPCLASS_BUFFERS); @@ -3397,27 +2783,12 @@ PVRSRVGetDCBuffersBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - psGetDispClassBuffersOUT->eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(IMG_HANDLE) * PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS, - (IMG_PVOID *)&pahBuffer, 0, - "Temp Swapchain Buffers"); - - if (psGetDispClassBuffersOUT->eError != PVRSRV_OK) - { - return 0; - } -#endif psGetDispClassBuffersOUT->eError = PVRSRVGetDCBuffersKM(pvDispClassInfo, pvSwapChain, &psGetDispClassBuffersOUT->ui32BufferCount, -#if defined (SUPPORT_SID_INTERFACE) - pahBuffer, -#else psGetDispClassBuffersOUT->ahBuffer, -#endif psGetDispClassBuffersOUT->asPhyAddr); if (psGetDispClassBuffersOUT->eError != PVRSRV_OK) { @@ -3428,37 +2799,19 @@ PVRSRVGetDCBuffersBW(IMG_UINT32 ui32BridgeID, for(i = 0; i < psGetDispClassBuffersOUT->ui32BufferCount; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hBufferExt; -#else IMG_HANDLE hBufferExt; -#endif /* PRQA S 1461 15 */ /* ignore warning about enum type being converted */ -#if defined (SUPPORT_SID_INTERFACE) - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &hBufferExt, - pahBuffer[i], - PVRSRV_HANDLE_TYPE_DISP_BUFFER, - (PVRSRV_HANDLE_ALLOC_FLAG)(PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE | PVRSRV_HANDLE_ALLOC_FLAG_SHARED), - psGetDispClassBuffersIN->hSwapChain); -#else PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &hBufferExt, psGetDispClassBuffersOUT->ahBuffer[i], PVRSRV_HANDLE_TYPE_DISP_BUFFER, (PVRSRV_HANDLE_ALLOC_FLAG)(PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE | PVRSRV_HANDLE_ALLOC_FLAG_SHARED), psGetDispClassBuffersIN->hSwapChain); -#endif psGetDispClassBuffersOUT->ahBuffer[i] = hBufferExt; } -#if defined (SUPPORT_SID_INTERFACE) - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(IMG_HANDLE) * PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS, - (IMG_PVOID)pahBuffer, 0); -#endif COMMIT_HANDLE_BATCH_OR_ERROR(psGetDispClassBuffersOUT->eError, psPerProc) @@ -3473,9 +2826,6 @@ PVRSRVSwapToDCBufferBW(IMG_UINT32 ui32BridgeID, { IMG_VOID *pvDispClassInfo; IMG_VOID *pvSwapChainBuf; -#if defined (SUPPORT_SID_INTERFACE) - IMG_HANDLE hPrivateTag; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER); @@ -3500,35 +2850,12 @@ PVRSRVSwapToDCBufferBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - if (psSwapDispClassBufferIN->hPrivateTag != 0) - { - psRetOUT->eError = - PVRSRVLookupSubHandle(psPerProc->psHandleBase, - &hPrivateTag, - psSwapDispClassBufferIN->hPrivateTag, - PVRSRV_HANDLE_TYPE_DISP_BUFFER, - psSwapDispClassBufferIN->hDeviceKM); - if(psRetOUT->eError != PVRSRV_OK) - { - return 0; - } - } - else - { - hPrivateTag = IMG_NULL; - } -#endif psRetOUT->eError = PVRSRVSwapToDCBufferKM(pvDispClassInfo, pvSwapChainBuf, psSwapDispClassBufferIN->ui32SwapInterval, -#if defined (SUPPORT_SID_INTERFACE) - hPrivateTag, -#else psSwapDispClassBufferIN->hPrivateTag, -#endif psSwapDispClassBufferIN->ui32ClipRectCount, psSwapDispClassBufferIN->sClipRect); @@ -3538,34 +2865,45 @@ PVRSRVSwapToDCBufferBW(IMG_UINT32 ui32BridgeID, static IMG_INT PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2 *psSwapDispClassBufferIN, - PVRSRV_BRIDGE_RETURN *psRetOUT, + PVRSRV_BRIDGE_OUT_SWAP_DISPCLASS_TO_BUFFER2 *psSwapDispClassBufferOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_VOID *pvPrivData = IMG_NULL; + IMG_HANDLE hFence = IMG_NULL; IMG_VOID *pvDispClassInfo; IMG_VOID *pvSwapChain; IMG_UINT32 i; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + int iReleaseFd = get_unused_fd(); + if(iReleaseFd < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to find unused fd (%d)", + __func__, iReleaseFd)); + return 0; + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER2); - psRetOUT->eError = + psSwapDispClassBufferOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvDispClassInfo, psSwapDispClassBufferIN->hDeviceKM, PVRSRV_HANDLE_TYPE_DISP_INFO); - if(psRetOUT->eError != PVRSRV_OK) + if(psSwapDispClassBufferOUT->eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up DISP_INFO handle")); return 0; } - psRetOUT->eError = + psSwapDispClassBufferOUT->eError = PVRSRVLookupSubHandle(psPerProc->psHandleBase, &pvSwapChain, psSwapDispClassBufferIN->hSwapChain, PVRSRV_HANDLE_TYPE_DISP_SWAP_CHAIN, psSwapDispClassBufferIN->hDeviceKM); - if(psRetOUT->eError != PVRSRV_OK) + if(psSwapDispClassBufferOUT->eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up DISP_BUFFER handle")); return 0; @@ -3589,33 +2927,37 @@ PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID, for (i = 0; i < psSwapDispClassBufferIN->ui32NumMemInfos; i++) { - PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - psRetOUT->eError = + psSwapDispClassBufferOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_PVOID *)&psKernelMemInfo, psSwapDispClassBufferIN->ppsKernelMemInfos[i], PVRSRV_HANDLE_TYPE_MEM_INFO); - if(psRetOUT->eError != PVRSRV_OK) + if(psSwapDispClassBufferOUT->eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up MEM_INFO handle")); return 0; } + psSwapDispClassBufferIN->ppsKernelMemInfos[i] = psKernelMemInfo; - psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - (IMG_PVOID *)&psKernelSyncInfo, - psSwapDispClassBufferIN->ppsKernelSyncInfos[i], - PVRSRV_HANDLE_TYPE_SYNC_INFO); - if(psRetOUT->eError != PVRSRV_OK) +#if !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) { - PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up SYNC_INFO handle")); - return 0; - } + PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; - psSwapDispClassBufferIN->ppsKernelMemInfos[i] = psKernelMemInfo; - psSwapDispClassBufferIN->ppsKernelSyncInfos[i] = psKernelSyncInfo; + psSwapDispClassBufferOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_PVOID *)&psKernelSyncInfo, + psSwapDispClassBufferIN->ppsKernelSyncInfos[i], + PVRSRV_HANDLE_TYPE_SYNC_INFO); + if(psSwapDispClassBufferOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up SYNC_INFO handle")); + return 0; + } + psSwapDispClassBufferIN->ppsKernelSyncInfos[i] = psKernelSyncInfo; + } +#endif /* !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ } if(psSwapDispClassBufferIN->ui32PrivDataLength > 0) @@ -3643,7 +2985,7 @@ PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID, } } - psRetOUT->eError = + psSwapDispClassBufferOUT->eError = PVRSRVSwapToDCBuffer2KM(pvDispClassInfo, pvSwapChain, psSwapDispClassBufferIN->ui32SwapInterval, @@ -3651,15 +2993,32 @@ PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID, psSwapDispClassBufferIN->ppsKernelSyncInfos, psSwapDispClassBufferIN->ui32NumMemInfos, pvPrivData, - psSwapDispClassBufferIN->ui32PrivDataLength); + psSwapDispClassBufferIN->ui32PrivDataLength, + &hFence); - if(psRetOUT->eError != PVRSRV_OK) + if(psSwapDispClassBufferOUT->eError != PVRSRV_OK) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psSwapDispClassBufferIN->ui32PrivDataLength, pvPrivData, IMG_NULL); } +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + if(hFence) + { + struct sync_fence *psFence = hFence; + sync_fence_install(psFence, iReleaseFd); + psSwapDispClassBufferOUT->hFence = (IMG_HANDLE)iReleaseFd; + } + else + { + psSwapDispClassBufferOUT->hFence = (IMG_HANDLE)-1; + put_unused_fd(iReleaseFd); + } +#else /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + psSwapDispClassBufferOUT->hFence = (IMG_HANDLE)-1; +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + return 0; } @@ -3854,6 +3213,7 @@ PVRSRVGetBCBufferBW(IMG_UINT32 ui32BridgeID, return 0; } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ static IMG_INT PVRSRVAllocSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, @@ -3870,7 +3230,7 @@ PVRSRVAllocSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, psAllocSharedSysMemOUT->eError = PVRSRVAllocSharedSysMemoryKM(psPerProc, psAllocSharedSysMemIN->ui32Flags, - psAllocSharedSysMemIN->ui32Size, + psAllocSharedSysMemIN->uSize, &psKernelMemInfo); if(psAllocSharedSysMemOUT->eError != PVRSRV_OK) { @@ -3889,22 +3249,7 @@ PVRSRVAllocSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, psKernelMemInfo->ui32Flags; psAllocSharedSysMemOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize; -#if defined (SUPPORT_SID_INTERFACE) - if (psKernelMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocHandleNR(psPerProc->psHandleBase, - &psAllocSharedSysMemOUT->sClientMemInfo.hMappingInfo, - psKernelMemInfo->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_NONE); - } - else - { - psAllocSharedSysMemOUT->sClientMemInfo.hMappingInfo = 0; - } -#else psAllocSharedSysMemOUT->sClientMemInfo.hMappingInfo = psKernelMemInfo->sMemBlk.hOSMemHandle; -#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psAllocSharedSysMemOUT->sClientMemInfo.hKernelMemInfo, @@ -3930,11 +3275,7 @@ PVRSRVFreeSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, psFreeSharedSysMemOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID **)&psKernelMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psFreeSharedSysMemIN->hKernelMemInfo, -#else psFreeSharedSysMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); if(psFreeSharedSysMemOUT->eError != PVRSRV_OK) @@ -3944,27 +3285,10 @@ PVRSRVFreeSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRVFreeSharedSysMemoryKM(psKernelMemInfo); if(psFreeSharedSysMemOUT->eError != PVRSRV_OK) return 0; -#if defined (SUPPORT_SID_INTERFACE) - if (psFreeSharedSysMemIN->hMappingInfo != 0) - { - psFreeSharedSysMemOUT->eError = - PVRSRVReleaseHandle(psPerProc->psHandleBase, - psFreeSharedSysMemIN->hMappingInfo, - PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); - if(psFreeSharedSysMemOUT->eError != PVRSRV_OK) - { - return 0; - } - } -#endif psFreeSharedSysMemOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - psFreeSharedSysMemIN->hKernelMemInfo, -#else psFreeSharedSysMemIN->psKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); return 0; } @@ -3977,11 +3301,7 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, { PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_HANDLE_TYPE eHandleType; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hParent; -#else IMG_HANDLE hParent; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_MAP_MEMINFO_MEM); NEW_HANDLE_BATCH_OR_ERROR(psMapMemInfoMemOUT->eError, psPerProc, 2) @@ -3998,7 +3318,7 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, switch (eHandleType) { -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) case PVRSRV_HANDLE_TYPE_MEM_INFO: case PVRSRV_HANDLE_TYPE_MEM_INFO_REF: case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO: @@ -4025,11 +3345,7 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, { return 0; } -#if defined (SUPPORT_SID_INTERFACE) - if (hParent == 0) -#else if (hParent == IMG_NULL) -#endif { hParent = psMapMemInfoMemIN->hKernelMemInfo; } @@ -4048,23 +3364,7 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, psKernelMemInfo->ui32Flags; psMapMemInfoMemOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize; -#if defined (SUPPORT_SID_INTERFACE) - if (psKernelMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapMemInfoMemOUT->sClientMemInfo.hMappingInfo, - psKernelMemInfo->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_MEM_INFO_REF, - PVRSRV_HANDLE_ALLOC_FLAG_MULTI, - hParent); - } - else - { - psMapMemInfoMemOUT->sClientMemInfo.hMappingInfo = 0; - } -#else psMapMemInfoMemOUT->sClientMemInfo.hMappingInfo = psKernelMemInfo->sMemBlk.hOSMemHandle; -#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psMapMemInfoMemOUT->sClientMemInfo.hKernelMemInfo, @@ -4093,25 +3393,9 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, psMapMemInfoMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; -#if defined (SUPPORT_SID_INTERFACE) - if (psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) - { - PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, - &psMapMemInfoMemOUT->sClientSyncInfo.hMappingInfo, - psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, - PVRSRV_HANDLE_TYPE_SYNC_INFO, - PVRSRV_HANDLE_ALLOC_FLAG_MULTI, - psMapMemInfoMemOUT->sClientMemInfo.hKernelMemInfo); - } - else - { - psMapMemInfoMemOUT->sClientSyncInfo.hMappingInfo = 0; - } -#else psMapMemInfoMemOUT->sClientSyncInfo.hMappingInfo = psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; #endif -#endif psMapMemInfoMemOUT->sClientMemInfo.psClientSyncInfo = &psMapMemInfoMemOUT->sClientSyncInfo; @@ -4174,7 +3458,7 @@ _SetDispatchTableEntry(IMG_UINT32 ui32Index, BridgeWrapperFunction pfFunction, const IMG_CHAR *pszFunctionName) { - static IMG_UINT32 ui32PrevIndex = ~0UL; /* -1 */ + static IMG_UINT uiPrevIndex = ~0U; /* -1 */ #if !defined(DEBUG) PVR_UNREFERENCED_PARAMETER(pszIOCName); #endif @@ -4217,20 +3501,20 @@ _SetDispatchTableEntry(IMG_UINT32 ui32Index, * etc is likly to modify the available ioctls and thus be a point where * mistakes are exposed. This isn't run at at a performance critical time. */ -// if((ui32PrevIndex != (IMG_UINT32)-1) && - if((ui32PrevIndex != ~0UL) && - ((ui32Index >= ui32PrevIndex + DISPATCH_TABLE_GAP_THRESHOLD) || - (ui32Index <= ui32PrevIndex))) +// if((uiPrevIndex != (IMG_UINT)-1) && + if((uiPrevIndex != ~0U) && + ((ui32Index >= uiPrevIndex + DISPATCH_TABLE_GAP_THRESHOLD) || + (ui32Index <= uiPrevIndex))) { #if defined(DEBUG_BRIDGE_KM) PVR_DPF((PVR_DBG_WARNING, "%s: There is a gap in the dispatch table between indices %u (%s) and %u (%s)", - __FUNCTION__, ui32PrevIndex, g_BridgeDispatchTable[ui32PrevIndex].pszIOCName, + __FUNCTION__, uiPrevIndex, g_BridgeDispatchTable[uiPrevIndex].pszIOCName, ui32Index, pszIOCName)); #else PVR_DPF((PVR_DBG_WARNING, "%s: There is a gap in the dispatch table between indices %u and %u (%s)", - __FUNCTION__, (IMG_UINT)ui32PrevIndex, (IMG_UINT)ui32Index, pszIOCName)); + __FUNCTION__, (IMG_UINT)uiPrevIndex, (IMG_UINT)ui32Index, pszIOCName)); #endif PVR_DPF((PVR_DBG_ERROR, "NOTE: Enabling DEBUG_BRIDGE_KM_DISPATCH_TABLE may help debug this issue.")); } @@ -4243,7 +3527,7 @@ _SetDispatchTableEntry(IMG_UINT32 ui32Index, g_BridgeDispatchTable[ui32Index].ui32CopyFromUserTotalBytes = 0; #endif - ui32PrevIndex = ui32Index; + uiPrevIndex = ui32Index; } static IMG_INT @@ -4340,10 +3624,6 @@ PVRSRVEventObjectOpenBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN *psEventObjectOpenOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_EVENTOBJECT_KM sEventObject; - IMG_HANDLE hOSEvent; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_EVENT_OBJECT_OPEN); @@ -4351,11 +3631,7 @@ PVRSRVEventObjectOpenBW(IMG_UINT32 ui32BridgeID, psEventObjectOpenOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sEventObject.hOSEventKM, -#else &psEventObjectOpenIN->sEventObject.hOSEventKM, -#endif psEventObjectOpenIN->sEventObject.hOSEventKM, PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT); @@ -4364,38 +3640,18 @@ PVRSRVEventObjectOpenBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - OSMemCopy(&sEventObject.szName, - &psEventObjectOpenIN->sEventObject.szName, - EVENTOBJNAME_MAXLENGTH); - - psEventObjectOpenOUT->eError = OSEventObjectOpenKM(&sEventObject, &hOSEvent); -#else psEventObjectOpenOUT->eError = OSEventObjectOpenKM(&psEventObjectOpenIN->sEventObject, &psEventObjectOpenOUT->hOSEvent); -#endif if(psEventObjectOpenOUT->eError != PVRSRV_OK) { return 0; } -#if defined (SUPPORT_SID_INTERFACE) -/* Windows7, WinXP and Vista already use an Index type handle which the client glue uses directly */ -/* Linux requires a SID handle */ -#if !defined (WINXP) && !defined(SUPPORT_VISTA) - PVRSRVAllocHandleNR(psPerProc->psHandleBase, - &psEventObjectOpenOUT->hOSEvent, - hOSEvent, - PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT, - PVRSRV_HANDLE_ALLOC_FLAG_MULTI); -#endif -#else PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psEventObjectOpenOUT->hOSEvent, psEventObjectOpenOUT->hOSEvent, PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT, PVRSRV_HANDLE_ALLOC_FLAG_MULTI); -#endif COMMIT_HANDLE_BATCH_OR_ERROR(psEventObjectOpenOUT->eError, psPerProc) @@ -4410,19 +3666,12 @@ PVRSRVEventObjectCloseBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hOSEventKM; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_EVENTOBJECT_KM sEventObject; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_EVENT_OBJECT_CLOSE); psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sEventObject.hOSEventKM, -#else &psEventObjectCloseIN->sEventObject.hOSEventKM, -#endif psEventObjectCloseIN->sEventObject.hOSEventKM, PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT); if(psRetOUT->eError != PVRSRV_OK) @@ -4440,20 +3689,7 @@ PVRSRVEventObjectCloseBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - if(CopyFromUserWrapper(psPerProc, ui32BridgeID, - &sEventObject.szName, - &psEventObjectCloseIN->sEventObject.szName, - EVENTOBJNAME_MAXLENGTH) != PVRSRV_OK) - { - /*not nulling pointer, out of scope*/ - return -EFAULT; - } - - psRetOUT->eError = OSEventObjectCloseKM(&sEventObject, hOSEventKM); -#else psRetOUT->eError = OSEventObjectCloseKM(&psEventObjectCloseIN->sEventObject, hOSEventKM); -#endif return 0; } @@ -4581,6 +3817,17 @@ static PVRSRV_ERROR DoModifyCompleteSyncOps(MODIFY_SYNC_OP_INFO *psModSyncOpInfo psKernelSyncInfo->psSyncData->ui32ReadOpsComplete++; } + /* update the ROp2Complete */ + if(psModSyncOpInfo->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_RO2_INC) + { + psKernelSyncInfo->psSyncData->ui32ReadOps2Complete++; + } + + PVR_TTRACE(PVRSRV_TRACE_GROUP_MODOBJ, PVRSRV_TRACE_CLASS_CMD_COMP_START, MODOBJ_TOKEN_COMPLETE_PENDING); + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_MODOBJ, MODOBJ_TOKEN_SYNC_UPDATE, + psKernelSyncInfo, PVRSRV_SYNCOP_COMPLETE); + PVR_TTRACE(PVRSRV_TRACE_GROUP_MODOBJ, PVRSRV_TRACE_CLASS_CMD_COMP_END, MODOBJ_TOKEN_COMPLETE_PENDING); + return PVRSRV_OK; } @@ -4715,8 +3962,6 @@ PVRSRVDestroySyncInfoModObjBW(IMG_UINT32 return 0; } - PVRSRVKernelSyncInfoDecRef(psModSyncOpInfo->psKernelSyncInfo, IMG_NULL); - psDestroySyncInfoModObjOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, psDestroySyncInfoModObjIN->hKernelSyncInfoModObj, PVRSRV_HANDLE_TYPE_SYNC_INFO_MOD_OBJ); @@ -4799,14 +4044,42 @@ PVRSRVModifyPendingSyncOpsBW(IMG_UINT32 ui32BridgeID, psModifySyncOpsOUT->ui32WriteOpsPending = psKernelSyncInfo->psSyncData->ui32WriteOpsPending; psModifySyncOpsOUT->ui32ReadOps2Pending = psKernelSyncInfo->psSyncData->ui32ReadOps2Pending; + PVR_TTRACE(PVRSRV_TRACE_GROUP_MODOBJ, PVRSRV_TRACE_CLASS_CMD_START, MODOBJ_TOKEN_MODIFY_PENDING); if(psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC) { - psKernelSyncInfo->psSyncData->ui32WriteOpsPending++; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_MODOBJ, MODOBJ_TOKEN_WRITE_SYNC, + psKernelSyncInfo, PVRSRV_SYNCOP_SAMPLE); + } + else if (psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_RO_INC) + { + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_MODOBJ, MODOBJ_TOKEN_READ_SYNC, + psKernelSyncInfo, PVRSRV_SYNCOP_SAMPLE); + } + else if (psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_RO2_INC) + { + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_MODOBJ, MODOBJ_TOKEN_READ2_SYNC, + psKernelSyncInfo, PVRSRV_SYNCOP_SAMPLE); + } + else + { + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_MODOBJ, MODOBJ_TOKEN_READ_WRITE_SYNC, + psKernelSyncInfo, PVRSRV_SYNCOP_SAMPLE); + } + PVR_TTRACE(PVRSRV_TRACE_GROUP_MODOBJ, PVRSRV_TRACE_CLASS_CMD_END, MODOBJ_TOKEN_MODIFY_PENDING); + + if(psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC) + { + SyncTakeWriteOp(psKernelSyncInfo, SYNC_OP_CLASS_MODOBJ); } if(psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_RO_INC) { - psKernelSyncInfo->psSyncData->ui32ReadOpsPending++; + SyncTakeReadOp(psKernelSyncInfo, SYNC_OP_CLASS_MODOBJ); + } + + if(psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_RO2_INC) + { + SyncTakeReadOp2(psKernelSyncInfo, SYNC_OP_CLASS_MODOBJ); } /* pull the resman item to the front of the list */ @@ -5209,8 +4482,6 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_EXT_MEMORY, DummyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY, PVRSRVMapDeviceMemoryBW); SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DEV_MEMORY, PVRSRVUnmapDeviceMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEVICECLASS_MEMORY, PVRSRVMapDeviceClassMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DEVICECLASS_MEMORY, PVRSRVUnmapDeviceClassMemoryBW); SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_MEM_INFO_TO_USER, DummyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_MEM_INFO_FROM_USER, DummyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM, PVRSRVExportDeviceMemBW); @@ -5218,10 +4489,6 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS, PVRSRVChangeDeviceMemoryAttributesBW); SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY_2, PVRSRVMapDeviceMemoryBW); SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2, PVRSRVExportDeviceMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MULTI_MANAGE_DEV_MEM, PVRSRVMultiManageDevMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CORE_CMD_RESERVED_1, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CORE_CMD_RESERVED_2, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CORE_CMD_RESERVED_3, DummyBW); #if defined(SUPPORT_ION) SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_ION_HANDLE, PVRSRVMapIonHandleBW); SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_ION_HANDLE, PVRSRVUnmapIonHandleBW); @@ -5275,6 +4542,10 @@ CommonBridgeInit(IMG_VOID) /* DisplayClass APIs */ SetDispatchTableEntry(PVRSRV_BRIDGE_GET_OEMJTABLE, DummyBW); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEVICECLASS_MEMORY, PVRSRVMapDeviceClassMemoryBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DEVICECLASS_MEMORY, PVRSRVUnmapDeviceClassMemoryBW); + /* device class enum */ SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_CLASS, PVRSRVEnumerateDCBW); @@ -5305,6 +4576,37 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_CLOSE_BUFFERCLASS_DEVICE, PVRSRVCloseBCDeviceBW); SetDispatchTableEntry(PVRSRV_BRIDGE_GET_BUFFERCLASS_INFO, PVRSRVGetBCInfoBW); SetDispatchTableEntry(PVRSRV_BRIDGE_GET_BUFFERCLASS_BUFFER, PVRSRVGetBCBufferBW); +#else /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEVICECLASS_MEMORY, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DEVICECLASS_MEMORY, DummyBW); + + /* device class enum */ + SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_CLASS, DummyBW); + + /* display class API */ + SetDispatchTableEntry(PVRSRV_BRIDGE_OPEN_DISPCLASS_DEVICE, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_CLOSE_DISPCLASS_DEVICE, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DISPCLASS_FORMATS, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DISPCLASS_DIMS, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_SYSBUFFER, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_INFO, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_CREATE_DISPCLASS_SWAPCHAIN, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_DESTROY_DISPCLASS_SWAPCHAIN, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_DSTRECT, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_SRCRECT, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_DSTCOLOURKEY, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_SRCCOLOURKEY, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_BUFFERS, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER2, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_SYSTEM, DummyBW); + + /* buffer class API */ + SetDispatchTableEntry(PVRSRV_BRIDGE_OPEN_BUFFERCLASS_DEVICE, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_CLOSE_BUFFERCLASS_DEVICE, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_GET_BUFFERCLASS_INFO, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_GET_BUFFERCLASS_BUFFER, DummyBW); +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ /* Wrap/Unwrap external memory */ SetDispatchTableEntry(PVRSRV_BRIDGE_WRAP_EXT_MEMORY, PVRSRVWrapExtMemoryBW); @@ -5416,6 +4718,7 @@ IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, case PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_DISCONNECT_SERVICES): case PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_INITSRV_CONNECT): case PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_INITSRV_DISCONNECT): + case PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_UM_KM_COMPAT_CHECK): break; default: PVR_DPF((PVR_DBG_ERROR, "%s: Driver initialisation not completed yet.", @@ -5476,15 +4779,21 @@ IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, __FUNCTION__, ui32BridgeID)); goto return_fault; } - pfBridgeHandler = - (BridgeWrapperFunction)g_BridgeDispatchTable[ui32BridgeID].pfFunction; - err = pfBridgeHandler(ui32BridgeID, + + if( ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_UM_KM_COMPAT_CHECK)) + PVRSRVCompatCheckKM(psBridgeIn, psBridgeOut); + else + { + pfBridgeHandler = + (BridgeWrapperFunction)g_BridgeDispatchTable[ui32BridgeID].pfFunction; + err = pfBridgeHandler(ui32BridgeID, psBridgeIn, psBridgeOut, psPerProc); - if(err < 0) - { - goto return_fault; + if(err < 0) + { + goto return_fault; + } } #if defined(__linux__) diff --git a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.h b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.h index b0145f795fa..0a1cc6e196c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.h +++ b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_pvr_bridge.h @@ -52,7 +52,7 @@ extern "C" { #if defined(__linux__) #define PVRSRV_GET_BRIDGE_ID(X) _IOC_NR(X) #else -#define PVRSRV_GET_BRIDGE_ID(X) ((X) - PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST)) +#define PVRSRV_GET_BRIDGE_ID(X) ((X) - PVRSRV_IOWR(PVRSRV_BRIDGE_UMKM_CMD_FIRST)) #endif #ifndef ENOMEM @@ -99,7 +99,7 @@ CopyToUserWrapper(PVRSRV_PER_PROCESS_DATA *pProcData, #define ASSIGN_AND_EXIT_ON_ERROR(error, src) \ ASSIGN_AND_RETURN_ON_ERROR(error, src, 0) -#if defined (PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) #ifdef INLINE_IS_PRAGMA #pragma inline(NewHandleBatch) #endif diff --git a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.c b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.c index 25baf2936d7..2ccdc661c49 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.c +++ b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.c @@ -52,11 +52,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * handle. */ PVRSRV_ERROR -#if defined (SUPPORT_SID_INTERFACE) -PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHandle, IMG_SID hMHandle) -#else PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHandle, IMG_HANDLE hMHandle) -#endif { IMG_HANDLE hMHandleInt; PVRSRV_HANDLE_TYPE eHandleType; @@ -76,7 +72,7 @@ PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHan switch(eHandleType) { -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) case PVRSRV_HANDLE_TYPE_MEM_INFO: case PVRSRV_HANDLE_TYPE_MEM_INFO_REF: case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO: diff --git a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.h b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.h index 04d5168a2f8..e32fa886bfc 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.h +++ b/drivers/gpu/pvr/services4/srvkm/bridged/bridged_support.h @@ -55,11 +55,7 @@ extern "C" { * Derive the internal OS specific memory handle from a secure * handle. */ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phOSMemHandle, IMG_SID hMHandle); -#else PVRSRV_ERROR PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phOSMemHandle, IMG_HANDLE hMHandle); -#endif #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c b/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c index bee5dc6af19..f23fd49593b 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c @@ -141,9 +141,6 @@ SGXGetInternalDevInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; -#if defined (SUPPORT_SID_INTERFACE) - SGX_INTERNAL_DEVINFO_KM sSGXInternalDevInfo; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_GETINTERNALDEVINFO); @@ -159,11 +156,7 @@ SGXGetInternalDevInfoBW(IMG_UINT32 ui32BridgeID, psSGXGetInternalDevInfoOUT->eError = SGXGetInternalDevInfoKM(hDevCookieInt, -#if defined (SUPPORT_SID_INTERFACE) - &sSGXInternalDevInfo); -#else &psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo); -#endif /* * Handle is not allocated in batch mode, as there is no resource @@ -172,11 +165,7 @@ SGXGetInternalDevInfoBW(IMG_UINT32 ui32BridgeID, psSGXGetInternalDevInfoOUT->eError = PVRSRVAllocHandle(psPerProc->psHandleBase, &psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle, -#if defined (SUPPORT_SID_INTERFACE) - sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle, -#else psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); @@ -194,12 +183,7 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, IMG_UINT32 i; IMG_INT ret = 0; IMG_UINT32 ui32NumDstSyncs; -#if defined (SUPPORT_SID_INTERFACE) - SGX_CCB_KICK_KM sCCBKickKM = {{0}}; - IMG_HANDLE ahSyncInfoHandles[16]; -#else IMG_HANDLE *phKernelSyncInfoHandles = IMG_NULL; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DOKICK); @@ -216,11 +200,7 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.hCCBKernelMemInfo, -#else &psDoKickIN->sCCBKick.hCCBKernelMemInfo, -#endif psDoKickIN->sCCBKick.hCCBKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); @@ -229,24 +209,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - if (psDoKickIN->sCCBKick.ui32NumDstSyncObjects > 16) - { - return 0; - } - - if(psDoKickIN->sCCBKick.hTA3DSyncInfo != 0) -#else if(psDoKickIN->sCCBKick.hTA3DSyncInfo != IMG_NULL) -#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.hTA3DSyncInfo, -#else &psDoKickIN->sCCBKick.hTA3DSyncInfo, -#endif psDoKickIN->sCCBKick.hTA3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -256,19 +223,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, } } -#if defined (SUPPORT_SID_INTERFACE) - if(psDoKickIN->sCCBKick.hTASyncInfo != 0) -#else if(psDoKickIN->sCCBKick.hTASyncInfo != IMG_NULL) -#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.hTASyncInfo, -#else &psDoKickIN->sCCBKick.hTASyncInfo, -#endif psDoKickIN->sCCBKick.hTASyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -292,19 +251,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, } #endif -#if defined (SUPPORT_SID_INTERFACE) - if(psDoKickIN->sCCBKick.h3DSyncInfo != 0) -#else if(psDoKickIN->sCCBKick.h3DSyncInfo != IMG_NULL) -#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.h3DSyncInfo, -#else &psDoKickIN->sCCBKick.h3DSyncInfo, -#endif psDoKickIN->sCCBKick.h3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -323,18 +274,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.ui32NumTASrcSyncs = psDoKickIN->sCCBKick.ui32NumTASrcSyncs; -#endif for(i=0; i<psDoKickIN->sCCBKick.ui32NumTASrcSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.ahTASrcKernelSyncInfo[i], -#else &psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i], -#endif psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -350,18 +294,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.ui32NumTADstSyncs = psDoKickIN->sCCBKick.ui32NumTADstSyncs; -#endif for(i=0; i<psDoKickIN->sCCBKick.ui32NumTADstSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.ahTADstKernelSyncInfo[i], -#else &psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i], -#endif psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -377,18 +314,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.ui32Num3DSrcSyncs = psDoKickIN->sCCBKick.ui32Num3DSrcSyncs; -#endif for(i=0; i<psDoKickIN->sCCBKick.ui32Num3DSrcSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.ah3DSrcKernelSyncInfo[i], -#else &psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i], -#endif psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -405,18 +335,12 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.ui32NumSrcSyncs = psDoKickIN->sCCBKick.ui32NumSrcSyncs; -#endif +#if !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) for(i=0; i<psDoKickIN->sCCBKick.ui32NumSrcSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.ahSrcKernelSyncInfo[i], -#else &psDoKickIN->sCCBKick.ahSrcKernelSyncInfo[i], -#endif psDoKickIN->sCCBKick.ahSrcKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -425,7 +349,8 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } } -#endif/* #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */ +#endif /* !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ +#endif /* defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */ if (psDoKickIN->sCCBKick.ui32NumTAStatusVals > SGX_MAX_TA_STATUS_VALS) { @@ -437,25 +362,14 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = #if defined(SUPPORT_SGX_NEW_STATUS_VALS) PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.asTAStatusUpdate[i].hKernelMemInfo, -#else &psDoKickIN->sCCBKick.asTAStatusUpdate[i].hKernelMemInfo, -#endif psDoKickIN->sCCBKick.asTAStatusUpdate[i].hKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.asTAStatusUpdate[i].sCtlStatus = psDoKickIN->sCCBKick.asTAStatusUpdate[i].sCtlStatus; -#endif #else PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.ahTAStatusSyncInfo[i], -#else &psDoKickIN->sCCBKick.ahTAStatusSyncInfo[i], -#endif psDoKickIN->sCCBKick.ahTAStatusSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); #endif @@ -475,24 +389,13 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = #if defined(SUPPORT_SGX_NEW_STATUS_VALS) PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.as3DStatusUpdate[i].hKernelMemInfo, -#else &psDoKickIN->sCCBKick.as3DStatusUpdate[i].hKernelMemInfo, -#endif psDoKickIN->sCCBKick.as3DStatusUpdate[i].hKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.as3DStatusUpdate[i].sCtlStatus = psDoKickIN->sCCBKick.as3DStatusUpdate[i].sCtlStatus; -#endif #else PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.ah3DStatusSyncInfo[i], -#else &psDoKickIN->sCCBKick.ah3DStatusSyncInfo[i], -#endif psDoKickIN->sCCBKick.ah3DStatusSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); #endif @@ -526,9 +429,6 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - sCCBKickKM.pahDstSyncHandles = phKernelSyncInfoHandles; -#else if(CopyFromUserWrapper(psPerProc, ui32BridgeID, phKernelSyncInfoHandles, @@ -541,17 +441,12 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, /* Set sCCBKick.pahDstSyncHandles to point to the local memory */ psDoKickIN->sCCBKick.pahDstSyncHandles = phKernelSyncInfoHandles; -#endif for( i = 0; i < ui32NumDstSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.pahDstSyncHandles[i], -#else &psDoKickIN->sCCBKick.pahDstSyncHandles[i], -#endif psDoKickIN->sCCBKick.pahDstSyncHandles[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -564,11 +459,7 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM.hKernelHWSyncListMemInfo, -#else &psDoKickIN->sCCBKick.hKernelHWSyncListMemInfo, -#endif psDoKickIN->sCCBKick.hKernelHWSyncListMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); @@ -578,34 +469,9 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, } } -#if defined (SUPPORT_SID_INTERFACE) - OSMemCopy(&sCCBKickKM.sCommand, &psDoKickIN->sCCBKick.sCommand, sizeof(sCCBKickKM.sCommand)); - - sCCBKickKM.ui32NumDstSyncObjects = psDoKickIN->sCCBKick.ui32NumDstSyncObjects; - sCCBKickKM.ui32NumTAStatusVals = psDoKickIN->sCCBKick.ui32NumTAStatusVals; - sCCBKickKM.ui32Num3DStatusVals = psDoKickIN->sCCBKick.ui32Num3DStatusVals; - sCCBKickKM.bFirstKickOrResume = psDoKickIN->sCCBKick.bFirstKickOrResume; - sCCBKickKM.ui32CCBOffset = psDoKickIN->sCCBKick.ui32CCBOffset; - sCCBKickKM.bTADependency = psDoKickIN->sCCBKick.bTADependency; - -#if defined(NO_HARDWARE) || defined(PDUMP) - sCCBKickKM.bTerminateOrAbort = psDoKickIN->sCCBKick.bTerminateOrAbort; -#endif -#if defined(PDUMP) - sCCBKickKM.ui32CCBDumpWOff = psDoKickIN->sCCBKick.ui32CCBDumpWOff; -#endif - -#if defined(NO_HARDWARE) - sCCBKickKM.ui32WriteOpsPendingVal = psDoKickIN->sCCBKick.ui32WriteOpsPendingVal; -#endif -#endif /* #if defined (SUPPORT_SID_INTERFACE) */ psRetOUT->eError = SGXDoKickKM(hDevCookieInt, -#if defined (SUPPORT_SID_INTERFACE) - &sCCBKickKM); -#else &psDoKickIN->sCCBKick); -#endif PVRSRV_BRIDGE_SGX_DOKICK_RETURN_RESULT: @@ -657,9 +523,6 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { IMG_HANDLE hDevCookieInt; PVRSRV_TRANSFER_SGX_KICK *psKick; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_TRANSFER_SGX_KICK_KM sKickKM = {0}; -#endif IMG_UINT32 i; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SUBMITTRANSFER); @@ -693,11 +556,7 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.hCCBMemInfo, -#else &psKick->hCCBMemInfo, -#endif psKick->hCCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -709,11 +568,7 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.hTASyncInfo, -#else &psKick->hTASyncInfo, -#endif psKick->hTASyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -726,11 +581,7 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.h3DSyncInfo, -#else &psKick->h3DSyncInfo, -#endif psKick->h3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -748,11 +599,7 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.ahSrcSyncInfo[i], -#else &psKick->ahSrcSyncInfo[i], -#endif psKick->ahSrcSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -770,11 +617,7 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.ahDstSyncInfo[i], -#else &psKick->ahDstSyncInfo[i], -#endif psKick->ahDstSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -783,21 +626,7 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, } } -#if defined (SUPPORT_SID_INTERFACE) - sKickKM.sHWTransferContextDevVAddr = psKick->sHWTransferContextDevVAddr; - sKickKM.ui32SharedCmdCCBOffset = psKick->ui32SharedCmdCCBOffset; - sKickKM.ui32NumSrcSync = psKick->ui32NumSrcSync; - sKickKM.ui32NumDstSync = psKick->ui32NumDstSync; - sKickKM.ui32Flags = psKick->ui32Flags; - sKickKM.ui32PDumpFlags = psKick->ui32PDumpFlags; -#if defined(PDUMP) - sKickKM.ui32CCBDumpWOff = psKick->ui32CCBDumpWOff; -#endif - - psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, &sKickKM); -#else psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, psKick); -#endif return 0; } @@ -896,9 +725,6 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, { IMG_HANDLE hDevCookieInt; PVRSRV_2D_SGX_KICK *psKick; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_2D_SGX_KICK_KM sKickKM; -#endif IMG_UINT32 i; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SUBMIT2D); @@ -935,11 +761,7 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.hCCBMemInfo, -#else &psKick->hCCBMemInfo, -#endif psKick->hCCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -947,19 +769,11 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - if (psKick->hTASyncInfo != 0) -#else if (psKick->hTASyncInfo != IMG_NULL) -#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.hTASyncInfo, -#else &psKick->hTASyncInfo, -#endif psKick->hTASyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -967,22 +781,12 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } -#if defined (SUPPORT_SID_INTERFACE) - else - { - sKickKM.hTASyncInfo = IMG_NULL; - } -#endif if (psKick->h3DSyncInfo != IMG_NULL) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.h3DSyncInfo, -#else &psKick->h3DSyncInfo, -#endif psKick->h3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -990,39 +794,12 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } -#if defined (SUPPORT_SID_INTERFACE) - else - { - sKickKM.h3DSyncInfo = IMG_NULL; - } -#endif if (psKick->ui32NumSrcSync > SGX_MAX_2D_SRC_SYNC_OPS) { psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; return 0; } -#if defined (SUPPORT_SID_INTERFACE) - for (i = 0; i < SGX_MAX_2D_SRC_SYNC_OPS; i++) - { - if (i < psKick->ui32NumSrcSync) - { - psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - &sKickKM.ahSrcSyncInfo[i], - psKick->ahSrcSyncInfo[i], - PVRSRV_HANDLE_TYPE_SYNC_INFO); - if(psRetOUT->eError != PVRSRV_OK) - { - return 0; - } - } - else - { - sKickKM.ahSrcSyncInfo[i] = IMG_NULL; - } - } -#else for (i = 0; i < psKick->ui32NumSrcSync; i++) { psRetOUT->eError = @@ -1035,17 +812,12 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } -#endif if (psKick->hDstSyncInfo != IMG_NULL) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &sKickKM.hDstSyncInfo, -#else &psKick->hDstSyncInfo, -#endif psKick->hDstSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -1053,28 +825,9 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } -#if defined (SUPPORT_SID_INTERFACE) - else - { - sKickKM.hDstSyncInfo = IMG_NULL; - } - - /* copy common members across */ - sKickKM.ui32SharedCmdCCBOffset = psKick->ui32SharedCmdCCBOffset; - sKickKM.ui32NumSrcSync = psKick->ui32NumSrcSync; - sKickKM.ui32PDumpFlags = psKick->ui32PDumpFlags; - sKickKM.sHW2DContextDevVAddr = psKick->sHW2DContextDevVAddr; -#if defined(PDUMP) - sKickKM.ui32CCBDumpWOff = psKick->ui32CCBDumpWOff; -#endif -#endif psRetOUT->eError = -#if defined (SUPPORT_SID_INTERFACE) - SGXSubmit2DKM(hDevCookieInt, &sKickKM); -#else SGXSubmit2DKM(hDevCookieInt, psKick); -#endif return 0; } @@ -1230,19 +983,12 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_ERROR eError = PVRSRV_OK; -#else PVRSRV_ERROR eError; -#endif IMG_BOOL bDissociateFailed = IMG_FALSE; IMG_BOOL bLookupFailed = IMG_FALSE; IMG_BOOL bReleaseFailed = IMG_FALSE; IMG_HANDLE hDummy; IMG_UINT32 i; -#if defined (SUPPORT_SID_INTERFACE) - SGX_BRIDGE_INIT_INFO_KM asInitInfoKM = {0}; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DEVINITPART2); @@ -1264,7 +1010,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, { return 0; } - + /* Check all the meminfo handles */ eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDummy, @@ -1372,28 +1118,6 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bLookupFailed = IMG_TRUE; } -#if defined(FIX_HW_BRN_29702) - eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - &hDummy, - psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bLookupFailed = IMG_TRUE; - } -#endif - -#if defined(FIX_HW_BRN_29823) - eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - &hDummy, - psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bLookupFailed = IMG_TRUE; - } -#endif - #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, @@ -1463,25 +1187,6 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } #endif -#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559) - eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - &hDummy, - psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bLookupFailed = IMG_TRUE; - } - - eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - &hDummy, - psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bLookupFailed = IMG_TRUE; - } -#endif #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, @@ -1507,17 +1212,9 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; -#else IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; -#endif -#if defined (SUPPORT_SID_INTERFACE) - if (hHandle == 0) -#else if (hHandle == IMG_NULL) -#endif { continue; } @@ -1541,11 +1238,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, /* Lookup and release the device memory handles */ eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelCCBMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1554,11 +1247,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelCCBCtlMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1567,11 +1256,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelCCBEventKickerMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1581,11 +1266,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelSGXHostCtlMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1594,11 +1275,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelSGXTA3DCtlMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1608,11 +1285,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1622,11 +1295,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #endif eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelSGXMiscMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1637,11 +1306,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(SGX_SUPPORT_HWPROFILING) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelHWProfilingMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1652,11 +1317,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(SUPPORT_SGX_HWPERF) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelHWPerfCBMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1666,11 +1327,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #endif eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelTASigBufferMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1679,11 +1336,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernel3DSigBufferMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1691,44 +1344,10 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } -#if defined(FIX_HW_BRN_29702) - eError = PVRSRVLookupHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelCFIMemInfo, -#else - &psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo, -#endif - psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bLookupFailed = IMG_TRUE; - } -#endif - -#if defined(FIX_HW_BRN_29823) - eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelDummyTermStreamMemInfo, -#else - &psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo, -#endif - psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bReleaseFailed = IMG_TRUE; - } -#endif - #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAVDMStreamMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1736,11 +1355,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAIndexStreamMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1748,11 +1363,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAPDSMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1760,11 +1371,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAUSEMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1772,11 +1379,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAParamMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1784,11 +1387,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAPMPTMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1796,11 +1395,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWATPCMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1808,11 +1403,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelClearClipWAPSGRgnHdrMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1820,25 +1411,6 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } #endif -#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559) - eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, - &psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo, - psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bReleaseFailed = IMG_TRUE; - } - - eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, - &psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo, - psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if (eError != PVRSRV_OK) - { - bReleaseFailed = IMG_TRUE; - } -#endif #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, @@ -1853,11 +1425,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - &asInitInfoKM.hKernelEDMStatusBufferMemInfo, -#else &psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, -#endif psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1868,26 +1436,14 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; - IMG_HANDLE *phHandleKM = &asInitInfoKM.asInitMemHandles[i]; - - if (hHandle == 0) -#else IMG_HANDLE *phHandle = &psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; if (*phHandle == IMG_NULL) -#endif continue; eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, -#if defined (SUPPORT_SID_INTERFACE) - phHandleKM, - hHandle, -#else phHandle, *phHandle, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) { @@ -1908,62 +1464,38 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } /* Dissociate device memory from caller */ -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBCtlMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBEventKickerMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXHostCtlMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXTA3DCtlMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; @@ -1971,11 +1503,7 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #endif /* Dissociate SGX MiscInfo buffer from user space */ -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXMiscMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; @@ -1983,166 +1511,49 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(SGX_SUPPORT_HWPROFILING) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelHWProfilingMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif -#endif #if defined(SUPPORT_SGX_HWPERF) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelHWPerfCBMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } #endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelTASigBufferMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo); -#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernel3DSigBufferMemInfo); -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo); -#endif - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } - -#if defined(FIX_HW_BRN_29702) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCFIMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo); - bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#endif - -#if defined(FIX_HW_BRN_29823) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelDummyTermStreamMemInfo); if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } -#else - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo); - bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#endif #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAVDMStreamMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAIndexStreamMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPDSMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAUSEMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAParamMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPMPTMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWATPCMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPSGRgnHdrMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif -#endif -#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo); - bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); - - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo); - bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo); @@ -2150,25 +1561,13 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) -#if defined (SUPPORT_SID_INTERFACE) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelEDMStatusBufferMemInfo); - if (eError != PVRSRV_OK) - { - bDissociateFailed = IMG_TRUE; - } -#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif -#endif for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_HANDLE hHandle = asInitInfoKM.asInitMemHandles[i]; -#else IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; -#endif if (hHandle == IMG_NULL) continue; @@ -2183,16 +1582,6 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, /* If any dissociations failed, free all the device memory passed in */ if(bDissociateFailed) { -#if defined (SUPPORT_SID_INTERFACE) - PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBMemInfo); - PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBCtlMemInfo); - PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXHostCtlMemInfo); - PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXTA3DCtlMemInfo); -#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) - PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo); -#endif - PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXMiscMemInfo); -#else PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo); PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo); PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo); @@ -2201,19 +1590,12 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo); #endif PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo); -#endif for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_HANDLE hHandle = asInitInfoKM.asInitMemHandles[i]; - - if (hHandle == 0) -#else IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; if (hHandle == IMG_NULL) -#endif continue; PVRSRVFreeDeviceMemKM(hDevCookieInt, (PVRSRV_KERNEL_MEM_INFO *)hHandle); @@ -2229,33 +1611,10 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, return 0; } -#if defined (SUPPORT_SID_INTERFACE) - asInitInfoKM.sScripts = psSGXDevInitPart2IN->sInitInfo.sScripts; - asInitInfoKM.ui32ClientBuildOptions = psSGXDevInitPart2IN->sInitInfo.ui32ClientBuildOptions; - asInitInfoKM.sSGXStructSizes = psSGXDevInitPart2IN->sInitInfo.sSGXStructSizes; - asInitInfoKM.ui32CacheControl = psSGXDevInitPart2IN->sInitInfo.ui32CacheControl; - asInitInfoKM.ui32EDMTaskReg0 = psSGXDevInitPart2IN->sInitInfo.ui32EDMTaskReg0; - asInitInfoKM.ui32EDMTaskReg1 = psSGXDevInitPart2IN->sInitInfo.ui32EDMTaskReg1; - asInitInfoKM.ui32ClkGateStatusReg = psSGXDevInitPart2IN->sInitInfo.ui32ClkGateStatusReg; - asInitInfoKM.ui32ClkGateStatusMask = psSGXDevInitPart2IN->sInitInfo.ui32ClkGateStatusMask; - - OSMemCopy(&asInitInfoKM.asInitDevData , - &psSGXDevInitPart2IN->sInitInfo.asInitDevData, - sizeof(asInitInfoKM.asInitDevData)); - OSMemCopy(&asInitInfoKM.aui32HostKickAddr, - &psSGXDevInitPart2IN->sInitInfo.aui32HostKickAddr, - sizeof(asInitInfoKM.aui32HostKickAddr)); - - psSGXDevInitPart2OUT->eError = - DevInitSGXPart2KM(psPerProc, - hDevCookieInt, - &asInitInfoKM); -#else psSGXDevInitPart2OUT->eError = DevInitSGXPart2KM(psPerProc, hDevCookieInt, &psSGXDevInitPart2IN->sInitInfo); -#endif return 0; } @@ -2404,11 +1763,7 @@ SGXUnregisterHWTransferContextBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_RETURN *psRetOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_HANDLE hHWTransferContextInt = 0; -#else IMG_HANDLE hHWTransferContextInt; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_UNREGISTER_HW_TRANSFER_CONTEXT); @@ -2785,11 +2140,7 @@ SGXAddSharedPBDescBW(IMG_UINT32 ui32BridgeID, IMG_UINT32 ui32KernelMemInfoHandlesCount = psSGXAddSharedPBDescIN->ui32KernelMemInfoHandlesCount; IMG_INT ret = 0; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID *phKernelMemInfoHandles = 0; -#else IMG_HANDLE *phKernelMemInfoHandles = IMG_NULL; -#endif PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfos = IMG_NULL; IMG_UINT32 i; PVRSRV_ERROR eError; @@ -2999,9 +2350,6 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, { IMG_HANDLE hDevCookieInt; IMG_UINT32 i; -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; -#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGXINFO_FOR_SRVINIT); NEW_HANDLE_BATCH_OR_ERROR(psSGXInfoForSrvinitOUT->eError, psPerProc, PVRSRV_MAX_CLIENT_HEAPS); @@ -3024,12 +2372,7 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, psSGXInfoForSrvinitOUT->eError = SGXGetInfoForSrvinitKM(hDevCookieInt, -#if defined (SUPPORT_SID_INTERFACE) - &asHeapInfo[0], - &psSGXInfoForSrvinitOUT->sInitInfo.sPDDevPAddr); -#else &psSGXInfoForSrvinitOUT->sInitInfo); -#endif if(psSGXInfoForSrvinitOUT->eError != PVRSRV_OK) { @@ -3042,28 +2385,6 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, psHeapInfo = &psSGXInfoForSrvinitOUT->sInitInfo.asHeapInfo[i]; -#if defined (SUPPORT_SID_INTERFACE) - if ((asHeapInfo[i].ui32HeapID != (IMG_UINT32)SGX_UNDEFINED_HEAP_ID) && - (asHeapInfo[i].hDevMemHeap != IMG_NULL)) - { - /* Allocate heap handle */ - PVRSRVAllocHandleNR(psPerProc->psHandleBase, - &psHeapInfo->hDevMemHeap, - asHeapInfo[i].hDevMemHeap, - PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, - PVRSRV_HANDLE_ALLOC_FLAG_SHARED); - } - else - { - psHeapInfo->hDevMemHeap = 0; - } - - psHeapInfo->ui32HeapID = asHeapInfo[i].ui32HeapID; - psHeapInfo->sDevVAddrBase = asHeapInfo[i].sDevVAddrBase; - psHeapInfo->ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize; - psHeapInfo->ui32Attribs = asHeapInfo[i].ui32Attribs; - psHeapInfo->ui32XTileStride = asHeapInfo[i].ui32XTileStride; -#else if (psHeapInfo->ui32HeapID != (IMG_UINT32)SGX_UNDEFINED_HEAP_ID) { IMG_HANDLE hDevMemHeapExt; @@ -3079,7 +2400,6 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, psHeapInfo->hDevMemHeap = hDevMemHeapExt; } } -#endif } COMMIT_HANDLE_BATCH_OR_ERROR(psSGXInfoForSrvinitOUT->eError, psPerProc); @@ -3097,11 +2417,7 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, *****************************************************************************/ static IMG_VOID DumpBufferArray(PVRSRV_PER_PROCESS_DATA *psPerProc, -#if defined (SUPPORT_SID_INTERFACE) - PSGX_KICKTA_DUMP_BUFFER_KM psBufferArray, -#else PSGX_KICKTA_DUMP_BUFFER psBufferArray, -#endif IMG_UINT32 ui32BufferArrayLength, IMG_BOOL bDumpPolls) { @@ -3109,11 +2425,7 @@ DumpBufferArray(PVRSRV_PER_PROCESS_DATA *psPerProc, for (i=0; i<ui32BufferArrayLength; i++) { -#if defined (SUPPORT_SID_INTERFACE) - PSGX_KICKTA_DUMP_BUFFER_KM psBuffer; -#else PSGX_KICKTA_DUMP_BUFFER psBuffer; -#endif PVRSRV_KERNEL_MEM_INFO *psCtrlMemInfoKM; IMG_CHAR * pszName; IMG_HANDLE hUniqueTag; @@ -3225,17 +2537,12 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_UINT32 i; -#if defined (SUPPORT_SID_INTERFACE) - SGX_KICKTA_DUMP_BUFFER *psUMPtr; - SGX_KICKTA_DUMP_BUFFER_KM *psKickTADumpBufferKM, *psKMPtr; -#else #if defined(__QNXNTO__) const IMG_UINT32 NAME_BUFFER_SIZE = 30; IMG_PCHAR pszNameBuffer, pszName; IMG_UINT32 ui32NameBufferArraySize, ui32NameLength; #endif SGX_KICKTA_DUMP_BUFFER *psKickTADumpBuffer; -#endif IMG_UINT32 ui32BufferArrayLength = psPDumpBufferArrayIN->ui32BufferArrayLength; IMG_UINT32 ui32BufferArraySize = @@ -3246,22 +2553,14 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY); -#if defined (SUPPORT_SID_INTERFACE) - if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - ui32BufferArraySize, - (IMG_PVOID *)&psKickTADumpBufferKM, 0, - "Array of Kick Tile Accelerator Dump Buffer") != PVRSRV_OK) -#else if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, (IMG_PVOID *)&psKickTADumpBuffer, 0, "Array of Kick Tile Accelerator Dump Buffer") != PVRSRV_OK) -#endif { return -ENOMEM; } -#if !defined (SUPPORT_SID_INTERFACE) if(CopyFromUserWrapper(psPerProc, ui32BridgeID, psKickTADumpBuffer, @@ -3311,25 +2610,14 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, } } #endif -#endif for(i = 0; i < ui32BufferArrayLength; i++) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_VOID *pvMemInfo = IMG_NULL; - psUMPtr = &psPDumpBufferArrayIN->psBufferArray[i]; - psKMPtr = &psKickTADumpBufferKM[i]; -#else IMG_VOID *pvMemInfo; -#endif eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psUMPtr->hKernelMemInfo, -#else psKickTADumpBuffer[i].hKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(eError != PVRSRV_OK) @@ -3338,20 +2626,12 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, "PVRSRVLookupHandle failed (%d)", eError)); break; } -#if defined (SUPPORT_SID_INTERFACE) - psKMPtr->hKernelMemInfo = pvMemInfo; -#else psKickTADumpBuffer[i].hKernelMemInfo = pvMemInfo; -#endif #if defined(SUPPORT_SGX_NEW_STATUS_VALS) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, -#if defined (SUPPORT_SID_INTERFACE) - psUMPtr->hCtrlKernelMemInfo, -#else psKickTADumpBuffer[i].hCtrlKernelMemInfo, -#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(eError != PVRSRV_OK) @@ -3360,46 +2640,23 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, "PVRSRVLookupHandle failed (%d)", eError)); break; } -#if defined (SUPPORT_SID_INTERFACE) - psKMPtr->hCtrlKernelMemInfo = pvMemInfo; - psKMPtr->sCtrlDevVAddr = psUMPtr->sCtrlDevVAddr; -#else psKickTADumpBuffer[i].hCtrlKernelMemInfo = pvMemInfo; #endif -#endif -#if defined (SUPPORT_SID_INTERFACE) - psKMPtr->ui32SpaceUsed = psUMPtr->ui32SpaceUsed; - psKMPtr->ui32Start = psUMPtr->ui32Start; - psKMPtr->ui32End = psUMPtr->ui32End; - psKMPtr->ui32BufferSize = psUMPtr->ui32BufferSize; - psKMPtr->ui32BackEndLength = psUMPtr->ui32BackEndLength; - psKMPtr->uiAllocIndex = psUMPtr->uiAllocIndex; - psKMPtr->pvLinAddr = psUMPtr->pvLinAddr; - psKMPtr->pszName = psUMPtr->pszName; -#endif } if(eError == PVRSRV_OK) { DumpBufferArray(psPerProc, -#if defined (SUPPORT_SID_INTERFACE) - psKickTADumpBufferKM, -#else psKickTADumpBuffer, -#endif ui32BufferArrayLength, psPDumpBufferArrayIN->bDumpPolls); } -#if defined (SUPPORT_SID_INTERFACE) - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBufferKM, 0); -#else OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBuffer, 0); #if defined (__QNXNTO__) OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32NameBufferArraySize, pszNameBuffer, 0); #endif -#endif /*not nulling pointer, out of scope*/ return 0; @@ -3702,7 +2959,7 @@ SGXPDumpHWPerfCBBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { #if defined(SUPPORT_SGX_HWPERF) -#if defined(__linux__) +#if defined(__linux__) || defined(__QNXNTO__) PVRSRV_SGXDEV_INFO *psDevInfo; PVRSRV_DEVICE_NODE *psDeviceNode; IMG_HANDLE hDevMemContextInt = 0; diff --git a/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.h b/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.h index 3cb6282a6ba..3cb6282a6ba 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.h +++ b/drivers/gpu/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.h diff --git a/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c b/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c index 9ce7a114f3c..10135425cb7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c +++ b/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c @@ -50,23 +50,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lists.h" static IMG_BOOL -ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags); +ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags); static IMG_VOID BM_FreeMemory (IMG_VOID *pH, IMG_UINTPTR_T base, BM_MAPPING *psMapping); static IMG_BOOL BM_ImportMemory(IMG_VOID *pH, IMG_SIZE_T uSize, IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, - IMG_UINT32 uFlags, IMG_PVOID pvPrivData, + IMG_UINT32 ui32Flags, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase); -static IMG_INT32 +static IMG_BOOL DevMemoryAlloc (BM_CONTEXT *pBMContext, BM_MAPPING *pMapping, IMG_SIZE_T *pActualSize, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_UINT32 dev_vaddr_alignment, IMG_DEV_VIRTADDR *pDevVAddr); -static IMG_INT32 +static IMG_VOID DevMemoryFree (BM_MAPPING *pMapping); /*! @@ -90,7 +90,7 @@ DevMemoryFree (BM_MAPPING *pMapping); @Input psBMHeap - BM heap @Input psDevVAddr - device virtual address (optional) @Input uSize - requested buffer size in bytes. - @Input uFlags - property flags for the buffer. + @Input ui32Flags - property flags for the buffer. @Input uDevVAddrAlignment - required device virtual address alignment, or 0. @Input pvPrivData - opaque private data passed through to allocator @@ -107,7 +107,7 @@ AllocMemory (BM_CONTEXT *pBMContext, BM_HEAP *psBMHeap, IMG_DEV_VIRTADDR *psDevVAddr, IMG_SIZE_T uSize, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_UINT32 uDevVAddrAlignment, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, @@ -122,16 +122,16 @@ AllocMemory (BM_CONTEXT *pBMContext, RA_ARENA *pArena = IMG_NULL; PVR_DPF ((PVR_DBG_MESSAGE, - "AllocMemory (uSize=0x%x, uFlags=0x%x, align=0x%x)", - uSize, uFlags, uDevVAddrAlignment)); + "AllocMemory (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x, align=0x%x)", + uSize, ui32Flags, uDevVAddrAlignment)); /* what to do depends on combination of DevVaddr generation and backing RAM requirement */ - if(uFlags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) + if(ui32Flags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) { - if(uFlags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) + if(ui32Flags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) { /* user supplied DevVAddr, RAM backing */ PVR_DPF ((PVR_DBG_ERROR, "AllocMemory: combination of DevVAddr management and RAM backing mode unsupported")); @@ -156,82 +156,64 @@ AllocMemory (BM_CONTEXT *pBMContext, } /* Now allocate from the arena we chose above. */ - /* in case of a pageable buffer, we must bypass RA which could - * combine/split individual mappings between buffers: - */ - if (uFlags & (PVRSRV_MEM_SPARSE | PVRSRV_HAP_GPU_PAGEABLE)) + if (ui32Flags & PVRSRV_MEM_SPARSE) { IMG_BOOL bSuccess; - IMG_SIZE_T puiActualSize; - IMG_SIZE_T uRequestSize = uSize; + IMG_SIZE_T uActualSize; - if(uFlags & PVRSRV_MEM_SPARSE) - { - uRequestSize = ui32ChunkSize * ui32NumPhysChunks; - uSize = ui32ChunkSize * ui32NumVirtChunks; - } + /* Allocate physcial memory */ + bSuccess = BM_ImportMemory(psBMHeap, + ui32ChunkSize * ui32NumPhysChunks, + &uActualSize, + &pMapping, + ui32Flags, + pvPrivData, + ui32PrivDataLength, + IMG_NULL); /* We allocate VM space */ - /* Allocate physical memory */ - if (!BM_ImportMemory(psBMHeap, - uRequestSize, - &puiActualSize, - &pMapping, - uFlags, - pvPrivData, - ui32PrivDataLength, - (IMG_UINTPTR_T *)&(pBuf->DevVAddr.uiAddr))) + if (!bSuccess) { - PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: Failed to allocate device memory")); + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: BM_ImportMemory failed")); return IMG_FALSE; } - pBuf->hOSMemHandle = pMapping->hOSMemHandle; - /* We allocate VM space for sparse area */ - if(uFlags & PVRSRV_MEM_SPARSE) + if (uActualSize != ui32ChunkSize * ui32NumPhysChunks) { - if (puiActualSize != ui32ChunkSize * ui32NumPhysChunks) - { - /* - * Most likely the chunk size was not host page multiple, - * so return with an error - */ - PVR_DPF((PVR_DBG_ERROR, "AllocMemory: Failed to allocate" - "memory for sparse allocation")); - BM_FreeMemory(pArena, IMG_NULL, pMapping); - return IMG_FALSE; - } - - pMapping->uSizeVM = uSize; - pMapping->ui32ChunkSize = ui32ChunkSize; - pMapping->ui32NumVirtChunks = ui32NumVirtChunks; - pMapping->ui32NumPhysChunks = ui32NumPhysChunks; - pMapping->pabMapChunk = pabMapChunk; + /* + Most likley the chunksize was not host page multiple so + return with an error + */ + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: Failed to allocate memory for sparse allocation")); + BM_FreeMemory(pArena, IMG_NULL, pMapping); + return IMG_FALSE; + } - if (!(uFlags & PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC)) - { - /* Allocate VA space and map in the physical memory */ - bSuccess = DevMemoryAlloc (pBMContext, - pMapping, - IMG_NULL, - uFlags, - (IMG_UINT32)uDevVAddrAlignment, - &pMapping->DevVAddr); - if (!bSuccess) - { - PVR_DPF((PVR_DBG_ERROR, - "AllocMemory: Failed to allocate device memory")); - BM_FreeMemory(pArena, IMG_NULL, pMapping); - return IMG_FALSE; - } + pMapping->uSizeVM = ui32ChunkSize * ui32NumVirtChunks; + uSize = pMapping->uSizeVM; + pMapping->ui32ChunkSize = ui32ChunkSize; + pMapping->ui32NumVirtChunks = ui32NumVirtChunks; + pMapping->ui32NumPhysChunks = ui32NumPhysChunks; + pMapping->pabMapChunk = pabMapChunk; - /* uDevVAddrAlignment is currently set to zero so QAC - * generates warning which we override */ - /* PRQA S 3356,3358 1 */ - PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); - pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr; - } + /* Allocate VA space and map in the physical memory */ + bSuccess = DevMemoryAlloc (pBMContext, + pMapping, + IMG_NULL, + ui32Flags, + uDevVAddrAlignment, + &pMapping->DevVAddr); + if (!bSuccess) + { + PVR_DPF((PVR_DBG_ERROR, + "AllocMemory: Failed to allocate device memory")); + BM_FreeMemory(pArena, IMG_NULL, pMapping); + return IMG_FALSE; } + + /* uDevVAddrAlignment is currently set to zero so QAC generates warning which we override */ + /* PRQA S 3356,3358 1 */ + PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); + pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr; } else { @@ -239,15 +221,14 @@ AllocMemory (BM_CONTEXT *pBMContext, uSize, IMG_NULL, (IMG_VOID*) &pMapping, - uFlags, + ui32Flags, uDevVAddrAlignment, 0, pvPrivData, ui32PrivDataLength, (IMG_UINTPTR_T *)&(pBuf->DevVAddr.uiAddr))) { - PVR_DPF((PVR_DBG_ERROR, "AllocMemory: RA_Alloc(0x%x) hOSMemHandle %p, flags 0x%08x FAILED", - uSize, pMapping->hOSMemHandle, uFlags)); + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: RA_Alloc(0x%" SIZE_T_FMT_LEN "x) FAILED", uSize)); return IMG_FALSE; } } @@ -283,9 +264,9 @@ AllocMemory (BM_CONTEXT *pBMContext, * will have a physical address, else 0 */ pBuf->CpuPAddr.uiAddr = pMapping->CpuPAddr.uiAddr + uOffset; - if(uFlags & PVRSRV_MEM_ZERO) + if(ui32Flags & PVRSRV_MEM_ZERO) { - if(!ZeroBuf(pBuf, pMapping, uSize, psBMHeap->ui32Attribs | uFlags)) + if(!ZeroBuf(pBuf, pMapping, uSize, psBMHeap->ui32Attribs | ui32Flags)) { return IMG_FALSE; } @@ -293,7 +274,7 @@ AllocMemory (BM_CONTEXT *pBMContext, } else { - if(uFlags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) + if(ui32Flags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) { /* user supplied DevVAddr, no RAM backing */ PVR_ASSERT(psDevVAddr != IMG_NULL); @@ -341,7 +322,7 @@ AllocMemory (BM_CONTEXT *pBMContext, (IMG_PVOID *)&pMapping, IMG_NULL, "Buffer Manager Mapping") != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "AllocMemory: OSAllocMem(0x%x) FAILED", sizeof(*pMapping))); + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: OSAllocMem(0x%" SIZE_T_FMT_LEN "x) FAILED", sizeof(*pMapping))); return IMG_FALSE; } @@ -354,7 +335,6 @@ AllocMemory (BM_CONTEXT *pBMContext, pMapping->CpuVAddr = IMG_NULL; pMapping->CpuPAddr.uiAddr = 0; pMapping->DevVAddr = pBuf->DevVAddr; - pMapping->ui32MappingCount = 1; pMapping->psSysAddr = IMG_NULL; pMapping->uSize = uSize; pMapping->hOSMemHandle = 0; @@ -362,7 +342,6 @@ AllocMemory (BM_CONTEXT *pBMContext, /* Record the arena pointer in the mapping. */ pMapping->pArena = pArena; - pMapping->ui32DevVAddrAlignment = uDevVAddrAlignment; /* record the heap */ pMapping->pBMHeap = psBMHeap; @@ -370,18 +349,18 @@ AllocMemory (BM_CONTEXT *pBMContext, /* output some stats */ PVR_DPF ((PVR_DBG_MESSAGE, - "AllocMemory: pMapping=%08x: DevV=%08X CpuV=%08x CpuP=%08X uSize=0x%x", - (IMG_UINTPTR_T)pMapping, + "AllocMemory: pMapping=%p: DevV=%08X CpuV=%p CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", + pMapping, pMapping->DevVAddr.uiAddr, - (IMG_UINTPTR_T)pMapping->CpuVAddr, + pMapping->CpuVAddr, pMapping->CpuPAddr.uiAddr, pMapping->uSize)); PVR_DPF ((PVR_DBG_MESSAGE, - "AllocMemory: pBuf=%08x: DevV=%08X CpuV=%08x CpuP=%08X uSize=0x%x", - (IMG_UINTPTR_T)pBuf, + "AllocMemory: pBuf=%p: DevV=%08X CpuV=%p CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", + pBuf, pBuf->DevVAddr.uiAddr, - (IMG_UINTPTR_T)pBuf->CpuVAddr, + pBuf->CpuVAddr, pBuf->CpuPAddr.uiAddr, uSize)); @@ -406,7 +385,7 @@ AllocMemory (BM_CONTEXT *pBMContext, @Input bPhysContig - Is the wrap physically contiguous. @Input psAddr - List of pages to wrap. @Input pvCPUVAddr - Optional CPU Kernel virtual address (page aligned) of memory to wrap - @Input uFlags - property flags for the buffer. + @Input ui32Flags - property flags for the buffer. @Output Buf - receives a pointer to a descriptor of the allocated buffer. @Return IMG_TRUE - Success @@ -416,27 +395,36 @@ AllocMemory (BM_CONTEXT *pBMContext, static IMG_BOOL WrapMemory (BM_HEAP *psBMHeap, IMG_SIZE_T uSize, - IMG_SIZE_T ui32BaseOffset, + IMG_SIZE_T uiBaseOffset, IMG_BOOL bPhysContig, IMG_SYS_PHYADDR *psAddr, IMG_VOID *pvCPUVAddr, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, BM_BUF *pBuf) { IMG_DEV_VIRTADDR DevVAddr = {0}; BM_MAPPING *pMapping; - IMG_INT32 bResult; - IMG_SIZE_T const ui32PageSize = HOST_PAGESIZE(); + IMG_BOOL bResult; + IMG_SIZE_T const uPageSize = HOST_PAGESIZE(); + /* We should not pass down R/W flags into the OS layers so create ui32Attribs */ + IMG_UINT32 ui32Attribs = ui32Flags & ~(PVRSRV_MEM_READ | PVRSRV_MEM_WRITE); PVR_DPF ((PVR_DBG_MESSAGE, - "WrapMemory(psBMHeap=%08X, size=0x%x, offset=0x%x, bPhysContig=0x%x, pvCPUVAddr = 0x%08x, flags=0x%x)", - (IMG_UINTPTR_T)psBMHeap, uSize, ui32BaseOffset, bPhysContig, (IMG_UINTPTR_T)pvCPUVAddr, uFlags)); + "WrapMemory(psBMHeap=%p, size=0x%" SIZE_T_FMT_LEN "x, offset=0x%" SIZE_T_FMT_LEN + "x, bPhysContig=0x%x, sysPAddr=0x" SYSPADDR_FMT ", pvCPUVAddr = 0x%p, flags=0x%x)", + psBMHeap, + uSize, + uiBaseOffset, + bPhysContig, + psAddr->uiAddr, + pvCPUVAddr, + ui32Flags)); - PVR_ASSERT((psAddr->uiAddr & (ui32PageSize - 1)) == 0); + PVR_ASSERT((psAddr->uiAddr & (uPageSize - 1)) == 0); /* Only need lower 12 bits of the cpu addr - don't care what size a void* is */ - PVR_ASSERT(((IMG_UINTPTR_T)pvCPUVAddr & (ui32PageSize - 1)) == 0); + PVR_ASSERT(((IMG_UINTPTR_T)pvCPUVAddr & (uPageSize - 1)) == 0); - uSize += ui32BaseOffset; + uSize += uiBaseOffset; uSize = HOST_PAGEALIGN (uSize); /* allocate a mocked-up mapping */ @@ -445,7 +433,7 @@ WrapMemory (BM_HEAP *psBMHeap, (IMG_PVOID *)&pMapping, IMG_NULL, "Mocked-up mapping") != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSAllocMem(0x%x) FAILED",sizeof(*pMapping))); + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSAllocMem(0x%" SIZE_T_FMT_LEN "x) FAILED", sizeof(*pMapping))); return IMG_FALSE; } @@ -467,10 +455,10 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSRegisterMem(pMapping->CpuPAddr, pMapping->CpuVAddr, pMapping->uSize, - uFlags, + ui32Attribs, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterMem Phys=0x%08X, Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterMem Phys=0x" CPUPADDR_FMT ", Size=%" SIZE_T_FMT_LEN "u) failed", pMapping->CpuPAddr.uiAddr, pMapping->uSize)); goto fail_cleanup; } @@ -483,10 +471,10 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSRegisterDiscontigMem(pMapping->psSysAddr, pMapping->CpuVAddr, pMapping->uSize, - uFlags, + ui32Attribs, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterDiscontigMem Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterDiscontigMem Size=0x%" SIZE_T_FMT_LEN "u) failed", pMapping->uSize)); goto fail_cleanup; } @@ -501,12 +489,12 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSReservePhys(pMapping->CpuPAddr, pMapping->uSize, - uFlags, + ui32Attribs, IMG_NULL, &pMapping->CpuVAddr, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReservePhys Phys=0x%08X, Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReservePhys Phys=0x" CPUPADDR_FMT ", Size=%" SIZE_T_FMT_LEN "u) failed", pMapping->CpuPAddr.uiAddr, pMapping->uSize)); goto fail_cleanup; } @@ -518,11 +506,11 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSReserveDiscontigPhys(pMapping->psSysAddr, pMapping->uSize, - uFlags, + ui32Attribs, &pMapping->CpuVAddr, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReserveDiscontigPhys Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReserveDiscontigPhys Size=%" SIZE_T_FMT_LEN "u) failed", pMapping->uSize)); goto fail_cleanup; } @@ -530,18 +518,18 @@ WrapMemory (BM_HEAP *psBMHeap, } /* - * Allocate device memory for this buffer. Map wrapped pages as read/write + * Allocate device memory for this buffer. */ bResult = DevMemoryAlloc(psBMHeap->pBMContext, pMapping, IMG_NULL, - uFlags | PVRSRV_MEM_READ | PVRSRV_MEM_WRITE, - IMG_CAST_TO_DEVVADDR_UINT(ui32PageSize), + ui32Flags, + IMG_CAST_TO_DEVVADDR_UINT(uPageSize), &DevVAddr); - if (bResult <= 0) + if (!bResult) { PVR_DPF((PVR_DBG_ERROR, - "WrapMemory: DevMemoryAlloc(0x%x) failed", + "WrapMemory: DevMemoryAlloc(0x%" SIZE_T_FMT_LEN "x) failed", pMapping->uSize)); goto fail_cleanup; } @@ -552,17 +540,17 @@ WrapMemory (BM_HEAP *psBMHeap, * addresses associated with this allocation are placed at the same * offset within the underlying chunk. */ - pBuf->CpuPAddr.uiAddr = pMapping->CpuPAddr.uiAddr + ui32BaseOffset; - if(!ui32BaseOffset) + pBuf->CpuPAddr.uiAddr = pMapping->CpuPAddr.uiAddr + uiBaseOffset; + if(!uiBaseOffset) { pBuf->hOSMemHandle = pMapping->hOSMemHandle; } else { if(OSGetSubMemHandle(pMapping->hOSMemHandle, - ui32BaseOffset, - (pMapping->uSize-ui32BaseOffset), - uFlags, + uiBaseOffset, + (pMapping->uSize - uiBaseOffset), + ui32Attribs, &pBuf->hOSMemHandle)!=PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSGetSubMemHandle failed")); @@ -571,13 +559,13 @@ WrapMemory (BM_HEAP *psBMHeap, } if(pMapping->CpuVAddr) { - pBuf->CpuVAddr = (IMG_VOID*) ((IMG_UINTPTR_T)pMapping->CpuVAddr + ui32BaseOffset); + pBuf->CpuVAddr = (IMG_VOID*) ((IMG_UINTPTR_T)pMapping->CpuVAddr + uiBaseOffset); } - pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr + IMG_CAST_TO_DEVVADDR_UINT(ui32BaseOffset); + pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr + IMG_CAST_TO_DEVVADDR_UINT(uiBaseOffset); - if(uFlags & PVRSRV_MEM_ZERO) + if(ui32Flags & PVRSRV_MEM_ZERO) { - if(!ZeroBuf(pBuf, pMapping, uSize, uFlags)) + if(!ZeroBuf(pBuf, pMapping, uSize, ui32Flags)) { return IMG_FALSE; } @@ -585,19 +573,19 @@ WrapMemory (BM_HEAP *psBMHeap, PVR_DPF ((PVR_DBG_MESSAGE, "DevVaddr.uiAddr=%08X", DevVAddr.uiAddr)); PVR_DPF ((PVR_DBG_MESSAGE, - "WrapMemory: DevV=%08X CpuP=%08X uSize=0x%x", + "WrapMemory: DevV=%08X CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", pMapping->DevVAddr.uiAddr, pMapping->CpuPAddr.uiAddr, pMapping->uSize)); PVR_DPF ((PVR_DBG_MESSAGE, - "WrapMemory: DevV=%08X CpuP=%08X uSize=0x%x", + "WrapMemory: DevV=%08X CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", pBuf->DevVAddr.uiAddr, pBuf->CpuPAddr.uiAddr, uSize)); pBuf->pMapping = pMapping; return IMG_TRUE; fail_cleanup: - if(ui32BaseOffset && pBuf->hOSMemHandle) + if(uiBaseOffset && pBuf->hOSMemHandle) { - OSReleaseSubMemHandle(pBuf->hOSMemHandle, uFlags); + OSReleaseSubMemHandle(pBuf->hOSMemHandle, ui32Attribs); } if(pMapping && (pMapping->CpuVAddr || pMapping->hOSMemHandle)) @@ -605,16 +593,16 @@ fail_cleanup: switch(pMapping->eCpuMemoryOrigin) { case hm_wrapped: - OSUnReservePhys(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnReservePhys(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; case hm_wrapped_virtaddr: - OSUnRegisterMem(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnRegisterMem(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; case hm_wrapped_scatter: - OSUnReserveDiscontigPhys(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnReserveDiscontigPhys(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; case hm_wrapped_scatter_virtaddr: - OSUnRegisterDiscontigMem(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnRegisterDiscontigMem(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; default: break; @@ -630,19 +618,19 @@ fail_cleanup: static IMG_BOOL -ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags) +ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags) { IMG_VOID *pvCpuVAddr; if(pBuf->CpuVAddr) { - OSMemSet(pBuf->CpuVAddr, 0, ui32Bytes); + OSMemSet(pBuf->CpuVAddr, 0, uBytes); } else if(pMapping->eCpuMemoryOrigin == hm_contiguous || pMapping->eCpuMemoryOrigin == hm_wrapped) { pvCpuVAddr = OSMapPhysToLin(pBuf->CpuPAddr, - ui32Bytes, + uBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); @@ -651,17 +639,17 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui3 PVR_DPF((PVR_DBG_ERROR, "ZeroBuf: OSMapPhysToLin for contiguous buffer failed")); return IMG_FALSE; } - OSMemSet(pvCpuVAddr, 0, ui32Bytes); + OSMemSet(pvCpuVAddr, 0, uBytes); OSUnMapPhysToLin(pvCpuVAddr, - ui32Bytes, + uBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); } else { - IMG_SIZE_T ui32BytesRemaining = ui32Bytes; - IMG_SIZE_T ui32CurrentOffset = 0; + IMG_SIZE_T uBytesRemaining = uBytes; + IMG_SIZE_T uCurrentOffset = 0; IMG_CPU_PHYADDR CpuPAddr; /* Walk through the pBuf one page at a time and use @@ -669,21 +657,21 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui3 PVR_ASSERT(pBuf->hOSMemHandle); - while(ui32BytesRemaining > 0) + while(uBytesRemaining > 0) { - IMG_SIZE_T ui32BlockBytes = MIN(ui32BytesRemaining, HOST_PAGESIZE()); - CpuPAddr = OSMemHandleToCpuPAddr(pBuf->hOSMemHandle, ui32CurrentOffset); + IMG_SIZE_T uBlockBytes = MIN(uBytesRemaining, HOST_PAGESIZE()); + CpuPAddr = OSMemHandleToCpuPAddr(pBuf->hOSMemHandle, uCurrentOffset); /* If the CpuPAddr isn't page aligned then start by writing up to the next page - * boundary (or ui32BytesRemaining if less), so that subsequent iterations can + * boundary (or uBytesRemaining if less), so that subsequent iterations can * copy full physical pages. */ if(CpuPAddr.uiAddr & (HOST_PAGESIZE() -1)) { - ui32BlockBytes = - MIN(ui32BytesRemaining, (IMG_UINT32)(HOST_PAGEALIGN(CpuPAddr.uiAddr) - CpuPAddr.uiAddr)); + uBlockBytes = + MIN(uBytesRemaining, (IMG_UINT32)(HOST_PAGEALIGN(CpuPAddr.uiAddr) - CpuPAddr.uiAddr)); } pvCpuVAddr = OSMapPhysToLin(CpuPAddr, - ui32BlockBytes, + uBlockBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); @@ -692,15 +680,15 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui3 PVR_DPF((PVR_DBG_ERROR, "ZeroBuf: OSMapPhysToLin while zeroing non-contiguous memory FAILED")); return IMG_FALSE; } - OSMemSet(pvCpuVAddr, 0, ui32BlockBytes); + OSMemSet(pvCpuVAddr, 0, uBlockBytes); OSUnMapPhysToLin(pvCpuVAddr, - ui32BlockBytes, + uBlockBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); - ui32BytesRemaining -= ui32BlockBytes; - ui32CurrentOffset += ui32BlockBytes; + uBytesRemaining -= uBlockBytes; + uCurrentOffset += uBlockBytes; } } @@ -734,9 +722,9 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) PVRSRV_DEVICE_NODE *psDeviceNode; PVR_DPF ((PVR_DBG_MESSAGE, - "FreeBuf: pBuf=0x%x: DevVAddr=%08X CpuVAddr=0x%x CpuPAddr=%08X", - (IMG_UINTPTR_T)pBuf, pBuf->DevVAddr.uiAddr, - (IMG_UINTPTR_T)pBuf->CpuVAddr, pBuf->CpuPAddr.uiAddr)); + "FreeBuf: pBuf=0x%p: DevVAddr=%08X CpuVAddr=0x%p CpuPAddr=" CPUPADDR_FMT, + pBuf, pBuf->DevVAddr.uiAddr, + pBuf->CpuVAddr, pBuf->CpuPAddr.uiAddr)); /* record mapping */ pMapping = pBuf->pMapping; @@ -777,11 +765,9 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) OSReleaseSubMemHandle(pBuf->hOSMemHandle, ui32Flags); } } - if(ui32Flags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) { /* Submemhandle is required by exported mappings */ - if ((pBuf->ui32ExportCount == 0) && (pBuf->ui32RefCount == 0)) { /* @@ -789,27 +775,17 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) Note: currently no need to distinguish between hm_env and hm_contiguous */ PVR_ASSERT(pBuf->ui32ExportCount == 0); - if (pBuf->pMapping->ui32Flags & (PVRSRV_MEM_SPARSE | PVRSRV_HAP_GPU_PAGEABLE)) + if (pBuf->pMapping->ui32Flags & PVRSRV_MEM_SPARSE) { - IMG_UINT32 ui32FreeSize = 0; - IMG_PVOID pvFreePtr = IMG_NULL; - - if(pBuf->pMapping->ui32Flags & PVRSRV_MEM_SPARSE) - { - ui32FreeSize = sizeof(IMG_BOOL) * pBuf->pMapping->ui32NumVirtChunks; - pvFreePtr = pBuf->pMapping->pabMapChunk; - } - - /* With sparse and page-able allocations we don't go through the sub-alloc RA */ + IMG_UINT32 ui32FreeSize = sizeof(IMG_BOOL) * pBuf->pMapping->ui32NumVirtChunks; + IMG_PVOID pvFreePtr = pBuf->pMapping->pabMapChunk; + + /* With sparse allocations we don't go through the sub-alloc RA */ BM_FreeMemory(pBuf->pMapping->pBMHeap, pBuf->DevVAddr.uiAddr, pBuf->pMapping); - - if(pvFreePtr) - { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32FreeSize, pvFreePtr, IMG_NULL); - } } else { @@ -1559,7 +1535,7 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, BM_CONTEXT *pBMContext; BM_HEAP *psBMHeap; SYS_DATA *psSysData; - IMG_UINT32 uFlags; + IMG_UINT32 ui32Flags; if (pui32Flags == IMG_NULL) { @@ -1568,11 +1544,11 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, return IMG_FALSE; } - uFlags = *pui32Flags; + ui32Flags = *pui32Flags; PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Alloc (uSize=0x%x, uFlags=0x%x, uDevVAddrAlignment=0x%x)", - uSize, uFlags, uDevVAddrAlignment)); + "BM_Alloc (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x, uDevVAddrAlignment=0x%x)", + uSize, ui32Flags, uDevVAddrAlignment)); SysAcquireData(&psSysData); @@ -1604,7 +1580,7 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, psBMHeap, psDevVAddr, uSize, - uFlags, + ui32Flags, uDevVAddrAlignment, pvPrivData, ui32PrivDataLength, @@ -1621,24 +1597,24 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Alloc (uSize=0x%x, uFlags=0x%x)", - uSize, uFlags)); + "BM_Alloc (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x)", + uSize, ui32Flags)); /* * Assign the handle and return. */ pBuf->ui32RefCount = 1; *phBuf = (BM_HANDLE)pBuf; - *pui32Flags = uFlags | psBMHeap->ui32Attribs; + *pui32Flags = ui32Flags | psBMHeap->ui32Attribs; /* * If the user has specified heap CACHETYPE flags themselves, * override any CACHETYPE flags inherited from the heap. */ - if(uFlags & PVRSRV_HAP_CACHETYPE_MASK) + if(ui32Flags & PVRSRV_HAP_CACHETYPE_MASK) { *pui32Flags &= ~PVRSRV_HAP_CACHETYPE_MASK; - *pui32Flags |= (uFlags & PVRSRV_HAP_CACHETYPE_MASK); + *pui32Flags |= (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK); } return IMG_TRUE; @@ -1657,13 +1633,13 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, @Input psDeviceNode @Input psSysPAddr - system address array - @Input ui32PageSize - size of address array + @Input uPageSize - size of address array @Return IMG_BOOL *****************************************************************************/ static IMG_BOOL -ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSysPAddr, IMG_UINT32 ui32PageCount, IMG_SIZE_T ui32PageSize) +ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSysPAddr, IMG_UINT32 ui32PageCount, IMG_SIZE_T uPageSize) { IMG_UINT32 i; @@ -1677,7 +1653,7 @@ ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSy return IMG_FALSE; } - sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + ui32PageSize; + sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + uPageSize; if (!SysVerifySysPAddrToDevPAddr(psDeviceNode->sDevId.eDeviceType, sEndSysPAddr)) { @@ -1704,7 +1680,7 @@ ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSy *****************************************************************************/ static IMG_BOOL -ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStartSysPAddr, IMG_SIZE_T ui32Range) +ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStartSysPAddr, IMG_SIZE_T uRange) { IMG_SYS_PHYADDR sEndSysPAddr; @@ -1713,7 +1689,7 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar return IMG_FALSE; } - sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + ui32Range; + sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + uRange; if (!SysVerifySysPAddrToDevPAddr(psDeviceNode->sDevId.eDeviceType, sEndSysPAddr)) { @@ -1723,9 +1699,9 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar return IMG_TRUE; } -#define WRAP_MAPPING_SIZE(ui32ByteSize, ui32PageOffset) HOST_PAGEALIGN((ui32ByteSize) + (ui32PageOffset)) +#define WRAP_MAPPING_SIZE(uByteSize, uPageOffset) HOST_PAGEALIGN((uByteSize) + (uPageOffset)) -#define WRAP_PAGE_COUNT(ui32ByteSize, ui32PageOffset, ui32HostPageSize) (WRAP_MAPPING_SIZE(ui32ByteSize, ui32PageOffset) / (ui32HostPageSize)) +#define WRAP_PAGE_COUNT(uByteSize, uPageOffset, uHostPageSize) (WRAP_MAPPING_SIZE(uByteSize, uPageOffset) / (uHostPageSize)) #endif @@ -1740,12 +1716,12 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar The wrapped memory must be page aligned. BM_Wrap will roundup the size to a multiple of cpu pages. - @Input ui32Size - size of memory to wrap. + @Input uSize - size of memory to wrap. @Input ui32Offset - Offset into page of memory to wrap. @Input bPhysContig - Is the wrap physically contiguous. @Input psSysAddr - list of system physical page addresses of memory to wrap. @Input pvCPUVAddr - optional CPU kernel virtual address (Page aligned) of memory to wrap. - @Input uFlags - bit mask of buffer property flags. + @Input ui32Flags - bit mask of buffer property flags. @output phBuf - receives the buffer handle. @Return IMG_TRUE - Success. @@ -1754,8 +1730,8 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar *****************************************************************************/ IMG_BOOL BM_Wrap ( IMG_HANDLE hDevMemHeap, - IMG_SIZE_T ui32Size, - IMG_SIZE_T ui32Offset, + IMG_SIZE_T uSize, + IMG_SIZE_T uOffset, IMG_BOOL bPhysContig, IMG_SYS_PHYADDR *psSysAddr, IMG_VOID *pvCPUVAddr, @@ -1767,29 +1743,41 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, BM_HEAP *psBMHeap; SYS_DATA *psSysData; IMG_SYS_PHYADDR sHashAddress; - IMG_UINT32 uFlags; + IMG_UINT32 ui32Flags; psBMHeap = (BM_HEAP*)hDevMemHeap; psBMContext = psBMHeap->pBMContext; - uFlags = psBMHeap->ui32Attribs & (PVRSRV_HAP_CACHETYPE_MASK | PVRSRV_HAP_MAPTYPE_MASK | PVRSRV_HAP_MAPPING_CTRL_MASK); + ui32Flags = psBMHeap->ui32Attribs & (PVRSRV_HAP_CACHETYPE_MASK | PVRSRV_HAP_MAPTYPE_MASK); if ((pui32Flags != IMG_NULL) && ((*pui32Flags & PVRSRV_HAP_CACHETYPE_MASK) != 0)) { - uFlags &= ~PVRSRV_HAP_CACHETYPE_MASK; - uFlags |= *pui32Flags & PVRSRV_HAP_CACHETYPE_MASK; + ui32Flags &= ~PVRSRV_HAP_CACHETYPE_MASK; + ui32Flags |= *pui32Flags & PVRSRV_HAP_CACHETYPE_MASK; + } + + if ((pui32Flags != IMG_NULL) && ((*pui32Flags & (PVRSRV_MEM_READ | PVRSRV_MEM_WRITE)) != 0)) + { + ui32Flags &= ~(PVRSRV_MEM_READ | PVRSRV_MEM_WRITE); + ui32Flags |= *pui32Flags & (PVRSRV_MEM_READ | PVRSRV_MEM_WRITE); } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Wrap (uSize=0x%x, uOffset=0x%x, bPhysContig=0x%x, pvCPUVAddr=0x%x, uFlags=0x%x)", - ui32Size, ui32Offset, bPhysContig, (IMG_UINTPTR_T)pvCPUVAddr, uFlags)); + "BM_Wrap (uSize=0x%" SIZE_T_FMT_LEN "x, uOffset=0x%" SIZE_T_FMT_LEN + "x, bPhysContig=0x%x, syspAddr=0x" SYSPADDR_FMT ", pvCPUVAddr=0x%p, ui32Flags=0x%x)", + uSize, + uOffset, + bPhysContig, + psSysAddr->uiAddr, + pvCPUVAddr, + ui32Flags)); SysAcquireData(&psSysData); #if defined(PVR_LMA) if (bPhysContig) { - if (!ValidSysPAddrRangeForDev(psBMContext->psDeviceNode, *psSysAddr, WRAP_MAPPING_SIZE(ui32Size, ui32Offset))) + if (!ValidSysPAddrRangeForDev(psBMContext->psDeviceNode, *psSysAddr, WRAP_MAPPING_SIZE(uSize, uOffset))) { PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: System address range invalid for device")); return IMG_FALSE; @@ -1797,9 +1785,9 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, } else { - IMG_SIZE_T ui32HostPageSize = HOST_PAGESIZE(); + IMG_SIZE_T uHostPageSize = HOST_PAGESIZE(); - if (!ValidSysPAddrArrayForDev(psBMContext->psDeviceNode, psSysAddr, WRAP_PAGE_COUNT(ui32Size, ui32Offset, ui32HostPageSize), ui32HostPageSize)) + if (!ValidSysPAddrArrayForDev(psBMContext->psDeviceNode, psSysAddr, WRAP_PAGE_COUNT(uSize, uOffset, uHostPageSize), uHostPageSize)) { PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: Array of system addresses invalid for device")); return IMG_FALSE; @@ -1813,27 +1801,29 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, sHashAddress = psSysAddr[0]; /* Add the in-page offset to ensure a unique hash */ - sHashAddress.uiAddr += ui32Offset; + sHashAddress.uiAddr += uOffset; - /* See if this address has already been wrapped */ - pBuf = (BM_BUF *)HASH_Retrieve(psBMContext->pBufferHash, sHashAddress.uiAddr); + /* See if this address has already been wrapped, note that the cast is ok as this is only local mem */ + pBuf = (BM_BUF *)HASH_Retrieve(psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr); if(pBuf) { - IMG_SIZE_T ui32MappingSize = HOST_PAGEALIGN (ui32Size + ui32Offset); + IMG_SIZE_T uMappingSize = HOST_PAGEALIGN (uSize + uOffset); /* Check base address, size and contiguity type match */ - if(pBuf->pMapping->uSize == ui32MappingSize && (pBuf->pMapping->eCpuMemoryOrigin == hm_wrapped || + if(pBuf->pMapping->uSize == uMappingSize && (pBuf->pMapping->eCpuMemoryOrigin == hm_wrapped || pBuf->pMapping->eCpuMemoryOrigin == hm_wrapped_virtaddr)) { PVR_DPF((PVR_DBG_MESSAGE, - "BM_Wrap (Matched previous Wrap! uSize=0x%x, uOffset=0x%x, SysAddr=%08X)", - ui32Size, ui32Offset, sHashAddress.uiAddr)); + "BM_Wrap (Matched previous Wrap! uSize=0x%" SIZE_T_FMT_LEN "x, uOffset=0x%" SIZE_T_FMT_LEN "x, SysAddr=" SYSPADDR_FMT ")", + uSize, + uOffset, + sHashAddress.uiAddr)); PVRSRVBMBufIncRef(pBuf); *phBuf = (BM_HANDLE)pBuf; if(pui32Flags) - *pui32Flags = uFlags; + *pui32Flags = ui32Flags; return IMG_TRUE; } @@ -1861,7 +1851,7 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, /* * Actually perform the memory wrap. */ - if (WrapMemory (psBMHeap, ui32Size, ui32Offset, bPhysContig, psSysAddr, pvCPUVAddr, uFlags, pBuf) != IMG_TRUE) + if (WrapMemory (psBMHeap, uSize, uOffset, bPhysContig, psSysAddr, pvCPUVAddr, ui32Flags, pBuf) != IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: WrapMemory FAILED")); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof (BM_BUF), pBuf, IMG_NULL); @@ -1877,17 +1867,17 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, /* Have we calculated the right Hash key ? */ PVR_ASSERT(SysSysPAddrToCpuPAddr(sHashAddress).uiAddr == pBuf->CpuPAddr.uiAddr); - if (!HASH_Insert (psBMContext->pBufferHash, sHashAddress.uiAddr, (IMG_UINTPTR_T)pBuf)) + if (!HASH_Insert (psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr, (IMG_UINTPTR_T)pBuf)) { - FreeBuf (pBuf, uFlags, IMG_TRUE); + FreeBuf (pBuf, ui32Flags, IMG_TRUE); PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: HASH_Insert FAILED")); return IMG_FALSE; } } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Wrap (uSize=0x%x, uFlags=0x%x, devVAddr=%08X)", - ui32Size, uFlags, pBuf->DevVAddr.uiAddr)); + "BM_Wrap (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x, devVAddr=%08X)", + uSize, ui32Flags, pBuf->DevVAddr.uiAddr)); /* * Assign the handle and return. @@ -1897,7 +1887,7 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, if(pui32Flags) { /* need to override the heap attributes SINGLE PROC to MULT_PROC. */ - *pui32Flags = (uFlags & ~PVRSRV_HAP_MAPTYPE_MASK) | PVRSRV_HAP_MULTI_PROCESS; + *pui32Flags = (ui32Flags & ~PVRSRV_HAP_MAPTYPE_MASK) | PVRSRV_HAP_MULTI_PROCESS; } return IMG_TRUE; @@ -1964,7 +1954,7 @@ BM_Free (BM_HANDLE hBuf, SYS_DATA *psSysData; IMG_SYS_PHYADDR sHashAddr; - PVR_DPF ((PVR_DBG_MESSAGE, "BM_Free (h=0x%x)", (IMG_UINTPTR_T)hBuf)); + PVR_DPF ((PVR_DBG_MESSAGE, "BM_Free (h=0x%p)", hBuf)); PVR_ASSERT (pBuf!=IMG_NULL); if (pBuf == IMG_NULL) @@ -2014,8 +2004,8 @@ BM_HandleToCpuVaddr (BM_HANDLE hBuf) } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_HandleToCpuVaddr(h=0x%x)=0x%x", - (IMG_UINTPTR_T)hBuf, (IMG_UINTPTR_T)pBuf->CpuVAddr)); + "BM_HandleToCpuVaddr(h=0x%p)=0x%p", + hBuf, pBuf->CpuVAddr)); return pBuf->CpuVAddr; } @@ -2045,7 +2035,7 @@ BM_HandleToDevVaddr (BM_HANDLE hBuf) return DevVAddr; } - PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToDevVaddr(h=0x%x)=%08X", (IMG_UINTPTR_T)hBuf, pBuf->DevVAddr.uiAddr)); + PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToDevVaddr(h=0x%p)=%08X", hBuf, pBuf->DevVAddr.uiAddr)); return pBuf->DevVAddr; } @@ -2076,7 +2066,7 @@ BM_HandleToSysPaddr (BM_HANDLE hBuf) return PhysAddr; } - PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToSysPaddr(h=0x%x)=%08X", (IMG_UINTPTR_T)hBuf, pBuf->CpuPAddr.uiAddr)); + PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToSysPaddr(h=0lx%p)=" CPUPADDR_FMT, hBuf, pBuf->CpuPAddr.uiAddr)); return SysCpuPAddrToSysPAddr (pBuf->CpuPAddr); } @@ -2106,106 +2096,11 @@ BM_HandleToOSMemHandle(BM_HANDLE hBuf) } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_HandleToOSMemHandle(h=0x%x)=0x%x", - (IMG_UINTPTR_T)hBuf, (IMG_UINTPTR_T)pBuf->hOSMemHandle)); + "BM_HandleToOSMemHandle(h=0x%p)=0x%p", + hBuf, pBuf->hOSMemHandle)); return pBuf->hOSMemHandle; } -/*---------------------------------------------------------------------------- -<function> - FUNCTION: BM_UnmapFromDev - - PURPOSE: Unmaps a buffer from GPU virtual address space, but otherwise - leaves buffer intact (ie. not changing any CPU virtual space - mappings, etc). This in conjunction with BM_RemapToDev() can - be used to migrate buffers in and out of GPU virtual address - space to deal with fragmentation and/or limited size of GPU - MMU. - - PARAMETERS: In: hBuf - buffer handle. - RETURNS: IMG_TRUE - Success - IMG_FALSE - Failure -</function> ------------------------------------------------------------------------------*/ -IMG_INT32 -BM_UnmapFromDev(BM_HANDLE hBuf) -{ - BM_BUF *pBuf = (BM_BUF *)hBuf; - BM_MAPPING *pMapping; - IMG_INT32 result; - - PVR_ASSERT (pBuf != IMG_NULL); - - if (pBuf == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "BM_UnmapFromDev: invalid parameter")); - return -(PVRSRV_ERROR_INVALID_PARAMS); - } - - pMapping = pBuf->pMapping; - - if ((pMapping->ui32Flags & PVRSRV_HAP_GPU_PAGEABLE) == 0) - { - PVR_DPF((PVR_DBG_ERROR, "BM_UnmapFromDev: cannot unmap non-pageable buffer")); - return -(PVRSRV_ERROR_STILL_MAPPED); - } - - result = DevMemoryFree(pMapping); - - if(result == 0) - pBuf->DevVAddr.uiAddr = PVRSRV_BAD_DEVICE_ADDRESS; - - return result; -} - -/*---------------------------------------------------------------------------- -<function> - FUNCTION: BM_RemapToDev - - PURPOSE: Maps a buffer back into GPU virtual address space, after it - has been BM_UnmapFromDev()'d. After this operation, the GPU - virtual address may have changed, so BM_HandleToDevVaddr() - should be called to get the new address. - - PARAMETERS: In: hBuf - buffer handle. - RETURNS: IMG_TRUE - Success - IMG_FALSE - Failure -</function> ------------------------------------------------------------------------------*/ -IMG_INT32 -BM_RemapToDev(BM_HANDLE hBuf) -{ - BM_BUF *pBuf = (BM_BUF *)hBuf; - BM_MAPPING *pMapping; - IMG_INT32 mapCount; - - PVR_ASSERT (pBuf != IMG_NULL); - - if (pBuf == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "BM_RemapToDev: invalid parameter")); - return -PVRSRV_ERROR_INVALID_PARAMS; - } - - pMapping = pBuf->pMapping; - - if ((pMapping->ui32Flags & PVRSRV_HAP_GPU_PAGEABLE) == 0) - { - PVR_DPF((PVR_DBG_ERROR, "BM_RemapToDev: cannot remap non-pageable buffer")); - return -PVRSRV_ERROR_BAD_MAPPING; - } - - mapCount = DevMemoryAlloc(pMapping->pBMHeap->pBMContext, pMapping, IMG_NULL, - pMapping->ui32Flags, pMapping->ui32DevVAddrAlignment, &pBuf->DevVAddr); - - if(mapCount <= 0) - { - PVR_DPF((PVR_DBG_WARNING, "BM_RemapToDev: failed to allocate device memory")); - } - - return mapCount; -} - /*! ****************************************************************************** @@ -2224,52 +2119,48 @@ BM_RemapToDev(BM_HANDLE hBuf) allocation. @Output pActualSize - the actual size of the block allocated in bytes. - @Input uFlags - allocation flags + @Input ui32Flags - allocation flags @Input dev_vaddr_alignment - required device virtual address alignment, or 0. @Output pDevVAddr - receives the device virtual base address of the allocated block. - @Return IMG_INT32 - Reference count - -1 - Failed. + @Return IMG_TRUE - Success + IMG_FALSE - Failed. *****************************************************************************/ -static IMG_INT32 +static IMG_BOOL DevMemoryAlloc (BM_CONTEXT *pBMContext, BM_MAPPING *pMapping, IMG_SIZE_T *pActualSize, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_UINT32 dev_vaddr_alignment, IMG_DEV_VIRTADDR *pDevVAddr) { PVRSRV_DEVICE_NODE *psDeviceNode; #ifdef PDUMP IMG_UINT32 ui32PDumpSize = (IMG_UINT32)pMapping->uSize; + IMG_UINT32 ui32PDumpFlags; #endif - if(pMapping->ui32MappingCount > 0) - { - pMapping->ui32MappingCount++; - *pDevVAddr = pMapping->DevVAddr; - return pMapping->ui32MappingCount; - } - psDeviceNode = pBMContext->psDeviceNode; - pMapping->ui32DevVAddrAlignment = dev_vaddr_alignment; +#ifdef PDUMP +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + ui32PDumpFlags = psDeviceNode->pfnMMUIsHeapShared(pMapping->pBMHeap->pMMUHeap) + ? PDUMP_FLAGS_PERSISTENT : PDUMP_FLAGS_CONTINUOUS; +#else + ui32PDumpFlags = PDUMP_FLAGS_CONTINUOUS; +#endif +#endif - if(uFlags & PVRSRV_MEM_INTERLEAVED) + if(ui32Flags & PVRSRV_MEM_INTERLEAVED) { /* double the size */ - /* don't continue to alter the size each time a buffer is remapped.. - * we only want to do this the first time - */ - /* TODO: FIXME: There is something wrong with this logic */ - if (pMapping->ui32MappingCount == 0) - pMapping->uSize *= 2; + pMapping->uSize *= 2; } #ifdef PDUMP - if(uFlags & PVRSRV_MEM_DUMMY) + if(ui32Flags & PVRSRV_MEM_DUMMY) { /* only one page behind a dummy allocation */ ui32PDumpSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; @@ -2287,8 +2178,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, &(pMapping->DevVAddr))) { PVR_DPF((PVR_DBG_ERROR, "DevMemoryAlloc ERROR MMU_Alloc")); - pDevVAddr->uiAddr = PVRSRV_BAD_DEVICE_ADDRESS; - return -(PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY); + return IMG_FALSE; } #ifdef SUPPORT_SGX_MMU_BYPASS @@ -2303,12 +2193,8 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->hOSMemHandle, ui32PDumpSize, pMapping->pBMHeap->sDevArena.ui32DataPageSize, -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - psDeviceNode->pfnMMUIsHeapShared(pMapping->pBMHeap->pMMUHeap), -#else - IMG_FALSE, // unused -#endif /* SUPPORT_PDUMP_MULTI_PROCESS */ - (IMG_HANDLE)pMapping); + (IMG_HANDLE)pMapping, + ui32PDumpFlags); #endif switch (pMapping->eCpuMemoryOrigin) @@ -2317,7 +2203,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, case hm_wrapped_virtaddr: case hm_contiguous: { - if (uFlags & PVRSRV_MEM_SPARSE) + if (ui32Flags & PVRSRV_MEM_SPARSE) { /* Check if this device supports sparse mappings */ PVR_ASSERT(psDeviceNode->pfnMMUMapPagesSparse != IMG_NULL); @@ -2328,7 +2214,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->ui32NumVirtChunks, pMapping->ui32NumPhysChunks, pMapping->pabMapChunk, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } else @@ -2337,7 +2223,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->DevVAddr, SysCpuPAddrToSysPAddr (pMapping->CpuPAddr), pMapping->uSize, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } *pDevVAddr = pMapping->DevVAddr; @@ -2345,7 +2231,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, } case hm_env: { - if (uFlags & PVRSRV_MEM_SPARSE) + if (ui32Flags & PVRSRV_MEM_SPARSE) { /* Check if this device supports sparse mappings */ PVR_ASSERT(psDeviceNode->pfnMMUMapShadowSparse != IMG_NULL); @@ -2358,7 +2244,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->CpuVAddr, pMapping->hOSMemHandle, pDevVAddr, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } else @@ -2369,7 +2255,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->CpuVAddr, pMapping->hOSMemHandle, pDevVAddr, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } break; @@ -2381,7 +2267,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->DevVAddr, pMapping->psSysAddr, pMapping->uSize, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); *pDevVAddr = pMapping->DevVAddr; @@ -2391,47 +2277,38 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, PVR_DPF((PVR_DBG_ERROR, "Illegal value %d for pMapping->eCpuMemoryOrigin", pMapping->eCpuMemoryOrigin)); - return -(PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE); + return IMG_FALSE; } #ifdef SUPPORT_SGX_MMU_BYPASS DisableHostAccess(pBMContext->psMMUContext); #endif - pMapping->ui32MappingCount = 1; - - return pMapping->ui32MappingCount; + return IMG_TRUE; } -static IMG_INT32 +static IMG_VOID DevMemoryFree (BM_MAPPING *pMapping) { PVRSRV_DEVICE_NODE *psDeviceNode; IMG_DEV_PHYADDR sDevPAddr; #ifdef PDUMP IMG_UINT32 ui32PSize; + IMG_UINT32 ui32PDumpFlags; #endif - if(pMapping->ui32MappingCount > 1) - { - pMapping->ui32MappingCount--; - - /* Nothing else to do for now */ - return pMapping->ui32MappingCount; - } - - if (pMapping->ui32MappingCount == 0) - { - /* already unmapped from GPU.. bail */ - return -(PVRSRV_ERROR_MAPPING_NOT_FOUND); - } - - /* Then pMapping->ui32MappingCount is 1 - * ready to release GPU mapping */ - psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode; sDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr); +#ifdef PDUMP +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + ui32PDumpFlags = psDeviceNode->pfnMMUIsHeapShared(pMapping->pBMHeap->pMMUHeap) + ? PDUMP_FLAGS_PERSISTENT : PDUMP_FLAGS_CONTINUOUS; +#else + ui32PDumpFlags = PDUMP_FLAGS_CONTINUOUS; +#endif +#endif + if (sDevPAddr.uiAddr != 0) { #ifdef PDUMP @@ -2452,20 +2329,17 @@ DevMemoryFree (BM_MAPPING *pMapping) pMapping->pBMHeap->sDevArena.ui32DataPageSize, (IMG_HANDLE)pMapping, (pMapping->ui32Flags & PVRSRV_MEM_INTERLEAVED) ? IMG_TRUE : IMG_FALSE, - (pMapping->ui32Flags & PVRSRV_MEM_SPARSE) ? IMG_TRUE : IMG_FALSE); + (pMapping->ui32Flags & PVRSRV_MEM_SPARSE) ? IMG_TRUE : IMG_FALSE, + ui32PDumpFlags); #endif } PVR_ASSERT(pMapping->uSizeVM != 0); psDeviceNode->pfnMMUFree (pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr, IMG_CAST_TO_DEVVADDR_UINT(pMapping->uSizeVM)); - - pMapping->ui32MappingCount = 0; - - return pMapping->ui32MappingCount; } /* If this array grows larger, it might be preferable to use a hashtable rather than an array. */ #ifndef XPROC_WORKAROUND_NUM_SHAREABLES -#define XPROC_WORKAROUND_NUM_SHAREABLES 500 +#define XPROC_WORKAROUND_NUM_SHAREABLES 200 #endif #define XPROC_WORKAROUND_BAD_SHAREINDEX 0773407734 @@ -2480,14 +2354,6 @@ static IMG_UINT32 gXProcWorkaroundState = XPROC_WORKAROUND_UNKNOWN; /* PRQA S 0686 10 */ /* force compiler to init structure */ XPROC_DATA gXProcWorkaroundShareData[XPROC_WORKAROUND_NUM_SHAREABLES] = {{0}}; -IMG_INT32 BM_XProcGetShareDataRefCount(IMG_UINT32 ui32Index) -{ - if(ui32Index >= XPROC_WORKAROUND_NUM_SHAREABLES) - return -1; - - return gXProcWorkaroundShareData[ui32Index].ui32RefCount; -} - PVRSRV_ERROR BM_XProcWorkaroundSetShareIndex(IMG_UINT32 ui32Index) { /* if you fail this assertion - did you acquire the mutex? @@ -2581,8 +2447,7 @@ XProcWorkaroundAllocShareable(RA_ARENA *psArena, if (ui32AllocFlags != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags) { PVR_DPF((PVR_DBG_ERROR, - "%s ERROR: Flags don't match (Shared 0x%08x, Requested 0x%08x)!", - __FUNCTION__, + "Can't! Flags don't match! (I had 0x%08x, you gave 0x%08x)", gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, ui32AllocFlags)); return PVRSRV_ERROR_INVALID_PARAMS; @@ -2591,24 +2456,14 @@ XProcWorkaroundAllocShareable(RA_ARENA *psArena, if (ui32Size != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32Size) { PVR_DPF((PVR_DBG_ERROR, - "%s ERROR: Size doesn't match (Shared %d, Requested %d) with flags 0x%08x - 0x%08x!", - __FUNCTION__, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32Size, - ui32Size, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, - ui32AllocFlags)); + "Can't! Size doesn't match!")); return PVRSRV_ERROR_INVALID_PARAMS; } if (ui32PageSize != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32PageSize) { PVR_DPF((PVR_DBG_ERROR, - "%s ERROR: Page Size doesn't match (Shared %d, Requested %d) with flags 0x%08x - 0x%08x!", - __FUNCTION__, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32PageSize, - ui32PageSize, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, - ui32AllocFlags)); + "Can't! Page Size doesn't match!")); return PVRSRV_ERROR_INVALID_PARAMS; } @@ -2780,7 +2635,7 @@ IMG_VOID _BM_XProcIndexRelease(IMG_UINT32 ui32Index) } sSysPAddr = gXProcWorkaroundShareData[ui32Index].sSysPAddr; RA_Free (gXProcWorkaroundShareData[ui32Index].psArena, - sSysPAddr.uiAddr, + (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } else @@ -2827,7 +2682,7 @@ static IMG_VOID XProcWorkaroundFreeShareable(IMG_HANDLE hOSMemHandle) which may be >= requested size @Output ppsMapping - receives the arbitrary user reference associated with the underlying storage. - @Input uFlags - bit mask of allocation flags + @Input ui32Flags - bit mask of allocation flags @Input pvPrivData - opaque private data passed through to allocator @Input ui32PrivDataLength - length of opaque private data @Output pBase - receives a pointer to the allocated storage. @@ -2841,7 +2696,7 @@ BM_ImportMemory (IMG_VOID *pH, IMG_SIZE_T uRequestSize, IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase) @@ -2849,14 +2704,15 @@ BM_ImportMemory (IMG_VOID *pH, BM_MAPPING *pMapping; BM_HEAP *pBMHeap = pH; BM_CONTEXT *pBMContext = pBMHeap->pBMContext; - IMG_INT32 uResult; + IMG_BOOL bResult; IMG_SIZE_T uSize; IMG_SIZE_T uPSize; IMG_SIZE_T uDevVAddrAlignment = 0; /* ? */ PVR_DPF ((PVR_DBG_MESSAGE, - "BM_ImportMemory (pBMContext=0x%x, uRequestSize=0x%x, uFlags=0x%x, uAlign=0x%x)", - (IMG_UINTPTR_T)pBMContext, uRequestSize, uFlags, uDevVAddrAlignment)); + "BM_ImportMemory (pBMContext=0x%p, uRequestSize=0x%" SIZE_T_FMT_LEN + "x, ui32Flags=0x%x, uAlign=0x%" SIZE_T_FMT_LEN "x)", + pBMContext, uRequestSize, ui32Flags, uDevVAddrAlignment)); PVR_ASSERT (ppsMapping != IMG_NULL); PVR_ASSERT (pBMContext != IMG_NULL); @@ -2882,15 +2738,14 @@ BM_ImportMemory (IMG_VOID *pH, pMapping->hOSMemHandle = 0; pMapping->CpuVAddr = 0; pMapping->DevVAddr.uiAddr = 0; - pMapping->ui32MappingCount = 0; pMapping->CpuPAddr.uiAddr = 0; pMapping->uSize = uSize; - if ((uFlags & PVRSRV_MEM_SPARSE) == 0) + if ((ui32Flags & PVRSRV_MEM_SPARSE) == 0) { pMapping->uSizeVM = uSize; } pMapping->pBMHeap = pBMHeap; - pMapping->ui32Flags = uFlags; + pMapping->ui32Flags = ui32Flags; /* * If anyone want's to know, pass back the actual size of our allocation. @@ -2912,16 +2767,11 @@ BM_ImportMemory (IMG_VOID *pH, uPSize = pMapping->uSize; } - if (uFlags & PVRSRV_MEM_XPROC) + if (ui32Flags & PVRSRV_MEM_XPROC) { IMG_UINT32 ui32Attribs = pBMHeap->ui32Attribs | PVRSRV_MEM_XPROC; IMG_BOOL bBadBackingStoreType; - if(uFlags & PVRSRV_MEM_ION) - { - ui32Attribs |= PVRSRV_MEM_ION; - } - bBadBackingStoreType = IMG_TRUE; if ((ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) != 0) @@ -2956,7 +2806,7 @@ BM_ImportMemory (IMG_VOID *pH, &pMapping->hOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%x) failed", + "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%" SIZE_T_FMT_LEN "x) failed", uPSize)); goto fail_mapping_alloc; } @@ -3000,7 +2850,7 @@ BM_ImportMemory (IMG_VOID *pH, &pMapping->hOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%x) failed", + "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%" SIZE_T_FMT_LEN "x) failed", uPSize)); goto fail_mapping_alloc; } @@ -3060,7 +2910,7 @@ BM_ImportMemory (IMG_VOID *pH, &pMapping->hOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: OSAllocPages(0x%x) failed", + "BM_ImportMemory: OSAllocPages(0x%" SIZE_T_FMT_LEN "x) failed", uPSize)); goto fail_mapping_alloc; } @@ -3102,7 +2952,7 @@ BM_ImportMemory (IMG_VOID *pH, ui32PrivDataLength, (IMG_UINTPTR_T *)&sSysPAddr.uiAddr)) { - PVR_DPF((PVR_DBG_ERROR, "BM_ImportMemory: RA_Alloc(0x%x) FAILED", uPSize)); + PVR_DPF((PVR_DBG_ERROR, "BM_ImportMemory: RA_Alloc(0x%" SIZE_T_FMT_LEN "x) FAILED", uPSize)); goto fail_mapping_alloc; } @@ -3128,42 +2978,21 @@ BM_ImportMemory (IMG_VOID *pH, goto fail_mapping_alloc; } - if(uFlags & PVRSRV_MEM_ION) - { - IMG_UINT32 ui32AddressOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_UINT32 ui32NumAddrOffsets = PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES; - - IMG_INT32 retSize = OSGetMemMultiPlaneInfo(pMapping->hOSMemHandle, - ui32AddressOffsets, &ui32NumAddrOffsets); - - if(retSize > 0 && pActualSize) - { - *pActualSize = pMapping->uSize = retSize; - } - } - /* * Allocate some device memory for what we just allocated. */ - /* - * Do not allocate GPU mapping if NO_GPU_VIRTUAL_ON_ALLOC is requested. - * In the case where CBI is enabled, this allows for late - * GPU mapping. This flag is, otherwise, used in cases where only - * the memory management feature of the driver is utilized, without - * a need for GPU rendering - */ - if ((uFlags & (PVRSRV_MEM_SPARSE | PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC)) == 0) + if ((ui32Flags & PVRSRV_MEM_SPARSE) == 0) { - uResult = DevMemoryAlloc (pBMContext, + bResult = DevMemoryAlloc (pBMContext, pMapping, IMG_NULL, - uFlags, + ui32Flags, (IMG_UINT32)uDevVAddrAlignment, &pMapping->DevVAddr); - if (uResult <= 0) + if (!bResult) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: DevMemoryAlloc(0x%x) failed", + "BM_ImportMemory: DevMemoryAlloc(0x%" SIZE_T_FMT_LEN "x) failed", pMapping->uSize)); goto fail_dev_mem_alloc; } @@ -3172,10 +3001,9 @@ BM_ImportMemory (IMG_VOID *pH, /* PRQA S 3356,3358 1 */ PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); PVR_ASSERT(pBase); + *pBase = pMapping->DevVAddr.uiAddr; } - if(pBase) - *pBase = pMapping->DevVAddr.uiAddr; *ppsMapping = pMapping; PVR_DPF ((PVR_DBG_MESSAGE, "BM_ImportMemory: IMG_TRUE")); @@ -3199,7 +3027,7 @@ fail_dev_mem_alloc: uPSize = pMapping->uSize; } - if (uFlags & PVRSRV_MEM_XPROC) + if (ui32Flags & PVRSRV_MEM_XPROC) { XProcWorkaroundFreeShareable(pMapping->hOSMemHandle); } @@ -3223,7 +3051,7 @@ fail_dev_mem_alloc: pMapping->hOSMemHandle); } sSysPAddr = SysCpuPAddrToSysPAddr(pMapping->CpuPAddr); - RA_Free (pBMHeap->pLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + RA_Free (pBMHeap->pLocalDevMemArena, (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } } fail_mapping_alloc: @@ -3259,8 +3087,8 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) PVR_UNREFERENCED_PARAMETER (_base); PVR_DPF ((PVR_DBG_MESSAGE, - "BM_FreeMemory (h=0x%x, base=0x%x, psMapping=0x%x)", - (IMG_UINTPTR_T)h, _base, (IMG_UINTPTR_T)psMapping)); + "BM_FreeMemory (h=0x%p, base=0x" UINTPTR_FMT ", psMapping=0x%p)", + h, _base, psMapping)); PVR_ASSERT (psMapping != IMG_NULL); @@ -3315,7 +3143,7 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) sSysPAddr = SysCpuPAddrToSysPAddr(psMapping->CpuPAddr); - RA_Free (pBMHeap->pLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + RA_Free (pBMHeap->pLocalDevMemArena, (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } else { @@ -3326,8 +3154,8 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) /*not nulling pointer, copy on stack*/ PVR_DPF((PVR_DBG_MESSAGE, - "..BM_FreeMemory (h=0x%x, base=0x%x)", - (IMG_UINTPTR_T)h, _base)); + "..BM_FreeMemory (h=0x%p, base=0x" UINTPTR_FMT ")", + h, _base)); } /*! diff --git a/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c b/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c index d047c7838b3..7a96e0ed533 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c +++ b/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c @@ -1,4 +1,5 @@ /*************************************************************************/ /*! +@File @Title Device class services functions @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved @Description Kernel services functions for device class devices @@ -49,21 +50,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "deviceid.h" #include "lists.h" -#if defined(CONFIG_GCBV) -#include "gc_bvmapping.h" + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include "pvr_sync.h" #endif PVRSRV_ERROR AllocateDeviceID(SYS_DATA *psSysData, IMG_UINT32 *pui32DevID); PVRSRV_ERROR FreeDeviceID(SYS_DATA *psSysData, IMG_UINT32 ui32DevID); -#if defined(SUPPORT_MISR_IN_THREAD) -void OSVSyncMISR(IMG_HANDLE, IMG_BOOL); -#endif - -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) -IMG_VOID PVRSRVFreeCommandCompletePacketKM(IMG_HANDLE hCmdCookie, - IMG_BOOL bScheduleMISR); -#endif /*********************************************************************** Local Display Class Structures ************************************************************************/ @@ -1166,6 +1160,14 @@ static PVRSRV_ERROR DestroyDCSwapChain(PVRSRV_DC_SWAPCHAIN *psSwapChain) #if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) if (psSwapChain->ppsLastSyncInfos) { + for (i = 0; i < psSwapChain->ui32LastNumSyncInfos; i++) + { + if (psSwapChain->ppsLastSyncInfos[i]) + { + PVRSRVKernelSyncInfoDecRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); + psSwapChain->ppsLastSyncInfos[i] = IMG_NULL; + } + } OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * psSwapChain->ui32LastNumSyncInfos, psSwapChain->ppsLastSyncInfos, IMG_NULL); } @@ -1276,7 +1278,6 @@ PVRSRV_ERROR PVRSRVCreateDCSwapChainKM (PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_UINT32 i; DISPLAY_INFO sDisplayInfo; - if(!hDeviceKM || !psDstSurfAttrib || !psSrcSurfAttrib @@ -1287,18 +1288,14 @@ PVRSRV_ERROR PVRSRVCreateDCSwapChainKM (PVRSRV_PER_PROCESS_DATA *psPerProc, return PVRSRV_ERROR_INVALID_PARAMS; } + OSMemSet (apsSyncData, 0, sizeof(PVRSRV_SYNC_DATA *) * PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS); + if (ui32BufferCount > PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateDCSwapChainKM: Too many buffers")); return PVRSRV_ERROR_TOOMANYBUFFERS; } - if (ui32BufferCount < 2) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateDCSwapChainKM: Too few buffers")); - return PVRSRV_ERROR_TOO_FEW_BUFFERS; - } - psDCInfo = DCDeviceHandleToDCInfo(hDeviceKM); if( ui32Flags & PVRSRV_CREATE_SWAPCHAIN_QUERY ) @@ -1428,7 +1425,7 @@ PVRSRV_ERROR PVRSRVCreateDCSwapChainKM (PVRSRV_PER_PROCESS_DATA *psPerProc, psSwapChain->ui32RefCount = 1; psSwapChain->ui32Flags = ui32Flags; - /* Save pointer in DC structure if ti's shared struct */ + /* Save pointer in DC structure if it's shared struct */ if( ui32Flags & PVRSRV_CREATE_SWAPCHAIN_SHARED ) { if(! psDCInfo->psDCSwapChainShared ) @@ -1610,32 +1607,6 @@ PVRSRV_ERROR PVRSRVGetDCBuffersKM(IMG_HANDLE hDeviceKM, phBuffer[i] = (IMG_HANDLE)&psSwapChain->asBuffer[i]; } -#if defined(SUPPORT_GET_DC_BUFFERS_SYS_PHYADDRS) - for(i = 0; i < *pui32BufferCount; i++) - { - IMG_UINT32 ui32ByteSize, ui32TilingStride; - IMG_SYS_PHYADDR *pPhyAddr; - IMG_BOOL bIsContiguous; - IMG_HANDLE hOSMapInfo; - IMG_VOID *pvVAddr; - - eError = psDCInfo->psFuncTable->pfnGetBufferAddr(psDCInfo->hExtDevice, - ahExtBuffer[i], - &pPhyAddr, - &ui32ByteSize, - &pvVAddr, - &hOSMapInfo, - &bIsContiguous, - &ui32TilingStride); - if(eError != PVRSRV_OK) - { - break; - } - - psPhyAddr[i] = *pPhyAddr; - } -#endif /* defined(SUPPORT_GET_DC_BUFFERS_SYS_PHYADDRS) */ - return eError; } @@ -1679,21 +1650,6 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, return PVRSRV_ERROR_INVALID_SWAPINTERVAL; } -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) - - if(psDCInfo->psFuncTable->pfnQuerySwapCommandID != IMG_NULL) - { - psDCInfo->psFuncTable->pfnQuerySwapCommandID(psDCInfo->hExtDevice, - psBuffer->psSwapChain->hExtSwapChain, - psBuffer->sDeviceClassBuffer.hExtBuffer, - hPrivateTag, - &ui16SwapCommandID, - &bAddReferenceToLast); - - } - -#endif - /* get the queue from the buffer structure */ psQueue = psBuffer->psSwapChain->psQueue; @@ -1717,6 +1673,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, apsSrcSync, sizeof(DISPLAYCLASS_FLIP_COMMAND) + (sizeof(IMG_RECT) * ui32ClipRectCount), IMG_NULL, + IMG_NULL, IMG_NULL); if(eError != PVRSRV_OK) { @@ -1836,20 +1793,27 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, PVRSRV_KERNEL_SYNC_INFO **ppsSyncInfos, IMG_UINT32 ui32NumMemSyncInfos, IMG_PVOID pvPrivData, - IMG_UINT32 ui32PrivDataLength) + IMG_UINT32 ui32PrivDataLength, + IMG_HANDLE *phFence) { + IMG_UINT32 ui32NumSyncInfos = ui32NumMemSyncInfos; + IMG_UINT32 ui32NumMemInfos = ui32NumMemSyncInfos; PVRSRV_KERNEL_SYNC_INFO **ppsCompiledSyncInfos; IMG_UINT32 i, ui32NumCompiledSyncInfos; DISPLAYCLASS_FLIP_COMMAND2 *psFlipCmd; PVRSRV_DISPLAYCLASS_INFO *psDCInfo; PVRSRV_DC_SWAPCHAIN *psSwapChain; - PVRSRV_ERROR eError = PVRSRV_OK; CALLBACK_DATA *psCallbackData; PVRSRV_QUEUE_INFO *psQueue; PVRSRV_COMMAND *psCommand; IMG_PVOID *ppvMemInfos; + PVRSRV_ERROR eError; SYS_DATA *psSysData; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA] = {}; +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + if(!hDeviceKM || !hSwapChain || !ppsMemInfos || !ppsSyncInfos || ui32NumMemSyncInfos < 1) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Invalid parameters")); @@ -1881,7 +1845,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, psCallbackData->ui32PrivDataLength = ui32PrivDataLength; if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(IMG_VOID *) * ui32NumMemSyncInfos, + sizeof(IMG_VOID *) * ui32NumMemInfos, (IMG_VOID **)&ppvMemInfos, IMG_NULL, "Swap Command Meminfos") != PVRSRV_OK) { @@ -1890,13 +1854,22 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, goto Exit; } - for(i = 0; i < ui32NumMemSyncInfos; i++) + for(i = 0; i < ui32NumMemInfos; i++) { ppvMemInfos[i] = ppsMemInfos[i]; } psCallbackData->ppvMemInfos = ppvMemInfos; - psCallbackData->ui32NumMemInfos = ui32NumMemSyncInfos; + psCallbackData->ui32NumMemInfos = ui32NumMemInfos; + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + eError = PVRSyncFencesToSyncInfos(ppsSyncInfos, &ui32NumSyncInfos, apsFence); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: PVRSyncFencesToSyncInfos failed")); + goto Exit; + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ /* get the queue from the buffer structure */ psQueue = psSwapChain->psQueue; @@ -1905,21 +1878,35 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, if(psSwapChain->ppsLastSyncInfos) { IMG_UINT32 ui32NumUniqueSyncInfos = psSwapChain->ui32LastNumSyncInfos; + IMG_BOOL *abUnique; IMG_UINT32 j; + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_BOOL) * psSwapChain->ui32LastNumSyncInfos, + (IMG_VOID **)&abUnique, IMG_NULL, + "Unique booleans") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for unique booleans")); + goto Exit; + } + for(j = 0; j < psSwapChain->ui32LastNumSyncInfos; j++) { - for(i = 0; i < ui32NumMemSyncInfos; i++) + abUnique[j] = IMG_TRUE; + for(i = 0; i < ui32NumSyncInfos; i++) { + PVR_ASSERT(psSwapChain->ppsLastSyncInfos[j]); + PVR_ASSERT(ppsSyncInfos[i]); if(psSwapChain->ppsLastSyncInfos[j] == ppsSyncInfos[i]) { - psSwapChain->ppsLastSyncInfos[j] = IMG_NULL; + abUnique[j] = IMG_FALSE; ui32NumUniqueSyncInfos--; + break; } } } - ui32NumCompiledSyncInfos = ui32NumMemSyncInfos + ui32NumUniqueSyncInfos; + ui32NumCompiledSyncInfos = ui32NumSyncInfos + ui32NumUniqueSyncInfos; if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumCompiledSyncInfos, @@ -1927,24 +1914,132 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, "Compiled syncinfos") != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_BOOL) * psSwapChain->ui32LastNumSyncInfos, + (IMG_VOID *)abUnique, IMG_NULL); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); +#endif goto Exit; } - OSMemCopy(ppsCompiledSyncInfos, ppsSyncInfos, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumMemSyncInfos); - for(j = 0, i = ui32NumMemSyncInfos; j < psSwapChain->ui32LastNumSyncInfos; j++) + OSMemCopy(ppsCompiledSyncInfos, ppsSyncInfos, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumSyncInfos); + for(j = 0, i = ui32NumSyncInfos; j < psSwapChain->ui32LastNumSyncInfos; j++) { - if(psSwapChain->ppsLastSyncInfos[j]) + if(abUnique[j]) { ppsCompiledSyncInfos[i] = psSwapChain->ppsLastSyncInfos[j]; i++; } } + + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_BOOL) * psSwapChain->ui32LastNumSyncInfos, + (IMG_VOID *)abUnique, IMG_NULL); } else #endif /* !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) */ { - ppsCompiledSyncInfos = ppsSyncInfos; - ui32NumCompiledSyncInfos = ui32NumMemSyncInfos; + IMG_UINT32 j, ui32Missing = 0; + + /* Older synchronization schemes would just pass down the syncinfos + * hanging off of the meminfos. So we would expect identical lists. + * However, newer drivers may send down additional synchronization + * i.e. for TQ fence operations. In such a case we need to allocate + * more space for the compiled syncinfos to ensure everything is + * ROP2 synchronized. + */ + for(i = 0; i < ui32NumMemInfos; i++) + { + for(j = 0; j < ui32NumSyncInfos; j++) + { + if(ppsSyncInfos[j] == ppsMemInfos[i]->psKernelSyncInfo) + break; + } + + if(j == ui32NumSyncInfos) + ui32Missing++; + } + + if(ui32Missing) + { + IMG_UINT32 k; + + ui32NumCompiledSyncInfos = ui32NumSyncInfos + ui32Missing; + + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumCompiledSyncInfos, + (IMG_VOID **)&ppsCompiledSyncInfos, IMG_NULL, + "Compiled syncinfos") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); +#endif + goto Exit; + } + + for(i = 0; i < ui32NumSyncInfos; i++) + { + ppsCompiledSyncInfos[i] = ppsSyncInfos[i]; + } + + k = i; + for(i = 0; i < ui32NumMemInfos; i++) + { + for(j = 0; j < ui32NumSyncInfos; j++) + { + if(ppsSyncInfos[j] == ppsMemInfos[i]->psKernelSyncInfo) + break; + } + + if(j == ui32NumSyncInfos) + { + /* Insert the unique one */ + PVR_ASSERT(k < ui32NumCompiledSyncInfos); + ppsCompiledSyncInfos[k] = ppsMemInfos[i]->psKernelSyncInfo; + k++; + } + } + + PVR_ASSERT(k == ui32NumCompiledSyncInfos); + + /* As a further complication, if we have multiple displays, we + * might see the same layer/meminfo submitted twice. This is + * valid, as the layer might be needed by two separate pipes, + * but we should not use the meminfo's synchronization twice + * because this will deadlock the queue processor. + * + * For now, work over the meminfo end of the compiled syncs + * list and collapse any duplicates. We can assume the fence + * sync part of the array has already been de-duplicated. + */ + k = ui32NumSyncInfos; + for(i = ui32NumSyncInfos; i < ui32NumCompiledSyncInfos; i++) + { + /* Compare the i'th entry with all that follow */ + for(j = i + 1; j < ui32NumCompiledSyncInfos; j++) + { + if(ppsCompiledSyncInfos[i] == ppsCompiledSyncInfos[j]) + break; + } + + if(j == ui32NumCompiledSyncInfos) + { + /* No duplicate found. Use this entry */ + ppsCompiledSyncInfos[k] = ppsCompiledSyncInfos[i]; + k++; + } + } + ui32NumCompiledSyncInfos = k; + } + else + { + ppsCompiledSyncInfos = ppsSyncInfos; + ui32NumCompiledSyncInfos = ui32NumSyncInfos; + } } /* insert the command (header) */ @@ -1958,7 +2053,17 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, ppsCompiledSyncInfos, sizeof(DISPLAYCLASS_FLIP_COMMAND2), FreePrivateData, - psCallbackData); + psCallbackData, + phFence); + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + /* InsertCommand bumped the refcount on the raw sync objects, so we + * can put the fences now. Even if the fences are deleted, the syncs + * will persist. + */ + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); +#endif if (ppsCompiledSyncInfos != ppsSyncInfos) { @@ -1990,7 +2095,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, psFlipCmd->ui32PrivDataLength = ui32PrivDataLength; psFlipCmd->ppsMemInfos = (PDC_MEM_INFO *)ppvMemInfos; - psFlipCmd->ui32NumMemInfos = ui32NumMemSyncInfos; + psFlipCmd->ui32NumMemInfos = ui32NumMemInfos; /* Even though this is "unused", we have to initialize it, * as the display controller might NULL-test it. @@ -2026,6 +2131,11 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to submit command")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_fence_put(psCommand->pvCleanupFence); + sync_fence_put(*phFence); + *phFence = IMG_NULL; +#endif goto Exit; } @@ -2040,34 +2150,60 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to schedule MISR")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_fence_put(*phFence); + *phFence = IMG_NULL; +#endif goto Exit; } #if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) /* Reallocate the syncinfo list if it was too small */ - if (psSwapChain->ui32LastNumSyncInfos < ui32NumMemSyncInfos) + if (psSwapChain->ui32LastNumSyncInfos < ui32NumSyncInfos) { if (psSwapChain->ppsLastSyncInfos) { + for (i = 0; i < psSwapChain->ui32LastNumSyncInfos; i++) + { + if (psSwapChain->ppsLastSyncInfos[i]) + { + PVRSRVKernelSyncInfoDecRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); + psSwapChain->ppsLastSyncInfos[i] = IMG_NULL; + } + } OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * psSwapChain->ui32LastNumSyncInfos, psSwapChain->ppsLastSyncInfos, IMG_NULL); } if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumMemSyncInfos, + sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumSyncInfos, (IMG_VOID **)&psSwapChain->ppsLastSyncInfos, IMG_NULL, "Last syncinfos") != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_fence_put(*phFence); + *phFence = IMG_NULL; +#endif goto Exit; } } - psSwapChain->ui32LastNumSyncInfos = ui32NumMemSyncInfos; + for (i = 0; i < psSwapChain->ui32LastNumSyncInfos; i++) + { + if (psSwapChain->ppsLastSyncInfos[i]) + { + PVRSRVKernelSyncInfoDecRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); + psSwapChain->ppsLastSyncInfos[i] = IMG_NULL; + } + } - for(i = 0; i < ui32NumMemSyncInfos; i++) + psSwapChain->ui32LastNumSyncInfos = ui32NumSyncInfos; + + for(i = 0; i < ui32NumSyncInfos; i++) { psSwapChain->ppsLastSyncInfos[i] = ppsSyncInfos[i]; + PVRSRVKernelSyncInfoIncRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); } #endif /* !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) */ @@ -2119,7 +2255,7 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, psSwapChain = psSwapChainRef->psSwapChain; /* - If more then 1 reference to the swapchain exist then + If more than 1 reference to the swapchain exists then ignore any request to swap to the system buffer */ if (psSwapChain->ui32RefCount > 1) @@ -2130,21 +2266,6 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, /* get the queue from the buffer structure */ psQueue = psSwapChain->psQueue; -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) - - if(psDCInfo->psFuncTable->pfnQuerySwapCommandID != IMG_NULL) - { - psDCInfo->psFuncTable->pfnQuerySwapCommandID(psDCInfo->hExtDevice, - psSwapChain->hExtSwapChain, - psDCInfo->sSystemBuffer.sDeviceClassBuffer.hExtBuffer, - 0, - &ui16SwapCommandID, - &bAddReferenceToLast); - - } - -#endif - /* specify the syncs */ apsSrcSync[0] = psDCInfo->sSystemBuffer.sDeviceClassBuffer.psKernelSyncInfo; if(bAddReferenceToLast && psSwapChain->psLastFlipBuffer) @@ -2168,6 +2289,7 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, apsSrcSync, sizeof(DISPLAYCLASS_FLIP_COMMAND), IMG_NULL, + IMG_NULL, IMG_NULL); if(eError != PVRSRV_OK) { @@ -2372,69 +2494,6 @@ PVRSRVDCMemInfoIsPhysContig(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) return OSMemHandleIsPhysContig(psKernelMemInfo->sMemBlk.hOSMemHandle); } -static PVRSRV_ERROR PVRSRVDCMemInfoGetBvHandle(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo, IMG_VOID **handle) -{ -#if !defined(CONFIG_GCBV) - *handle = NULL; - return PVRSRV_ERROR_NOT_SUPPORTED; -#else - *handle = gc_meminfo_to_hndl(psKernelMemInfo); - return PVRSRV_OK; -#endif -} - -/*! -****************************************************************************** - - @Function PVRSRVDCMemInfoGetCpuMultiPlanePAddr - - @Description returns physical addresses of a multi-plane buffer - - - @Input psKernelMemInfo - Pointer to Kernel Memory Info structure - puPlaneByteOffsets - requested offset inside the plane. - If the array is a NULL pointer, 0 requested offsets - are assumed for all planes; - pui32NumAddrOffsets - specifying the size of the user array. - If the array is smaller than the number of the planes - for this buffer, the correct size will be set and an - error returned back; - -@Output pPlanePAddrs - array of plane physical addresses of the returned size - in pui32NumAddrOffsets; - pui32NumAddrOffsets - contains the real number of planes for the buffer; - -@Return IMG_INT32 : size of the entire buffer or negative number on ERROR - -******************************************************************************/ -static IMG_INT32 -PVRSRVDCMemInfoGetCpuMultiPlanePAddr(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo, - IMG_SIZE_T* puPlaneByteOffsets, IMG_CPU_PHYADDR* pPlanePAddrs, - IMG_UINT32* pui32NumAddrOffsets) -{ - IMG_UINT32 aui32PlaneAddressOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_INT32 i32Ret; - IMG_UINT32 i; - - i32Ret = OSGetMemMultiPlaneInfo(psKernelMemInfo->sMemBlk.hOSMemHandle, - aui32PlaneAddressOffsets, - pui32NumAddrOffsets); - - if((i32Ret < 0) || (pPlanePAddrs == IMG_NULL)) - return i32Ret; - - for (i = 0; i < *pui32NumAddrOffsets; i++) - { - IMG_SIZE_T uiReqByteOffsets = puPlaneByteOffsets ? puPlaneByteOffsets[i] : 0; - - uiReqByteOffsets += aui32PlaneAddressOffsets[i]; - - pPlanePAddrs[i] = OSMemHandleToCpuPAddr(psKernelMemInfo->sMemBlk.hOSMemHandle, uiReqByteOffsets); - } - - return i32Ret; -} - /*! ****************************************************************************** @@ -2458,22 +2517,13 @@ IMG_BOOL PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *psJTable) psJTable->pfnPVRSRVOEMFunction = &SysOEMFunction; psJTable->pfnPVRSRVRegisterCmdProcList = &PVRSRVRegisterCmdProcListKM; psJTable->pfnPVRSRVRemoveCmdProcList = &PVRSRVRemoveCmdProcListKM; -#if defined(SUPPORT_MISR_IN_THREAD) - psJTable->pfnPVRSRVCmdComplete = &OSVSyncMISR; -#else - psJTable->pfnPVRSRVCmdComplete = &PVRSRVCommandCompleteKM; -#endif + psJTable->pfnPVRSRVCmdComplete = &PVRSRVCommandCompleteKM; psJTable->pfnPVRSRVRegisterSystemISRHandler = &PVRSRVRegisterSystemISRHandler; psJTable->pfnPVRSRVRegisterPowerDevice = &PVRSRVRegisterPowerDevice; -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) - psJTable->pfnPVRSRVFreeCmdCompletePacket = &PVRSRVFreeCommandCompletePacketKM; -#endif psJTable->pfnPVRSRVDCMemInfoGetCpuVAddr = &PVRSRVDCMemInfoGetCpuVAddr; psJTable->pfnPVRSRVDCMemInfoGetCpuPAddr = &PVRSRVDCMemInfoGetCpuPAddr; psJTable->pfnPVRSRVDCMemInfoGetByteSize = &PVRSRVDCMemInfoGetByteSize; psJTable->pfnPVRSRVDCMemInfoIsPhysContig = &PVRSRVDCMemInfoIsPhysContig; - psJTable->pfnPVRSRVDCMemInfoGetBvHandle = &PVRSRVDCMemInfoGetBvHandle; - psJTable->pfnPVRSRVDCMemInfoGetCpuMultiPlanePAddr = PVRSRVDCMemInfoGetCpuMultiPlanePAddr; return IMG_TRUE; } diff --git a/drivers/gpu/pvr/services4/srvkm/common/deviceid.h b/drivers/gpu/pvr/services4/srvkm/common/deviceid.h index 1cf9f0fdd39..1cf9f0fdd39 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/deviceid.h +++ b/drivers/gpu/pvr/services4/srvkm/common/deviceid.h diff --git a/drivers/gpu/pvr/services4/srvkm/common/devicemem.c b/drivers/gpu/pvr/services4/srvkm/common/devicemem.c index 872c0bab0ff..ac68bcf80bb 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/devicemem.c +++ b/drivers/gpu/pvr/services4/srvkm/common/devicemem.c @@ -47,15 +47,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pdump_km.h" #include "pvr_bridge_km.h" #include "osfunc.h" -#if defined(CONFIG_GCBV) -#include "gc_bvmapping.h" -#endif +#include "devicemem.h" #if defined(SUPPORT_ION) #include "ion.h" #include "env_perproc.h" +#include "ion_sync.h" + +/* Start size of the g_IonSyncHash hash table */ +#define ION_SYNC_HASH_SIZE 20 +HASH_TABLE *g_psIonSyncHash = IMG_NULL; #endif +#include "lists.h" + /* local function prototypes */ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemHeap, @@ -84,6 +89,8 @@ typedef struct _RESMAN_MAP_DEVICE_MEM_DATA_ PVRSRV_KERNEL_MEM_INFO *psSrcMemInfo; } RESMAN_MAP_DEVICE_MEM_DATA; +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + /* map device class resman memory storage structure */ @@ -96,7 +103,103 @@ typedef struct _PVRSRV_DC_MAPINFO_ PVRSRV_DEVICECLASS_BUFFER *psDeviceClassBuffer; } PVRSRV_DC_MAPINFO; +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + static IMG_UINT32 g_ui32SyncUID = 0; +#if defined (MEM_TRACK_INFO_DEBUG) +PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoHead = NULL; +PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoTail = NULL; +IMG_UINT32 g_ui32NumOfOpsRecorded = 0; +#endif + +static PVRSRV_KERNEL_SYNC_INFO *g_psSyncInfoList = IMG_NULL; + +#if defined (MEM_TRACK_INFO_DEBUG) +/*! +****************************************************************************** + + @Function PVRSRVAddMemTrackInfo + + @Description + + Adds the current psMemTrackInfo instance to the head of list represented by gMemTrackInfo + + @Input psMemTrackInfo : + @Output + + @Return + +******************************************************************************/ +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVAddMemTrackInfo(PVRSRV_MEM_TRACK_INFO *psMemTrackInfo) +{ + g_ui32NumOfOpsRecorded++; + psMemTrackInfo->next = g_psMemTrackInfoHead; + psMemTrackInfo->prev = IMG_NULL; + if(g_psMemTrackInfoHead) + { + g_psMemTrackInfoHead->prev = psMemTrackInfo; + } + else + g_psMemTrackInfoTail = psMemTrackInfo; + g_psMemTrackInfoHead = psMemTrackInfo; + if(g_ui32NumOfOpsRecorded > MAX_MEM_TRACK_OPS) + { + PVRSRV_MEM_TRACK_INFO *psFreePtr; + psFreePtr = g_psMemTrackInfoTail; + g_psMemTrackInfoTail = g_psMemTrackInfoTail->prev; + g_psMemTrackInfoTail->next = IMG_NULL; + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + psFreePtr, IMG_NULL); + g_ui32NumOfOpsRecorded--; + } +} + +/*! +****************************************************************************** + + @Function PVRSRVPrintMemTrackInfo + + @Description + + Dumps the mem tracking info + + @Input ui32FaultAddr: + @Output + + @Return + +******************************************************************************/ +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVPrintMemTrackInfo(IMG_UINT32 ui32FaultAddr) +{ + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + const IMG_CHAR *apszMemOpNames[] = {"UNKNOWN", "DEVICE", "DEVICECLASS", "WRAPPED", "MAPPED", "ION", "ALLOC", "FREE"}; + psMemTrackInfo = g_psMemTrackInfoHead; + + PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVMemTrackInfo: Dumping mem tracking info\n")); + PVR_DPF((PVR_DBG_MESSAGE,"DevVAddr | Size | Memory Op | Process ID | Ref Count | Task Name | Heap ID | Time Stamp(uSec)\n")); + while(psMemTrackInfo) + { + if((ui32FaultAddr >= psMemTrackInfo->sDevVAddr.uiAddr) && + (ui32FaultAddr < (psMemTrackInfo->sDevVAddr.uiAddr + psMemTrackInfo->uSize))) + { + PVR_DPF((PVR_DBG_MESSAGE,"***************************\n")); + } + PVR_DPF((PVR_DBG_MESSAGE,"0x%-8x | 0x%-8zx | %-13s | %-11d | %-6u | %-15s | %10s | %-15u ", + psMemTrackInfo->sDevVAddr.uiAddr, + psMemTrackInfo->uSize, + apszMemOpNames[psMemTrackInfo->eOp], + psMemTrackInfo->ui32Pid, + psMemTrackInfo->ui32RefCount, + psMemTrackInfo->asTaskName, + psMemTrackInfo->heapId, + psMemTrackInfo->ui32TimeStampUSecs)); + psMemTrackInfo = psMemTrackInfo->next; + } +} +#endif /*! ****************************************************************************** @@ -116,11 +219,7 @@ static IMG_UINT32 g_ui32SyncUID = 0; ******************************************************************************/ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapsKM(IMG_HANDLE hDevCookie, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *psHeapInfo) -#else PVRSRV_HEAP_INFO *psHeapInfo) -#endif { PVRSRV_DEVICE_NODE *psDeviceNode; IMG_UINT32 ui32HeapCount; @@ -188,11 +287,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE *phDevMemContext, IMG_UINT32 *pui32ClientHeapCount, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *psHeapInfo, -#else PVRSRV_HEAP_INFO *psHeapInfo, -#endif IMG_BOOL *pbCreated, IMG_BOOL *pbShared) { @@ -204,7 +299,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook IMG_DEV_PHYADDR sPDDevPAddr; IMG_UINT32 i; -#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) +#if !defined(PVR_SECURE_HANDLES) PVR_UNREFERENCED_PARAMETER(pbShared); #endif @@ -260,7 +355,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook psHeapInfo[ui32ClientHeapCount].ui32XTileStride = 0; #endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_TRUE; #endif ui32ClientHeapCount++; @@ -294,7 +389,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook #else psHeapInfo[ui32ClientHeapCount].ui32XTileStride = 0; #endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_FALSE; #endif @@ -345,11 +440,7 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemContext, IMG_UINT32 *pui32ClientHeapCount, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *psHeapInfo, -#else PVRSRV_HEAP_INFO *psHeapInfo, -#endif IMG_BOOL *pbShared) { PVRSRV_DEVICE_NODE *psDeviceNode; @@ -358,7 +449,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie IMG_HANDLE hDevMemHeap; IMG_UINT32 i; -#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) +#if !defined(PVR_SECURE_HANDLES) PVR_UNREFERENCED_PARAMETER(pbShared); #endif @@ -396,7 +487,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_TRUE; #endif ui32ClientHeapCount++; @@ -426,7 +517,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_FALSE; #endif @@ -442,34 +533,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie return PVRSRV_OK; } -static PVRSRV_ERROR UpdateDeviceMemoryPlaneOffsets(PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - if(psMemInfo->ui32Flags & PVRSRV_MEM_ION) - { - - PVRSRV_MEMBLK *psMemBlock = &(psMemInfo->sMemBlk); - IMG_UINT32 ui32AddressOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_UINT32 ui32NumAddrOffsets = PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES; - - IMG_INT32 retSize = OSGetMemMultiPlaneInfo(psMemBlock->hOSMemHandle, - ui32AddressOffsets, &ui32NumAddrOffsets); - - if((retSize > 0) && ui32NumAddrOffsets) - { - int i; - for(i = 0; i < PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES; i++) - { - if(i < ui32NumAddrOffsets) - psMemInfo->planeOffsets[i] = ui32AddressOffsets[i]; - else - psMemInfo->planeOffsets[i] = (IMG_INT32)-1; - } - } - } - - return PVRSRV_OK; - -} /*! ****************************************************************************** @@ -535,15 +598,6 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, psMemBlock = &(psMemInfo->sMemBlk); - /* ION and DYNAMIC re-mapping - * require the PAGEABLE FLAG set - */ - if (ui32Flags & (PVRSRV_MEM_ION | - PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC)) - { - ui32Flags |= PVRSRV_HAP_GPU_PAGEABLE; - } - /* BM supplied Device Virtual Address with physical backing RAM */ psMemInfo->ui32Flags = ui32Flags | PVRSRV_MEM_RAM_BACKED_ALLOCATION; @@ -593,9 +647,6 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, /* Clear the Backup buffer pointer as we do not have one at this point. We only allocate this as we are going up/down */ psMemInfo->pvSysBackupBuffer = IMG_NULL; - /* Update the Multimedia plane offsets */ - UpdateDeviceMemoryPlaneOffsets(psMemInfo); - /* * Setup the output. */ @@ -756,13 +807,41 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, psSyncData->ui32LastReadOpDumpVal = 0; psSyncData->ui64LastWrite = 0; +#if defined(SUPPORT_PER_SYNC_DEBUG) + psKernelSyncInfo->ui32OperationMask = 0; + memset(psKernelSyncInfo->aui32OpInfo, 0, sizeof(psKernelSyncInfo->aui32OpInfo)); + memset(psKernelSyncInfo->aui32ReadOpSample, 0, sizeof(psKernelSyncInfo->aui32ReadOpSample)); + memset(psKernelSyncInfo->aui32WriteOpSample, 0, sizeof(psKernelSyncInfo->aui32WriteOpSample)); + memset(psKernelSyncInfo->aui32ReadOp2Sample, 0, sizeof(psKernelSyncInfo->aui32ReadOp2Sample)); + psKernelSyncInfo->ui32HistoryIndex = 0; +#endif + + /* + Note: + PDumping here means that we PDump syncs that we might not + need to know about for the multi-process but this + unavoidable as there is no point where we can PDump + that guarantees it will be initialised before we us it + (e.g. kick time is too late as the client might have + issued a POL on it before that point) + */ #if defined(PDUMP) - PDUMPCOMMENT("Allocating kernel sync object"); + PDUMPCOMMENTWITHFLAGS( +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + PDUMP_FLAGS_PERSISTENT, +#else + PDUMP_FLAGS_CONTINUOUS, +#endif + "Allocating kernel sync object"); PDUMPMEM(psKernelSyncInfo->psSyncDataMemInfoKM->pvLinAddrKM, psKernelSyncInfo->psSyncDataMemInfoKM, 0, (IMG_UINT32)psKernelSyncInfo->psSyncDataMemInfoKM->uAllocSize, +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + PDUMP_FLAGS_PERSISTENT, +#else PDUMP_FLAGS_CONTINUOUS, +#endif MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); #endif @@ -776,6 +855,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, OSAtomicInc(psKernelSyncInfo->pvRefCount); + /* Add the SyncInfo to a global list */ + List_PVRSRV_KERNEL_SYNC_INFO_Insert(&g_psSyncInfoList, psKernelSyncInfo); + /* return result */ *ppsKernelSyncInfo = psKernelSyncInfo; @@ -805,8 +887,32 @@ IMG_VOID IMG_CALLCONV PVRSRVReleaseSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelS { if (OSAtomicDecAndTest(psKernelSyncInfo->pvRefCount)) { + /* Remove the SyncInfo to a global list */ + List_PVRSRV_KERNEL_SYNC_INFO_Remove(psKernelSyncInfo); + + #if defined(PDUMP) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "Wait for write ops to flush to PDump value (%d)", + psKernelSyncInfo->psSyncData->ui32LastOpDumpVal); + PDUMPMEMPOL(psKernelSyncInfo->psSyncDataMemInfoKM, + offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), + psKernelSyncInfo->psSyncData->ui32LastOpDumpVal, + 0xffffffff, + PDUMP_POLL_OPERATOR_EQUAL, + PDUMP_FLAGS_CONTINUOUS, + MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "Wait for read ops to flush to PDump value (%d)", + psKernelSyncInfo->psSyncData->ui32LastReadOpDumpVal); + PDUMPMEMPOL(psKernelSyncInfo->psSyncDataMemInfoKM, + offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), + psKernelSyncInfo->psSyncData->ui32LastReadOpDumpVal, + 0xffffffff, + PDUMP_POLL_OPERATOR_EQUAL, + PDUMP_FLAGS_CONTINUOUS, + MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + #endif + FreeDeviceMem(psKernelSyncInfo->psSyncDataMemInfoKM); - + /* Catch anyone who is trying to access the freed structure */ psKernelSyncInfo->psSyncDataMemInfoKM = IMG_NULL; psKernelSyncInfo->psSyncData = IMG_NULL; @@ -883,22 +989,40 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVRSRV_FREE_CALLBACK_ORIGIN eCallbackOrigin) { PVRSRV_ERROR eError = PVRSRV_OK; - +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; +#endif PVR_UNREFERENCED_PARAMETER(ui32Param); /* decrement the refcount */ PVRSRVKernelMemInfoDecRef(psMemInfo); +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_FREE; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif + /* check no other processes has this meminfo mapped */ if (psMemInfo->ui32RefCount == 0) { if((psMemInfo->ui32Flags & PVRSRV_MEM_EXPORTED) != 0) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMemInfo = 0; -#else IMG_HANDLE hMemInfo = IMG_NULL; -#endif /* find the handle */ eError = PVRSRVFindHandle(KERNEL_HANDLE_BASE, @@ -930,9 +1054,22 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, freeExternal(psMemInfo); case PVRSRV_MEMTYPE_DEVICE: case PVRSRV_MEMTYPE_DEVICECLASS: - if (psMemInfo->psKernelSyncInfo) +#if defined(SUPPORT_ION) + if (psMemInfo->hIonSyncInfo) { - PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); + /* + For syncs attached to Ion imported buffers we handle + things a little differently + */ + PVRSRVIonBufferSyncInfoDecRef(psMemInfo->hIonSyncInfo, psMemInfo); + } + else +#endif + { + if (psMemInfo->psKernelSyncInfo) + { + PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); + } } break; default: @@ -941,11 +1078,6 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, } } -#if defined(CONFIG_GCBV) - if (psMemInfo->ui32Flags & PVRSRV_MAP_GC_MMU) - gc_bvunmap_meminfo(psMemInfo); -#endif - /* * FreeDeviceMem2 will do the right thing, freeing * the virtual memory info when the allocator calls @@ -1033,103 +1165,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie, /*! ****************************************************************************** - @Function PVRSRVRemapToDevKM - - @Description - - Remaps buffer to GPU virtual address space - - @Input psMemInfo - - @Return PVRSRV_ERROR : 0 means the memory is still unmapped - ERROR, - * bigger than 0 (mapping reference count) - success mapping - * smaller than 0 - PVRSRV error -******************************************************************************/ -IMG_EXPORT -IMG_INT32 IMG_CALLCONV PVRSRVRemapToDevKM(IMG_HANDLE hDevCookie, - PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_DEV_VIRTADDR *psDevVAddr) -{ - PVRSRV_MEMBLK *psMemBlock; - IMG_INT32 result; - - PVR_UNREFERENCED_PARAMETER(hDevCookie); - - if (!psMemInfo) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVRemapToDevKM: invalid parameters")); - return PVRSRV_ERROR_INVALID_PARAMS; - } - - psMemBlock = &(psMemInfo->sMemBlk); - - result = BM_RemapToDev(psMemBlock->hBuffer); - - if(result <= 0) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVRemapToDevKM: could not remap")); - } - - *psDevVAddr = psMemInfo->sDevVAddr = - psMemBlock->sDevVirtAddr = BM_HandleToDevVaddr(psMemBlock->hBuffer); - - UpdateDeviceMemoryPlaneOffsets(psMemInfo); - - return result; -} - - -/*! -****************************************************************************** - - @Function PVRSRVUnmapFromDevKM - - @Description - - Unmaps buffer from GPU virtual address space - - @Input psMemInfo - - @Return PVRSRV_ERROR : 0 means the memory is unmapped, - * bigger than 0 (mapping reference count) still mapped - * smaller than 0 - PVRSRV error -******************************************************************************/ -IMG_EXPORT -IMG_INT32 IMG_CALLCONV PVRSRVUnmapFromDevKM(IMG_HANDLE hDevCookie, - PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - PVRSRV_MEMBLK *psMemBlock; - IMG_INT32 result; - - PVR_UNREFERENCED_PARAMETER(hDevCookie); - - if (!psMemInfo) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVUnmapFromDevKM: invalid parameters")); - return PVRSRV_ERROR_INVALID_PARAMS; - } - - psMemBlock = &(psMemInfo->sMemBlk); - - result = BM_UnmapFromDev(psMemBlock->hBuffer); - /* 0 means the memory is unmapped, - * bigger than 0 (mapping ref count) still mapped - * smaller than 0 PVRSRV error - */ - if(result < 0) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVUnmapFromDevKM: could not unmap")); - } - - psMemInfo->sDevVAddr = - psMemBlock->sDevVirtAddr = BM_HandleToDevVaddr(psMemBlock->hBuffer); - - return result; -} - - -/*! -****************************************************************************** - @Function PVRSRVAllocDeviceMemKM @Description @@ -1166,6 +1201,13 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, PVRSRV_ERROR eError; BM_HEAP *psBMHeap; IMG_HANDLE hDevMemContext; +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + IMG_UINT32 i; + IMG_CHAR *pszName = "Heap not found"; + DEVICE_MEMORY_INFO *psDevMemoryInfo; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; +#endif if (!hDevMemHeap || ((ui32Size == 0) && ((ui32Flags & PVRSRV_MEM_SPARSE) == 0)) || @@ -1233,11 +1275,6 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, return eError; } -#if defined(CONFIG_GCBV) - if (ui32Flags & PVRSRV_MAP_GC_MMU) - gc_bvmap_meminfo(psMemInfo); -#endif - if (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ) { psMemInfo->psKernelSyncInfo = IMG_NULL; @@ -1258,7 +1295,23 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, goto free_mainalloc; } } +#if defined (MEM_TRACK_INFO_DEBUG) + psBMHeap = (BM_HEAP*)hDevMemHeap; + hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; + psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; + psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; + + for(i=0; i<PVRSRV_MAX_CLIENT_HEAPS; i++) + { + if(HEAP_IDX(psDeviceMemoryHeap[i].ui32HeapID) == psDevMemoryInfo->ui32MappingHeapID) + { + pszName = psDeviceMemoryHeap[i].pszName; + break; + } + } + OSStringCopy(psMemInfo->heapId, pszName); +#endif /* * Setup the output. */ @@ -1288,6 +1341,26 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, psMemInfo->memType = PVRSRV_MEMTYPE_DEVICE; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_ALLOC; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif /* * And I think we're done for now.... */ @@ -1315,6 +1388,90 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR); } +PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo) +{ + PVRSRV_ION_SYNC_INFO *psIonSyncInfo; + PVRSRV_ERROR eError; + IMG_BOOL bRet; + + /* Check the hash to see if we already have a sync for this buffer */ + psIonSyncInfo = (PVRSRV_ION_SYNC_INFO *) HASH_Retrieve(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique); + if (psIonSyncInfo == 0) + { + /* This buffer is new to us, create the syncinfo for it */ + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + (IMG_VOID **)&psIonSyncInfo, IMG_NULL, + "Ion Synchronization Info"); + if (eError != PVRSRV_OK) + { + return eError; + } + + eError = PVRSRVAllocSyncInfoKM(hDevCookie, + hDevMemContext, + &psIonSyncInfo->psSyncInfo); + if (eError != PVRSRV_OK) + { + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + psIonSyncInfo, + IMG_NULL); + + return eError; + } +#if defined(SUPPORT_MEMINFO_IDS) + psIonSyncInfo->ui64Stamp = ++g_ui64MemInfoID; +#else + psIonSyncInfo->ui64Stamp = 0; +#endif + bRet = HASH_Insert(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique, (IMG_UINTPTR_T) psIonSyncInfo); + if (!bRet) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + + PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL); + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + psIonSyncInfo, + IMG_NULL); + + return eError; + } + + psIonSyncInfo->ui32RefCount = 0; + psIonSyncInfo->hUnique = hUnique; + } + + psIonSyncInfo->ui32RefCount++; + *ppsIonSyncInfo = psIonSyncInfo; + return PVRSRV_OK; +} + +IMG_VOID PVRSRVIonBufferSyncRelease(PVRSRV_ION_SYNC_INFO *psIonSyncInfo) +{ + psIonSyncInfo->ui32RefCount--; + + if (psIonSyncInfo->ui32RefCount == 0) + { + PVRSRV_ION_SYNC_INFO *psLookup; + /* + If we're holding the last reference to the syncinfo + then free it + */ + psLookup = (PVRSRV_ION_SYNC_INFO *) HASH_Remove(g_psIonSyncHash, (IMG_UINTPTR_T) psIonSyncInfo->hUnique); + PVR_ASSERT(psLookup == psIonSyncInfo); + PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL); + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + psIonSyncInfo, + IMG_NULL); + } +} + /*! ****************************************************************************** @@ -1326,10 +1483,19 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, @Input psPerProc : PerProcess data @Input hDevCookie : Device node cookie - @Input hDevMemContext : Device memory context cookie - @Input hIon : Handle to ION buffer + @Input hDevMemHeap : Heap ion handles are mapped into + @Input ui32NumBuffers : Number of ion handles to map. (If one handle is being + mapped, this should be 1, not 0.) + @Input phIon : Array of ui32NumBuffers ion handles (fds) @Input ui32Flags : Mapping flags - @Input ui32Size : Mapping size + @Input ui32ChunkCount : If ui32NumBuffers is 1, this is the number of + "chunks" specified to be mapped into device-virtual + address space. If ui32NumBuffers > 1, it is ignored. + @Input pauiOffset : Array of offsets in device-virtual address space to map + "chunks" of physical from the ion allocation. + @Input pauiSize : Array of sizes in bytes of device-virtual address space to + map "chunks" of physical from the ion allocation. + @Input puiIonBufferSize : Size in bytes of resulting device-virtual mapping. @Output ppsKernelMemInfo: Output kernel meminfo if successful @Return PVRSRV_ERROR : @@ -1338,35 +1504,56 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, IMG_EXPORT PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevCookie, - IMG_HANDLE hDevMemContext, - IMG_HANDLE hIon, + IMG_HANDLE hDevMemHeap, + IMG_UINT32 ui32NumFDs, + IMG_INT32 *pi32BufferFDs, IMG_UINT32 ui32Flags, - IMG_UINT32 ui32Size, - PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo) + IMG_UINT32 ui32ChunkCount, + IMG_SIZE_T *pauiOffset, + IMG_SIZE_T *pauiSize, + IMG_SIZE_T *puiIonBufferSize, + PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo, + IMG_UINT64 *pui64Stamp) { PVRSRV_ENV_PER_PROCESS_DATA *psPerProcEnv = PVRSRVProcessPrivateData(psPerProc); PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo; - DEVICE_MEMORY_INFO *psDevMemoryInfo; - DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_SYS_PHYADDR *pasSysPhysAddr; + IMG_SYS_PHYADDR *pasAdjustedSysPhysAddr; PVRSRV_MEMBLK *psMemBlock; PVRSRV_ERROR eError; - IMG_HANDLE hDevMemHeap = IMG_NULL; IMG_HANDLE hPriv; + IMG_HANDLE hUnique; BM_HANDLE hBuffer; - IMG_UINT32 ui32HeapCount; + IMG_SIZE_T uiMapSize = 0; + IMG_SIZE_T uiAdjustOffset = 0; IMG_UINT32 ui32PageCount; IMG_UINT32 i; IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ)?IMG_FALSE:IMG_TRUE; - if ((hDevCookie == IMG_NULL) || (ui32Size == 0) - || (hDevMemContext == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)) + if ((hDevCookie == IMG_NULL) || (ui32ChunkCount == 0) + || (hDevMemHeap == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)) { PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__)); return PVRSRV_ERROR_INVALID_PARAMS; } + for (i=0;i<ui32ChunkCount;i++) + { + if ((pauiOffset[i] & HOST_PAGEMASK) != 0) + { + PVR_DPF((PVR_DBG_ERROR,"%s: Chunk offset is not page aligned", __FUNCTION__)); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if ((pauiSize[i] & HOST_PAGEMASK) != 0) + { + PVR_DPF((PVR_DBG_ERROR,"%s: Chunk size is not page aligned", __FUNCTION__)); + return PVRSRV_ERROR_INVALID_PARAMS; + } + uiMapSize += pauiSize[i]; + } + psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie; if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, @@ -1379,59 +1566,63 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, } OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO)); - /* Choose the heap to map to */ - ui32HeapCount = psDeviceNode->sDevMemoryInfo.ui32HeapCount; - psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; - psDeviceMemoryHeap = psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeap; - for(i=0; i<PVRSRV_MAX_CLIENT_HEAPS; i++) + /* Import the ION buffer into our ion_client and DMA map it */ + eError = IonImportBufferAndAcquirePhysAddr(psPerProcEnv->psIONClient, + ui32NumFDs, + pi32BufferFDs, + &ui32PageCount, + &pasSysPhysAddr, + &psNewKernelMemInfo->pvLinAddrKM, + &hPriv, + &hUnique); + if (eError != PVRSRV_OK) { - if(HEAP_IDX(psDeviceMemoryHeap[i].ui32HeapID) == psDevMemoryInfo->ui32IonHeapID) - { - if(psDeviceMemoryHeap[i].DevMemHeapType == DEVICE_MEMORY_HEAP_PERCONTEXT) - { - if (psDeviceMemoryHeap[i].ui32HeapSize > 0) - { - hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); - } - else - { - hDevMemHeap = IMG_NULL; - } - } - else - { - hDevMemHeap = psDevMemoryInfo->psDeviceMemoryHeap[i].hDevMemHeap; - } - break; - } + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ion buffer/buffer phys addr", __FUNCTION__)); + goto exitFailedImport; } - - if (hDevMemHeap == IMG_NULL) + + /* + Make sure the number of pages detected by the ion import are at least + the size of the total chunked region + */ + if(ui32PageCount * PAGE_SIZE < uiMapSize) { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ION heap", __FUNCTION__)); - eError = PVRSRV_ERROR_FAILED_TO_RETRIEVE_HEAPINFO; - goto exitFailedHeap; + PVR_DPF((PVR_DBG_ERROR, "%s: ion allocator returned fewer page addresses " + "than specified chunk size(s)", __FUNCTION__)); + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto exitFailedAdjustedAlloc; } - /* Import the ION buffer into our ion_client and DMA map it */ - eError = IonImportBufferAndAquirePhysAddr(psPerProcEnv->psIONClient, - hIon, - &ui32PageCount, - &pasSysPhysAddr, - &psNewKernelMemInfo->pvLinAddrKM, - &hPriv); - if (eError != PVRSRV_OK) + /* + An Ion buffer might have a number of "chunks" in it which need to be + mapped virtually continuous so we need to create a new array of + addresses based on this chunk data for the actual wrap + */ + if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()), + (IMG_VOID **)&pasAdjustedSysPhysAddr, IMG_NULL, + "Ion adjusted system address array") != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ion buffer/buffer phys addr", __FUNCTION__)); - goto exitFailedHeap; + PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for adjusted array", __FUNCTION__)); + goto exitFailedAdjustedAlloc; + } + OSMemSet(pasAdjustedSysPhysAddr, 0, sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE())); + + for (i=0;i<ui32ChunkCount;i++) + { + OSMemCopy(&pasAdjustedSysPhysAddr[uiAdjustOffset], + &pasSysPhysAddr[pauiOffset[i]/HOST_PAGESIZE()], + (pauiSize[i]/HOST_PAGESIZE()) * sizeof(IMG_SYS_PHYADDR)); + + uiAdjustOffset += pauiSize[i]/HOST_PAGESIZE(); } /* Wrap the returned addresses into our memory context */ if (!BM_Wrap(hDevMemHeap, - ui32Size, + uiMapSize, 0, IMG_FALSE, - pasSysPhysAddr, + pasAdjustedSysPhysAddr, IMG_NULL, &ui32Flags, /* This function clobbers our bits in ui32Flags */ &hBuffer)) @@ -1447,11 +1638,11 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, psMemBlock->hOSMemHandle = BM_HandleToOSMemHandle(hBuffer); psMemBlock->hBuffer = (IMG_HANDLE) hBuffer; psMemBlock->hOSWrapMem = hPriv; /* Saves creating a new element as we know hOSWrapMem will not be used */ - psMemBlock->psIntSysPAddr = pasSysPhysAddr; + psMemBlock->psIntSysPAddr = pasAdjustedSysPhysAddr; psNewKernelMemInfo->ui32Flags = ui32Flags; psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psNewKernelMemInfo->uAllocSize = ui32Size; + psNewKernelMemInfo->uAllocSize = uiMapSize; psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION; PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo); @@ -1464,13 +1655,25 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, } else { - eError = PVRSRVAllocSyncInfoKM(hDevCookie, - hDevMemContext, - &psNewKernelMemInfo->psKernelSyncInfo); + PVRSRV_ION_SYNC_INFO *psIonSyncInfo; + BM_HEAP *psBMHeap; + IMG_HANDLE hDevMemContext; + + psBMHeap = (BM_HEAP*)hDevMemHeap; + hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; + + eError = PVRSRVIonBufferSyncInfoIncRef(hUnique, + hDevCookie, + hDevMemContext, + &psIonSyncInfo, + psNewKernelMemInfo); if(eError != PVRSRV_OK) { goto exitFailedSync; } + psNewKernelMemInfo->hIonSyncInfo = psIonSyncInfo; + psNewKernelMemInfo->psKernelSyncInfo = IonBufferSyncGetKernelSyncInfo(psIonSyncInfo); + *pui64Stamp = IonBufferSyncGetStamp(psIonSyncInfo); } /* register with the resman */ @@ -1487,23 +1690,29 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION; + /* + As the user doesn't tell us the size, just the "chunk" information + return actual size of the Ion buffer so we can mmap it. + */ + *puiIonBufferSize = ui32PageCount * HOST_PAGESIZE(); *ppsKernelMemInfo = psNewKernelMemInfo; return PVRSRV_OK; exitFailedResman: if (psNewKernelMemInfo->psKernelSyncInfo) { - PVRSRVKernelSyncInfoDecRef(psNewKernelMemInfo->psKernelSyncInfo, psNewKernelMemInfo); + PVRSRVIonBufferSyncInfoDecRef(psNewKernelMemInfo->hIonSyncInfo, psNewKernelMemInfo); } exitFailedSync: BM_Free(hBuffer, ui32Flags); exitFailedWrap: - IonUnimportBufferAndReleasePhysAddr(hPriv); OSFreeMem(PVRSRV_PAGEABLE_SELECT, - sizeof(IMG_SYS_PHYADDR) * ui32PageCount, - pasSysPhysAddr, + sizeof(IMG_SYS_PHYADDR) * uiAdjustOffset, + pasAdjustedSysPhysAddr, IMG_NULL); -exitFailedHeap: +exitFailedAdjustedAlloc: + IonUnimportBufferAndReleasePhysAddr(hPriv); +exitFailedImport: OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), psNewKernelMemInfo, @@ -1707,10 +1916,23 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, IMG_VOID *pvPageAlignedCPUVAddr; IMG_SYS_PHYADDR *psIntSysPAddr = IMG_NULL; IMG_HANDLE hOSWrapMem = IMG_NULL; - DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; - IMG_UINT32 i; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap;IMG_UINT32 i; +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + IMG_CHAR *pszName="Heap not found"; +#endif IMG_SIZE_T uPageCount = 0; + PVR_DPF ((PVR_DBG_MESSAGE, + "PVRSRVWrapExtMemoryKM (uSize=0x%" SIZE_T_FMT_LEN "x, uPageOffset=0x%" + SIZE_T_FMT_LEN "x, bPhysContig=%d, extSysPAddr=" SYSPADDR_FMT + ", pvLinAddr=%p, ui32Flags=%u)", + uByteSize, + uPageOffset, + bPhysContig, + psExtSysPAddr?psExtSysPAddr->uiAddr:0x0, + pvLinAddr, + ui32Flags)); psDeviceNode = (PVRSRV_DEVICE_NODE*)hDevCookie; PVR_ASSERT(psDeviceNode != IMG_NULL); @@ -1759,6 +1981,21 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, */ bPhysContig = IMG_FALSE; } +#if !defined(__QNXNTO__) + else + { + if (psExtSysPAddr) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter, physical address passing is not supported")); + } + else + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter, no address specificed")); + } + return PVRSRV_ERROR_INVALID_PARAMS; + } +#endif + /* Choose the heap to map to */ psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; @@ -1772,6 +2009,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, if (psDeviceMemoryHeap[i].ui32HeapSize > 0) { hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } else { @@ -1781,6 +2021,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, else { hDevMemHeap = psDevMemoryInfo->psDeviceMemoryHeap[i].hDevMemHeap; + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } break; } @@ -1804,7 +2047,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, } OSMemSet(psMemInfo, 0, sizeof(*psMemInfo)); - psMemInfo->ui32Flags = ui32Flags; + /* + Force the memory to be read/write. This used to be done in the BM, but + ion imports don't want this behaviour + */ + psMemInfo->ui32Flags = ui32Flags | PVRSRV_MEM_READ | PVRSRV_MEM_WRITE; psMemBlock = &(psMemInfo->sMemBlk); @@ -1867,10 +2114,32 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, psMemInfo, 0, &UnwrapExtMemoryCallBack); - +#if defined (MEM_TRACK_INFO_DEBUG) + OSStringCopy(psMemInfo->heapId, pszName); +#endif /* return the meminfo */ *ppsMemInfo = psMemInfo; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_WRAPPED; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif + return PVRSRV_OK; /* error handling: */ @@ -2023,6 +2292,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer PVRSRV_DEVICE_NODE *psDeviceNode; IMG_VOID *pvPageAlignedCPUVAddr; RESMAN_MAP_DEVICE_MEM_DATA *psMapData = IMG_NULL; +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + DEVICE_MEMORY_INFO *psDevMemoryInfo; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; + BM_HEAP *psBMHeap; + IMG_HANDLE hDevMemContext; +#endif /* check params */ if(!psSrcMemInfo || !hDstDevMemHeap || !ppsDstMemInfo) @@ -2090,7 +2366,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer } OSMemSet(psMemInfo, 0, sizeof(*psMemInfo)); - psMemInfo->ui32Flags = psSrcMemInfo->ui32Flags; + + /* + Force the memory to be read/write. This used to be done in the BM, but + ion imports don't want this behaviour + */ + psMemInfo->ui32Flags = psSrcMemInfo->ui32Flags | PVRSRV_MEM_READ | PVRSRV_MEM_WRITE; psMemBlock = &(psMemInfo->sMemBlk); @@ -2160,9 +2441,49 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer psMapData, 0, &UnmapDeviceMemoryCallBack); +#if defined (MEM_TRACK_INFO_DEBUG) + psBMHeap = (BM_HEAP*)hDstDevMemHeap; + hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; + psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; + psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; + + for(i=0; i<PVRSRV_MAX_CLIENT_HEAPS; i++) + { + if(HEAP_IDX(psDeviceMemoryHeap[i].ui32HeapID) == psDevMemoryInfo->ui32MappingHeapID) + break; + } + + if(i == PVRSRV_MAX_CLIENT_HEAPS) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVMapDeviceMemoryKM: unable to find mapping heap")); + eError = PVRSRV_ERROR_UNABLE_TO_FIND_MAPPING_HEAP; + OSStringCopy(psMemInfo->heapId, "Heap not found"); + } + else + OSStringCopy(psMemInfo->heapId, psDeviceMemoryHeap[i].pszName); +#endif *ppsDstMemInfo = psMemInfo; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_MAPPED; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif return PVRSRV_OK; /* error handling: */ @@ -2193,6 +2514,7 @@ ErrorExit: return eError; } +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /*! ****************************************************************************** @@ -2298,15 +2620,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * DEVICE_MEMORY_INFO *psDevMemoryInfo; DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_HANDLE hDevMemHeap = IMG_NULL; - IMG_SIZE_T uByteSize; - IMG_SIZE_T ui32Offset; - IMG_SIZE_T ui32PageSize = HOST_PAGESIZE(); + IMG_UINT32 ui32ByteSize; + IMG_SIZE_T uOffset; + IMG_SIZE_T uPageSize = HOST_PAGESIZE(); BM_HANDLE hBuffer; PVRSRV_MEMBLK *psMemBlock; IMG_BOOL bBMError; IMG_UINT32 i; PVRSRV_DC_MAPINFO *psDCMapInfo = IMG_NULL; - +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + IMG_CHAR *pszName = "Heap not found"; +#endif if(!hDeviceClassBuffer || !ppsMemInfo || !phOSMapInfo || !hDevMemContext) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVMapDeviceClassMemoryKM: invalid parameters")); @@ -2349,7 +2674,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * eError = psDeviceClassBuffer->pfnGetBufferAddr(psDeviceClassBuffer->hExtDevice, psDeviceClassBuffer->hExtBuffer, &psSysPAddr, - &uByteSize, + &ui32ByteSize, &pvCPUVAddr, phOSMapInfo, &bPhysContig, @@ -2374,6 +2699,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * if (psDeviceMemoryHeap[i].ui32HeapSize > 0) { hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } else { @@ -2383,6 +2711,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * else { hDevMemHeap = psDevMemoryInfo->psDeviceMemoryHeap[i].hDevMemHeap; + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } break; } @@ -2396,8 +2727,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * } /* Only need lower 12 bits of the cpu addr - don't care what size a void* is */ - ui32Offset = ((IMG_UINTPTR_T)pvCPUVAddr) & (ui32PageSize - 1); - pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)pvCPUVAddr - ui32Offset); + uOffset = ((IMG_UINTPTR_T)pvCPUVAddr) & (uPageSize - 1); + pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)pvCPUVAddr - uOffset); eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), @@ -2411,11 +2742,17 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * OSMemSet(psMemInfo, 0, sizeof(*psMemInfo)); + /* + Force the memory to be read/write. This used to be done in the BM, but + ion imports don't want this behaviour + */ + psMemInfo->ui32Flags |= PVRSRV_MEM_READ | PVRSRV_MEM_WRITE; + psMemBlock = &(psMemInfo->sMemBlk); bBMError = BM_Wrap(hDevMemHeap, - uByteSize, - ui32Offset, + ui32ByteSize, + uOffset, bPhysContig, psSysPAddr, pvPageAlignedCPUVAddr, @@ -2444,7 +2781,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * /* Fill in the public fields of the MEM_INFO structure */ psMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psMemInfo->uAllocSize = uByteSize; + psMemInfo->uAllocSize = ui32ByteSize; psMemInfo->psKernelSyncInfo = psDeviceClassBuffer->psKernelSyncInfo; PVR_ASSERT(psMemInfo->psKernelSyncInfo != IMG_NULL); @@ -2491,9 +2828,31 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * PVRSRVKernelMemInfoIncRef(psMemInfo); psMemInfo->memType = PVRSRV_MEMTYPE_DEVICECLASS; +#if defined (MEM_TRACK_INFO_DEBUG) + OSStringCopy(psMemInfo->heapId, pszName); +#endif /* return the meminfo */ *ppsMemInfo = psMemInfo; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_DEVICECLASS; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif #if defined(SUPPORT_PDUMP_MULTI_PROCESS) /* If the 3PDD supplies a kernel virtual address, we can PDUMP it */ @@ -2510,7 +2869,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * * behaviour. */ PDUMPCOMMENT("Dump display surface"); - PDUMPMEM(IMG_NULL, psMemInfo, ui32Offset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); + PDUMPMEM(IMG_NULL, psMemInfo, uOffset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); } #endif return PVRSRV_OK; @@ -2548,6 +2907,7 @@ ErrorExitPhase1: return eError; } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKernelMemInfo, IMG_UINT32 ui32Attribs) @@ -2573,8 +2933,189 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKerne return PVRSRV_OK; } +PVRSRV_ERROR IMG_CALLCONV PVRSRVInitDeviceMem(IMG_VOID) +{ + PVRSRV_ERROR eError = PVRSRV_OK; + +#if defined(SUPPORT_ION) + /* + For Ion buffers we need to store which ones we know about so + we don't give the same buffer a different sync + */ + g_psIonSyncHash = HASH_Create(ION_SYNC_HASH_SIZE); + if (g_psIonSyncHash == IMG_NULL) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + } +#endif + + return eError; +} + +IMG_VOID IMG_CALLCONV PVRSRVDeInitDeviceMem(IMG_VOID) +{ +#if defined(SUPPORT_ION) + HASH_Delete(g_psIonSyncHash); +#endif +} + +#if defined(MEM_TRACK_INFO_DEBUG) +/*! +****************************************************************************** + + @Function PVRSRVFreeMemOps + + @Description + Frees the list of tracked mem ops represented by g_psMemTrackInfoHead + + @Input + @Output + + @Return + +******************************************************************************/ +IMG_VOID IMG_CALLCONV PVRSRVFreeMemOps(IMG_VOID) +{ + PVRSRV_MEM_TRACK_INFO *psFreePtr; + while(g_psMemTrackInfoHead) + { + psFreePtr = g_psMemTrackInfoHead; + g_psMemTrackInfoHead = g_psMemTrackInfoHead->next; + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + psFreePtr, IMG_NULL); + } +} +#endif + +static PVRSRV_ERROR PVRSRVDumpSync(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + PVR_LOG(("\tSyncInfo %d:", psKernelSyncInfo->ui32UID)); + PVR_LOG(("\t\tWrite ops (0x%08x): P/C = %d/%d (0x%08x/0x%08x)", + psKernelSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psKernelSyncInfo->psSyncData->ui32WriteOpsPending, + psKernelSyncInfo->psSyncData->ui32WriteOpsComplete, + psKernelSyncInfo->psSyncData->ui32WriteOpsPending, + psKernelSyncInfo->psSyncData->ui32WriteOpsComplete)); + PVR_LOG(("\t\tRead ops (0x%08x): P/C = %d/%d (0x%08x/0x%08x)", + psKernelSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psKernelSyncInfo->psSyncData->ui32ReadOpsPending, + psKernelSyncInfo->psSyncData->ui32ReadOpsComplete, + psKernelSyncInfo->psSyncData->ui32ReadOpsPending, + psKernelSyncInfo->psSyncData->ui32ReadOpsComplete)); + PVR_LOG(("\t\tRead ops 2 (0x%08x): P/C = %d/%d (0x%08x/0x%08x)", + psKernelSyncInfo->sReadOps2CompleteDevVAddr.uiAddr, + psKernelSyncInfo->psSyncData->ui32ReadOps2Pending, + psKernelSyncInfo->psSyncData->ui32ReadOps2Complete, + psKernelSyncInfo->psSyncData->ui32ReadOps2Pending, + psKernelSyncInfo->psSyncData->ui32ReadOps2Complete)); + +#if defined(SUPPORT_PER_SYNC_DEBUG) + { + IMG_UINT32 i; + PVR_LOG(("\t\t --- Per sync debug ---")); + + PVR_LOG(("\t\tOperationMask = 0x%08x", psKernelSyncInfo->ui32OperationMask)); + + + for (i=0;i<PER_SYNC_HISTORY;i++) + { + IMG_UINT32 ui32Index = (i + psKernelSyncInfo->ui32HistoryIndex) % PER_SYNC_HISTORY; + IMG_UINT32 ui32OpInfo = psKernelSyncInfo->aui32OpInfo[ui32Index]; + + if (ui32OpInfo & SYNC_OP_HAS_DATA) + { + IMG_UINT32 ui32OpClass = (ui32OpInfo & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + IMG_UINT32 ui32OpType = (ui32OpInfo & SYNC_OP_TYPE_MASK) >> SYNC_OP_TYPE_SHIFT; + IMG_CHAR *pzClass; + IMG_CHAR *pzType; + + PVR_LOG(("\t\tOperation last - %d\n", PER_SYNC_HISTORY - i)); + + switch(ui32OpClass) + { + case SYNC_OP_CLASS_MODOBJ: + pzClass = "MODOBJ"; + break; + case SYNC_OP_CLASS_QUEUE: + pzClass = "QUEUE"; + break; + case SYNC_OP_CLASS_KICKTA: + pzClass = "KICKTA"; + break; + case SYNC_OP_CLASS_TQ_3D: + pzClass = "TQ_3D"; + break; + case SYNC_OP_CLASS_TQ_2D: + pzClass = "TQ_2D"; + break; + default: + pzClass = "Unknown"; + } + switch(ui32OpType) + { + case SYNC_OP_TYPE_READOP: + pzType = "READOP"; + break; + case SYNC_OP_TYPE_WRITEOP: + pzType = "WRITEOP"; + break; + case SYNC_OP_TYPE_READOP2: + pzType = "READOP2"; + break; + default: + pzType = "Unknown"; + } + PVR_LOG(("\t\t\tui32OpType = 0x%08x", ui32OpInfo)); + PVR_LOG(("\t\t\t\t%s, %s, %s, %s", + pzClass, + pzType, + (ui32OpInfo & SYNC_OP_TAKE) ?"TAKE":"No TAKE", + (ui32OpInfo & SYNC_OP_ROLLBACK) ?"ROLLBACK":"No ROLLBACK")); + + PVR_LOG(("\t\t\ti32ReadOpSample = %d (0x%08x)", + psKernelSyncInfo->aui32ReadOpSample[ui32Index], + psKernelSyncInfo->aui32ReadOpSample[ui32Index])); + PVR_LOG(("\t\t\taui32WriteOpSample = %d (0x%08x)", + psKernelSyncInfo->aui32WriteOpSample[ui32Index], + psKernelSyncInfo->aui32WriteOpSample[ui32Index])); + PVR_LOG(("\t\t\taui32ReadOp2Sample = %d (0x%08x)", + psKernelSyncInfo->aui32ReadOp2Sample[ui32Index], + psKernelSyncInfo->aui32ReadOp2Sample[ui32Index])); + } + } + } +#endif + return PVRSRV_OK; +} + + +static PVRSRV_ERROR PVRSRVDumpActiveSync(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + if ((psKernelSyncInfo->psSyncData->ui32WriteOpsComplete != psKernelSyncInfo->psSyncData->ui32WriteOpsPending) || + (psKernelSyncInfo->psSyncData->ui32ReadOpsComplete != psKernelSyncInfo->psSyncData->ui32ReadOpsPending) || + (psKernelSyncInfo->psSyncData->ui32ReadOps2Complete != psKernelSyncInfo->psSyncData->ui32ReadOps2Pending)) + { + PVRSRVDumpSync(psKernelSyncInfo); + } + return PVRSRV_OK; +} + +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVDumpSyncs(IMG_BOOL bActiveOnly) +{ + if (bActiveOnly) + { + PVR_LOG(("Active syncs")); + List_PVRSRV_KERNEL_SYNC_INFO_PVRSRV_ERROR_Any(g_psSyncInfoList, PVRSRVDumpActiveSync); + } + else + { + PVR_LOG(("All syncs")); + List_PVRSRV_KERNEL_SYNC_INFO_PVRSRV_ERROR_Any(g_psSyncInfoList, PVRSRVDumpSync); + } +} /****************************************************************************** End of file (devicemem.c) ******************************************************************************/ - diff --git a/drivers/gpu/pvr/services4/srvkm/common/handle.c b/drivers/gpu/pvr/services4/srvkm/common/handle.c index 1e260470e7e..b9facfdf181 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/handle.c +++ b/drivers/gpu/pvr/services4/srvkm/common/handle.c @@ -40,7 +40,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) /* See handle.h for a description of the handle API. */ /* @@ -78,14 +78,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define INDEX_IS_VALID(psBase, i) ((i) < (psBase)->ui32TotalHandCount) /* Valid handles are never NULL, but handle array indices are based from 0 */ -#if defined (SUPPORT_SID_INTERFACE) -#define INDEX_TO_HANDLE(i) ((IMG_SID)((i) + 1)) -#define HANDLE_TO_INDEX(h) ((IMG_UINT32)(h) - 1) -#else #define INDEX_TO_HANDLE(i) ((IMG_HANDLE)((IMG_UINTPTR_T)(i) + 1)) #define HANDLE_TO_INDEX(h) ((IMG_UINT32)(IMG_UINTPTR_T)(h) - 1) -#endif #define INDEX_TO_BLOCK_INDEX(i) DIVIDE_BY_BLOCK_SIZE(i) #define BLOCK_INDEX_TO_INDEX(i) MULTIPLY_BY_BLOCK_SIZE(i) @@ -150,11 +145,7 @@ struct sHandleList { IMG_UINT32 ui32Prev; IMG_UINT32 ui32Next; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hParent; -#else IMG_HANDLE hParent; -#endif }; enum ePVRSRVInternalHandleFlag @@ -324,11 +315,7 @@ typedef IMG_UINTPTR_T HAND_KEY[HAND_KEY_LEN]; #pragma inline(HandleListInit) #endif static INLINE -#if defined (SUPPORT_SID_INTERFACE) -IMG_VOID HandleListInit(IMG_UINT32 ui32Index, struct sHandleList *psList, IMG_SID hParent) -#else IMG_VOID HandleListInit(IMG_UINT32 ui32Index, struct sHandleList *psList, IMG_HANDLE hParent) -#endif { psList->ui32Next = ui32Index; psList->ui32Prev = ui32Index; @@ -484,11 +471,7 @@ IMG_BOOL NoParent(struct sHandle *psHandle) #pragma inline(ParentHandle) #endif static INLINE -#if defined (SUPPORT_SID_INTERFACE) -IMG_SID ParentHandle(struct sHandle *psHandle) -#else IMG_HANDLE ParentHandle(struct sHandle *psHandle) -#endif { return psHandle->sSiblings.hParent; } @@ -721,11 +704,7 @@ PVRSRV_ERROR IterateOverChildren(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psP #pragma inline(GetHandleStructure) #endif static INLINE -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **ppsHandle, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) -#else PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **ppsHandle, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) -#endif { IMG_UINT32 ui32Index = HANDLE_TO_INDEX(hHandle); struct sHandle *psHandle; @@ -734,9 +713,6 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps if (!INDEX_IS_VALID(psBase, ui32Index)) { PVR_DPF((PVR_DBG_ERROR, "GetHandleStructure: Handle index out of range (%u >= %u)", ui32Index, psBase->ui32TotalHandCount)); -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif return PVRSRV_ERROR_HANDLE_INDEX_OUT_OF_RANGE; } @@ -744,9 +720,6 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps if (psHandle->eType == PVRSRV_HANDLE_TYPE_NONE) { PVR_DPF((PVR_DBG_ERROR, "GetHandleStructure: Handle not allocated (index: %u)", ui32Index)); -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif return PVRSRV_ERROR_HANDLE_NOT_ALLOCATED; } @@ -757,9 +730,6 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps if (eType != PVRSRV_HANDLE_TYPE_NONE && eType != psHandle->eType) { PVR_DPF((PVR_DBG_ERROR, "GetHandleStructure: Handle type mismatch (%d != %d)", eType, psHandle->eType)); -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif return PVRSRV_ERROR_HANDLE_TYPE_MISMATCH; } @@ -787,11 +757,7 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps #pragma inline(ParentIfPrivate) #endif static INLINE -#if defined (SUPPORT_SID_INTERFACE) -IMG_SID ParentIfPrivate(struct sHandle *psHandle) -#else IMG_HANDLE ParentIfPrivate(struct sHandle *psHandle) -#endif { return TEST_ALLOC_FLAG(psHandle, PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE) ? ParentHandle(psHandle) : IMG_NULL; @@ -814,11 +780,7 @@ IMG_HANDLE ParentIfPrivate(struct sHandle *psHandle) #pragma inline(InitKey) #endif static INLINE -#if defined (SUPPORT_SID_INTERFACE) -IMG_VOID InitKey(HAND_KEY aKey, PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_SID hParent) -#else IMG_VOID InitKey(HAND_KEY aKey, PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hParent) -#endif { PVR_UNREFERENCED_PARAMETER(psBase); @@ -1125,14 +1087,9 @@ static PVRSRV_ERROR FreeHandle(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psHan if (!TEST_ALLOC_FLAG(psHandle, PVRSRV_HANDLE_ALLOC_FLAG_MULTI) && !BATCHED_HANDLE_PARTIALLY_FREE(psHandle)) { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHandle; - hHandle = (IMG_SID) HASH_Remove_Extended(psBase->psHashTab, aKey); -#else IMG_HANDLE hHandle; hHandle = (IMG_HANDLE) HASH_Remove_Extended(psBase->psHashTab, aKey); -#endif PVR_ASSERT(hHandle != IMG_NULL); PVR_ASSERT(hHandle == INDEX_TO_HANDLE(ui32Index)); @@ -1339,11 +1296,7 @@ static PVRSRV_ERROR FreeHandleBase(PVRSRV_HANDLE_BASE *psBase) #pragma inline(FindHandle) #endif static INLINE -#if defined (SUPPORT_SID_INTERFACE) -IMG_SID FindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_SID hParent) -#else IMG_HANDLE FindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hParent) -#endif { HAND_KEY aKey; @@ -1351,11 +1304,7 @@ IMG_HANDLE FindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDL InitKey(aKey, psBase, pvData, eType, hParent); -#if defined (SUPPORT_SID_INTERFACE) - return (IMG_SID) HASH_Retrieve_Extended(psBase->psHashTab, aKey); -#else return (IMG_HANDLE) HASH_Retrieve_Extended(psBase->psHashTab, aKey); -#endif } /*! @@ -1457,19 +1406,11 @@ static PVRSRV_ERROR EnsureFreeHandles(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui3 @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_SID hParent) -#else static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent) -#endif { IMG_UINT32 ui32NewIndex = DEFAULT_MAX_INDEX_PLUS_ONE; struct sHandle *psNewHandle = IMG_NULL; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHandle; -#else IMG_HANDLE hHandle; -#endif HAND_KEY aKey; PVRSRV_ERROR eError; @@ -1662,24 +1603,12 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag) -#else PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag) -#endif { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHandle; -#else IMG_HANDLE hHandle; -#endif PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - *phHandle = 0; -#else *phHandle = IMG_NULL; -#endif if (HANDLES_BATCHED(psBase)) { @@ -1697,11 +1626,7 @@ PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, { /* See if there is already a handle for this data pointer */ hHandle = FindHandle(psBase, pvData, eType, IMG_NULL); -#if defined (SUPPORT_SID_INTERFACE) - if (hHandle != 0) -#else if (hHandle != IMG_NULL) -#endif { struct sHandle *psHandle; @@ -1724,9 +1649,6 @@ PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, goto exit_ok; } -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif return PVRSRV_ERROR_HANDLE_NOT_SHAREABLE; } } @@ -1759,26 +1681,15 @@ exit_ok: @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_SID hParent) -#else PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent) -#endif { struct sHandle *psPHand; struct sHandle *psCHand; PVRSRV_ERROR eError; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hParentKey; - IMG_SID hHandle; - - *phHandle = 0; -#else IMG_HANDLE hParentKey; IMG_HANDLE hHandle; *phHandle = IMG_NULL; -#endif if (HANDLES_BATCHED(psBase)) { @@ -1806,11 +1717,7 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand { /* See if there is already a handle for this data pointer */ hHandle = FindHandle(psBase, pvData, eType, hParentKey); -#if defined (SUPPORT_SID_INTERFACE) - if (hHandle != 0) -#else if (hHandle != IMG_NULL) -#endif { struct sHandle *psCHandle; PVRSRV_ERROR eErr; @@ -1835,9 +1742,6 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand *phHandle = hHandle; goto exit_ok; } -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif return PVRSRV_ERROR_HANDLE_NOT_SHAREABLE; } } @@ -1886,26 +1790,14 @@ exit_ok: @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType) -#else PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType) -#endif { -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hHandle; -#else IMG_HANDLE hHandle; -#endif PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); /* See if there is a handle for this data pointer */ -#if defined (SUPPORT_SID_INTERFACE) - hHandle = (IMG_SID) FindHandle(psBase, pvData, eType, IMG_NULL); -#else hHandle = (IMG_HANDLE) FindHandle(psBase, pvData, eType, IMG_NULL); -#endif if (hHandle == IMG_NULL) { return PVRSRV_ERROR_HANDLE_NOT_FOUND; @@ -1933,11 +1825,7 @@ PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, PVRSRV_HANDLE_TYPE *peType, IMG_SID hHandle) -#else PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, PVRSRV_HANDLE_TYPE *peType, IMG_HANDLE hHandle) -#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; @@ -1946,9 +1834,7 @@ PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *pp if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupHandleAnyType: Error looking up handle (%d)", eError)); -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif + OSDumpStack(); return eError; } @@ -1974,27 +1860,18 @@ PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *pp @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) -#else PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) -#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); -#if defined (SUPPORT_SID_INTERFACE) - PVR_ASSERT(hHandle != 0); -#endif eError = GetHandleStructure(psBase, &psHandle, hHandle, eType); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupHandle: Error looking up handle (%d)", eError)); -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif + OSDumpStack(); return eError; } @@ -2020,25 +1897,19 @@ PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType, IMG_SID hAncestor) -#else PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hAncestor) -#endif { struct sHandle *psPHand; struct sHandle *psCHand; PVRSRV_ERROR eError; PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); -#if defined (SUPPORT_SID_INTERFACE) - PVR_ASSERT(hHandle != 0); -#endif eError = GetHandleStructure(psBase, &psCHand, hHandle, eType); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupSubHandle: Error looking up subhandle (%d)", eError)); + OSDumpStack(); return eError; } @@ -2076,11 +1947,7 @@ PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvDat not regarded as an error. ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phParent, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) -#else PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phParent, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) -#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; @@ -2091,6 +1958,7 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVGetParentHandle: Error looking up subhandle (%d)", eError)); + OSDumpStack(); return eError; } @@ -2116,11 +1984,7 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) -#else PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) -#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; @@ -2131,9 +1995,7 @@ PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupAndReleaseHandle: Error looking up handle (%d)", eError)); -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif + OSDumpStack(); return eError; } @@ -2157,11 +2019,7 @@ PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID @Return Error code or PVRSRV_OK ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) -#else PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) -#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; @@ -2172,6 +2030,7 @@ PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVReleaseHandle: Error looking up handle (%d)", eError)); + OSDumpStack(); return eError; } @@ -2683,7 +2542,7 @@ PVRSRV_ERROR PVRSRVHandleDeInit(IMG_VOID) } #else /* disable warning about empty module */ -#endif /* #if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) */ +#endif /* #if defined(PVR_SECURE_HANDLES) */ /****************************************************************************** End of file (handle.c) ******************************************************************************/ diff --git a/drivers/gpu/pvr/services4/srvkm/common/hash.c b/drivers/gpu/pvr/services4/srvkm/common/hash.c index 1569425109f..72432fd562c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/hash.c +++ b/drivers/gpu/pvr/services4/srvkm/common/hash.c @@ -425,8 +425,8 @@ HASH_Insert_Extended (HASH_TABLE *pHash, IMG_VOID *pKey, IMG_UINTPTR_T v) BUCKET *pBucket; PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Insert_Extended: Hash=0x%08x, pKey=0x%08x, v=0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey, v)); + "HASH_Insert_Extended: Hash=0x%p, pKey=0x%p, v=0x" UINTPTR_FMT, + pHash, pKey, v)); PVR_ASSERT (pHash != IMG_NULL); @@ -488,8 +488,8 @@ IMG_BOOL HASH_Insert (HASH_TABLE *pHash, IMG_UINTPTR_T k, IMG_UINTPTR_T v) { PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Insert: Hash=0x%x, k=0x%x, v=0x%x", - (IMG_UINTPTR_T)pHash, k, v)); + "HASH_Insert: Hash=0x%p, k=0x" UINTPTR_FMT ", v=0x" UINTPTR_FMT, + pHash, k, v)); return HASH_Insert_Extended(pHash, &k, v); } @@ -513,8 +513,8 @@ HASH_Remove_Extended(HASH_TABLE *pHash, IMG_VOID *pKey) BUCKET **ppBucket; IMG_UINT32 uIndex; - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove_Extended: Hash=0x%x, pKey=0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove_Extended: Hash=0x%p, pKey=0x%p", + pHash, pKey)); PVR_ASSERT (pHash != IMG_NULL); @@ -553,14 +553,14 @@ HASH_Remove_Extended(HASH_TABLE *pHash, IMG_VOID *pKey) } PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Remove_Extended: Hash=0x%x, pKey=0x%x = 0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey, v)); + "HASH_Remove_Extended: Hash=0x%p, pKey=0x%p = 0x" UINTPTR_FMT, + pHash, pKey, v)); return v; } } PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Remove_Extended: Hash=0x%x, pKey=0x%x = 0x0 !!!!", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + "HASH_Remove_Extended: Hash=0x%p, pKey=0x%p = 0x0 !!!!", + pHash, pKey)); return 0; } @@ -580,8 +580,8 @@ HASH_Remove_Extended(HASH_TABLE *pHash, IMG_VOID *pKey) IMG_UINTPTR_T HASH_Remove (HASH_TABLE *pHash, IMG_UINTPTR_T k) { - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove: Hash=0x%x, k=0x%x", - (IMG_UINTPTR_T)pHash, k)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove: Hash=0x%p, k=0x" UINTPTR_FMT, + pHash, k)); return HASH_Remove_Extended(pHash, &k); } @@ -605,8 +605,8 @@ HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey) BUCKET **ppBucket; IMG_UINT32 uIndex; - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve_Extended: Hash=0x%x, pKey=0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve_Extended: Hash=0x%p, pKey=0x%p", + pHash, pKey)); PVR_ASSERT (pHash != IMG_NULL); @@ -627,14 +627,14 @@ HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey) IMG_UINTPTR_T v = pBucket->v; PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Retrieve: Hash=0x%x, pKey=0x%x = 0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey, v)); + "HASH_Retrieve: Hash=0x%p, pKey=0x%p = 0x" UINTPTR_FMT, + pHash, pKey, v)); return v; } } PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Retrieve: Hash=0x%x, pKey=0x%x = 0x0 !!!!", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + "HASH_Retrieve: Hash=0x%p, pKey=0x%p = 0x0 !!!!", + pHash, pKey)); return 0; } @@ -653,8 +653,8 @@ HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey) IMG_UINTPTR_T HASH_Retrieve (HASH_TABLE *pHash, IMG_UINTPTR_T k) { - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve: Hash=0x%x, k=0x%x", - (IMG_UINTPTR_T)pHash, k)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve: Hash=0x%p, k=0x" UINTPTR_FMT, + pHash, k)); return HASH_Retrieve_Extended(pHash, &k); } diff --git a/drivers/gpu/pvr/services4/srvkm/common/lists.c b/drivers/gpu/pvr/services4/srvkm/common/lists.c index c6e1ee881a6..4ffdb0d3806 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/lists.c +++ b/drivers/gpu/pvr/services4/srvkm/common/lists.c @@ -75,6 +75,9 @@ IMPLEMENT_LIST_ANY_VA_2(PVRSRV_POWER_DEV, PVRSRV_ERROR, PVRSRV_OK) IMPLEMENT_LIST_INSERT(PVRSRV_POWER_DEV) IMPLEMENT_LIST_REMOVE(PVRSRV_POWER_DEV) +IMPLEMENT_LIST_ANY_2(PVRSRV_KERNEL_SYNC_INFO, PVRSRV_ERROR, PVRSRV_OK); +IMPLEMENT_LIST_INSERT(PVRSRV_KERNEL_SYNC_INFO) +IMPLEMENT_LIST_REMOVE(PVRSRV_KERNEL_SYNC_INFO) /*=================================================================== BELOW ARE IMPLEMENTED SOME COMMON CALLBACKS USED IN DIFFERENT FILES diff --git a/drivers/gpu/pvr/services4/srvkm/common/mem.c b/drivers/gpu/pvr/services4/srvkm/common/mem.c index cccdd24b01f..cccdd24b01f 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/mem.c +++ b/drivers/gpu/pvr/services4/srvkm/common/mem.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c b/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c index 04432b1f2c3..f79e7cb3d89 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c +++ b/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c @@ -86,12 +86,12 @@ extern "C" */ IMG_VOID OSCheckMemDebug(IMG_PVOID pvCpuVAddr, IMG_SIZE_T uSize, const IMG_CHAR *pszFileName, const IMG_UINT32 uLine) { - OSMEM_DEBUG_INFO const *psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINT32)pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); + OSMEM_DEBUG_INFO const *psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINTPTR_T)pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); /* invalid pointer */ if (pvCpuVAddr == IMG_NULL) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : null pointer" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : null pointer" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -102,7 +102,7 @@ extern "C" /* align */ if (((IMG_UINT32)pvCpuVAddr&3) != 0) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : invalid alignment" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : invalid alignment" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -113,7 +113,7 @@ extern "C" /*check guard region before*/ if (!MemCheck((IMG_PVOID)psInfo->sGuardRegionBefore, 0xB1, sizeof(psInfo->sGuardRegionBefore))) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : guard region before overwritten" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : guard region before overwritten" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -124,7 +124,9 @@ extern "C" /*check size*/ if (uSize != psInfo->uSize) { - PVR_DPF((PVR_DBG_WARNING, "Pointer 0x%X : supplied size was different to stored size (0x%X != 0x%X)" + PVR_DPF((PVR_DBG_WARNING, + "Pointer 0x%p : supplied size was different to stored size (0x%" + SIZE_T_FMT_LEN "X != 0x%" SIZE_T_FMT_LEN "X)" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, uSize, psInfo->uSize, pszFileName, uLine, @@ -135,7 +137,9 @@ extern "C" /*check size parity*/ if ((0x01234567 ^ psInfo->uSizeParityCheck) != psInfo->uSize) { - PVR_DPF((PVR_DBG_WARNING, "Pointer 0x%X : stored size parity error (0x%X != 0x%X)" + PVR_DPF((PVR_DBG_WARNING, + "Pointer 0x%p : stored size parity error (0x%" + SIZE_T_FMT_LEN "X != 0x%" SIZE_T_FMT_LEN "X)" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, psInfo->uSize, 0x01234567 ^ psInfo->uSizeParityCheck, pszFileName, uLine, @@ -151,9 +155,9 @@ extern "C" /*check padding after*/ if (uSize) { - if (!MemCheck((IMG_VOID*)((IMG_UINT32)pvCpuVAddr + uSize), 0xB2, TEST_BUFFER_PADDING_AFTER)) + if (!MemCheck((IMG_VOID*)((IMG_UINTPTR_T)pvCpuVAddr + uSize), 0xB2, TEST_BUFFER_PADDING_AFTER)) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : guard region after overwritten" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : guard region after overwritten" " - referenced from %s:%d - allocated from %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -164,7 +168,7 @@ extern "C" /* allocated... */ if (psInfo->eValid != isAllocated) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : not allocated (freed? %d)" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : not allocated (freed? %d)" " - referenced %s:%d - freed %s:%d", pvCpuVAddr, psInfo->eValid == isFree, pszFileName, uLine, @@ -223,12 +227,12 @@ extern "C" psInfo->uSizeParityCheck = 0x01234567 ^ ui32Size; /*point to the user data section*/ - *ppvCpuVAddr = (IMG_PVOID) ((IMG_UINT32)*ppvCpuVAddr)+TEST_BUFFER_PADDING_STATUS; + *ppvCpuVAddr = (IMG_PVOID) ((IMG_UINTPTR_T)*ppvCpuVAddr)+TEST_BUFFER_PADDING_STATUS; #ifdef PVRSRV_LOG_MEMORY_ALLOCS /*this is here to simplify the surounding logging macro, that is a expression maybe the macro should be an expression */ - PVR_TRACE(("Allocated pointer (after debug info): 0x%X from %s:%d", *ppvCpuVAddr, pszFilename, ui32Line)); + PVR_TRACE(("Allocated pointer (after debug info): 0x%p from %s:%d", *ppvCpuVAddr, pszFilename, ui32Line)); #endif return PVRSRV_OK; @@ -250,7 +254,7 @@ extern "C" OSMemSet(pvCpuVAddr, 0xBF, ui32Size + TEST_BUFFER_PADDING_AFTER); /*point to the starting address of the total allocated memory*/ - psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINT32) pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); + psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINTPTR_T) pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); /*update dbg info struct*/ psInfo->uSize = 0; diff --git a/drivers/gpu/pvr/services4/srvkm/common/metrics.c b/drivers/gpu/pvr/services4/srvkm/common/metrics.c index 7370ec16ed7..7370ec16ed7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/metrics.c +++ b/drivers/gpu/pvr/services4/srvkm/common/metrics.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c b/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c index 19ba9ea2be0..19ba9ea2be0 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c +++ b/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c b/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c index 2d96dc3a7e3..efedb61d7bc 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c +++ b/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c @@ -75,26 +75,9 @@ static IMG_UINT16 gui16MMUContextUsage = 0; IMG_UINT32 g_ui32EveryLineCounter = 1U; #endif -#ifdef INLINE_IS_PRAGMA -#pragma inline(_PDumpIsPersistent) -#endif -static INLINE -IMG_BOOL _PDumpIsPersistent(IMG_VOID) -{ - PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); - - if(psPerProc == IMG_NULL) - { - /* only occurs early in driver init, and init phase is already persistent */ - return IMG_FALSE; - } - return psPerProc->bPDumpPersistent; -} - #if defined(SUPPORT_PDUMP_MULTI_PROCESS) -static INLINE IMG_BOOL _PDumpIsProcessActive(IMG_VOID) { PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); @@ -226,6 +209,36 @@ PVRSRV_ERROR PDumpSetFrameKM(IMG_UINT32 ui32Frame) #endif } +static IMG_BOOL _PDumpWillCapture(IMG_UINT32 ui32Flags) +{ + /* + FIXME: + We really need to know if the PDump client is connected so we can + check if the continuous data will be saved or not. + */ + if ((ui32Flags & PDUMP_FLAGS_PERSISTENT) || (ui32Flags & PDUMP_FLAGS_CONTINUOUS)) + { + return IMG_TRUE; + } + else + { + return PDumpIsCaptureFrameKM(); + } +} + +IMG_BOOL PDumpWillCapture(IMG_UINT32 ui32Flags) +{ +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + if( _PDumpIsProcessActive() ) + { + return _PDumpWillCapture(ui32Flags); + } + return PVRSRV_OK; +#else + return _PDumpWillCapture(ui32Flags); +#endif +} + /************************************************************************** * Function Name : PDumpRegWithFlagsKM * Inputs : pszPDumpDevName, Register offset, and value to write @@ -240,16 +253,20 @@ PVRSRV_ERROR PDumpRegWithFlagsKM(IMG_CHAR *pszPDumpRegName, { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING() + + PDUMP_LOCK(); PDUMP_DBG(("PDumpRegWithFlagsKM")); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:0x%08X 0x%08X\r\n", pszPDumpRegName, ui32Reg, ui32Data); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -293,14 +310,10 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, PVRSRV_ERROR eErr; IMG_UINT32 ui32PollCount; - PDUMP_GET_SCRIPT_STRING(); + + PDUMP_LOCK(); PDUMP_DBG(("PDumpRegPolWithFlagsKM")); - if ( _PDumpIsPersistent() ) - { - /* Don't pdump-poll if the process is persistent */ - return PVRSRV_OK; - } ui32PollCount = POLL_COUNT_LONG; @@ -309,10 +322,12 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, ui32Mask, eOperator, ui32PollCount, POLL_DELAY); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -355,8 +370,8 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32NumBytes, IMG_UINT32 ui32PageSize, - IMG_BOOL bShared, - IMG_HANDLE hUniqueTag) + IMG_HANDLE hUniqueTag, + IMG_UINT32 ui32Flags) { PVRSRV_ERROR eErr; IMG_PUINT8 pui8LinAddr; @@ -364,16 +379,11 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_UINT32 ui32NumPages; IMG_DEV_PHYADDR sDevPAddr; IMG_UINT32 ui32Page; - IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; - + IMG_UINT32 ui32PageSizeShift = 0; + IMG_UINT32 ui32PageSizeTmp; PDUMP_GET_SCRIPT_STRING(); -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - /* Always dump physical pages backing a shared allocation */ - ui32Flags |= ( _PDumpIsPersistent() || bShared ) ? PDUMP_FLAGS_PERSISTENT : 0; -#else - PVR_UNREFERENCED_PARAMETER(bShared); - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; -#endif + + PDUMP_LOCK(); /* However, lin addr is only required in non-linux OSes */ #if !defined(LINUX) @@ -384,12 +394,22 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, PVR_ASSERT(((IMG_UINT32) ui32NumBytes & HOST_PAGEMASK) == 0); /* + Compute the amount to right-shift in order to divide by the page-size. + Required for 32-bit PAE kernels (thus phys addresses are 64-bits) where + 64-bit division is unsupported. + */ + ui32PageSizeTmp = ui32PageSize; + while (ui32PageSizeTmp >>= 1) + ui32PageSizeShift++; + + /* Write a comment to the PDump2 script streams indicating the memory allocation */ - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- MALLOC :%s:VA_%08X 0x%08X %u\r\n", - psDevID->pszPDumpDevName, ui32DevVAddr, ui32NumBytes, ui32PageSize); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- MALLOC :%s:VA_%08X 0x%08X %u (%d pages)\r\n", + psDevID->pszPDumpDevName, ui32DevVAddr, ui32NumBytes, ui32PageSize, ui32NumBytes / ui32PageSize); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -399,7 +419,7 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, */ pui8LinAddr = (IMG_PUINT8) pvLinAddr; ui32Offset = 0; - ui32NumPages = ui32NumBytes / ui32PageSize; + ui32NumPages = ui32NumBytes >> ui32PageSizeShift; while (ui32NumPages) { ui32NumPages--; @@ -415,24 +435,29 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, pui8LinAddr, ui32PageSize, &sDevPAddr); - ui32Page = (IMG_UINT32)(sDevPAddr.uiAddr / ui32PageSize); + ui32Page = (IMG_UINT32)(sDevPAddr.uiAddr >> ui32PageSizeShift); /* increment kernel virtual address */ pui8LinAddr += ui32PageSize; ui32Offset += ui32PageSize; - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_%08X%08X %u %u 0x%08X\r\n", + sDevPAddr.uiAddr = ui32Page * ui32PageSize; + + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_" UINTPTR_FMT DEVPADDR_FMT " %u %u 0x" DEVPADDR_FMT "\r\n", psDevID->pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, - ui32Page * ui32PageSize, + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr, ui32PageSize, ui32PageSize, - ui32Page * ui32PageSize); + sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); } + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -454,13 +479,13 @@ PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_DEV_PHYADDR sDevPAddr; - PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize - 1)) == 0); + ui32Flags |= PDUMP_FLAGS_CONTINUOUS; - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; - + /* Write a comment to the PDump2 script streams indicating the memory allocation */ @@ -472,6 +497,7 @@ PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, ui32PTSize); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -491,19 +517,22 @@ PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, ui32PTSize, &sDevPAddr); - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_%08X%08X 0x%X %u 0x%08X\r\n", + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_" UINTPTR_FMT DEVPADDR_FMT + " 0x%X %u 0x" DEVPADDR_FMT "\r\n", psDevId->pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr, ui32PTSize,//size ui32PTSize,//alignment sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -521,21 +550,20 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, IMG_UINT32 ui32PageSize, IMG_HANDLE hUniqueTag, IMG_BOOL bInterleaved, - IMG_BOOL bSparse) + IMG_BOOL bSparse, + IMG_UINT32 ui32Flags) { PVRSRV_ERROR eErr; IMG_UINT32 ui32NumPages, ui32PageCounter; IMG_DEV_PHYADDR sDevPAddr; - IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; PVRSRV_DEVICE_NODE *psDeviceNode; - PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); PVR_ASSERT(((IMG_UINT32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(((IMG_UINT32) ui32NumBytes & (ui32PageSize - 1)) == 0); psDeviceNode = psBMHeap->pBMContext->psDeviceNode; - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; /* Write a comment to the PDUMP2 script streams indicating the memory free @@ -544,22 +572,10 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, psDeviceNode->sDevId.pszPDumpDevName, sDevVAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - /* if we're dumping a shared heap, need to ensure phys allocation - * is freed even if this app isn't the one marked for pdumping - */ - { - PVRSRV_DEVICE_NODE *psDeviceNode = psBMHeap->pBMContext->psDeviceNode; - - if( psDeviceNode->pfnMMUIsHeapShared(psBMHeap->pMMUHeap) ) - { - ui32Flags |= PDUMP_FLAGS_PERSISTENT; - } - } -#endif PDumpOSWriteString2(hScript, ui32Flags); /* @@ -580,10 +596,13 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, PVR_ASSERT(sDevPAddr.uiAddr != 0); - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", - psDeviceNode->sDevId.pszPDumpDevName, (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_" UINTPTR_FMT DEVPADDR_FMT "\r\n", + psDeviceNode->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -595,6 +614,8 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, sDevVAddr.uiAddr += ui32PageSize; } + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -614,12 +635,10 @@ PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, { PVRSRV_ERROR eErr; IMG_DEV_PHYADDR sDevPAddr; - PDUMP_GET_SCRIPT_STRING(); - PVR_UNREFERENCED_PARAMETER(ui32PTSize); - ui32Flags |= PDUMP_FLAGS_CONTINUOUS; - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; + + PDUMP_LOCK(); /* override QAC warning about wrap around */ PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize-1UL)) == 0); /* PRQA S 3382 */ @@ -630,6 +649,7 @@ PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:PAGE_TABLE\r\n", psDevID->pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -650,17 +670,19 @@ PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, &sDevPAddr); { - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_" UINTPTR_FMT DEVPADDR_FMT "\r\n", psDevID->pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -684,8 +706,11 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, { PVRSRV_ERROR eErr; IMG_CHAR *pszRegString; + IMG_DEV_PHYADDR sDevPAddr; + PDUMP_GET_SCRIPT_STRING() - + + PDUMP_LOCK(); if(psMMUAttrib->pszPDRegRegion != IMG_NULL) { pszRegString = psMMUAttrib->pszPDRegRegion; @@ -699,14 +724,18 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, Write to the MMU script stream indicating the physical page directory */ #if defined(SGX_FEATURE_36BIT_MMU) + sDevPAddr.uiAddr = ((ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", + "WRW :%s:$1 :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag, - (ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr, + ui32Data & ~psMMUAttrib->ui32PDEMask); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -715,6 +744,7 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -725,25 +755,31 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); #else + sDevPAddr.uiAddr = ((ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "WRW :%s:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", + "WRW :%s:0x%08X :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", pszRegString, ui32Reg, psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, - (ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift, + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr, ui32Data & ~psMMUAttrib->ui32PDEMask); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); #endif + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -800,14 +836,10 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); if (PDumpOSIsSuspended()) { - return PVRSRV_OK; - } - - if ( _PDumpIsPersistent() ) - { - /* Don't pdump-poll if the process is persistent */ + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -831,6 +863,7 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, MEMPOLL_DELAY); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -864,11 +897,11 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "POL :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %d %d %d\r\n", + "POL :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %d %d %d\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), - sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask)), ui32Value, ui32Mask, eOperator, @@ -876,10 +909,12 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, MEMPOLL_DELAY); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -913,12 +948,13 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, IMG_UINT32 ui32ParamOutPos; PDUMP_MMU_ATTRIB *psMMUAttrib; IMG_UINT32 ui32DataPageSize; - PDUMP_GET_SCRIPT_AND_FILE_STRING(); - + + PDUMP_LOCK(); /* PRQA S 3415 1 */ /* side effects desired */ if (ui32Bytes == 0 || PDumpOSIsSuspended()) { + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -931,24 +967,10 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, if (!PDumpOSJTInitialised()) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - /* if we're dumping a shared heap, need to ensure phys allocation - * is initialised even if this app isn't the one marked for pdumping - */ - { - BM_HEAP *pHeap = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap; - PVRSRV_DEVICE_NODE *psDeviceNode = pHeap->pBMContext->psDeviceNode; - - if( psDeviceNode->pfnMMUIsHeapShared(pHeap->pMMUHeap) ) - { - ui32Flags |= PDUMP_FLAGS_PERSISTENT; - } - } -#endif - /* setup memory addresses */ if(pvAltLinAddr) { @@ -979,6 +1001,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, ui32Bytes, ui32Flags)) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } @@ -992,6 +1015,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, } if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } @@ -1000,9 +1024,9 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, */ eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "-- LDB :%s:VA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "-- LDB :%s:VA_" UINTPTR_FMT "%08X:0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, psMemInfo->sDevVAddr.uiAddr, ui32Offset, ui32Bytes, @@ -1010,6 +1034,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -1059,16 +1084,17 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "LDB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "LDB :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), - sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask)), ui32BlockBytes, ui32ParamOutPos, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -1092,6 +1118,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, ui32ParamOutPos += ui32BlockBytes; } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1191,26 +1218,35 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, IMG_UINT32 ui32BlockBytes; IMG_UINT8* pui8LinAddr; IMG_DEV_PHYADDR sDevPAddr; + IMG_DEV_PHYADDR sDevPAddrTmp; IMG_CPU_PHYADDR sCpuPAddr; IMG_UINT32 ui32Offset; IMG_UINT32 ui32ParamOutPos; IMG_UINT32 ui32PageMask; /* mask for the physical page backing the PT */ +#if !defined(SGX_FEATURE_36BIT_MMU) + IMG_DEV_PHYADDR sDevPAddrTmp2; +#endif PDUMP_GET_SCRIPT_AND_FILE_STRING(); - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; + + PDUMP_LOCK(); + if (PDumpOSIsSuspended()) { + PDUMP_UNLOCK(); return PVRSRV_OK; } if (!PDumpOSJTInitialised()) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } if (!pvLinAddr) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_INVALID_PARAMS; } @@ -1229,6 +1265,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, ui32Bytes, ui32Flags | PDUMP_FLAGS_CONTINUOUS)) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } @@ -1242,6 +1279,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, } if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } } @@ -1295,16 +1333,17 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, { eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "LDB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "LDB :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, + (IMG_UINTPTR_T)hUniqueTag1, sDevPAddr.uiAddr & ~ui32PageMask, - sDevPAddr.uiAddr & ui32PageMask, + (unsigned int)(sDevPAddr.uiAddr & ui32PageMask), ui32BlockBytes, ui32ParamOutPos, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1319,15 +1358,18 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, { /* PT entry points to non-null page */ #if defined(SGX_FEATURE_36BIT_MMU) + sDevPAddrTmp.uiAddr = ((ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift); + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", + "WRW :%s:$1 :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x0\r\n", psMMUAttrib->sDevId.pszPDumpDevName, psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag2, - (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift); + (IMG_UINTPTR_T)hUniqueTag2, + sDevPAddrTmp.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1336,6 +1378,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1345,36 +1388,44 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, ui32PTE & ~psMMUAttrib->ui32PDEMask); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); + sDevPAddrTmp.uiAddr = (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:$1\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:$1\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag1, - (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, - (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr + ui32Offset) & ui32PageMask), psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); #else + sDevPAddrTmp.uiAddr = (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask; + sDevPAddrTmp2.uiAddr = (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, - (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr + ui32Offset) & ui32PageMask), psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2, - (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift, - ui32PTE & ~psMMUAttrib->ui32PDEMask); + (IMG_UINTPTR_T)hUniqueTag2, + sDevPAddrTmp2.uiAddr, + (unsigned int)(ui32PTE & ~psMMUAttrib->ui32PDEMask)); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1385,17 +1436,20 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, #if !defined(FIX_HW_BRN_31620) PVR_ASSERT((ui32PTE & psMMUAttrib->ui32PTEValid) == 0UL); #endif + sDevPAddrTmp.uiAddr = (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X 0x%08X%08X\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X" UINTPTR_FMT "\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, - (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, - (ui32PTE << psMMUAttrib->ui32PTEAlignShift), - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2); + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr + ui32Offset) & ui32PageMask), + ui32PTE << psMMUAttrib->ui32PTEAlignShift, + (IMG_UINTPTR_T)hUniqueTag2); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1415,6 +1469,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, ui32ParamOutPos += ui32BlockBytes; } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1433,11 +1488,14 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_UINT32 ui32ParamOutPos; PDUMP_MMU_ATTRIB *psMMUAttrib; IMG_UINT32 ui32PageMask; /* mask for the physical page backing the PT */ + IMG_DEV_PHYADDR sDevPAddrTmp; PDUMP_GET_SCRIPT_AND_FILE_STRING(); + PDUMP_LOCK(); if (!PDumpOSJTInitialised()) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } @@ -1452,6 +1510,7 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, sizeof(IMG_DEV_PHYADDR), ui32Flags)) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } @@ -1465,24 +1524,28 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, } if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } /* Write a comment indicating the PD phys addr write, so that the offsets * into the param stream increase in correspondence with the number of bytes * written. */ + sDevPAddrTmp.uiAddr = sPDDevPAddr.uiAddr & ~ui32PageMask; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "-- LDB :%s:PA_0x%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "-- LDB :%s:PA_0x" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08" SIZE_T_FMT_LEN "X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - sPDDevPAddr.uiAddr & ~ui32PageMask, - sPDDevPAddr.uiAddr & ui32PageMask, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)(sPDDevPAddr.uiAddr & ui32PageMask), sizeof(IMG_DEV_PHYADDR), ui32ParamOutPos, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -1496,103 +1559,70 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); sDevPAddr.uiAddr += ui32PageByteOffset + ui32Offset; - if ((sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask) != 0UL) - { #if defined(SGX_FEATURE_36BIT_MMU) - eErr = PDumpOSBufprintf(hScript, - ui32MaxLenScript, - "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag2, - sPDDevPAddr.uiAddr); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); - - eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "AND :%s:$2 :%s:$1 0xFFFFFFFF\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + sDevPAddrTmp.uiAddr = sPDDevPAddr.uiAddr & ~ui32PageMask; - eErr = PDumpOSBufprintf(hScript, + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:$2\r\n", + "WRW :%s:$1 :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag1, - (sDevPAddr.uiAddr) & ~(psMMUAttrib->ui32DataPageMask), - (sDevPAddr.uiAddr) & (psMMUAttrib->ui32DataPageMask), - psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + psMMUAttrib->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag2, + sDevPAddrTmp.uiAddr, + (unsigned int)(sPDDevPAddr.uiAddr & ui32PageMask)); + if(eErr != PVRSRV_OK) + { + PDUMP_UNLOCK(); + return eErr; + } + PDumpOSWriteString2(hScript, ui32Flags); - eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "SHR :%s:$2 :%s:$1 0x20\r\n", + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "SHR :%s:$1 :%s:$1 0x4\r\n", psMMUAttrib->sDevId.pszPDumpDevName, psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + if(eErr != PVRSRV_OK) + { + PDUMP_UNLOCK(); + return eErr; + } - eErr = PDumpOSBufprintf(hScript, + PDumpOSWriteString2(hScript, ui32Flags); + sDevPAddrTmp.uiAddr = sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask); + + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:$2\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:$1\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag1, - (sDevPAddr.uiAddr + 4) & ~(psMMUAttrib->ui32DataPageMask), - (sDevPAddr.uiAddr + 4) & (psMMUAttrib->ui32DataPageMask), + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr) & (psMMUAttrib->ui32DataPageMask)), psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); -#else - eErr = PDumpOSBufprintf(hScript, - ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - sDevPAddr.uiAddr & ~ui32PageMask, - sDevPAddr.uiAddr & ui32PageMask, - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2, - sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask, - sPDDevPAddr.uiAddr & ~psMMUAttrib->ui32PDEMask); - if(eErr != PVRSRV_OK) - { - return eErr; - } -#endif + if(eErr != PVRSRV_OK) + { + PDUMP_UNLOCK(); + return eErr; } - else +#else + eErr = PDumpOSBufprintf(hScript, + ui32MaxLenScript, + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X \r\n", + psMMUAttrib->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddr.uiAddr & ~ui32PageMask, + (unsigned int)(sDevPAddr.uiAddr & ui32PageMask), + psMMUAttrib->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag2, + sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask, + (unsigned int)(sPDDevPAddr.uiAddr & ~psMMUAttrib->ui32PDEMask)); + if(eErr != PVRSRV_OK) { - PVR_ASSERT(!(sDevPAddr.uiAddr & psMMUAttrib->ui32PTEValid)); - eErr = PDumpOSBufprintf(hScript, - ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X 0x%08X\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - sDevPAddr.uiAddr & ~ui32PageMask, - sDevPAddr.uiAddr & ui32PageMask, - sPDDevPAddr.uiAddr); - if(eErr != PVRSRV_OK) - { - return eErr; - } + PDUMP_UNLOCK(); + return eErr; } +#endif PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1612,13 +1642,10 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) #endif IMG_UINT32 ui32LenCommentPrefix; PDUMP_GET_SCRIPT_STRING(); + + PDUMP_LOCK(); PDUMP_DBG(("PDumpCommentKM")); -#if defined(PDUMP_DEBUG_OUTFILES) - /* include comments in the "extended" init phase. - * default is to ignore them. - */ - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; -#endif + /* Put \r \n sequence at the end if it isn't already there */ PDumpOSVerifyLineEnding(pszComment, ui32MaxLen); @@ -1637,23 +1664,27 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) { PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s (continuous set)", g_ui32EveryLineCounter, pszComment)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } else if(ui32Flags & PDUMP_FLAGS_PERSISTENT) { PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s (persistent set)", g_ui32EveryLineCounter, pszComment)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } else { PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s", g_ui32EveryLineCounter, pszComment)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } #else PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %s", pszComment)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; #endif } @@ -1675,9 +1706,12 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) if( (eErr != PVRSRV_OK) && (eErr != PVRSRV_ERROR_PDUMP_BUF_OVERFLOW)) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1696,6 +1730,7 @@ PVRSRV_ERROR PDumpCommentWithFlags(IMG_UINT32 ui32Flags, IMG_CHAR * pszFormat, . PDUMP_va_list ap; PDUMP_GET_MSG_STRING(); + PDUMP_LOCK_MSG(); /* Construct the string */ PDUMP_va_start(ap, pszFormat); eErr = PDumpOSVSprintf(pszMsg, ui32MaxLen, pszFormat, ap); @@ -1703,9 +1738,12 @@ PVRSRV_ERROR PDumpCommentWithFlags(IMG_UINT32 ui32Flags, IMG_CHAR * pszFormat, . if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK_MSG(); return eErr; } - return PDumpCommentKM(pszMsg, ui32Flags); + eErr = PDumpCommentKM(pszMsg, ui32Flags); + PDUMP_UNLOCK_MSG(); + return eErr; } /************************************************************************** @@ -1723,6 +1761,7 @@ PVRSRV_ERROR PDumpComment(IMG_CHAR *pszFormat, ...) PDUMP_va_list ap; PDUMP_GET_MSG_STRING(); + PDUMP_LOCK_MSG(); /* Construct the string */ PDUMP_va_start(ap, pszFormat); eErr = PDumpOSVSprintf(pszMsg, ui32MaxLen, pszFormat, ap); @@ -1730,9 +1769,12 @@ PVRSRV_ERROR PDumpComment(IMG_CHAR *pszFormat, ...) if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK_MSG(); return eErr; } - return PDumpCommentKM(pszMsg, PDUMP_FLAGS_CONTINUOUS); + eErr = PDumpCommentKM(pszMsg, PDUMP_FLAGS_CONTINUOUS); + PDUMP_UNLOCK_MSG(); + return eErr; } /************************************************************************** @@ -1748,10 +1790,12 @@ PVRSRV_ERROR PDumpDriverInfoKM(IMG_CHAR *pszString, IMG_UINT32 ui32Flags) IMG_UINT32 ui32MsgLen; PDUMP_GET_MSG_STRING(); + PDUMP_LOCK_MSG(); /* Construct the string */ eErr = PDumpOSSprintf(pszMsg, ui32MaxLen, "%s", pszString); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK_MSG(); return eErr; } @@ -1766,13 +1810,17 @@ PVRSRV_ERROR PDumpDriverInfoKM(IMG_CHAR *pszString, IMG_UINT32 ui32Flags) { if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) { + PDUMP_UNLOCK_MSG(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } else { + PDUMP_UNLOCK_MSG(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } } + + PDUMP_UNLOCK_MSG(); return PVRSRV_OK; } @@ -1818,13 +1866,9 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); - if ( _PDumpIsPersistent() ) - { - return PVRSRV_OK; - } - PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); + PDUMP_LOCK(); /* find MMU context ID */ ui32MMUContextID = psDeviceNode->pfnMMUGetContextID( hDevMemContext ); @@ -1845,10 +1889,13 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, eMemFormat); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2( hScript, ui32PDumpFlags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1880,9 +1927,9 @@ PVRSRV_ERROR PDumpReadRegKM ( IMG_CHAR *pszPDumpRegName, { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); - PVR_UNREFERENCED_PARAMETER(ui32Size); + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SAB :%s:0x%08X 0x%08X %s\r\n", @@ -1892,11 +1939,13 @@ PVRSRV_ERROR PDumpReadRegKM ( IMG_CHAR *pszPDumpRegName, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2( hScript, ui32PDumpFlags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1954,6 +2003,7 @@ static PVRSRV_ERROR PDumpSignatureRegister (PVRSRV_DEVICE_IDENTIFIER *psDevId, PDumpOSWriteString2(hScript, ui32Flags); *pui32FileOffset += ui32Size; + return PVRSRV_OK; } @@ -2000,7 +2050,6 @@ PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_UINT32 ui32FileOffset, ui32Flags; - PDUMP_GET_FILE_STRING(); ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; @@ -2013,6 +2062,12 @@ PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, return eErr; } + /* + Note: + PDumpCommentWithFlags will take the lock so we defer the lock + taking until here + */ + PDUMP_LOCK(); PDumpRegisterRange(psDevId, pszFileName, pui32Registers, @@ -2021,6 +2076,7 @@ PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, sizeof(IMG_UINT32), ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2044,7 +2100,6 @@ PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_UINT32 ui32FileOffset, ui32Flags; - PDUMP_GET_FILE_STRING(); ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; @@ -2057,6 +2112,12 @@ PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, return eErr; } + /* + Note: + PDumpCommentWithFlags will take the lock so we defer the lock + taking until here + */ + PDUMP_LOCK(); PDumpRegisterRange(psDevId, pszFileName, pui32Registers, @@ -2064,6 +2125,7 @@ PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, &ui32FileOffset, sizeof(IMG_UINT32), ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2085,7 +2147,6 @@ PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_UINT32 ui32FileOffset, ui32Flags; - PDUMP_GET_FILE_STRING(); ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0UL; @@ -2097,7 +2158,12 @@ PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, { return eErr; } - + /* + Note: + PDumpCommentWithFlags will take the lock so we defer the lock + taking until here + */ + PDUMP_LOCK(); PDumpRegisterRange(psDevId, pszFileName, pui32Registers, @@ -2106,6 +2172,7 @@ PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, sizeof(IMG_UINT32), ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2124,14 +2191,18 @@ PVRSRV_ERROR PDumpRegRead(IMG_CHAR *pszPDumpRegName, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "RDW :%s:0x%X\r\n", pszPDumpRegName, ui32RegOffset); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2156,7 +2227,8 @@ PVRSRV_ERROR PDumpSaveMemKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); - + + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SAB :%s:v%x:0x%08X 0x%08X 0x%08X %s.bin\r\n", @@ -2168,10 +2240,13 @@ PVRSRV_ERROR PDumpSaveMemKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32PDumpFlags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2189,14 +2264,18 @@ PVRSRV_ERROR PDumpCycleCountRegRead(PVRSRV_DEVICE_IDENTIFIER *psDevId, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "RDW :%s:0x%X\r\n", psDevId->pszPDumpRegName, ui32RegOffset); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2286,9 +2365,9 @@ PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, IMG_DEV_VIRTADDR sDevVPageAddr; //IMG_CPU_PHYADDR CpuPAddr; PDUMP_MMU_ATTRIB *psMMUAttrib; - PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); psMMUAttrib = ((BM_BUF*)psROffMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; /* Check the offset and size don't exceed the bounds of the allocation */ @@ -2324,19 +2403,22 @@ PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "CBP :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X 0x%08X\r\n", + "CBP :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X 0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), - sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask)), ui32WPosVal, ui32PacketSize, ui32BufferSize); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2352,14 +2434,19 @@ PVRSRV_ERROR PDumpIDLWithFlags(IMG_UINT32 ui32Clocks, IMG_UINT32 ui32Flags) { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + + PDUMP_LOCK(); PDUMP_DBG(("PDumpIDLWithFlags")); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "IDL %u\r\n", ui32Clocks); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2617,10 +2704,13 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); + eErr = _PdumpAllocMMUContext(&ui32MMUContextID); if(eErr != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PDumpSetMMUContext: _PdumpAllocMMUContext failed: %d", eErr)); + PDUMP_UNLOCK(); return eErr; } @@ -2633,15 +2723,16 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "MMU :%s:v%d %d :%s:PA_%08X%08X\r\n", + "MMU :%s:v%d %d :%s:PA_" UINTPTR_FMT DEVPADDR_FMT "\r\n", pszMemSpace, ui32MMUContextID, ui32MMUType, pszMemSpace, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, + (IMG_UINTPTR_T)hUniqueTag1, sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); @@ -2649,6 +2740,7 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, /* return the MMU Context ID */ *pui32MMUContextID = ui32MMUContextID; + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2674,6 +2766,12 @@ PVRSRV_ERROR PDumpClearMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, * all OSes and platforms */ PDumpComment("Clear MMU Context for memory space %s\r\n", pszMemSpace); + + /* + Note: + PDumpComment takes the lock so we can't take it until here + */ + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MMU :%s:v%d\r\n", @@ -2681,17 +2779,21 @@ PVRSRV_ERROR PDumpClearMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, ui32MMUContextID); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } + PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); eErr = _PdumpFreeMMUContext(ui32MMUContextID); if(eErr != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PDumpClearMMUContext: _PdumpFreeMMUContext failed: %d", eErr)); + PDUMP_UNLOCK(); return eErr; } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2719,6 +2821,7 @@ PVRSRV_ERROR PDumpStoreMemToFile(PDUMP_MMU_ATTRIB *psMMUAttrib, PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); /* query the buffer manager for the physical pages that back the virtual address @@ -2736,17 +2839,18 @@ PVRSRV_ERROR PDumpStoreMemToFile(PDUMP_MMU_ATTRIB *psMMUAttrib, PDumpOSBufprintf(hScript, ui32MaxLen, - "SAB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "SAB :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, - sDevPAddr.uiAddr & ~psMMUAttrib->ui32DataPageMask, - sDevPAddr.uiAddr & psMMUAttrib->ui32DataPageMask, + (IMG_UINTPTR_T)hUniqueTag, + (sDevPAddr.uiAddr & ~psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & psMMUAttrib->ui32DataPageMask), ui32Size, ui32FileOffset, pszFileName); PDumpOSWriteString2(hScript, ui32PDumpFlags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2768,6 +2872,8 @@ PVRSRV_ERROR PDumpRegBasedCBP(IMG_CHAR *pszPDumpRegName, { PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); + PDumpOSBufprintf(hScript, ui32MaxLen, "CBP :%s:0x%08X 0x%08X 0x%08X 0x%08X\r\n", @@ -2777,7 +2883,8 @@ PVRSRV_ERROR PDumpRegBasedCBP(IMG_CHAR *pszPDumpRegName, ui32PacketSize, ui32BufferSize); PDumpOSWriteString2(hScript, ui32Flags); - + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2843,7 +2950,7 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC /* Return if process is not marked for pdumping, unless it's persistent. */ if ( (_PDumpIsProcessActive() == IMG_FALSE ) && - ((ui32Flags & PDUMP_FLAGS_PERSISTENT) == 0) ) + ((ui32Flags & PDUMP_FLAGS_PERSISTENT) == 0) && psCtrl->bInitPhaseComplete) { return ui32BCount; } @@ -2867,6 +2974,7 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC if (ui32BytesWritten == 0) { + PVR_DPF((PVR_DBG_ERROR, "DbgWrite: Failed to send persistent data")); PDumpOSReleaseExecution(); } @@ -2893,7 +3001,8 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC while (((IMG_UINT32) ui32BCount > 0) && (ui32BytesWritten != 0xFFFFFFFFU)) { - if ((ui32Flags & PDUMP_FLAGS_CONTINUOUS) != 0) + /* If we're in the init phase we treat persisent as meaning continuous */ + if (((ui32Flags & PDUMP_FLAGS_CONTINUOUS) != 0) || ((ui32Flags & PDUMP_FLAGS_PERSISTENT) != 0)) { /* If pdump client (or its equivalent) isn't running then throw continuous data away. @@ -2942,6 +3051,10 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC */ if (ui32BytesWritten == 0) { + if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) + { + PVR_DPF((PVR_DBG_ERROR, "Buffer is full during writing of %s", &pui8Data[ui32Off])); + } PDumpOSReleaseExecution(); } @@ -2950,7 +3063,13 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC ui32Off += ui32BytesWritten; ui32BCount -= ui32BytesWritten; } - + else + { + if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) + { + PVR_DPF((PVR_DBG_ERROR, "Error during writing of %s", &pui8Data[ui32Off])); + } + } /* loop exits when i) all data is written, or ii) an unrecoverable error occurs */ } diff --git a/drivers/gpu/pvr/services4/srvkm/common/perproc.c b/drivers/gpu/pvr/services4/srvkm/common/perproc.c index 3918bb20eb5..3918bb20eb5 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/perproc.c +++ b/drivers/gpu/pvr/services4/srvkm/common/perproc.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/power.c b/drivers/gpu/pvr/services4/srvkm/common/power.c index 511a690d4e4..511a690d4e4 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/power.c +++ b/drivers/gpu/pvr/services4/srvkm/common/power.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c b/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c index 1b5312c02d0..ea1fcaf319d 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c +++ b/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c @@ -48,24 +48,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pdump_km.h" #include "deviceid.h" #include "ra.h" -#if defined(__linux__) -#include "sysfs.h" -#endif #if defined(TTRACE) #include "ttrace.h" #endif #include "perfkm.h" +#include "devicemem.h" #include "pvrversion.h" #include "lists.h" IMG_UINT32 g_ui32InitFlags; -extern int powering_down; /* mark which parts of Services were initialised */ #define INIT_DATA_ENABLE_PDUMPINIT 0x1U -#define INIT_DATA_ENABLE_TTARCE 0x2U +#define INIT_DATA_ENABLE_TTRACE 0x2U +#define INIT_DATA_ENABLE_DEVMEM 0x4U /*! ****************************************************************************** @@ -158,7 +156,37 @@ PVRSRV_ERROR FreeDeviceID(SYS_DATA *psSysData, IMG_UINT32 ui32DevID) return PVRSRV_ERROR_INVALID_DEVICEID; } +/*! +****************************************************************************** + + @Function PVRSRVCompatCheckKM + + @Description UM/KM ddk branch Compatibility check function + + @input psUserModeDDKDetails: User mode DDK version + + @output In case of incompatibility, returns PVRSRV_ERROR_DDK_VERSION_MISMATCH + @Return PVRSRV_ERROR + +******************************************************************************/ +IMG_VOID IMG_CALLCONV PVRSRVCompatCheckKM(PVRSRV_BRIDGE_IN_COMPAT_CHECK *psUserModeDDKDetails, PVRSRV_BRIDGE_RETURN *psRetOUT) +{ + + if(psUserModeDDKDetails->ui32DDKVersion != ((PVRVERSION_MAJ << 16) | (PVRVERSION_MIN << 8)) + || (psUserModeDDKDetails->ui32DDKBuild != PVRVERSION_BUILD)) + { + psRetOUT->eError = PVRSRV_ERROR_DDK_VERSION_MISMATCH; + PVR_DPF((PVR_DBG_ERROR, "(FAIL) UM-KM DDK Mismatch UM-(%d) KM-(%d).", + psUserModeDDKDetails->ui32DDKBuild, PVRVERSION_BUILD)); + } + else + { + psRetOUT->eError = PVRSRV_OK; + PVR_DPF((PVR_DBG_MESSAGE, "UM DDK-(%d) and KM DDK-(%d) match. [ OK ]", + psUserModeDDKDetails->ui32DDKBuild ,PVRVERSION_BUILD)); + } +} /*! ****************************************************************************** @@ -207,8 +235,8 @@ IMG_UINT32 ReadHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset) IMG_EXPORT IMG_VOID WriteHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value) { - PVR_DPF((PVR_DBG_MESSAGE,"WriteHWReg Base:%x, Offset: %x, Value %x", - (IMG_UINTPTR_T)pvLinRegBaseAddr,ui32Offset,ui32Value)); + PVR_DPF((PVR_DBG_MESSAGE,"WriteHWReg Base:%p, Offset: %x, Value %x", + pvLinRegBaseAddr,ui32Offset,ui32Value)); *(IMG_UINT32*)((IMG_UINTPTR_T)pvLinRegBaseAddr+ui32Offset) = ui32Value; } @@ -366,14 +394,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) { PVRSRV_ERROR eError; -#if defined(__linux__) - eError = PVRSRVCreateSysfsEntry(); - if (eError != PVRSRV_OK) - { - goto Error; - } -#endif - /* Initialise Resource Manager */ eError = ResManInit(); if (eError != PVRSRV_OK) @@ -406,16 +426,16 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; /* Create an event object */ - if(OSAllocMem( PVRSRV_PAGEABLE_SELECT, + if((eError = OSAllocMem( PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_EVENTOBJECT) , (IMG_VOID **)&psSysData->psGlobalEventObject, 0, - "Event Object") != PVRSRV_OK) + "Event Object")) != PVRSRV_OK) { goto Error; } - if(OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) + if((eError = OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject)) != PVRSRV_OK) { goto Error; } @@ -429,12 +449,21 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) eError = PVRSRVTimeTraceInit(); if (eError != PVRSRV_OK) goto Error; - g_ui32InitFlags |= INIT_DATA_ENABLE_TTARCE; + g_ui32InitFlags |= INIT_DATA_ENABLE_TTRACE; #endif +#if defined(PDUMP) /* Initialise pdump */ PDUMPINIT(); g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; +#endif + +#if defined(SUPPORT_ION) + eError = PVRSRVInitDeviceMem(); + if (eError != PVRSRV_OK) + goto Error; + g_ui32InitFlags |= INIT_DATA_ENABLE_DEVMEM; +#endif PERFINIT(); return eError; @@ -472,19 +501,35 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData) PERFDEINIT(); + +#if defined(SUPPORT_ION) + if ((g_ui32InitFlags & INIT_DATA_ENABLE_DEVMEM) > 0) + { + PVRSRVDeInitDeviceMem(); + } +#endif + +#if defined(MEM_TRACK_INFO_DEBUG) + /* Free the list of memory operations */ + PVRSRVFreeMemOps(); +#endif + #if defined(TTRACE) /* deinitialise ttrace */ - if ((g_ui32InitFlags & INIT_DATA_ENABLE_TTARCE) > 0) + if ((g_ui32InitFlags & INIT_DATA_ENABLE_TTRACE) > 0) { PVRSRVTimeTraceDeinit(); } #endif + +#if defined(PDUMP) /* deinitialise pdump */ if( (g_ui32InitFlags & INIT_DATA_ENABLE_PDUMPINIT) > 0) { PDUMPDEINIT(); } - +#endif + /* destroy event object */ if(psSysData->psGlobalEventObject) { @@ -1148,11 +1193,7 @@ static PVRSRV_ERROR PVRSRVGetMiscInfoKM_Device_AnyVaCb(PVRSRV_DEVICE_NODE *psDev ******************************************************************************/ IMG_EXPORT -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO_KM *psMiscInfo) -#else PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) -#endif { SYS_DATA *psSysData; @@ -1338,16 +1379,10 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } else { -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo = psMiscInfo->sCacheOpCtl.psKernelMemInfo; - - if(!psMiscInfo->sCacheOpCtl.psKernelMemInfo) -#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_PER_PROCESS_DATA *psPerProc; if(!psMiscInfo->sCacheOpCtl.u.psKernelMemInfo) -#endif { PVR_DPF((PVR_DBG_WARNING, "PVRSRVGetMiscInfoKM: " "Ignoring non-deferred cache op with no meminfo")); @@ -1361,9 +1396,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) "to combine deferred cache ops with immediate ones")); } -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#else psPerProc = PVRSRVFindPerProcessData(); if(PVRSRVLookupHandle(psPerProc->psHandleBase, @@ -1375,7 +1407,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) "Can't find kernel meminfo")); return PVRSRV_ERROR_INVALID_PARAMS; } -#endif if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH) { @@ -1389,12 +1420,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } else if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_CLEAN) { - if(!OSCleanCPUCacheRangeKM(psKernelMemInfo->sMemBlk.hOSMemHandle, - 0, - psMiscInfo->sCacheOpCtl.pvBaseVAddr, - psMiscInfo->sCacheOpCtl.ui32Length)) + if(psMiscInfo->sCacheOpCtl.ui32Length!=0) { - return PVRSRV_ERROR_CACHEOP_FAILED; + if(!OSCleanCPUCacheRangeKM(psKernelMemInfo->sMemBlk.hOSMemHandle, + 0, + psMiscInfo->sCacheOpCtl.pvBaseVAddr, + psMiscInfo->sCacheOpCtl.ui32Length)) + { + return PVRSRV_ERROR_CACHEOP_FAILED; + } } } } @@ -1402,16 +1436,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) if((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT) != 0UL) { -#if !defined (SUPPORT_SID_INTERFACE) PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_PER_PROCESS_DATA *psPerProc; -#endif psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT; -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#else psPerProc = PVRSRVFindPerProcessData(); if(PVRSRVLookupHandle(psPerProc->psHandleBase, @@ -1425,7 +1454,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } psMiscInfo->sGetRefCountCtl.ui32RefCount = psKernelMemInfo->ui32RefCount; -#endif } if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT) != 0UL) @@ -1442,11 +1470,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } #endif /* #if defined(PVRSRV_RESET_ON_HWTIMEOUT) */ +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT) != 0UL) { - PVRSRVSetDCState(DC_STATE_FORCE_SWAP_TO_SYSTEM); + PVRSRVProcessQueues(IMG_TRUE); psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT; } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ return PVRSRV_OK; } @@ -1486,9 +1516,8 @@ IMG_BOOL IMG_CALLCONV PVRSRVDeviceLISR(PVRSRV_DEVICE_NODE *psDeviceNode) { bStatus = (*psDeviceNode->pfnDeviceISR)(psDeviceNode->pvISRData); } - if(!powering_down) { - SysClearInterrupts(psSysData, psDeviceNode->ui32SOCInterruptBit); - } + + SysClearInterrupts(psSysData, psDeviceNode->ui32SOCInterruptBit); } out: @@ -1605,11 +1634,13 @@ IMG_VOID IMG_CALLCONV PVRSRVMISR(IMG_VOID *pvSysData) List_PVRSRV_DEVICE_NODE_ForEach(psSysData->psDeviceNodeList, &PVRSRVMISR_ForEachCb); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /* Process the queues. */ if (PVRSRVProcessQueues(IMG_FALSE) == PVRSRV_ERROR_PROCESSING_BLOCKED) { PVRSRVProcessQueues(IMG_FALSE); } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ /* signal global event object */ if (psSysData->psGlobalEventObject) @@ -1706,7 +1737,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSaveRestoreLiveSegments(IMG_HANDLE hArena, IMG_P return (PVRSRV_ERROR_OUT_OF_MEMORY); } - PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVSaveRestoreLiveSegments: Base %08x size %08x", sSegDetails.sCpuPhyAddr.uiAddr, sSegDetails.uiSize)); + PVR_DPF(( + PVR_DBG_MESSAGE, + "PVRSRVSaveRestoreLiveSegments: Base " CPUPADDR_FMT " size %" SIZE_T_FMT_LEN "x", + sSegDetails.sCpuPhyAddr.uiAddr, + sSegDetails.uiSize)); /* Map the device's local memory area onto the host. */ pvLocalMemCPUVAddr = OSMapPhysToLin(sSegDetails.sCpuPhyAddr, diff --git a/drivers/gpu/pvr/services4/srvkm/common/queue.c b/drivers/gpu/pvr/services4/srvkm/common/queue.c index 88b05a4c795..cddd6f9def5 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/queue.c +++ b/drivers/gpu/pvr/services4/srvkm/common/queue.c @@ -45,15 +45,47 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lists.h" #include "ttrace.h" +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include <linux/version.h> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) +#include <linux/sw_sync.h> +#else +#include <../drivers/staging/android/sw_sync.h> +#endif +static struct sync_fence *AllocQueueFence(struct sw_sync_timeline *psTimeline, IMG_UINT32 ui32FenceValue, const char *szName) +{ + struct sync_fence *psFence = IMG_NULL; + struct sync_pt *psPt; + + psPt = sw_sync_pt_create(psTimeline, ui32FenceValue); + if(psPt) + { + psFence = sync_fence_create(szName, psPt); + if(!psFence) + { + sync_pt_free(psPt); + } + } + + return psFence; +} +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + /* * The number of commands of each type which can be in flight at once. */ + +#define DC_MAX_SUPPORTED_QUEUES 1 #if defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) -#define DC_NUM_COMMANDS_PER_TYPE 2 +#define DC_NUM_COMMANDS_PER_QUEUE 2 #else -#define DC_NUM_COMMANDS_PER_TYPE 1 +#define DC_NUM_COMMANDS_PER_QUEUE 1 #endif +#define DC_NUM_COMMANDS_PER_TYPE (DC_NUM_COMMANDS_PER_QUEUE * DC_MAX_SUPPORTED_QUEUES) + +static IMG_UINT32 ui32NoOfSwapchainCreated = 0; + /* * List of private command processing function pointer tables and command * complete tables for a device in the system. @@ -87,8 +119,8 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) { PVRSRV_QUEUE_INFO *psQueue = (PVRSRV_QUEUE_INFO*)el; IMG_INT cmds = 0; - IMG_SIZE_T ui32ReadOffset; - IMG_SIZE_T ui32WriteOffset; + IMG_SIZE_T uReadOffset; + IMG_SIZE_T uWriteOffset; PVRSRV_COMMAND *psCmd; if(el == PVR_PROC_SEQ_START_TOKEN) @@ -99,16 +131,16 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) return; } - ui32ReadOffset = psQueue->ui32ReadOffset; - ui32WriteOffset = psQueue->ui32WriteOffset; + uReadOffset = psQueue->uReadOffset; + uWriteOffset = psQueue->uWriteOffset; - while (ui32ReadOffset != ui32WriteOffset) + while (uReadOffset != uWriteOffset) { - psCmd= (PVRSRV_COMMAND *)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + ui32ReadOffset); + psCmd= (PVRSRV_COMMAND *)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + uReadOffset); - seq_printf(sfile, "%x %x %5u %6u %3u %5u %2u %2u %3u \n", - (IMG_UINTPTR_T)psQueue, - (IMG_UINTPTR_T)psCmd, + seq_printf(sfile, "%p %p %5u %6u %3" SIZE_T_FMT_LEN "u %5u %2u %2u %3" SIZE_T_FMT_LEN "u \n", + psQueue, + psCmd, psCmd->ui32ProcessID, psCmd->CommandType, psCmd->uCmdSize, @@ -133,14 +165,14 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) } /* taken from UPDATE_QUEUE_ROFF in queue.h */ - ui32ReadOffset += psCmd->uCmdSize; - ui32ReadOffset &= psQueue->ui32QueueSize - 1; + uReadOffset += psCmd->uCmdSize; + uReadOffset &= psQueue->uQueueSize - 1; cmds++; } if (cmds == 0) { - seq_printf(sfile, "%x <empty>\n", (IMG_UINTPTR_T)psQueue); + seq_printf(sfile, "%p <empty>\n", psQueue); } } @@ -181,15 +213,15 @@ void* ProcSeqOff2ElementQueue(struct seq_file * sfile, loff_t off) * Macro to return space in given command queue */ #define GET_SPACE_IN_CMDQ(psQueue) \ - ((((psQueue)->ui32ReadOffset - (psQueue)->ui32WriteOffset) \ - + ((psQueue)->ui32QueueSize - 1)) & ((psQueue)->ui32QueueSize - 1)) + ((((psQueue)->uReadOffset - (psQueue)->uWriteOffset) \ + + ((psQueue)->uQueueSize - 1)) & ((psQueue)->uQueueSize - 1)) /*! * Macro to Write Offset in given command queue */ -#define UPDATE_QUEUE_WOFF(psQueue, ui32Size) \ - (psQueue)->ui32WriteOffset = ((psQueue)->ui32WriteOffset + (ui32Size)) \ - & ((psQueue)->ui32QueueSize - 1); +#define UPDATE_QUEUE_WOFF(psQueue, uSize) \ + (psQueue)->uWriteOffset = ((psQueue)->uWriteOffset + (uSize)) \ + & ((psQueue)->uQueueSize - 1); /*! * Check if an ops complete value has gone past the pending value. @@ -227,7 +259,7 @@ IMG_UINT32 PVRSRVGetWriteOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOO Note: This needs to be atomic and is provided the kernel driver is single threaded (non-rentrant) */ - ui32WriteOpsPending = psSyncInfo->psSyncData->ui32WriteOpsPending++; + ui32WriteOpsPending = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_QUEUE); } return ui32WriteOpsPending; @@ -254,7 +286,7 @@ IMG_UINT32 PVRSRVGetReadOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL if(bIsReadOp) { - ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOps2Pending++; + ui32ReadOpsPending = SyncTakeReadOp2(psSyncInfo, SYNC_OP_CLASS_QUEUE); } else { @@ -347,21 +379,21 @@ IMG_VOID QueueDumpDebugInfo(IMG_VOID) Kernel-side functions of User->Kernel transitions ******************************************************************************/ -static IMG_SIZE_T NearestPower2(IMG_SIZE_T ui32Value) +static IMG_SIZE_T NearestPower2(IMG_SIZE_T uValue) { - IMG_SIZE_T ui32Temp, ui32Result = 1; + IMG_SIZE_T uTemp, uResult = 1; - if(!ui32Value) + if(!uValue) return 0; - ui32Temp = ui32Value - 1; - while(ui32Temp) + uTemp = uValue - 1; + while(uTemp) { - ui32Result <<= 1; - ui32Temp >>= 1; + uResult <<= 1; + uTemp >>= 1; } - return ui32Result; + return uResult; } @@ -374,7 +406,7 @@ static IMG_SIZE_T NearestPower2(IMG_SIZE_T ui32Value) Creates a new command queue into which render/blt commands etc can be inserted. - @Input ui32QueueSize : + @Input uQueueSize : @Output ppsQueueInfo : @@ -382,15 +414,21 @@ static IMG_SIZE_T NearestPower2(IMG_SIZE_T ui32Value) ******************************************************************************/ IMG_EXPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, +PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize, PVRSRV_QUEUE_INFO **ppsQueueInfo) { PVRSRV_QUEUE_INFO *psQueueInfo; - IMG_SIZE_T ui32Power2QueueSize = NearestPower2(ui32QueueSize); + IMG_SIZE_T uPower2QueueSize = NearestPower2(uQueueSize); SYS_DATA *psSysData; PVRSRV_ERROR eError; IMG_HANDLE hMemBlock; + if (ui32NoOfSwapchainCreated >= DC_NUM_COMMANDS_PER_TYPE) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateCommandQueueKM: Swapchain already exists, increament DC_MAX_SUPPORTED_QUEUES to support more than one swapchain")); + return PVRSRV_ERROR_FLIP_CHAIN_EXISTS; + } + SysAcquireData(&psSysData); /* allocate an internal queue info structure */ @@ -410,7 +448,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, /* allocate the command queue buffer - allow for overrun */ eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - ui32Power2QueueSize + PVRSRV_MAX_CMD_SIZE, + uPower2QueueSize + PVRSRV_MAX_CMD_SIZE, &psQueueInfo->pvLinQueueKM, &hMemBlock, "Command Queue"); if (eError != PVRSRV_OK) @@ -423,10 +461,19 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, psQueueInfo->pvLinQueueUM = psQueueInfo->pvLinQueueKM; /* Sanity check: Should be zeroed by OSMemSet */ - PVR_ASSERT(psQueueInfo->ui32ReadOffset == 0); - PVR_ASSERT(psQueueInfo->ui32WriteOffset == 0); + PVR_ASSERT(psQueueInfo->uReadOffset == 0); + PVR_ASSERT(psQueueInfo->uWriteOffset == 0); + + psQueueInfo->uQueueSize = uPower2QueueSize; - psQueueInfo->ui32QueueSize = ui32Power2QueueSize; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + psQueueInfo->pvTimeline = sw_sync_timeline_create("pvr_queue_proc"); + if(psQueueInfo->pvTimeline == IMG_NULL) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateCommandQueueKM: sw_sync_timeline_create() failed")); + goto ErrorExit; + } +#endif /* if this is the first q, create a lock resource for the q list */ if (psSysData->psQueueList == IMG_NULL) @@ -457,6 +504,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, *ppsQueueInfo = psQueueInfo; + ui32NoOfSwapchainCreated++; + return PVRSRV_OK; ErrorExit: @@ -466,7 +515,7 @@ ErrorExit: if(psQueueInfo->pvLinQueueKM) { OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - psQueueInfo->ui32QueueSize, + psQueueInfo->uQueueSize, psQueueInfo->pvLinQueueKM, psQueueInfo->hMemBlock[1]); psQueueInfo->pvLinQueueKM = IMG_NULL; @@ -510,7 +559,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue /* PRQA S 3415,4109 1 */ /* macro format critical - leave alone */ LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) { - if(psQueueInfo->ui32ReadOffset == psQueueInfo->ui32WriteOffset) + if(psQueueInfo->uReadOffset == psQueueInfo->uWriteOffset) { bTimeout = IMG_FALSE; break; @@ -535,12 +584,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue goto ErrorExit; } + ui32NoOfSwapchainCreated--; + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_timeline_destroy(psQueueInfo->pvTimeline); +#endif + if(psQueue == psQueueInfo) { psSysData->psQueueList = psQueueInfo->psNextKM; OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - NearestPower2(psQueueInfo->ui32QueueSize) + PVRSRV_MAX_CMD_SIZE, + NearestPower2(psQueueInfo->uQueueSize) + PVRSRV_MAX_CMD_SIZE, psQueueInfo->pvLinQueueKM, psQueueInfo->hMemBlock[1]); psQueueInfo->pvLinQueueKM = IMG_NULL; @@ -560,7 +615,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue psQueue->psNextKM = psQueueInfo->psNextKM; OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - psQueueInfo->ui32QueueSize, + psQueueInfo->uQueueSize, psQueueInfo->pvLinQueueKM, psQueueInfo->hMemBlock[1]); psQueueInfo->pvLinQueueKM = IMG_NULL; @@ -626,40 +681,26 @@ ErrorExit: *****************************************************************************/ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetQueueSpaceKM(PVRSRV_QUEUE_INFO *psQueue, - IMG_SIZE_T ui32ParamSize, + IMG_SIZE_T uParamSize, IMG_VOID **ppvSpace) { - IMG_BOOL bTimeout = IMG_TRUE; - /* round to 4byte units */ - ui32ParamSize = (ui32ParamSize+3) & 0xFFFFFFFC; + uParamSize = (uParamSize + 3) & 0xFFFFFFFC; - if (ui32ParamSize > PVRSRV_MAX_CMD_SIZE) + if (uParamSize > PVRSRV_MAX_CMD_SIZE) { PVR_DPF((PVR_DBG_WARNING,"PVRSRVGetQueueSpace: max command size is %d bytes", PVRSRV_MAX_CMD_SIZE)); return PVRSRV_ERROR_CMD_TOO_BIG; } - /* PRQA S 3415,4109 1 */ /* macro format critical - leave alone */ - LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) - { - if (GET_SPACE_IN_CMDQ(psQueue) > ui32ParamSize) - { - bTimeout = IMG_FALSE; - break; - } - OSSleepms(1); - } END_LOOP_UNTIL_TIMEOUT(); - - if (bTimeout == IMG_TRUE) + if (GET_SPACE_IN_CMDQ(psQueue) > uParamSize) { - *ppvSpace = IMG_NULL; - - return PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE; + *ppvSpace = (IMG_VOID *)((IMG_UINTPTR_T)psQueue->pvLinQueueUM + psQueue->uWriteOffset); } else { - *ppvSpace = (IMG_VOID *)((IMG_UINTPTR_T)psQueue->pvLinQueueUM + psQueue->ui32WriteOffset); + *ppvSpace = IMG_NULL; + return PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE; } return PVRSRV_OK; @@ -695,17 +736,22 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, PVRSRV_KERNEL_SYNC_INFO *apsDstSync[], IMG_UINT32 ui32SrcSyncCount, PVRSRV_KERNEL_SYNC_INFO *apsSrcSync[], - IMG_SIZE_T ui32DataByteSize, + IMG_SIZE_T uDataByteSize, PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete, - IMG_HANDLE hCallbackData) + IMG_HANDLE hCallbackData, + IMG_HANDLE *phFence) { PVRSRV_ERROR eError; PVRSRV_COMMAND *psCommand; - IMG_SIZE_T ui32CommandSize; + IMG_SIZE_T uCommandSize; IMG_UINT32 i; SYS_DATA *psSysData; DEVICE_COMMAND_DATA *psDeviceCommandData; +#if !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + PVR_UNREFERENCED_PARAMETER(phFence); +#endif + /* Check that we've got enough space in our command complete data for this command */ SysAcquireData(&psSysData); psDeviceCommandData = psSysData->apsDeviceCommandData[ui32DevIndex]; @@ -718,24 +764,63 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, } /* Round up to nearest 32 bit size so pointer arithmetic works */ - ui32DataByteSize = (ui32DataByteSize + 3UL) & ~3UL; + uDataByteSize = (uDataByteSize + 3UL) & ~3UL; /* calc. command size */ - ui32CommandSize = sizeof(PVRSRV_COMMAND) + uCommandSize = sizeof(PVRSRV_COMMAND) + ((ui32DstSyncCount + ui32SrcSyncCount) * sizeof(PVRSRV_SYNC_OBJECT)) - + ui32DataByteSize; + + uDataByteSize; /* wait for space in queue */ - eError = PVRSRVGetQueueSpaceKM (psQueue, ui32CommandSize, (IMG_VOID**)&psCommand); + eError = PVRSRVGetQueueSpaceKM (psQueue, uCommandSize, (IMG_VOID**)&psCommand); if(eError != PVRSRV_OK) { return eError; } +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + if(phFence != IMG_NULL) + { + struct sync_fence *psRetireFence, *psCleanupFence; + + /* New command? New timeline target */ + psQueue->ui32FenceValue++; + + psRetireFence = AllocQueueFence(psQueue->pvTimeline, psQueue->ui32FenceValue, "pvr_queue_retire"); + if(!psRetireFence) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVInsertCommandKM: sync_fence_create() failed")); + psQueue->ui32FenceValue--; + return PVRSRV_ERROR_INVALID_PARAMS; + } + + /* This similar to the retire fence, except that it is destroyed + * when a display command completes, rather than at the whim of + * userspace. It is used to keep the timeline alive. + */ + psCleanupFence = AllocQueueFence(psQueue->pvTimeline, psQueue->ui32FenceValue, "pvr_queue_cleanup"); + if(!psCleanupFence) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVInsertCommandKM: sync_fence_create() #2 failed")); + sync_fence_put(psRetireFence); + psQueue->ui32FenceValue--; + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psCommand->pvCleanupFence = psCleanupFence; + psCommand->pvTimeline = psQueue->pvTimeline; + *phFence = psRetireFence; + } + else + { + psCommand->pvTimeline = IMG_NULL; + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + psCommand->ui32ProcessID = OSGetCurrentProcessIDKM(); /* setup the command */ - psCommand->uCmdSize = ui32CommandSize; /* this may change if cmd shrinks */ + psCommand->uCmdSize = uCommandSize; /* this may change if cmd shrinks */ psCommand->ui32DevIndex = ui32DevIndex; psCommand->CommandType = CommandType; psCommand->ui32DstSyncCount = ui32DstSyncCount; @@ -752,7 +837,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, + (ui32SrcSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); /* PRQA L:END_PTR_ASSIGNMENTS */ - psCommand->uDataSize = ui32DataByteSize;/* this may change if cmd shrinks */ + psCommand->uDataSize = uDataByteSize;/* this may change if cmd shrinks */ psCommand->pfnCommandComplete = pfnCommandComplete; psCommand->hCallbackData = hCallbackData; @@ -829,18 +914,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSubmitCommandKM(PVRSRV_QUEUE_INFO *psQueue, if (psCommand->ui32DstSyncCount > 0) { psCommand->psDstSync = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psQueue->pvLinQueueKM) - + psQueue->ui32WriteOffset + sizeof(PVRSRV_COMMAND)); + + psQueue->uWriteOffset + sizeof(PVRSRV_COMMAND)); } if (psCommand->ui32SrcSyncCount > 0) { psCommand->psSrcSync = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psQueue->pvLinQueueKM) - + psQueue->ui32WriteOffset + sizeof(PVRSRV_COMMAND) + + psQueue->uWriteOffset + sizeof(PVRSRV_COMMAND) + (psCommand->ui32DstSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); } psCommand->pvData = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psQueue->pvLinQueueKM) - + psQueue->ui32WriteOffset + sizeof(PVRSRV_COMMAND) + + psQueue->uWriteOffset + sizeof(PVRSRV_COMMAND) + (psCommand->ui32DstSyncCount * sizeof(PVRSRV_SYNC_OBJECT)) + (psCommand->ui32SrcSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); @@ -897,8 +982,8 @@ PVRSRV_ERROR CheckIfSyncIsQueued(PVRSRV_SYNC_OBJECT *psSync, COMMAND_COMPLETE_DA if (SYNCOPS_STALE(ui32WriteOpsComplete, psSync->ui32WriteOpsPending)) { PVR_DPF((PVR_DBG_WARNING, - "CheckIfSyncIsQueued: Stale syncops psSyncData:0x%x ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", - (IMG_UINTPTR_T)psSyncData, ui32WriteOpsComplete, psSync->ui32WriteOpsPending)); + "CheckIfSyncIsQueued: Stale syncops psSyncData:0x%p ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", + psSyncData, ui32WriteOpsComplete, psSync->ui32WriteOpsPending)); return PVRSRV_OK; } } @@ -979,8 +1064,8 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOps2Pending)) { PVR_DPF((PVR_DBG_WARNING, - "PVRSRVProcessCommand: Stale syncops psSyncData:0x%x ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", - (IMG_UINTPTR_T)psSyncData, ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending)); + "PVRSRVProcessCommand: Stale syncops psSyncData:0x%p ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", + psSyncData, ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending)); } if (!bFlush || @@ -1047,6 +1132,11 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, psCmdCompleteData->pfnCommandComplete = psCommand->pfnCommandComplete; psCmdCompleteData->hCallbackData = psCommand->hCallbackData; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + psCmdCompleteData->pvCleanupFence = psCommand->pvCleanupFence; + psCmdCompleteData->pvTimeline = psCommand->pvTimeline; +#endif + /* copy dst updates over */ psCmdCompleteData->ui32SrcSyncCount = psCommand->ui32SrcSyncCount; for (i=0; i<psCommand->ui32SrcSyncCount; i++) @@ -1082,10 +1172,13 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, */ psCmdCompleteData->bInUse = IMG_FALSE; eError = PVRSRV_ERROR_CMD_NOT_PROCESSED; + PVR_LOG(("Failed to submit command from queue processor, this could cause sync wedge!")); + } + else + { + /* Increment the CCB offset */ + psDeviceCommandData[psCommand->CommandType].ui32CCBOffset = (ui32CCBOffset + 1) % DC_NUM_COMMANDS_PER_TYPE; } - - /* Increment the CCB offset */ - psDeviceCommandData[psCommand->CommandType].ui32CCBOffset = (ui32CCBOffset + 1) % DC_NUM_COMMANDS_PER_TYPE; return eError; } @@ -1147,9 +1240,9 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush) while (psQueue) { - while (psQueue->ui32ReadOffset != psQueue->ui32WriteOffset) + while (psQueue->uReadOffset != psQueue->uWriteOffset) { - psCommand = (PVRSRV_COMMAND*)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + psQueue->ui32ReadOffset); + psCommand = (PVRSRV_COMMAND*)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + psQueue->uReadOffset); if (PVRSRVProcessCommand(psSysData, psCommand, bFlush) == PVRSRV_OK) { @@ -1177,44 +1270,7 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush) return PVRSRV_OK; } -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) -/*! -****************************************************************************** - - @Function PVRSRVCommandCompleteKM - - @Description Updates non-private command complete sync objects - - @Input hCmdCookie : command cookie - @Input bScheduleMISR : obsolete parameter - - @Return PVRSRV_ERROR - -******************************************************************************/ -IMG_INTERNAL -IMG_VOID PVRSRVFreeCommandCompletePacketKM(IMG_HANDLE hCmdCookie, - IMG_BOOL bScheduleMISR) -{ - COMMAND_COMPLETE_DATA *psCmdCompleteData = (COMMAND_COMPLETE_DATA *)hCmdCookie; - SYS_DATA *psSysData; - - PVR_UNREFERENCED_PARAMETER(bScheduleMISR); - - SysAcquireData(&psSysData); - - /* free command complete storage */ - psCmdCompleteData->bInUse = IMG_FALSE; - - /* FIXME: This may cause unrelated devices to be woken up. */ - PVRSRVScheduleDeviceCallbacks(); - - /* the MISR is always scheduled, regardless of bScheduleMISR */ - OSScheduleMISR(psSysData); -} - -#endif /* (SUPPORT_CUSTOM_SWAP_OPERATIONS) */ - -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) extern void sgxfreq_notif_sgx_frame_done(void); #endif /* (SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ @@ -1239,9 +1295,9 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, COMMAND_COMPLETE_DATA *psCmdCompleteData = (COMMAND_COMPLETE_DATA *)hCmdCookie; SYS_DATA *psSysData; -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) sgxfreq_notif_sgx_frame_done(); -#endif /* (SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#endif /* (SYS_OMAP_HAS_DVFS_FRAMEWORK) */ SysAcquireData(&psSysData); @@ -1292,6 +1348,14 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, psCmdCompleteData->pfnCommandComplete(psCmdCompleteData->hCallbackData); } +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + if(psCmdCompleteData->pvTimeline) + { + sw_sync_timeline_inc(psCmdCompleteData->pvTimeline, 1); + sync_fence_put(psCmdCompleteData->pvCleanupFence); + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + /* free command complete storage */ psCmdCompleteData->bInUse = IMG_FALSE; @@ -1305,8 +1369,6 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, } - - /*! ****************************************************************************** diff --git a/drivers/gpu/pvr/services4/srvkm/common/ra.c b/drivers/gpu/pvr/services4/srvkm/common/ra.c index f22c5baccd2..37c7176bc2a 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/ra.c +++ b/drivers/gpu/pvr/services4/srvkm/common/ra.c @@ -93,9 +93,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(__linux__) && defined(__KERNEL__) #include <linux/kernel.h> -#include "pvr_uaccess.h" #include "proc.h" -#include <linux/sched.h> #endif #ifdef USE_BM_FREESPACE_CHECK @@ -220,23 +218,13 @@ struct _RA_ARENA_ RA_STATISTICS sStatistics; #endif -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) #define PROC_NAME_SIZE 64 - struct proc_dir_entry* pProcInfo; - struct proc_dir_entry* pProcSegs; + struct pvr_proc_dir_entry* pProcInfo; + struct pvr_proc_dir_entry* pProcSegs; IMG_BOOL bInitProcEntry; - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - struct proc_dir_entry* pProcAllocFailThreshold; - - IMG_BOOL bFailAllocationOnce; - IMG_BOOL bFailAllocationPersist; - IMG_SIZE_T uAllocFailThreshold; - IMG_UINT32 uAllocFailMask; -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - #endif }; /* #define ENABLE_RA_DUMP 1 */ @@ -244,45 +232,19 @@ struct _RA_ARENA_ IMG_VOID RA_Dump (RA_ARENA *pArena); #endif -static INLINE IMG_BOOL RA_TestAllocationFail(RA_ARENA *pArena, IMG_SIZE_T size, IMG_UINT32 buff_type) -{ - #if defined (CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - if(pArena->bFailAllocationOnce == IMG_TRUE) - { - if((size > pArena->uAllocFailThreshold) && (pArena->uAllocFailMask & buff_type)) - { - if(pArena->bFailAllocationPersist == IMG_FALSE) - pArena->bFailAllocationOnce = IMG_FALSE; - return IMG_TRUE; - } - } - #endif //CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG - return IMG_FALSE; -} - -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) - +#if defined(CONFIG_PROC_FS) && defined(DEBUG) static void RA_ProcSeqShowInfo(struct seq_file *sfile, void* el); static void* RA_ProcSeqOff2ElementInfo(struct seq_file * sfile, loff_t off); static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el); static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off); - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) -static int RA_ProcSetAllocFailThreshold(struct file *file, const char __user *buffer, unsigned long count, void *data); -static void* RA_ProcSeqOff2AllocFailThreshold(struct seq_file * sfile, loff_t off); -static void RA_ProcSeqShowAllocFailThreshold(struct seq_file *sfile,void* el); -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - #endif /* defined(CONFIG_PROC_FS) && defined(DEBUG) */ -static PVRSRV_ERROR RA_DumpHeapInfo(RA_ARENA *pArena, IMG_UINT32 ui32DebugLevel); - #ifdef USE_BM_FREESPACE_CHECK IMG_VOID CheckBMFreespace(IMG_VOID); #endif -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) static IMG_CHAR *ReplaceSpaces(IMG_CHAR * const pS) { IMG_CHAR *pT; @@ -770,7 +732,7 @@ _InsertResourceSpan (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) } PVR_DPF ((PVR_DBG_MESSAGE, - "RA_InsertResourceSpan: arena='%s', base=0x%x, size=0x%x", + "RA_InsertResourceSpan: arena='%s', base=0x" UINTPTR_FMT ", size=0x%" SIZE_T_FMT_LEN "x", pArena->name, base, uSize)); pSpanStart = _BuildSpanMarker (base, uSize); @@ -1038,9 +1000,13 @@ _AttemptAllocAligned (RA_ARENA *pArena, else aligned_base = pBT->base; PVR_DPF ((PVR_DBG_MESSAGE, - "RA_AttemptAllocAligned: pBT-base=0x%x " - "pBT-size=0x%x alignedbase=0x%x size=0x%x", - pBT->base, pBT->uSize, aligned_base, uSize)); + "RA_AttemptAllocAligned: pBT-base=0x" UINTPTR_FMT " " + "pBT-size=0x%" SIZE_T_FMT_LEN "x alignedbase=0x" + UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", + pBT->base, + pBT->uSize, + aligned_base, + uSize)); if (pBT->base + pBT->uSize >= aligned_base + uSize) { @@ -1184,8 +1150,8 @@ RA_Create (IMG_CHAR *name, IMG_INT i; PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Create: name='%s', base=0x%x, uSize=0x%x, alloc=0x%x, free=0x%x", - name, base, uSize, (IMG_UINTPTR_T)imp_alloc, (IMG_UINTPTR_T)imp_free)); + "RA_Create: name='%s', base=0x" UINTPTR_FMT ", uSize=0x%" SIZE_T_FMT_LEN "x, alloc=0x%p, free=0x%p", + name, base, uSize, imp_alloc, imp_free)); if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, @@ -1208,22 +1174,30 @@ RA_Create (IMG_CHAR *name, pArena->uQuantum = uQuantum; #ifdef RA_STATS - OSMemSet(&pArena->sStatistics, 0x00, sizeof(pArena->sStatistics)); + pArena->sStatistics.uSpanCount = 0; + pArena->sStatistics.uLiveSegmentCount = 0; + pArena->sStatistics.uFreeSegmentCount = 0; + pArena->sStatistics.uFreeResourceCount = 0; + pArena->sStatistics.uTotalResourceCount = 0; + pArena->sStatistics.uCumulativeAllocs = 0; + pArena->sStatistics.uCumulativeFrees = 0; + pArena->sStatistics.uImportCount = 0; + pArena->sStatistics.uExportCount = 0; #endif -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) if(strcmp(pArena->name,"") != 0) { IMG_INT ret; IMG_CHAR szProcInfoName[PROC_NAME_SIZE]; IMG_CHAR szProcSegsName[PROC_NAME_SIZE]; - struct proc_dir_entry* (*pfnCreateProcEntrySeq)(const IMG_CHAR *, + struct pvr_proc_dir_entry* (*pfnCreateProcEntrySeq)(const IMG_CHAR *, IMG_VOID*, pvr_next_proc_seq_t, pvr_show_proc_seq_t, pvr_off2element_proc_seq_t, pvr_startstop_proc_seq_t, - write_proc_t); + pvr_proc_write_t); pArena->bInitProcEntry = !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL); @@ -1243,7 +1217,7 @@ RA_Create (IMG_CHAR *name, } ret = snprintf(szProcSegsName, sizeof(szProcSegsName), "ra_segs_%s", pArena->name); - if (ret > 0 && ret < sizeof(szProcSegsName)) + if (ret > 0 && ret < sizeof(szProcInfoName)) { pArena->pProcSegs = pfnCreateProcEntrySeq(ReplaceSpaces(szProcSegsName), pArena, NULL, RA_ProcSeqShowRegs, RA_ProcSeqOff2ElementRegs, NULL, NULL); @@ -1253,27 +1227,8 @@ RA_Create (IMG_CHAR *name, pArena->pProcSegs = 0; PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_segs proc entry for arena %s", pArena->name)); } - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - pArena->uAllocFailThreshold = ~0; - pArena->uAllocFailMask = ~0; - pArena->bFailAllocationOnce = IMG_FALSE; - pArena->bFailAllocationPersist = IMG_FALSE; - - ret = snprintf(szProcSegsName, sizeof(szProcSegsName), "ra_fail_alloc_thld_%s", pArena->name); - if (ret > 0 && ret < sizeof(szProcSegsName)) - { - pArena->pProcAllocFailThreshold = pfnCreateProcEntrySeq(ReplaceSpaces(szProcSegsName), pArena, NULL, - RA_ProcSeqShowAllocFailThreshold, RA_ProcSeqOff2AllocFailThreshold, NULL, RA_ProcSetAllocFailThreshold); - } - else - { - pArena->pProcAllocFailThreshold = 0; - PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_fail_alloc_thld proc entry for arena %s", pArena->name)); - } -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) } -#endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) */ +#endif /* defined(CONFIG_PROC_FS) && defined(DEBUG) */ pArena->pSegmentHash = HASH_Create (MINIMUM_HASH_SIZE); if (pArena->pSegmentHash==IMG_NULL) @@ -1339,8 +1294,8 @@ RA_Delete (RA_ARENA *pArena) if (pBT->type != btt_free) { PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: allocations still exist in the arena that is being destroyed")); - PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing allocations before destroying devmemcontext")); - PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); + PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing alocations before destroying devmemcontext")); + PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", pBT->base, pBT->uSize)); } _SegmentListRemove (pArena, pBT); @@ -1350,9 +1305,9 @@ RA_Delete (RA_ARENA *pArena) pArena->sStatistics.uSpanCount--; #endif } -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) { - IMG_VOID (*pfnRemoveProcEntrySeq)(struct proc_dir_entry*); + IMG_VOID (*pfnRemoveProcEntrySeq)(struct pvr_proc_dir_entry*); pfnRemoveProcEntrySeq = pArena->bInitProcEntry ? RemoveProcEntrySeq : RemovePerProcessProcEntrySeq; @@ -1365,13 +1320,6 @@ RA_Delete (RA_ARENA *pArena) { pfnRemoveProcEntrySeq( pArena->pProcSegs ); } - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - if(pArena->pProcAllocFailThreshold != 0) - { - pfnRemoveProcEntrySeq( pArena->pProcAllocFailThreshold ); - } -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) } #endif HASH_Delete (pArena->pSegmentHash); @@ -1403,7 +1351,7 @@ RA_TestDelete (RA_ARENA *pArena) if (pBT->type != btt_free) { PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: detected resource leak!")); - PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); + PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: base = 0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", pBT->base, pBT->uSize)); return IMG_FALSE; } } @@ -1438,7 +1386,7 @@ RA_Add (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) } PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Add: name='%s', base=0x%x, size=0x%x", pArena->name, base, uSize)); + "RA_Add: name='%s', base=0x" UINTPTR_FMT ", size=0x%" SIZE_T_FMT_LEN "x", pArena->name, base, uSize)); uSize = (uSize + pArena->uQuantum - 1) / pArena->uQuantum * pArena->uQuantum; return ((IMG_BOOL)(_InsertResource (pArena, base, uSize) != IMG_NULL)); @@ -1479,8 +1427,7 @@ RA_Alloc (RA_ARENA *pArena, IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *base) { - IMG_BOOL bResult = IMG_FALSE; - IMG_BOOL bTestAllocFail = IMG_FALSE; + IMG_BOOL bResult; IMG_SIZE_T uSize = uRequestSize; PVR_ASSERT (pArena!=IMG_NULL); @@ -1505,101 +1452,85 @@ RA_Alloc (RA_ARENA *pArena, } PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Alloc: arena='%s', size=0x%x(0x%x), alignment=0x%x, offset=0x%x", + "RA_Alloc: arena='%s', size=0x%" SIZE_T_FMT_LEN "x(0x%" SIZE_T_FMT_LEN "x), alignment=0x%x, offset=0x%x", pArena->name, uSize, uRequestSize, uAlignment, uAlignmentOffset)); - bTestAllocFail = RA_TestAllocationFail(pArena, uSize, ~0); - if(!bTestAllocFail) + /* if allocation failed then we might have an import source which + can provide more resource, else we will have to fail the + allocation to the caller. */ + bResult = _AttemptAllocAligned (pArena, uSize, ppsMapping, uFlags, + uAlignment, uAlignmentOffset, base); + if (!bResult) { - /* if allocation failed then we might have an import source which - can provide more resource, else we will have to fail the - allocation to the caller. */ - bResult = _AttemptAllocAligned (pArena, uSize, ppsMapping, uFlags, - uAlignment, uAlignmentOffset, base); - if (!bResult) + BM_MAPPING *psImportMapping; + IMG_UINTPTR_T import_base; + IMG_SIZE_T uImportSize = uSize; + + /* + Ensure that we allocate sufficient space to meet the uAlignment + constraint + */ + if (uAlignment > pArena->uQuantum) { - BM_MAPPING *psImportMapping; - IMG_UINTPTR_T import_base; - IMG_SIZE_T uImportSize = uSize; + uImportSize += (uAlignment - 1); + } - /* - Ensure that we allocate sufficient space to meet the uAlignment - constraint - */ - if (uAlignment > pArena->uQuantum) + /* ensure that we import according to the quanta of this arena */ + uImportSize = ((uImportSize + pArena->uQuantum - 1)/pArena->uQuantum)*pArena->uQuantum; + + bResult = + pArena->pImportAlloc (pArena->pImportHandle, uImportSize, &uImportSize, + &psImportMapping, uFlags, + pvPrivData, ui32PrivDataLength, &import_base); + if (bResult) + { + BT *pBT; + pBT = _InsertResourceSpan (pArena, import_base, uImportSize); + /* successfully import more resource, create a span to + represent it and retry the allocation attempt */ + if (pBT == IMG_NULL) { - uImportSize += (uAlignment - 1); + /* insufficient resources to insert the newly acquired span, + so free it back again */ + pArena->pImportFree(pArena->pImportHandle, import_base, + psImportMapping); + PVR_DPF ((PVR_DBG_MESSAGE, + "RA_Alloc: name='%s', size=0x%" SIZE_T_FMT_LEN "x failed!", + pArena->name, uSize)); + /* RA_Dump (arena); */ + return IMG_FALSE; } - - /* ensure that we import according to the quanta of this arena */ - uImportSize = ((uImportSize + pArena->uQuantum - 1)/pArena->uQuantum)*pArena->uQuantum; - - bResult = - pArena->pImportAlloc (pArena->pImportHandle, uImportSize, &uImportSize, - &psImportMapping, uFlags, - pvPrivData, ui32PrivDataLength, &import_base); - if (bResult) + pBT->psMapping = psImportMapping; +#ifdef RA_STATS + pArena->sStatistics.uFreeSegmentCount++; + pArena->sStatistics.uFreeResourceCount += uImportSize; + pArena->sStatistics.uImportCount++; + pArena->sStatistics.uSpanCount++; +#endif + bResult = _AttemptAllocAligned(pArena, uSize, ppsMapping, uFlags, + uAlignment, uAlignmentOffset, + base); + if (!bResult) { - BT *pBT; - pBT = _InsertResourceSpan (pArena, import_base, uImportSize); - /* successfully import more resource, create a span to - represent it and retry the allocation attempt */ - if (pBT == IMG_NULL) - { - /* insufficient resources to insert the newly acquired span, - so free it back again */ - pArena->pImportFree(pArena->pImportHandle, import_base, - psImportMapping); - PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Alloc: name='%s', size=0x%x failed!", - pArena->name, uSize)); - /* RA_Dump (arena); */ - return IMG_FALSE; - } - pBT->psMapping = psImportMapping; - #ifdef RA_STATS - pArena->sStatistics.uFreeSegmentCount++; - pArena->sStatistics.uFreeResourceCount += uImportSize; - pArena->sStatistics.uImportCount++; - pArena->sStatistics.uSpanCount++; - #endif - bResult = _AttemptAllocAligned(pArena, uSize, ppsMapping, uFlags, - uAlignment, uAlignmentOffset, - base); - if (!bResult) - { - PVR_DPF ((PVR_DBG_ERROR, - "RA_Alloc: name='%s' uAlignment failed!", - pArena->name)); - } + PVR_DPF ((PVR_DBG_MESSAGE, + "RA_Alloc: name='%s' uAlignment failed!", + pArena->name)); } } - #ifdef RA_STATS - if (bResult) - pArena->sStatistics.uCumulativeAllocs++; - #endif } +#ifdef RA_STATS + if (bResult) + pArena->sStatistics.uCumulativeAllocs++; +#endif - PVR_DPF((PVR_DBG_MESSAGE, - "RA_Alloc: arena=%s, size=0x%x(0x%x), alignment=0x%x, "\ - "offset=0x%x, result=%d", - pArena->name, - uSize, uRequestSize, uAlignment, uAlignmentOffset, - bResult)); + PVR_DPF ((PVR_DBG_MESSAGE, + "RA_Alloc: name='%s', size=0x%" SIZE_T_FMT_LEN "x, *base=0x" UINTPTR_FMT " = %d", + pArena->name, uSize, *base, bResult)); /* RA_Dump (pArena); ra_stats (pArena); */ - if (!bResult) { - PVR_LOG(("RA_Alloc %s %s: arena=%s, size=0x%x(0x%x), "\ - "alignment=0x%x, offset=0x%x", - (bResult ? "SUCCESS" : "FAILED"), - (bTestAllocFail ? "in TEST_MODE!" : " "), - pArena->name, - uSize, uRequestSize, uAlignment, uAlignmentOffset)); - RA_DumpHeapInfo(pArena, ~0); - } #if defined(VALIDATE_ARENA_TEST) ValidateArena(pArena); #endif @@ -1653,8 +1584,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_END))) { /* error - next span must be live, free or end */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1666,8 +1603,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_END))) { /* error - next span must be live or end */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1680,8 +1623,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_END)) { /* error - next span cannot be live, free or end */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1694,16 +1643,28 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_FREE))) { /* error - next span must be live or free */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } break; default: - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; break; @@ -1727,8 +1688,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == RESOURCE_SPAN_LIVE))) { /* error - next span must be free or live */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1740,16 +1707,28 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == RESOURCE_SPAN_LIVE))) { /* error - next span must be free or live */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } break; default: - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; break; @@ -1801,7 +1780,7 @@ RA_Free (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_BOOL bFreeBackingStore) #endif PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Free: name='%s', base=0x%x", pArena->name, base)); + "RA_Free: name='%s', base=0x" UINTPTR_FMT, pArena->name, base)); pBT = (BT *) HASH_Remove (pArena->pSegmentHash, base); PVR_ASSERT (pBT != IMG_NULL); @@ -1834,7 +1813,11 @@ RA_Free (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_BOOL bFreeBackingStore) { *p++ = 0xAA; } - PVR_DPF((PVR_DBG_MESSAGE,"BM_FREESPACE_CHECK: RA_Free Cleared %08X to %08X (size=0x%x)",(IMG_BYTE*)pBT->base + SysGetDevicePhysOffset(),endp-1,pBT->uSize)); + PVR_DPF((PVR_DBG_MESSAGE, + "BM_FREESPACE_CHECK: RA_Free Cleared %p to %p (size=0x%" SIZE_T_FMT_LEN "x)", + (IMG_BYTE*)pBT->base + SysGetDevicePhysOffset(), + endp - 1, + pBT->uSize)); } #endif _FreeBT (pArena, pBT, bFreeBackingStore); @@ -1934,7 +1917,7 @@ IMG_VOID CheckBMFreespace(IMG_VOID) #endif -#if (defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS)) || defined (RA_STATS) +#if (defined(CONFIG_PROC_FS) && defined(DEBUG)) || defined (RA_STATS) static IMG_CHAR * _BTType (IMG_INT eType) { @@ -1965,7 +1948,7 @@ RA_Dump (RA_ARENA *pArena) BT *pBT; PVR_ASSERT (pArena != IMG_NULL); PVR_DPF ((PVR_DBG_MESSAGE,"Arena '%s':", pArena->name)); - PVR_DPF ((PVR_DBG_MESSAGE," alloc=%08X free=%08X handle=%08X quantum=%d", + PVR_DPF ((PVR_DBG_MESSAGE," alloc=%p free=%p handle=%p quantum=%d", pArena->pImportAlloc, pArena->pImportFree, pArena->pImportHandle, pArena->uQuantum)); PVR_DPF ((PVR_DBG_MESSAGE," segment Chain:")); @@ -1978,8 +1961,8 @@ RA_Dump (RA_ARENA *pArena) for (pBT=pArena->pHeadSegment; pBT!=IMG_NULL; pBT=pBT->pNextSegment) { - PVR_DPF ((PVR_DBG_MESSAGE,"\tbase=0x%x size=0x%x type=%s", - (IMG_UINT32) pBT->base, pBT->uSize, _BTType (pBT->type))); + PVR_DPF ((PVR_DBG_MESSAGE,"\tbase=0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x type=%s", + pBT->base, pBT->uSize, _BTType (pBT->type))); } #ifdef HASH_TRACE @@ -1988,259 +1971,48 @@ RA_Dump (RA_ARENA *pArena) } #endif /* #if defined(ENABLE_RA_DUMP) */ -static PVRSRV_ERROR RA_DumpHeapInfo(RA_ARENA *pArena, IMG_UINT32 ui32DebugLevel) -{ - BT *pBT; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - { - IMG_UINT32 ui32PID = OSGetCurrentProcessIDKM(); - IMG_CHAR dirname_buffer[256]; - IMG_CHAR dirname[256]; - const IMG_CHAR *proc_basename = dirname_buffer; - dirname_buffer[255] = dirname[255] = '\0'; - - OSGetProcCmdline(ui32PID, dirname_buffer, sizeof(dirname_buffer)); - PVR_LOG(("\nCommand Line of the current process with ID %u is %s", ui32PID, dirname_buffer)); - - proc_basename = OSGetPathBaseName(dirname_buffer, sizeof(dirname_buffer)); - PVR_LOG(("Base Name of the current process with ID %u is %s", ui32PID, proc_basename)); - - } -#endif - - PVR_LOG(("Arena '%s':", pArena->name)); - - PVR_LOG(( " allocCB=%p freeCB=%p handle=%p quantum=%d", - pArena->pImportAlloc, - pArena->pImportFree, - pArena->pImportHandle, - pArena->uQuantum)); - - PVR_LOG(( "span count\t\t%u", pArena->sStatistics.uSpanCount)); - - PVR_LOG(( "live segment count\t%u", pArena->sStatistics.uLiveSegmentCount)); - - PVR_LOG(( "free segment count\t%u", pArena->sStatistics.uFreeSegmentCount)); - - PVR_LOG(( "free resource count\t%u (0x%x)", - pArena->sStatistics.uFreeResourceCount, - (IMG_UINT)pArena->sStatistics.uFreeResourceCount)); - - PVR_LOG(( "total allocs\t\t%u", pArena->sStatistics.uCumulativeAllocs)); - - PVR_LOG(( "total failed allocs\t%u", pArena->sStatistics.uFailedAllocCount)); - - PVR_LOG(( "total frees\t\t%u", pArena->sStatistics.uCumulativeFrees)); - PVR_LOG(( "import count\t\t%u", pArena->sStatistics.uImportCount)); - - PVR_LOG(( "export count\t\t%u", pArena->sStatistics.uExportCount)); - - PVR_LOG(( " segment Chain:")); - - if (pArena->pHeadSegment != IMG_NULL && - pArena->pHeadSegment->pPrevSegment != IMG_NULL) - { - PVR_LOG(( " error: head boundary tag has invalid pPrevSegment")); - } - - if (pArena->pTailSegment != IMG_NULL && - pArena->pTailSegment->pNextSegment != IMG_NULL) - { - PVR_LOG(( " error: tail boundary tag has invalid pNextSegment")); - } - - for (pBT=pArena->pHeadSegment; pBT!=IMG_NULL; pBT=pBT->pNextSegment) - { - PVR_LOG(( "%s base=0x%08x size=%08d(0x%08x) type=%s ref=%p", - ((pBT->type == btt_span) ? "\t\t" : "\t"), - (IMG_UINT32) pBT->base, - pBT->uSize, pBT->uSize, - _BTType(pBT->type), - pBT->psMapping)); - if(pBT->psMapping) - { - BM_MAPPING *psImportMapping = pBT->psMapping; - PVR_LOG(( "\t %p: mapping type %s, mapping count=%d, size=%08d(0x%08x), flags=0x%08x, align=0x%04x", - psImportMapping, - _BMMappingType(psImportMapping->eCpuMemoryOrigin), - psImportMapping->ui32MappingCount, - psImportMapping->uSize, psImportMapping->uSize, - psImportMapping->ui32Flags, - psImportMapping->ui32DevVAddrAlignment)); - } - } - - return PVRSRV_OK; -} - -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) -#define _PROC_SET_ALLOC_TH_BUFFER_SZ 32 -static int RA_ProcSetAllocFailThreshold(struct file *file, const char __user *buffer, unsigned long count, void *data) -{ - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)data; - RA_ARENA *pArena; - IMG_CHAR data_buffer[_PROC_SET_ALLOC_TH_BUFFER_SZ]; - IMG_INT32 value = ~0; - IMG_UINT32 mask = ~0; - IMG_INT32 format_ret; - - if ((handlers == NULL) || (handlers->data == NULL) || (count > sizeof(data_buffer))) - { - return -EINVAL; - } - - pArena = (RA_ARENA *)handlers->data; - - count = MIN(count, sizeof(data_buffer)); - - if (pvr_copy_from_user(data_buffer, buffer, count)) - return -EINVAL; - - if (data_buffer[count - 1] != '\n') - return -EINVAL; - - data_buffer[(sizeof(data_buffer) - 1)] = '\0'; - if((sizeof(data_buffer) -1) <= count) - data_buffer[count] = '\0'; - - PVR_LOG(("Buffer from the user is %s\n", data_buffer)); - format_ret = sscanf(data_buffer, "%i:0x%x", &value, &mask); - PVR_LOG(("Value set is %i, type is %x, format %i\n", value, mask, format_ret)); - if(format_ret <= 0) - return -EINVAL; - -/* - Heap Allocation Buffer Threshold Setting - for testing purposes only - Causes allocation of a GFX buffer of type MASK for the respective heap to - fail. - Format is <threshold value number>:<buffer type mask hex value> - for example: 1000:0x01. - Value of -1 disables the allocation fail test - Value bigger than and eq. to 0 enables the allocation fail test for - the first buffer only. - Value smaller than -1 enables the buffer allocation failure for this - heap until the test disables it. -*/ - if(value < 0) - { - if(value == -1) - { - pArena->bFailAllocationPersist = pArena->bFailAllocationOnce = IMG_FALSE; - } - else if(value == -2) - { - RA_DumpHeapInfo(pArena, ~0); - } - else - { - pArena->bFailAllocationPersist = pArena->bFailAllocationOnce = IMG_TRUE; - pArena->uAllocFailThreshold = -value; - } - } - else - { - pArena->bFailAllocationPersist = 0; - pArena->bFailAllocationOnce = 1; - pArena->uAllocFailThreshold = value; - } - - if(format_ret > 1) - { - if((pArena->bFailAllocationOnce == IMG_TRUE) && (mask == 0)) - pArena->uAllocFailMask = ~0; - else - pArena->uAllocFailMask = mask; - } - PVR_LOG(("*************** User Fail Heap Allocation Settings for %s *******************************\n", - pArena->name)); - PVR_LOG(("Fail Heap Allocation is %s in %s mode\n", (pArena->bFailAllocationOnce ? "Enabled": "Disabled"), - (pArena->bFailAllocationPersist ? "Persistent": "One-Shot"))); - PVR_LOG(("Fail Heap Allocation Buffer Size Threshold is %u with a Mask of 0x%x\n", - pArena->uAllocFailThreshold, pArena->uAllocFailMask)); - PVR_LOG(("*******************************************************************************************\n")); - return (count); -} - -static void* RA_ProcSeqOff2AllocFailThreshold(struct seq_file * sfile, loff_t off) -{ - - if(off <= 1) - return (void*)(IMG_INT)(off+1); - - return 0; -} - -static void RA_ProcSeqShowAllocFailThreshold(struct seq_file *sfile,void* el) -{ - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; - IMG_INT off = (IMG_INT)el; - - switch (off) - { - case 1: - seq_printf(sfile, "Heap Allocation Buffer Threshold Setting - for testing purposes only\n"); - seq_printf(sfile, "Format is <threshold value number>:<buffer type mask hex value> for example: 1000:0x01\n"); - seq_printf(sfile, "Value of -1 disables the allocation fail test\n"); - seq_printf(sfile, "Value of -2 dumps the heap entries to the kernel log\n"); - seq_printf(sfile, "Value => 0 enables the allocation fail test for the first buffer with the met threshold only\n"); - seq_printf(sfile, "Value < -2 enables the buffer allocation failure for this heap until the test disables it\n"); - break; - case 2: - seq_printf(sfile, "*********** Current Settings: ********************\n"); - seq_printf(sfile,"Fail Heap Allocation is %s in %s mode\n", (pArena->bFailAllocationOnce ? "Enabled": "Disabled"), - (pArena->bFailAllocationPersist ? "Persistent": "One-Shot")); - seq_printf(sfile, "Fail Heap Allocation Buffer Size Threshold is %u with a Mask of 0x%x\n", - pArena->uAllocFailThreshold, pArena->uAllocFailMask); - break; - } -} -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) static void RA_ProcSeqShowInfo(struct seq_file *sfile, void* el) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; - IMG_INT off = (IMG_INT)el; + RA_ARENA *pArena = (RA_ARENA *)PVRProcGetData(sfile->private); + IMG_UINTPTR_T off = (IMG_UINTPTR_T)el; switch (off) { case 1: - seq_printf(sfile, "quantum\t\t\t%u\n", pArena->uQuantum); + seq_printf(sfile, "quantum\t\t\t%" SIZE_T_FMT_LEN "u\n", pArena->uQuantum); break; case 2: - seq_printf(sfile, "import_handle\t\t%08X\n", (IMG_UINT)pArena->pImportHandle); + seq_printf(sfile, "import_handle\t\t%p\n", pArena->pImportHandle); break; #ifdef RA_STATS case 3: - seq_printf(sfile,"span count\t\t%u\n", pArena->sStatistics.uSpanCount); + seq_printf(sfile,"span count\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uSpanCount); break; case 4: - seq_printf(sfile, "live segment count\t%u\n", pArena->sStatistics.uLiveSegmentCount); + seq_printf(sfile, "live segment count\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uLiveSegmentCount); break; case 5: - seq_printf(sfile, "free segment count\t%u\n", pArena->sStatistics.uFreeSegmentCount); + seq_printf(sfile, "free segment count\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uFreeSegmentCount); break; case 6: - seq_printf(sfile, "free resource count\t%u (0x%x)\n", + seq_printf(sfile, "free resource count\t%" SIZE_T_FMT_LEN "u (0x%" SIZE_T_FMT_LEN "x)\n", pArena->sStatistics.uFreeResourceCount, - (IMG_UINT)pArena->sStatistics.uFreeResourceCount); + pArena->sStatistics.uFreeResourceCount); break; case 7: - seq_printf(sfile, "total allocs\t\t%u\n", pArena->sStatistics.uCumulativeAllocs); + seq_printf(sfile, "total allocs\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uCumulativeAllocs); break; case 8: - seq_printf(sfile, "total frees\t\t%u\n", pArena->sStatistics.uCumulativeFrees); + seq_printf(sfile, "total frees\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uCumulativeFrees); break; case 9: - seq_printf(sfile, "import count\t\t%u\n", pArena->sStatistics.uImportCount); + seq_printf(sfile, "import count\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uImportCount); break; case 10: - seq_printf(sfile, "export count\t\t%u\n", pArena->sStatistics.uExportCount); + seq_printf(sfile, "export count\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uExportCount); break; #endif } @@ -2254,14 +2026,13 @@ static void* RA_ProcSeqOff2ElementInfo(struct seq_file * sfile, loff_t off) #else if(off <= 1) #endif - return (void*)(IMG_INT)(off+1); + return (void*)(IMG_UINTPTR_T)(off+1); return 0; } static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; + RA_ARENA *pArena = (RA_ARENA *)PVRProcGetData(sfile->private); BT *pBT = (BT*)el; if (el == PVR_PROC_SEQ_START_TOKEN) @@ -2272,16 +2043,15 @@ static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el) if (pBT) { - seq_printf(sfile, "%08x %8x %4s %08x\n", - (IMG_UINT)pBT->base, (IMG_UINT)pBT->uSize, _BTType (pBT->type), - (IMG_UINT)pBT->psMapping); + seq_printf(sfile, "%p %" SIZE_T_FMT_LEN "x %4s %p\n", + (IMG_PVOID)pBT->base, pBT->uSize, _BTType (pBT->type), + pBT->psMapping); } } static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; + RA_ARENA *pArena = (RA_ARENA *)PVRProcGetData(sfile->private); BT *pBT = 0; if(off == 0) @@ -2291,7 +2061,6 @@ static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off) return (void*)pBT; } - #endif /* defined(CONFIG_PROC_FS) && defined(DEBUG) */ @@ -2323,7 +2092,7 @@ PVRSRV_ERROR RA_GetStats(RA_ARENA *pArena, CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, " allocCB=%p freeCB=%p handle=%p quantum=%d\n", + i32Count = OSSNPrintf(pszStr, 100, " allocCB=%p freeCB=%p handle=%p quantum=%" SIZE_T_FMT_LEN "u\n", pArena->pImportAlloc, pArena->pImportFree, pArena->pImportHandle, @@ -2331,37 +2100,44 @@ PVRSRV_ERROR RA_GetStats(RA_ARENA *pArena, UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "span count\t\t%u\n", pArena->sStatistics.uSpanCount); + i32Count = OSSNPrintf(pszStr, 100, "span count\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uSpanCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "live segment count\t%u\n", pArena->sStatistics.uLiveSegmentCount); + i32Count = OSSNPrintf(pszStr, 100, "live segment count\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uLiveSegmentCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "free segment count\t%u\n", pArena->sStatistics.uFreeSegmentCount); + i32Count = OSSNPrintf(pszStr, 100, "free segment count\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uFreeSegmentCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "free resource count\t%u (0x%x)\n", + i32Count = OSSNPrintf(pszStr, 100, "free resource count\t%" SIZE_T_FMT_LEN "u (0x%" SIZE_T_FMT_LEN "x)\n", pArena->sStatistics.uFreeResourceCount, - (IMG_UINT)pArena->sStatistics.uFreeResourceCount); + pArena->sStatistics.uFreeResourceCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "total allocs\t\t%u\n", pArena->sStatistics.uCumulativeAllocs); + i32Count = OSSNPrintf(pszStr, 100, "total allocs\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uCumulativeAllocs); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "total frees\t\t%u\n", pArena->sStatistics.uCumulativeFrees); + i32Count = OSSNPrintf(pszStr, 100, "total frees\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uCumulativeFrees); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "import count\t\t%u\n", pArena->sStatistics.uImportCount); + i32Count = OSSNPrintf(pszStr, 100, "import count\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uImportCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "export count\t\t%u\n", pArena->sStatistics.uExportCount); + i32Count = OSSNPrintf(pszStr, 100, "export count\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uExportCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); @@ -2387,8 +2163,8 @@ PVRSRV_ERROR RA_GetStats(RA_ARENA *pArena, for (pBT=pArena->pHeadSegment; pBT!=IMG_NULL; pBT=pBT->pNextSegment) { CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "\tbase=0x%x size=0x%x type=%s ref=%p\n", - (IMG_UINT32) pBT->base, + i32Count = OSSNPrintf(pszStr, 100, "\tbase=0x%p size=0x%" SIZE_T_FMT_LEN "x type=%s ref=%p\n", + (void *)pBT->base, pBT->uSize, _BTType(pBT->type), pBT->psMapping); @@ -2409,7 +2185,7 @@ PVRSRV_ERROR RA_GetStatsFreeMem(RA_ARENA *pArena, IMG_UINT32 ui32StrLen = *pui32StrLen; IMG_INT32 i32Count; CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "Bytes free: Arena %-30s: %u (0x%x)\n", pArena->name, + i32Count = OSSNPrintf(pszStr, 100, "Bytes free: Arena %-30s: %" SIZE_T_FMT_LEN "u (0x%" SIZE_T_FMT_LEN "x)\n", pArena->name, pArena->sStatistics.uFreeResourceCount, pArena->sStatistics.uFreeResourceCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); diff --git a/drivers/gpu/pvr/services4/srvkm/common/refcount.c b/drivers/gpu/pvr/services4/srvkm/common/refcount.c index fa64b234f43..a6dcb197566 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/refcount.c +++ b/drivers/gpu/pvr/services4/srvkm/common/refcount.c @@ -71,9 +71,11 @@ static DEFINE_SPINLOCK(gsCCBLock); #if defined(__linux__) #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 16) #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 17) +#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC (1U << 18) #else #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP 0 #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 0 +#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC 0 #endif #define PVRSRV_REFCOUNT_CCB_DEBUG_ALL ~0U @@ -81,6 +83,9 @@ static DEFINE_SPINLOCK(gsCCBLock); /*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/ static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO | +#if defined(SUPPORT_ION) + PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC | +#endif PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2; typedef struct @@ -120,7 +125,7 @@ void PVRSRVDumpRefCountCCB(void) /* Early on, we won't have MAX_REFCOUNT_CCB_SIZE messages */ if(!psRefCountCCBEntry->pszFile) - break; + continue; PVR_LOG(("%s %d %s:%d", psRefCountCCBEntry->pcMesg, psRefCountCCBEntry->ui32PID, @@ -477,7 +482,7 @@ void PVRSRVOffsetStructIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32RefCount, psOffsetStruct->ui32RefCount + 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -509,7 +514,7 @@ void PVRSRVOffsetStructDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32RefCount, psOffsetStruct->ui32RefCount - 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -541,7 +546,7 @@ void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32Mapped, psOffsetStruct->ui32Mapped + 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -573,7 +578,7 @@ void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32Mapped, psOffsetStruct->ui32Mapped - 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -583,6 +588,88 @@ skip: psOffsetStruct->ui32Mapped--; } +#if defined(SUPPORT_ION) +PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, + IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) +{ + PVRSRV_ERROR eError; + + /* + We have to do the call 1st as we need to Ion syninfo which it returns + */ + eError = PVRSRVIonBufferSyncAcquire(hUnique, + hDevCookie, + hDevMemContext, + ppsIonSyncInfo); + + if (eError == PVRSRV_OK) + { + if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC)) + goto skip; + + PVRSRV_LOCK_CCB(); + + gsRefCountCCB[giOffset].pszFile = pszFile; + gsRefCountCCB[giOffset].iLine = iLine; + gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM(); + snprintf(gsRefCountCCB[giOffset].pcMesg, + PVRSRV_REFCOUNT_CCB_MESG_MAX - 1, + PVRSRV_REFCOUNT_CCB_FMT_STRING, + "ION_SYNC", + (*ppsIonSyncInfo)->psSyncInfo, + psKernelMemInfo, + NULL, + *ppsIonSyncInfo, + (*ppsIonSyncInfo)->ui32RefCount - 1, + (*ppsIonSyncInfo)->ui32RefCount, + 0); + gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; + giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; + + PVRSRV_UNLOCK_CCB(); + } + +skip: + return eError; +} + +void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, + PVRSRV_ION_SYNC_INFO *psIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) +{ + if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC)) + goto skip; + + PVRSRV_LOCK_CCB(); + + gsRefCountCCB[giOffset].pszFile = pszFile; + gsRefCountCCB[giOffset].iLine = iLine; + gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM(); + snprintf(gsRefCountCCB[giOffset].pcMesg, + PVRSRV_REFCOUNT_CCB_MESG_MAX - 1, + PVRSRV_REFCOUNT_CCB_FMT_STRING, + "ION_SYNC", + psIonSyncInfo->psSyncInfo, + psKernelMemInfo, + NULL, + psIonSyncInfo, + psIonSyncInfo->ui32RefCount, + psIonSyncInfo->ui32RefCount - 1, + 0); + gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; + giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; + + PVRSRV_UNLOCK_CCB(); +skip: + PVRSRVIonBufferSyncRelease(psIonSyncInfo); +} + +#endif /* defined (SUPPORT_ION) */ + #endif /* defined(__linux__) */ #endif /* defined(PVRSRV_REFCOUNT_DEBUG) */ diff --git a/drivers/gpu/pvr/services4/srvkm/common/resman.c b/drivers/gpu/pvr/services4/srvkm/common/resman.c index aef102f98b7..1bb3ebf449c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/resman.c +++ b/drivers/gpu/pvr/services4/srvkm/common/resman.c @@ -359,11 +359,12 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext, FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_MAPPING, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_KERNEL_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE); - FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_CONTEXT, 0, 0, IMG_TRUE); - FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_MEM_INFO, 0, 0, IMG_TRUE); #if defined(SUPPORT_ION) FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ION, 0, 0, IMG_TRUE); #endif + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_CONTEXT, 0, 0, IMG_TRUE); + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_MEM_INFO, 0, 0, IMG_TRUE); + /* DISPLAY CLASS types: */ FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_SWAPCHAIN_REF, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_DEVICE, 0, 0, IMG_TRUE); @@ -436,13 +437,13 @@ PRESMAN_ITEM ResManRegisterRes(PRESMAN_CONTEXT psResManContext, VALIDATERESLIST(); PVR_DPF((PVR_DBG_MESSAGE, "ResManRegisterRes: register resource " - "Context 0x%x, ResType 0x%x, pvParam 0x%x, ui32Param 0x%x, " - "FreeFunc %08X", - (IMG_UINTPTR_T)psResManContext, + "Context 0x%p, ResType 0x%x, pvParam 0x%p, ui32Param 0x%x, " + "FreeFunc %p", + psResManContext, ui32ResType, - (IMG_UINTPTR_T)pvParam, + pvParam, ui32Param, - (IMG_UINTPTR_T)pfnFreeResource)); + pfnFreeResource)); /* Allocate memory for the new resource structure */ if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, @@ -504,8 +505,8 @@ PVRSRV_ERROR ResManFreeResByPtr(RESMAN_ITEM *psResItem, IMG_BOOL bForceCleanup) return PVRSRV_OK; } - PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByPtr: freeing resource at %08X", - (IMG_UINTPTR_T)psResItem)); + PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByPtr: freeing resource at %p", + psResItem)); /*Acquire resource list sync object*/ ACQUIRE_SYNC_OBJ; @@ -558,9 +559,9 @@ PVRSRV_ERROR ResManFreeResByCriteria(PRESMAN_CONTEXT psResManContext, VALIDATERESLIST(); PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByCriteria: " - "Context 0x%x, Criteria 0x%x, Type 0x%x, Addr 0x%x, Param 0x%x", - (IMG_UINTPTR_T)psResManContext, ui32SearchCriteria, ui32ResType, - (IMG_UINTPTR_T)pvParam, ui32Param)); + "Context 0x%p, Criteria 0x%x, Type 0x%x, Addr 0x%p, Param 0x%x", + psResManContext, ui32SearchCriteria, ui32ResType, + pvParam, ui32Param)); /* Free resources by criteria for this context */ eError = FreeResourceByCriteria(psResManContext, ui32SearchCriteria, @@ -688,17 +689,17 @@ IMG_INTERNAL PVRSRV_ERROR ResManFindResourceByPtr(PRESMAN_CONTEXT psResManContex ACQUIRE_SYNC_OBJ; PVR_DPF((PVR_DBG_MESSAGE, - "FindResourceByPtr: psItem=%08X, psItem->psNext=%08X", - (IMG_UINTPTR_T)psItem, (IMG_UINTPTR_T)psItem->psNext)); + "FindResourceByPtr: psItem=%p, psItem->psNext=%p", + psItem, psItem->psNext)); PVR_DPF((PVR_DBG_MESSAGE, - "FindResourceByPtr: Resource Ctx 0x%x, Type 0x%x, Addr 0x%x, " - "Param 0x%x, FnCall %08X, Flags 0x%x", - (IMG_UINTPTR_T)psResManContext, + "FindResourceByPtr: Resource Ctx 0x%p, Type 0x%x, Addr 0x%p, " + "Param 0x%x, FnCall %p, Flags 0x%x", + psResManContext, psItem->ui32ResType, - (IMG_UINTPTR_T)psItem->pvParam, + psItem->pvParam, psItem->ui32Param, - (IMG_UINTPTR_T)psItem->pfnFreeResource, + psItem->pfnFreeResource, psItem->ui32Flags)); /* Search resource items starting at after the first dummy item */ @@ -754,15 +755,16 @@ static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, #endif PVR_DPF((PVR_DBG_MESSAGE, - "FreeResourceByPtr: psItem=%08X, psItem->psNext=%08X", - (IMG_UINTPTR_T)psItem, (IMG_UINTPTR_T)psItem->psNext)); + "FreeResourceByPtr: psItem=%p, psItem->psNext=%p", + psItem, psItem->psNext)); PVR_DPF((PVR_DBG_MESSAGE, - "FreeResourceByPtr: Type 0x%x, Addr 0x%x, " - "Param 0x%x, FnCall %08X, Flags 0x%x", + "FreeResourceByPtr: Type 0x%x, Addr 0x%p, " + "Param 0x%x, FnCall %p, Flags 0x%x", psItem->ui32ResType, - (IMG_UINTPTR_T)psItem->pvParam, psItem->ui32Param, - (IMG_UINTPTR_T)psItem->pfnFreeResource, psItem->ui32Flags)); + psItem->pvParam, + psItem->ui32Param, + psItem->pfnFreeResource, psItem->ui32Flags)); /* Release resource list sync object just in case the free routine calls the resource manager */ RELEASE_SYNC_OBJ; @@ -941,11 +943,11 @@ static IMG_VOID ValidateResList(PRESMAN_LIST psResList) if (psCurContext->ppsThis != ppsThisContext) { PVR_DPF((PVR_DBG_WARNING, - "psCC=%08X psCC->ppsThis=%08X psCC->psNext=%08X ppsTC=%08X", - (IMG_UINTPTR_T)psCurContext, - (IMG_UINTPTR_T)psCurContext->ppsThis, - (IMG_UINTPTR_T)psCurContext->psNext, - (IMG_UINTPTR_T)ppsThisContext)); + "psCC=%p psCC->ppsThis=%p psCC->psNext=%p ppsTC=%p", + psCurContext, + psCurContext->ppsThis, + psCurContext->psNext, + ppsThisContext)); PVR_ASSERT(psCurContext->ppsThis == ppsThisContext); } @@ -959,11 +961,11 @@ static IMG_VOID ValidateResList(PRESMAN_LIST psResList) if (psCurItem->ppsThis != ppsThisItem) { PVR_DPF((PVR_DBG_WARNING, - "psCurItem=%08X psCurItem->ppsThis=%08X psCurItem->psNext=%08X ppsThisItem=%08X", - (IMG_UINTPTR_T)psCurItem, - (IMG_UINTPTR_T)psCurItem->ppsThis, - (IMG_UINTPTR_T)psCurItem->psNext, - (IMG_UINTPTR_T)ppsThisItem)); + "psCurItem=%p psCurItem->ppsThis=%p psCurItem->psNext=%p ppsThisItem=%p", + psCurItem, + psCurItem->ppsThis, + psCurItem->psNext, + ppsThisItem)); PVR_ASSERT(psCurItem->ppsThis == ppsThisItem); } diff --git a/drivers/gpu/pvr/services4/srvkm/common/ttrace.c b/drivers/gpu/pvr/services4/srvkm/common/ttrace.c index 574bf25c315..d1dd7882db7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/ttrace.c +++ b/drivers/gpu/pvr/services4/srvkm/common/ttrace.c @@ -123,7 +123,7 @@ PVRSRVTimeTraceAllocItem(IMG_UINT32 **pui32Item, IMG_UINT32 ui32Size) { PVRSRV_ERROR eError; - PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVTimeTraceAllocItem: Creating buffer for PID %u", (IMG_UINT32) ui32PID)); + PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVTimeTraceAllocItem: Creating buffer for PID %u", ui32PID)); eError = PVRSRVTimeTraceBufferCreate(ui32PID); if (eError != PVRSRV_OK) { @@ -171,7 +171,7 @@ PVRSRVTimeTraceAllocItem(IMG_UINT32 **pui32Item, IMG_UINT32 ui32Size) psBuffer->ui32Woff = psBuffer->ui32Woff + ui32Size; psBuffer->ui32ByteCount += ui32Size; - /* This allocation will start overwritting past our read pointer, move the read pointer along */ + /* This allocation will start overwriting past our read pointer, move the read pointer along */ while (psBuffer->ui32ByteCount > TIME_TRACE_BUFFER_SIZE) { IMG_UINT32 *psReadItem = (IMG_UINT32 *) &psBuffer->ui8Data[psBuffer->ui32Roff]; @@ -248,6 +248,7 @@ PVRSRV_ERROR PVRSRVTimeTraceBufferCreate(IMG_UINT32 ui32PID) ******************************************************************************/ PVRSRV_ERROR PVRSRVTimeTraceBufferDestroy(IMG_UINT32 ui32PID) { +#if !defined(TTRACE_KEEP_BUFFER_ON_EXIT) sTimeTraceBuffer *psBuffer; #if defined(DUMP_TTRACE_BUFFERS_ON_EXIT) @@ -264,6 +265,9 @@ PVRSRV_ERROR PVRSRVTimeTraceBufferDestroy(IMG_UINT32 ui32PID) PVR_DPF((PVR_DBG_ERROR, "PVRSRVTimeTraceBufferDestroy: Can't find trace buffer in hash table")); return PVRSRV_ERROR_INVALID_PARAMS; +#else + return PVRSRV_OK; +#endif } /*! @@ -535,7 +539,7 @@ static PVRSRV_ERROR PVRSRVDumpTimeTraceBuffer(IMG_UINTPTR_T hKey, IMG_UINTPTR_T IMG_UINT32 ui32Walker = psBuffer->ui32Roff; IMG_UINT32 ui32Read, ui32LineLen, ui32EOL, ui32MinLine; - PVR_DPF((PVR_DBG_ERROR, "TTB for PID %u:\n", (IMG_UINT32) hKey)); + PVR_LOG(("TTB for PID %u:\n", (IMG_UINT32) hKey)); while (ui32ByteCount) { @@ -547,25 +551,25 @@ static PVRSRV_ERROR PVRSRVDumpTimeTraceBuffer(IMG_UINTPTR_T hKey, IMG_UINTPTR_T if (ui32MinLine >= 4) { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X %08X %08X %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X %08X %08X %08X [", ui32ByteCount, pui32Buffer[0], pui32Buffer[1], pui32Buffer[2], pui32Buffer[3])); ui32Read = 4 * sizeof(IMG_UINT32); } else if (ui32MinLine >= 3) { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X %08X %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X %08X %08X [", ui32ByteCount, pui32Buffer[0], pui32Buffer[1], pui32Buffer[2])); ui32Read = 3 * sizeof(IMG_UINT32); } else if (ui32MinLine >= 2) { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X %08X [", ui32ByteCount, pui32Buffer[0], pui32Buffer[1])); ui32Read = 2 * sizeof(IMG_UINT32); } else { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X [", ui32ByteCount, pui32Buffer[0])); ui32Read = sizeof(IMG_UINT32); } diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.c index 44dc824ec50..8e4f159da4f 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.c @@ -274,6 +274,10 @@ struct _MMU_HEAP_ static IMG_VOID _DeferredFreePageTable (MMU_HEAP *pMMUHeap, IMG_UINT32 ui32PTIndex, IMG_BOOL bOSFreePT); +#if defined (MEM_TRACK_INFO_DEBUG) +IMG_IMPORT IMG_VOID PVRSRVPrintMemTrackInfo(IMG_UINT32 ui32FaultAddr); +#endif + #if defined(PDUMP) static IMG_VOID MMU_PDumpPageTables (MMU_HEAP *pMMUHeap, @@ -332,7 +336,7 @@ static IMG_VOID CheckPT(MMU_PT_INFO *psPTInfoList) PVR_DPF((PVR_DBG_ERROR, "ui32ValidPTECount: %u ui32Count: %u\n", psPTInfoList->ui32ValidPTECount, ui32Count)); DumpPT(psPTInfoList); - BUG(); + PVR_DBG_BREAK; } } #else /* PT_DEBUG */ @@ -348,7 +352,7 @@ static INLINE IMG_VOID CheckPT(MMU_PT_INFO *psPTInfoList) it read/write when we alter it. This allows us to check that our memory isn't being overwritten */ -#if defined(PVRSRV_MMU_MAKE_READWRITE_ON_DEMAND) +#if defined(__linux__) && defined(PVRSRV_MMU_MAKE_READWRITE_ON_DEMAND) #include <linux/version.h> @@ -848,6 +852,15 @@ _AllocPageTableMemory (MMU_HEAP *pMMUHeap, } else { + /* + We cannot use IMG_SYS_PHYADDR here, as that is 64-bit for 32-bit PAE builds. + The physical address in this call to RA_Alloc is specifically the SysPAddr + of local (card) space, and it is highly unlikely we would ever need to + support > 4GB of local (card) memory (this does assume that such local + memory will be mapped into System physical memory space at a low address so + that any and all local memory exists within the 4GB SYSPAddr range). + */ + IMG_UINTPTR_T uiLocalPAddr; IMG_SYS_PHYADDR sSysPAddr; /* @@ -864,12 +877,15 @@ _AllocPageTableMemory (MMU_HEAP *pMMUHeap, 0, IMG_NULL, 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) + &uiLocalPAddr)!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "_AllocPageTableMemory: ERROR call to RA_Alloc failed")); return IMG_FALSE; } + /* Munge the local PAddr back into the SysPAddr */ + sSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); /* note: actual ammount is pMMUHeap->ui32PTSize but must be a multiple of 4k pages */ @@ -986,8 +1002,9 @@ _FreePageTableMemory (MMU_HEAP *pMMUHeap, MMU_PT_INFO *psPTInfoList) /* just free from the first local memory arena (unlikely to be more than one local mem area(?)) + Note that the cast to IMG_UINTPTR_T is ok as we're local mem. */ - RA_Free (pMMUHeap->psDevArena->psDeviceMemoryHeapInfo->psLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + RA_Free (pMMUHeap->psDevArena->psDeviceMemoryHeapInfo->psLocalDevMemArena, (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } } @@ -1308,8 +1325,9 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT if((UINT32_MAX_VALUE - DevVAddr.uiAddr) < (ui32Size + pMMUHeap->ui32DataPageMask + pMMUHeap->ui32PTMask)) { - /* detected overflow, clamp to highest address */ + /* detected overflow, clamp to highest address, reserve all PDs */ sHighDevVAddr.uiAddr = UINT32_MAX_VALUE; + ui32PageTableCount = 1024; } else { @@ -1317,9 +1335,10 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT + ui32Size + pMMUHeap->ui32DataPageMask + pMMUHeap->ui32PTMask; + + ui32PageTableCount = sHighDevVAddr.uiAddr >> pMMUHeap->ui32PDShift; } - ui32PageTableCount = sHighDevVAddr.uiAddr >> pMMUHeap->ui32PDShift; /* Fix allocation of last 4MB */ if (ui32PageTableCount == 0) @@ -1343,10 +1362,18 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT DevVAddr.uiAddr = DevVAddr.uiAddr & (~BRN31620_PDE_CACHE_FILL_MASK); /* Round the end address of the PD allocation to cacheline */ - sHighDevVAddr.uiAddr = ((sHighDevVAddr.uiAddr + (BRN31620_PDE_CACHE_FILL_SIZE - 1)) & (~BRN31620_PDE_CACHE_FILL_MASK)); + if (UINT32_MAX_VALUE - sHighDevVAddr.uiAddr < (BRN31620_PDE_CACHE_FILL_SIZE - 1)) + { + sHighDevVAddr.uiAddr = UINT32_MAX_VALUE; + ui32PageTableCount = 1024; + } + else + { + sHighDevVAddr.uiAddr = ((sHighDevVAddr.uiAddr + (BRN31620_PDE_CACHE_FILL_SIZE - 1)) & (~BRN31620_PDE_CACHE_FILL_MASK)); + ui32PageTableCount = sHighDevVAddr.uiAddr >> pMMUHeap->ui32PDShift; + } ui32PDIndex = DevVAddr.uiAddr >> pMMUHeap->ui32PDShift; - ui32PageTableCount = sHighDevVAddr.uiAddr >> pMMUHeap->ui32PDShift; /* Fix allocation of last 4MB */ if (ui32PageTableCount == 0) @@ -1371,10 +1398,11 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT { ui32Flags |= PDUMP_FLAGS_CONTINUOUS; } - PDUMPCOMMENTWITHFLAGS(ui32Flags, "Alloc PTs (MMU Context ID == %u, PDBaseIndex == %u, Size == 0x%x)", + PDUMPCOMMENTWITHFLAGS(ui32Flags, "Alloc PTs (MMU Context ID == %u, PDBaseIndex == %u, Size == 0x%x, Shared = %s)", pMMUHeap->psMMUContext->ui32PDumpMMUContextID, pMMUHeap->ui32PDBaseIndex, - ui32Size); + ui32Size, + MMU_IsHeapShared(pMMUHeap)?"True":"False"); PDUMPCOMMENTWITHFLAGS(ui32Flags, "Alloc page table (page count == %08X)", ui32PageTableCount); PDUMPCOMMENTWITHFLAGS(ui32Flags, "Page directory mods (page count == %08X)", ui32PageTableCount); } @@ -1424,7 +1452,7 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT if(ppsPTInfoList[i]->hPTPageOSMemHandle == IMG_NULL && ppsPTInfoList[i]->PTPageCpuVAddr == IMG_NULL) { - IMG_DEV_PHYADDR sDevPAddr; + IMG_DEV_PHYADDR sDevPAddr = { 0 }; #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) IMG_UINT32 *pui32Tmp; IMG_UINT32 j; @@ -1473,7 +1501,9 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT { /* insert Page Table into all memory contexts */ MMU_CONTEXT *psMMUContext = (MMU_CONTEXT*)pMMUHeap->psMMUContext->psDevInfo->pvMMUContextList; - +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + PVRSRV_SGXDEV_INFO *psDevInfo = psMMUContext->psDevInfo; +#endif while(psMMUContext) { MakeKernelPageReadWrite(psMMUContext->pvPDCpuVAddr); @@ -1482,7 +1512,7 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT pui32PDEntry += ui32PDIndex; /* insert the page, specify the data page size and make the pde valid */ - pui32PDEntry[i] = (sDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) + pui32PDEntry[i] = (IMG_UINT32)(sDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) | pMMUHeap->ui32PDEPageSizeCtrl | SGX_MMU_PDE_VALID; MakeKernelPageReadOnly(psMMUContext->pvPDCpuVAddr); @@ -1492,8 +1522,16 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT if(psMMUContext->bPDumpActive) #endif { - //PDUMPCOMMENT("_DeferredAllocPTs: Dumping shared PDEs on context %d (%s)", psMMUContext->ui32PDumpMMUContextID, (psMMUContext->bPDumpActive) ? "active" : ""); - PDUMPPDENTRIES(&pMMUHeap->sMMUAttrib, psMMUContext->hPDOSMemHandle, (IMG_VOID*)&pui32PDEntry[i], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + /* + Any modification of the uKernel memory context + needs to be PDumped when we're multi-process + */ + IMG_UINT32 ui32HeapFlags = ( psMMUContext->sPDDevPAddr.uiAddr == psDevInfo->sKernelPDDevPAddr.uiAddr ) ? PDUMP_FLAGS_PERSISTENT : 0; +#else + IMG_UINT32 ui32HeapFlags = 0; +#endif + PDUMPPDENTRIES(&pMMUHeap->sMMUAttrib, psMMUContext->hPDOSMemHandle, (IMG_VOID*)&pui32PDEntry[i], sizeof(IMG_UINT32), ui32HeapFlags, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); } #endif /* PDUMP */ /* advance to next context */ @@ -1509,12 +1547,11 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT { MakeKernelPageReadWrite(pMMUHeap->psMMUContext->pvPDCpuVAddr); /* insert Page Table into only this memory context */ - pui32PDEntry[i] = (sDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) + pui32PDEntry[i] = (IMG_UINT32)(sDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) | pMMUHeap->ui32PDEPageSizeCtrl | SGX_MMU_PDE_VALID; MakeKernelPageReadOnly(pMMUHeap->psMMUContext->pvPDCpuVAddr); /* pdump the PD Page modifications */ - //PDUMPCOMMENT("_DeferredAllocPTs: Dumping kernel PDEs on context %d (%s)", pMMUHeap->psMMUContext->ui32PDumpMMUContextID, (pMMUHeap->psMMUContext->bPDumpActive) ? "active" : ""); PDUMPPDENTRIES(&pMMUHeap->sMMUAttrib, pMMUHeap->psMMUContext->hPDOSMemHandle, (IMG_VOID*)&pui32PDEntry[i], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); break; } @@ -1918,6 +1955,15 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I } else { + /* + We cannot use IMG_SYS_PHYADDR here, as that is 64-bit for 32-bit PAE builds. + The physical address in this call to RA_Alloc is specifically the SysPAddr + of local (card) space, and it is highly unlikely we would ever need to + support > 4GB of local (card) memory (this does assume that such local + memory will be mapped into System physical memory space at a low address so + that any and all local memory exists within the 4GB SYSPAddr range). + */ + IMG_UINTPTR_T uiLocalPAddr; IMG_SYS_PHYADDR sSysPAddr; /* allocate from the device's local memory arena */ @@ -1930,12 +1976,15 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, IMG_NULL, 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) + &uiLocalPAddr)!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; } + /* Munge the local PAddr back into the SysPAddr */ + sSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); sPDDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); @@ -1967,12 +2016,15 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, IMG_NULL, 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) + &uiLocalPAddr)!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; } + /* Munge the local PAddr back into the SysPAddr */ + sSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); psDevInfo->sDummyPTDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); @@ -1996,12 +2048,15 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, IMG_NULL, 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) + &uiLocalPAddr)!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; } + /* Munge the local PAddr back into the SysPAddr */ + sSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); psDevInfo->sDummyDataDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); @@ -2031,12 +2086,15 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, IMG_NULL, 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) + &uiLocalPAddr)!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; } + /* Munge the local PAddr back into the SysPAddr */ + sSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); psDevInfo->sBRN31620DummyPageDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); @@ -2069,12 +2127,15 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, IMG_NULL, 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) + &uiLocalPAddr)!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; } + /* Munge the local PAddr back into the SysPAddr */ + sSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); psDevInfo->sBRN31620DummyPTDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); @@ -2123,13 +2184,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I } #endif /* SUPPORT_PDUMP_MULTI_PROCESS */ /* pdump the PD malloc */ -#if IMG_ADDRSPACE_PHYSADDR_BITS == 32 - PDUMPCOMMENT("Alloc page directory for new MMU context (PDDevPAddr == 0x%08x)", - sPDDevPAddr.uiAddr); -#else - PDUMPCOMMENT("Alloc page directory for new MMU context, 64-bit arch detected (PDDevPAddr == 0x%08x%08x)", - sPDDevPAddr.uiHighAddr, sPDDevPAddr.uiAddr); -#endif + PDUMPCOMMENT("Alloc page directory for new MMU context (PDDevPAddr == 0x" DEVPADDR_FMT ")", sPDDevPAddr.uiAddr); PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevId, hPDOSMemHandle, 0, pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PD_UNIQUETAG); #endif /* PDUMP */ @@ -2377,13 +2432,8 @@ MMU_Finalise (MMU_CONTEXT *psMMUContext) PDUMPCLEARMMUCONTEXT(PVRSRV_DEVICE_TYPE_SGX, psMMUContext->psDeviceNode->sDevId.pszPDumpDevName, psMMUContext->ui32PDumpMMUContextID, 2); /* pdump the PD free */ -#if IMG_ADDRSPACE_PHYSADDR_BITS == 32 - PDUMPCOMMENT("Free page directory (PDDevPAddr == 0x%08x)", + PDUMPCOMMENT("Free page directory (PDDevPAddr == 0x" DEVPADDR_FMT ")", psMMUContext->sPDDevPAddr.uiAddr); -#else - PDUMPCOMMENT("Free page directory, 64-bit arch detected (PDDevPAddr == 0x%08x%08x)", - psMMUContext->sPDDevPAddr.uiHighAddr, psMMUContext->sPDDevPAddr.uiAddr); -#endif #endif /* PDUMP */ PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psMMUContext->hPDOSMemHandle, psMMUContext->pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); @@ -2467,8 +2517,8 @@ MMU_Finalise (MMU_CONTEXT *psMMUContext) SGX_MMU_PAGE_SIZE, PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, psMMUContext->hPDOSMemHandle); - /* and free the memory */ - RA_Free (psMMUContext->psDeviceNode->psLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + /* and free the memory, Note that the cast to IMG_UINTPTR_T is ok as we're local mem. */ + RA_Free (psMMUContext->psDeviceNode->psLocalDevMemArena, (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) /* if this is the last context free the dummy pages too */ @@ -2819,16 +2869,16 @@ MMU_UnmapPagesAndFreePTs (MMU_HEAP *psMMUHeap, RETURNS: ******************************************************************************/ static IMG_VOID MMU_FreePageTables(IMG_PVOID pvMMUHeap, - IMG_SIZE_T ui32Start, - IMG_SIZE_T ui32End, + IMG_SIZE_T uStart, + IMG_SIZE_T uEnd, IMG_HANDLE hUniqueTag) { MMU_HEAP *pMMUHeap = (MMU_HEAP*)pvMMUHeap; IMG_DEV_VIRTADDR Start; - Start.uiAddr = (IMG_UINT32)ui32Start; + Start.uiAddr = (IMG_UINT32)uStart; - MMU_UnmapPagesAndFreePTs(pMMUHeap, Start, (IMG_UINT32)((ui32End - ui32Start) >> pMMUHeap->ui32PTShift), hUniqueTag); + MMU_UnmapPagesAndFreePTs(pMMUHeap, Start, (IMG_UINT32)((uEnd - uStart) >> pMMUHeap->ui32PTShift), hUniqueTag); } /*! @@ -3086,7 +3136,7 @@ MMU_Alloc (MMU_HEAP *pMMUHeap, IMG_BOOL bStatus; PVR_DPF ((PVR_DBG_MESSAGE, - "MMU_Alloc: uSize=0x%x, flags=0x%x, align=0x%x", + "MMU_Alloc: uSize=0x%" SIZE_T_FMT_LEN "x, flags=0x%x, align=0x%x", uSize, uFlags, uDevVAddrAlignment)); /* @@ -3108,10 +3158,19 @@ MMU_Alloc (MMU_HEAP *pMMUHeap, &uiAddr); if(!bStatus) { - PVR_DPF((PVR_DBG_ERROR,"MMU_Alloc: RA_Alloc of VMArena failed")); - PVR_DPF((PVR_DBG_ERROR,"MMU_Alloc: Alloc of DevVAddr failed from heap %s ID%d", - pMMUHeap->psDevArena->pszName, - pMMUHeap->psDevArena->ui32HeapID)); + IMG_CHAR asCurrentProcessName[128]; + + PVR_DPF((PVR_DBG_ERROR,"MMU_Alloc: RA_Alloc of VMArena failed")); + OSGetCurrentProcessNameKM(asCurrentProcessName, 128); + PVR_DPF((PVR_DBG_ERROR,"MMU_Alloc: Alloc of DevVAddr failed from heap %s ID%d, pid: %d, task: %s", + pMMUHeap->psDevArena->pszName, + pMMUHeap->psDevArena->ui32HeapID, + OSGetCurrentProcessIDKM(), + asCurrentProcessName)); + #if defined (MEM_TRACK_INFO_DEBUG) + PVRSRVPrintMemTrackInfo(0); + #endif + return bStatus; } @@ -3467,7 +3526,10 @@ MMU_MapPage (MMU_HEAP *pMMUHeap, DevVAddr.uiAddr >> pMMUHeap->ui32PDShift, ui32Index )); PVR_DPF((PVR_DBG_ERROR, "MMU_MapPage: Page table entry value: 0x%08X", uTmp)); - PVR_DPF((PVR_DBG_ERROR, "MMU_MapPage: Physical page to map: 0x%08X", DevPAddr.uiAddr)); + + PVR_DPF((PVR_DBG_ERROR, "MMU_MapPage: Physical page to map: 0x" DEVPADDR_FMT, + DevPAddr.uiAddr)); + #if PT_DUMP DumpPT(ppsPTInfoList[0]); #endif @@ -3483,7 +3545,7 @@ MMU_MapPage (MMU_HEAP *pMMUHeap, MakeKernelPageReadWrite(ppsPTInfoList[0]->PTPageCpuVAddr); /* map in the physical page */ - pui32Tmp[ui32Index] = ((DevPAddr.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) + pui32Tmp[ui32Index] = ((IMG_UINT32)(DevPAddr.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) & ((~pMMUHeap->ui32DataPageMask)>>SGX_MMU_PTE_ADDR_ALIGNSHIFT)) | SGX_MMU_PTE_VALID | ui32MMUFlags; @@ -3546,10 +3608,14 @@ MMU_MapScatter (MMU_HEAP *pMMUHeap, DevVAddr.uiAddr += pMMUHeap->ui32DataPageSize; PVR_DPF ((PVR_DBG_MESSAGE, - "MMU_MapScatter: devVAddr=%08X, SysAddr=%08X, size=0x%x/0x%x", + "MMU_MapScatter: devVAddr=%x, SysAddr=" SYSPADDR_FMT ", size=0x%x/0x%" SIZE_T_FMT_LEN "x", DevVAddr.uiAddr, sSysAddr.uiAddr, uCount, uSize)); } +#if (SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE > 1) + MMU_InvalidatePageTableCache(pMMUHeap->psMMUContext->psDevInfo); +#endif + #if defined(PDUMP) MMU_PDumpPageTables (pMMUHeap, MapBaseDevVAddr, uSize, IMG_FALSE, hUniqueTag); #endif /* #if defined(PDUMP) */ @@ -3589,7 +3655,7 @@ MMU_MapPages (MMU_HEAP *pMMUHeap, PVR_ASSERT (pMMUHeap != IMG_NULL); - PVR_DPF ((PVR_DBG_MESSAGE, "MMU_MapPages: heap:%s, heap_id:%d devVAddr=%08X, SysPAddr=%08X, size=0x%x", + PVR_DPF ((PVR_DBG_MESSAGE, "MMU_MapPages: heap:%s, heap_id:%d devVAddr=%08X, SysPAddr=" SYSPADDR_FMT ", size=0x%" SIZE_T_FMT_LEN "x", pMMUHeap->psDevArena->pszName, pMMUHeap->psDevArena->ui32HeapID, DevVAddr.uiAddr, @@ -3627,6 +3693,10 @@ MMU_MapPages (MMU_HEAP *pMMUHeap, DevPAddr.uiAddr += ui32PAdvance; } +#if (SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE > 1) + MMU_InvalidatePageTableCache(pMMUHeap->psMMUContext->psDevInfo); +#endif + #if defined(PDUMP) MMU_PDumpPageTables (pMMUHeap, MapBaseDevVAddr, uSize, IMG_FALSE, hUniqueTag); #endif /* #if defined(PDUMP) */ @@ -3677,7 +3747,7 @@ MMU_MapPagesSparse (MMU_HEAP *pMMUHeap, PVR_ASSERT (pMMUHeap != IMG_NULL); - PVR_DPF ((PVR_DBG_MESSAGE, "MMU_MapPagesSparse: heap:%s, heap_id:%d devVAddr=%08X, SysPAddr=%08X, VM space=0x%x, PHYS space=0x%x", + PVR_DPF ((PVR_DBG_MESSAGE, "MMU_MapPagesSparse: heap:%s, heap_id:%d devVAddr=%08X, SysPAddr=" SYSPADDR_FMT ", VM space=0x%" SIZE_T_FMT_LEN "x, PHYS space=0x%x", pMMUHeap->psDevArena->pszName, pMMUHeap->psDevArena->ui32HeapID, DevVAddr.uiAddr, @@ -3720,6 +3790,10 @@ MMU_MapPagesSparse (MMU_HEAP *pMMUHeap, } pMMUHeap->bHasSparseMappings = IMG_TRUE; +#if (SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE > 1) + MMU_InvalidatePageTableCache(pMMUHeap->psMMUContext->psDevInfo); +#endif + #if defined(PDUMP) MMU_PDumpPageTables (pMMUHeap, MapBaseDevVAddr, uSizeVM, IMG_FALSE, hUniqueTag); #endif /* #if defined(PDUMP) */ @@ -3772,10 +3846,10 @@ MMU_MapShadow (MMU_HEAP *pMMUHeap, #endif PVR_DPF ((PVR_DBG_MESSAGE, - "MMU_MapShadow: DevVAddr:%08X, Bytes:0x%x, CPUVAddr:%08X", + "MMU_MapShadow: DevVAddr:%08X, Bytes:0x%" SIZE_T_FMT_LEN "x, CPUVAddr:%p", MapBaseDevVAddr.uiAddr, uByteSize, - (IMG_UINTPTR_T)CpuVAddr)); + CpuVAddr)); /* set the virtual and physical advance */ ui32VAdvance = pMMUHeap->ui32DataPageSize; @@ -3817,9 +3891,9 @@ MMU_MapShadow (MMU_HEAP *pMMUHeap, PVR_ASSERT((DevPAddr.uiAddr & pMMUHeap->ui32DataPageMask) == 0); PVR_DPF ((PVR_DBG_MESSAGE, - "Offset=0x%x: CpuVAddr=%08X, CpuPAddr=%08X, DevVAddr=%08X, DevPAddr=%08X", + "Offset=0x%x: CpuVAddr=%p, CpuPAddr=" CPUPADDR_FMT ", DevVAddr=%08X, DevPAddr=" DEVPADDR_FMT, uOffset, - (IMG_UINTPTR_T)CpuVAddr + uOffset, + (IMG_PVOID)((IMG_UINTPTR_T)CpuVAddr + uOffset), CpuPAddr.uiAddr, MapDevVAddr.uiAddr, DevPAddr.uiAddr)); @@ -3831,6 +3905,10 @@ MMU_MapShadow (MMU_HEAP *pMMUHeap, uOffset += ui32PAdvance; } +#if (SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE > 1) + MMU_InvalidatePageTableCache(pMMUHeap->psMMUContext->psDevInfo); +#endif + #if defined(PDUMP) MMU_PDumpPageTables (pMMUHeap, MapBaseDevVAddr, uByteSize, IMG_FALSE, hUniqueTag); #endif /* #if defined(PDUMP) */ @@ -3894,10 +3972,10 @@ MMU_MapShadowSparse (MMU_HEAP *pMMUHeap, #endif PVR_DPF ((PVR_DBG_MESSAGE, - "MMU_MapShadowSparse: DevVAddr:%08X, VM space:0x%x, CPUVAddr:%08X PHYS space:0x%x", + "MMU_MapShadowSparse: DevVAddr:%08X, VM space:0x%" SIZE_T_FMT_LEN "x, CPUVAddr:%p PHYS space:0x%x", MapBaseDevVAddr.uiAddr, uiSizeVM, - (IMG_UINTPTR_T)CpuVAddr, + CpuVAddr, ui32ChunkSize * ui32NumPhysChunks)); /* set the virtual and physical advance */ @@ -3937,9 +4015,9 @@ MMU_MapShadowSparse (MMU_HEAP *pMMUHeap, PVR_ASSERT((DevPAddr.uiAddr & pMMUHeap->ui32DataPageMask) == 0); PVR_DPF ((PVR_DBG_MESSAGE, - "Offset=0x%x: CpuVAddr=%08X, CpuPAddr=%08X, DevVAddr=%08X, DevPAddr=%08X", + "Offset=0x%x: CpuVAddr=%p, CpuPAddr=" CPUPADDR_FMT ", DevVAddr=%08X, DevPAddr=" DEVPADDR_FMT, uOffset, - (IMG_UINTPTR_T)CpuVAddr + uOffset, + (void *)((IMG_UINTPTR_T)CpuVAddr + uOffset), CpuPAddr.uiAddr, MapDevVAddr.uiAddr, DevPAddr.uiAddr)); @@ -3959,6 +4037,11 @@ MMU_MapShadowSparse (MMU_HEAP *pMMUHeap, } pMMUHeap->bHasSparseMappings = IMG_TRUE; + +#if (SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE > 1) + MMU_InvalidatePageTableCache(pMMUHeap->psMMUContext->psDevInfo); +#endif + #if defined(PDUMP) MMU_PDumpPageTables (pMMUHeap, MapBaseDevVAddr, uiSizeVM, IMG_FALSE, hUniqueTag); #endif /* #if defined(PDUMP) */ @@ -4261,6 +4344,16 @@ PVRSRV_ERROR MMU_BIFResetPDAlloc(PVRSRV_SGXDEV_INFO *psDevInfo) { /* non-UMA system */ + /* + We cannot use IMG_SYS_PHYADDR here, as that is 64-bit for 32-bit PAE builds. + The physical address in this call to RA_Alloc is specifically the SysPAddr + of local (card) space, and it is highly unlikely we would ever need to + support > 4GB of local (card) memory (this does assume that such local + memory will be mapped into System physical memory space at a low address so + that any and all local memory exists within the 4GB SYSPAddr range). + */ + IMG_UINTPTR_T uiLocalPAddr; + if(RA_Alloc(psLocalDevMemArena, 3 * SGX_MMU_PAGE_SIZE, IMG_NULL, @@ -4270,12 +4363,15 @@ PVRSRV_ERROR MMU_BIFResetPDAlloc(PVRSRV_SGXDEV_INFO *psDevInfo) 0, IMG_NULL, 0, - &(sMemBlockSysPAddr.uiAddr)) != IMG_TRUE) + &uiLocalPAddr) != IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_BIFResetPDAlloc: ERROR call to RA_Alloc failed")); return PVRSRV_ERROR_OUT_OF_MEMORY; } + /* Munge the local PAddr back into the SysPAddr */ + sMemBlockSysPAddr.uiAddr = uiLocalPAddr; + /* derive the CPU virtual address */ sMemBlockCpuPAddr = SysSysPAddrToCpuPAddr(sMemBlockSysPAddr); pui8MemBlock = OSMapPhysToLin(sMemBlockCpuPAddr, @@ -4342,7 +4438,8 @@ IMG_VOID MMU_BIFResetPDFree(PVRSRV_SGXDEV_INFO *psDevInfo) psDevInfo->hBIFResetPDOSMemHandle); sPDSysPAddr = SysDevPAddrToSysPAddr(PVRSRV_DEVICE_TYPE_SGX, psDevInfo->sBIFResetPDDevPAddr); - RA_Free(psLocalDevMemArena, sPDSysPAddr.uiAddr, IMG_FALSE); + /* Note that the cast to IMG_UINTPTR_T is ok as we're local mem. */ + RA_Free(psLocalDevMemArena, (IMG_UINTPTR_T)sPDSysPAddr.uiAddr, IMG_FALSE); } } @@ -4421,7 +4518,7 @@ PVRSRV_ERROR MMU_MapExtSystemCacheRegs(PVRSRV_DEVICE_NODE *psDeviceNode) { IMG_CHAR szScript[128]; - sprintf(szScript, "MALLOC :EXTSYSCACHE:PA_%08X%08X %u %u 0x%08X\r\n", 0, psDevInfo->sExtSysCacheRegsDevPBase.uiAddr, SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, psDevInfo->sExtSysCacheRegsDevPBase.uiAddr); + sprintf(szScript, "MALLOC :EXTSYSCACHE:PA_%08X%08X %u %u 0x%p\r\n", 0, psDevInfo->sExtSysCacheRegsDevPBase.uiAddr, SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, psDevInfo->sExtSysCacheRegsDevPBase.uiAddr); PDumpOSWriteString2(szScript, PDUMP_FLAGS_CONTINUOUS); } #endif @@ -4454,13 +4551,13 @@ PVRSRV_ERROR MMU_MapExtSystemCacheRegs(PVRSRV_DEVICE_NODE *psDeviceNode) eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", + "WRW :%s:PA_%p%p:0x%08X :%s:PA_%p%08X:0x%08X\r\n", sMMUAttrib.sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)PDUMP_PT_UNIQUETAG, - (sDevPAddr.uiAddr) & ~ui32PageMask, + PDUMP_PT_UNIQUETAG, + (IMG_PVOID)((sDevPAddr.uiAddr) & ~ui32PageMask), (sDevPAddr.uiAddr) & ui32PageMask, "EXTSYSCACHE", - (IMG_UINT32)(IMG_UINTPTR_T)PDUMP_PD_UNIQUETAG, + PDUMP_PD_UNIQUETAG, (ui32PTE & sMMUAttrib.ui32PDEMask) << sMMUAttrib.ui32PTEAlignShift, ui32PTE & ~sMMUAttrib.ui32PDEMask); if(eErr != PVRSRV_OK) @@ -4560,7 +4657,7 @@ static IMG_VOID PageTest(IMG_VOID* pMem, IMG_DEV_PHYADDR sDevPAddr) if (ui32WriteData != ui32ReadData) { // Mem fault - PVR_DPF ((PVR_DBG_ERROR, "Error - memory page test failed at device phys address 0x%08X", sDevPAddr.uiAddr + (n<<2) )); + PVR_DPF ((PVR_DBG_ERROR, "Error - memory page test failed at device phys address 0x" DEVPADDR_FMT, sDevPAddr.uiAddr + (n<<2) )); PVR_DBG_BREAK; bOK = IMG_FALSE; } @@ -4576,7 +4673,7 @@ static IMG_VOID PageTest(IMG_VOID* pMem, IMG_DEV_PHYADDR sDevPAddr) if (ui32WriteData != ui32ReadData) { // Mem fault - PVR_DPF ((PVR_DBG_ERROR, "Error - memory page test failed at device phys address 0x%08X", sDevPAddr.uiAddr + (n<<2) )); + PVR_DPF ((PVR_DBG_ERROR, "Error - memory page test failed at device phys address 0x" DEVPADDR_FMT, sDevPAddr.uiAddr + (n<<2))); PVR_DBG_BREAK; bOK = IMG_FALSE; } @@ -4584,11 +4681,11 @@ static IMG_VOID PageTest(IMG_VOID* pMem, IMG_DEV_PHYADDR sDevPAddr) if (bOK) { - PVR_DPF ((PVR_DBG_VERBOSE, "MMU Page 0x%08X is OK", sDevPAddr.uiAddr)); + PVR_DPF ((PVR_DBG_VERBOSE, "MMU Page 0x" DEVPADDR_FMT " is OK", sDevPAddr.uiAddr)); } else { - PVR_DPF ((PVR_DBG_VERBOSE, "MMU Page 0x%08X *** FAILED ***", sDevPAddr.uiAddr)); + PVR_DPF ((PVR_DBG_VERBOSE, "MMU Page 0x" DEVPADDR_FMT " *** FAILED ***", sDevPAddr.uiAddr)); } } #endif diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.h b/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.h index 3c849fc982b..3c849fc982b 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.h +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/mmu.h diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/pb.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/pb.c index 4ed18bb97e6..26e2ded8053 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/pb.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/pb.c @@ -100,7 +100,7 @@ SGXFindSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, ui32TotalPBSize, psStubPBDesc->ui32TotalPBSize)); } - if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + if(OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_MEM_INFO *) * psStubPBDesc->ui32SubKernelMemInfosCount, (IMG_VOID **)&ppsSharedPBDescSubKernelMemInfos, diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgx_bridge_km.h b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgx_bridge_km.h index f281c4e141d..260a26506c1 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgx_bridge_km.h +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgx_bridge_km.h @@ -55,28 +55,16 @@ extern "C" { #endif IMG_IMPORT -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK_KM *psKick); -#else PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick); -#endif #if defined(SGX_FEATURE_2D_HARDWARE) IMG_IMPORT -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK_KM *psKick); -#else PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK *psKick); #endif -#endif IMG_IMPORT PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, -#if defined (SUPPORT_SID_INTERFACE) - SGX_CCB_KICK_KM *psCCBKick); -#else SGX_CCB_KICK *psCCBKick); -#endif IMG_IMPORT PVRSRV_ERROR SGXGetPhysPageAddrKM(IMG_HANDLE hDevMemHeap, @@ -114,21 +102,12 @@ PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_IMPORT PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_HEAP_INFO_KM *pasHeapInfo, - IMG_DEV_PHYADDR *psPDDevPAddr); -#else SGX_BRIDGE_INFO_FOR_SRVINIT *psInitInfo); -#endif IMG_IMPORT PVRSRV_ERROR DevInitSGXPart2KM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevHandle, -#if defined (SUPPORT_SID_INTERFACE) - SGX_BRIDGE_INIT_INFO_KM *psInitInfo); -#else SGX_BRIDGE_INIT_INFO *psInitInfo); -#endif /*! * ***************************************************************************** @@ -262,11 +241,7 @@ SGXAddSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, ********************************************************************************/ IMG_IMPORT PVRSRV_ERROR SGXGetInternalDevInfoKM(IMG_HANDLE hDevCookie, -#if defined (SUPPORT_SID_INTERFACE) - SGX_INTERNAL_DEVINFO_KM *psSGXInternalDevInfo); -#else SGX_INTERNAL_DEVINFO *psSGXInternalDevInfo); -#endif #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxconfig.h b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxconfig.h index b9ebab9894a..632ab5150ff 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxconfig.h +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxconfig.h @@ -56,13 +56,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_KERNEL_DATA_HEAP_OFFSET 0x00000000 #endif -#if !defined(ION_HEAP_SIZE) && defined(SUPPORT_ION) - /* Default the Ion heap to 16MB */ - #define ION_HEAP_SIZE 0x01000000 -#else - #define ION_HEAP_SIZE 0 -#endif - #if SGX_FEATURE_ADDRESS_SPACE_SIZE == 32 #if defined(FIX_HW_BRN_31620) @@ -78,7 +71,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * For hybrid PB we have to split virtual PB range between the shared * PB and percontext PB due to the fact we only have one heap config * per device. - * If hybrid PB is enabled we split the space acording to HYBRID_SHARED_PB_SIZE. + * If hybrid PB is enabled we split the space according to HYBRID_SHARED_PB_SIZE. * i.e. HYBRID_SHARED_PB_SIZE defines the size of the shared PB and the * remainder is the size of the percontext PB. * If hybrid PB is not enabled then we still create both heaps (helps keep @@ -109,10 +102,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0xC0000000 - /* Size is defiend above */ + /* Size is defined above */ #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE (SGX_SHARED_3DPARAMETERS_HEAP_BASE + SGX_SHARED_3DPARAMETERS_SIZE) - /* Size is defiend above */ + /* Size is defined above */ #define SGX_TADATA_HEAP_BASE 0xD0000000 #define SGX_TADATA_HEAP_SIZE (0x0D000000-0x00001000) @@ -151,16 +144,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #if !defined(SUPPORT_MEMORY_TILING) - #if defined (SUPPORT_ION) - #define SGX_GENERAL_HEAP_BASE 0x10000000 - #define SGX_GENERAL_HEAP_SIZE (0xC2000000-ION_HEAP_SIZE-0x00001000) - - #define SGX_ION_HEAP_BASE (SGX_GENERAL_HEAP_BASE+SGX_GENERAL_HEAP_SIZE+0x00001000) - #define SGX_ION_HEAP_SIZE (ION_HEAP_SIZE-0x00001000) - #else - #define SGX_GENERAL_HEAP_BASE 0x10000000 - #define SGX_GENERAL_HEAP_SIZE (0xC2000000-0x00001000) - #endif + #define SGX_GENERAL_HEAP_BASE 0x10000000 + #define SGX_GENERAL_HEAP_SIZE (0xC2000000-0x00001000) #else #include <sgx_msvdx_defs.h> /* Create heaps with memory tiling enabled. @@ -185,7 +170,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * For hybrid PB we have to split virtual PB range between the shared * PB and percontext PB due to the fact we only have one heap config * per device. - * If hybrid PB is enabled we split the space acording to HYBRID_SHARED_PB_SIZE. + * If hybrid PB is enabled we split the space according to HYBRID_SHARED_PB_SIZE. * i.e. HYBRID_SHARED_PB_SIZE defines the size of the shared PB and the * remainder is the size of the percontext PB. * If hybrid PB is not enabled then we still create both heaps (helps keep @@ -216,10 +201,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0xD2000000 - /* Size is defiend above */ + /* Size is defined above */ #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE (SGX_SHARED_3DPARAMETERS_HEAP_BASE + SGX_SHARED_3DPARAMETERS_SIZE) - /* Size is defiend above */ + /* Size is defined above */ #define SGX_TADATA_HEAP_BASE 0xE2000000 #define SGX_TADATA_HEAP_SIZE (0x0D000000-0x00001000) @@ -258,26 +243,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_GENERAL_MAPPING_HEAP_SIZE (0x01800000-0x00001000-0x00001000) #define SGX_GENERAL_HEAP_BASE 0x01800000 - #define SGX_GENERAL_HEAP_SIZE (0x07000000-ION_HEAP_SIZE-0x00001000) + #define SGX_GENERAL_HEAP_SIZE (0x07000000-0x00001000) #else #define SGX_GENERAL_HEAP_BASE 0x00001000 #if defined(SUPPORT_LARGE_GENERAL_HEAP) - #define SGX_GENERAL_HEAP_SIZE (0x0B800000-ION_HEAP_SIZE-0x00001000-0x00001000) + #define SGX_GENERAL_HEAP_SIZE (0x0B800000-0x00001000-0x00001000) #else - #define SGX_GENERAL_HEAP_SIZE (0x08800000-ION_HEAP_SIZE-0x00001000-0x00001000) + #define SGX_GENERAL_HEAP_SIZE (0x08800000-0x00001000-0x00001000) #endif #endif -#if defined(SUPPORT_ION) - #define SGX_ION_HEAP_BASE (SGX_GENERAL_HEAP_BASE+SGX_GENERAL_HEAP_SIZE+0x00001000) - #define SGX_ION_HEAP_SIZE (ION_HEAP_SIZE-0x00001000) -#endif /* * For hybrid PB we have to split virtual PB range between the shared * PB and percontext PB due to the fact we only have one heap config * per device. - * If hybrid PB is enabled we split the space acording to HYBRID_SHARED_PB_SIZE. + * If hybrid PB is enabled we split the space according to HYBRID_SHARED_PB_SIZE. * i.e. HYBRID_SHARED_PB_SIZE defines the size of the shared PB and the * remainder is the size of the percontext PB. * If hybrid PB is not enabled then we still create both heaps (helps keep @@ -428,11 +409,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #error "sgxconfig.h: ERROR: SGX_VPB_TILED_HEAP overlaps SGX_3DPARAMETERS_HEAP" #endif #else - #if defined(SUPPORT_ION) - #if ((SGX_ION_HEAP_BASE + SGX_ION_HEAP_SIZE) >= SGX_SHARED_3DPARAMETERS_HEAP_BASE) - #error "sgxconfig.h: ERROR: SGX_ION_HEAP overlaps SGX_3DPARAMETERS_HEAP" - #endif - #endif #if ((SGX_GENERAL_HEAP_BASE + SGX_GENERAL_HEAP_SIZE) >= SGX_SHARED_3DPARAMETERS_HEAP_BASE) #error "sgxconfig.h: ERROR: SGX_GENERAL_HEAP overlaps SGX_3DPARAMETERS_HEAP" #endif diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinfokm.h b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinfokm.h index 125da097bf8..9a1ffcd452a 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinfokm.h +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinfokm.h @@ -71,7 +71,37 @@ extern "C" { /*Forward declaration*/ typedef struct _PVRSRV_STUB_PBDESC_ PVRSRV_STUB_PBDESC; +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) +typedef struct _PVRSRV_SYSTRACE_JOB_ +{ + IMG_UINT32 ui32JobID; + IMG_UINT32 ui32FrameNum; + IMG_UINT32 ui32RTData; + +} PVRSRV_SYSTRACE_JOB; + +typedef struct _PVRSRV_SYSTRACE_CONTEXT_ +{ + IMG_UINT32 ui32PID; + IMG_UINT32 ui32CtxID; + /*Every PID has a circular buffer of jobs*/ + IMG_UINT32 ui32Start; + IMG_UINT32 ui32End; + IMG_UINT32 ui32CurrentJobID; + PVRSRV_SYSTRACE_JOB asJobs[16]; + +} PVRSRV_SYSTRACE_CONTEXT; + +typedef struct _PVRSRV_SYSTRACE_DATA_ +{ + IMG_UINT64 ui64LastHostTimestamp; + IMG_UINT32 ui32LastSGXClocksx16; + IMG_UINT32 ui32Index; + IMG_UINT32 ui32CurrentCtxID; + PVRSRV_SYSTRACE_CONTEXT asSystraceContext[8]; +} PVRSRV_SYSTRACE_DATA; +#endif typedef struct _PVRSRV_SGX_CCB_INFO_ *PPVRSRV_SGX_CCB_INFO; @@ -149,16 +179,6 @@ typedef struct _PVRSRV_SGXDEV_INFO_ PPVRSRV_KERNEL_MEM_INFO psKernelHWPerfCBMemInfo; /*!< Meminfo for hardware performace circular buffer */ PPVRSRV_KERNEL_MEM_INFO psKernelTASigBufferMemInfo; /*!< Meminfo for TA signature buffer */ PPVRSRV_KERNEL_MEM_INFO psKernel3DSigBufferMemInfo; /*!< Meminfo for 3D signature buffer */ -#if defined(FIX_HW_BRN_29702) - PPVRSRV_KERNEL_MEM_INFO psKernelCFIMemInfo; /*!< Meminfo for cfi */ -#endif -#if defined(FIX_HW_BRN_29823) - PPVRSRV_KERNEL_MEM_INFO psKernelDummyTermStreamMemInfo; /*!< Meminfo for dummy terminate stream */ -#endif -#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559) - PPVRSRV_KERNEL_MEM_INFO psKernelVDMSnapShotBufferMemInfo; /*!< Meminfo for dummy snapshot buffer */ - PPVRSRV_KERNEL_MEM_INFO psKernelVDMCtrlStreamBufferMemInfo; /*!< Meminfo for dummy control stream */ -#endif #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) PPVRSRV_KERNEL_MEM_INFO psKernelVDMStateUpdateBufferMemInfo; /*!< Meminfo for state update buffer */ @@ -269,6 +289,11 @@ typedef struct _PVRSRV_SGXDEV_INFO_ IMG_HANDLE hKernelMMUContext; #endif +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + IMG_BOOL bSystraceInitialised; + PVRSRV_SYSTRACE_DATA *psSystraceData; +#endif + } PVRSRV_SGXDEV_INFO; @@ -385,12 +410,6 @@ typedef struct _SGX_BRIDGE_INIT_INFO_KM_ IMG_HANDLE hKernelTASigBufferMemInfo; IMG_HANDLE hKernel3DSigBufferMemInfo; -#if defined(FIX_HW_BRN_29702) - IMG_HANDLE hKernelCFIMemInfo; -#endif -#if defined(FIX_HW_BRN_29823) - IMG_HANDLE hKernelDummyTermStreamMemInfo; -#endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) IMG_HANDLE hKernelEDMStatusBufferMemInfo; #endif @@ -570,6 +589,8 @@ PVRSRV_ERROR SGXPostClockSpeedChange(IMG_HANDLE hDevHandle, IMG_VOID SGXPanic(PVRSRV_SGXDEV_INFO *psDevInfo); +IMG_VOID RunSGXREGDebugScripts(PVRSRV_SGXDEV_INFO *psDevInfo); + IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bDumpSGXRegs); diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinit.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinit.c index c8292818b4b..04b1748448e 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinit.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxinit.c @@ -68,7 +68,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "srvkm.h" #include "ttrace.h" -extern int powering_down; +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) +#include "systrace.h" +#endif + +IMG_UINT32 g_ui32HostIRQCountSample = 0; #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) @@ -195,11 +199,7 @@ static IMG_UINT32 DeinitDevInfo(PVRSRV_SGXDEV_INFO *psDevInfo) ******************************************************************************/ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, PVRSRV_DEVICE_NODE *psDeviceNode, -#if defined (SUPPORT_SID_INTERFACE) - SGX_BRIDGE_INIT_INFO_KM *psInitInfo) -#else SGX_BRIDGE_INIT_INFO *psInitInfo) -#endif { PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; PVRSRV_ERROR eError; @@ -237,16 +237,6 @@ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, #endif psDevInfo->psKernelTASigBufferMemInfo = psInitInfo->hKernelTASigBufferMemInfo; psDevInfo->psKernel3DSigBufferMemInfo = psInitInfo->hKernel3DSigBufferMemInfo; -#if defined(FIX_HW_BRN_29702) - psDevInfo->psKernelCFIMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelCFIMemInfo; -#endif -#if defined(FIX_HW_BRN_29823) - psDevInfo->psKernelDummyTermStreamMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelDummyTermStreamMemInfo; -#endif -#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559) - psDevInfo->psKernelVDMSnapShotBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelVDMSnapShotBufferMemInfo; - psDevInfo->psKernelVDMCtrlStreamBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelVDMCtrlStreamBufferMemInfo; -#endif #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) psDevInfo->psKernelVDMStateUpdateBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelVDMStateUpdateBufferMemInfo; @@ -344,13 +334,21 @@ static PVRSRV_ERROR SGXRunScript(PVRSRV_SGXDEV_INFO *psDevInfo, SGX_INIT_COMMAND } case SGX_INIT_OP_READ_HW_REG: { - OSReadHWReg(psDevInfo->pvRegsBaseKM, psComm->sReadHWReg.ui32Offset); + psComm->sReadHWReg.ui32Value = OSReadHWReg(psDevInfo->pvRegsBaseKM, psComm->sReadHWReg.ui32Offset); #if defined(PDUMP) PDUMPCOMMENT("SGXRunScript: Read HW reg operation"); PDumpRegRead(SGX_PDUMPREG_NAME, psComm->sReadHWReg.ui32Offset, PDUMP_FLAGS_CONTINUOUS); #endif break; } + case SGX_INIT_OP_PRINT_HW_REG: + { + psComm->sReadHWReg.ui32Value = OSReadHWReg(psDevInfo->pvRegsBaseKM, psComm->sReadHWReg.ui32Offset); + PVR_LOG(("\t(SGXREG) 0x%08X : 0x%08X", psComm->sReadHWReg.ui32Offset, psComm->sReadHWReg.ui32Value)); + + break; + } + #if defined(PDUMP) case SGX_INIT_OP_PDUMP_HW_REG: { @@ -377,6 +375,72 @@ static PVRSRV_ERROR SGXRunScript(PVRSRV_SGXDEV_INFO *psDevInfo, SGX_INIT_COMMAND return PVRSRV_ERROR_UNKNOWN_SCRIPT_OPERATION; } +/* Run scripts on given core */ +static PVRSRV_ERROR SGXRunScriptOnCore(PVRSRV_SGXDEV_INFO *psDevInfo, SGX_INIT_COMMAND *psScript, IMG_UINT32 ui32NumInitCommands, IMG_UINT32 ui32CoreNum) +{ + IMG_UINT32 ui32PC; + SGX_INIT_COMMAND *psComm; + +#if !defined(SGX_FEATURE_MP) + PVR_UNREFERENCED_PARAMETER(ui32CoreNum); +#endif + + for (ui32PC = 0, psComm = psScript; + ui32PC < ui32NumInitCommands; + ui32PC++, psComm++) + { + switch (psComm->eOp) + { + case SGX_INIT_OP_WRITE_HW_REG: + { + OSWriteHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(psComm->sWriteHWReg.ui32Offset,ui32CoreNum), psComm->sWriteHWReg.ui32Value); + PDUMPCOMMENT("SGXRunScriptOnCore: Write HW reg operation"); + PDUMPREG(SGX_PDUMPREG_NAME, SGX_MP_CORE_SELECT(psComm->sWriteHWReg.ui32Offset,ui32CoreNum), psComm->sWriteHWReg.ui32Value); + break; + } + case SGX_INIT_OP_READ_HW_REG: + { + psComm->sReadHWReg.ui32Value = OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(psComm->sReadHWReg.ui32Offset, ui32CoreNum)); +#if defined(PDUMP) + PDUMPCOMMENT("SGXRunScriptOnCore: Read HW reg operation"); + PDumpRegRead(SGX_PDUMPREG_NAME, SGX_MP_CORE_SELECT(psComm->sReadHWReg.ui32Offset,ui32CoreNum), PDUMP_FLAGS_CONTINUOUS); +#endif + break; + } + case SGX_INIT_OP_PRINT_HW_REG: + { + psComm->sReadHWReg.ui32Value = OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(psComm->sReadHWReg.ui32Offset,ui32CoreNum)); + PVR_LOG(("\t(SGXREG) 0x%08X : 0x%08X", SGX_MP_CORE_SELECT(psComm->sReadHWReg.ui32Offset, ui32CoreNum), psComm->sReadHWReg.ui32Value)); + + break; + } + +#if defined(PDUMP) + case SGX_INIT_OP_PDUMP_HW_REG: + { + PDUMPCOMMENT("SGXRunScriptOnCore: Dump HW reg operation"); + PDUMPREG(SGX_PDUMPREG_NAME, SGX_MP_CORE_SELECT(psComm->sPDumpHWReg.ui32Offset, ui32CoreNum), psComm->sPDumpHWReg.ui32Value); + break; + } +#endif + case SGX_INIT_OP_HALT: + { + return PVRSRV_OK; + } + case SGX_INIT_OP_ILLEGAL: + /* FALLTHROUGH */ + default: + { + PVR_DPF((PVR_DBG_ERROR,"SGXRunScriptOnCore: PC %d: Illegal command: %d", ui32PC, psComm->eOp)); + return PVRSRV_ERROR_UNKNOWN_SCRIPT_OPERATION; + } + } + + } + + return PVRSRV_ERROR_UNKNOWN_SCRIPT_OPERATION; +} + #if defined(SUPPORT_MEMORY_TILING) static PVRSRV_ERROR SGX_AllocMemTilingRangeInt(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_UINT32 ui32Start, @@ -852,11 +916,7 @@ static PVRSRV_ERROR DevInitSGXPart1 (IMG_VOID *pvDeviceNode) ******************************************************************************/ IMG_EXPORT -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, PVRSRV_HEAP_INFO_KM *pasHeapInfo, IMG_DEV_PHYADDR *psPDDevPAddr) -#else PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, SGX_BRIDGE_INFO_FOR_SRVINIT *psInitInfo) -#endif { PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_SGXDEV_INFO *psDevInfo; @@ -867,15 +927,9 @@ PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, SGX_BRIDGE_INFO_FOR_S psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevHandle; psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; -#if defined (SUPPORT_SID_INTERFACE) - *psPDDevPAddr = psDevInfo->sKernelPDDevPAddr; - - eError = PVRSRVGetDeviceMemHeapsKM(hDevHandle, pasHeapInfo); -#else psInitInfo->sPDDevPAddr = psDevInfo->sKernelPDDevPAddr; eError = PVRSRVGetDeviceMemHeapsKM(hDevHandle, &psInitInfo->asHeapInfo[0]); -#endif if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXGetInfoForSrvinit: PVRSRVGetDeviceMemHeapsKM failed (%d)", eError)); @@ -902,11 +956,7 @@ PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, SGX_BRIDGE_INFO_FOR_S IMG_EXPORT PVRSRV_ERROR DevInitSGXPart2KM (PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevHandle, -#if defined (SUPPORT_SID_INTERFACE) - SGX_BRIDGE_INIT_INFO_KM *psInitInfo) -#else SGX_BRIDGE_INIT_INFO *psInitInfo) -#endif { PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_SGXDEV_INFO *psDevInfo; @@ -1162,8 +1212,7 @@ static PVRSRV_ERROR DevDeInitSGX (IMG_VOID *pvDeviceNode) } } #endif /* #ifdef SGX_FEATURE_HOST_PORT */ - - + /* DeAllocate devinfo */ OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_SGXDEV_INFO), @@ -1185,35 +1234,6 @@ static PVRSRV_ERROR DevDeInitSGX (IMG_VOID *pvDeviceNode) } -#if defined(RESTRICTED_REGISTERS) && defined(SGX_FEATURE_MP) - -/*! -******************************************************************************* - - @Function SGXDumpMasterDebugReg - - @Description - - Dump a single SGX debug register value - - @Input psDevInfo - SGX device info - @Input pszName - string used for logging - @Input ui32RegAddr - SGX register offset - - @Return IMG_VOID - -******************************************************************************/ -static IMG_VOID SGXDumpMasterDebugReg (PVRSRV_SGXDEV_INFO *psDevInfo, - IMG_CHAR *pszName, - IMG_UINT32 ui32RegAddr) -{ - IMG_UINT32 ui32RegVal; - ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, ui32RegAddr); - PVR_LOG(("(HYD) %s%08X", pszName, ui32RegVal)); -} - -#endif /* defined(RESTRICTED_REGISTERS) */ - /*! ******************************************************************************* @@ -1255,9 +1275,45 @@ static INLINE IMG_UINT32 GetDirListBaseReg(IMG_UINT32 ui32Index) } #endif -#if defined(CONFIG_DSSCOMP) -void dsscomp_kdump(void); +/*! + * ************************************************************************** + * @Function RunSGXREGDebugScripts + * @Description Runs the SGXREG debug scripts + * + * @Input PVRSRV_SGXDEV_INFO + * @Output + * @Return IMG_VOID + * **************************************************************************/ + +IMG_VOID RunSGXREGDebugScripts (PVRSRV_SGXDEV_INFO *psDevInfo) +{ + IMG_UINT32 ui32Core; + PVRSRV_ERROR eError; + + /* Run SGXREGDebug scripts */ +#if defined(SGX_FEATURE_MP) + PVR_LOG(("(HYD)")); + eError = SGXRunScript(psDevInfo, psDevInfo->sScripts.asSGXREGDebugCommandsMaster, SGX_MAX_PRINT_COMMANDS); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"RunSGXREGDebugScripts: SGXREGDebugCommandsMaster SGXRunScript failed (%d)", eError)); + } #endif + + /* Run on each core */ + for (ui32Core = 0; ui32Core < SGX_FEATURE_MP_CORE_COUNT_3D; ui32Core++) + { + PVR_LOG(("(P%u)",ui32Core)); + eError = SGXRunScriptOnCore(psDevInfo, psDevInfo->sScripts.asSGXREGDebugCommandsSlave, SGX_MAX_PRINT_COMMANDS, ui32Core); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"RunSGXREGDebugScripts: SGXREGDebugCommandsSlave SGXRunScript failed (%d)", eError)); + } + } + /* Scripts end */ +} + + /*! ******************************************************************************* @@ -1279,43 +1335,23 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, { IMG_UINT32 ui32CoreNum; -#if defined(CONFIG_DSSCOMP) - dsscomp_kdump(); -#endif - PVR_LOG(("SGX debug (%s)", PVRVERSION_STRING)); if (bDumpSGXRegs) { - PVR_DPF((PVR_DBG_ERROR,"SGX Register Base Address (Linear): 0x%08X", (IMG_UINTPTR_T)psDevInfo->pvRegsBaseKM)); - PVR_DPF((PVR_DBG_ERROR,"SGX Register Base Address (Physical): 0x%08X", psDevInfo->sRegsPhysBase.uiAddr)); + PVR_DPF((PVR_DBG_ERROR,"SGX Register Base Address (Linear): 0x%p", psDevInfo->pvRegsBaseKM)); + PVR_DPF((PVR_DBG_ERROR,"SGX Register Base Address (Physical): 0x" SYSPADDR_FMT, psDevInfo->sRegsPhysBase.uiAddr)); + + /* Run SGXREGDebug Scripts */ + PVR_LOG(("Running SGXREG Debug Scripts:")); + RunSGXREGDebugScripts(psDevInfo); + PVR_LOG(("SGX Register Dump:")); SGXDumpDebugReg(psDevInfo, 0, "EUR_CR_CORE_ID: ", EUR_CR_CORE_ID); SGXDumpDebugReg(psDevInfo, 0, "EUR_CR_CORE_REVISION: ", EUR_CR_CORE_REVISION); -#if defined(RESTRICTED_REGISTERS) && defined(SGX_FEATURE_MP) - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_BIF_INT_STAT: ", EUR_CR_MASTER_BIF_INT_STAT); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_BIF_FAULT: ",EUR_CR_MASTER_BIF_FAULT); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_CLKGATESTATUS2: ",EUR_CR_MASTER_CLKGATESTATUS2 ); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_PIM_STATUS: ",EUR_CR_MASTER_VDM_PIM_STATUS); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_BIF_BANK_SET: ",EUR_CR_MASTER_BIF_BANK_SET); - - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_EVENT_STATUS: ",EUR_CR_MASTER_EVENT_STATUS); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_EVENT_STATUS2: ",EUR_CR_MASTER_EVENT_STATUS2); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_MP_PRIMITIVE: ",EUR_CR_MASTER_MP_PRIMITIVE); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_DPM_DPLIST_STATUS: ",EUR_CR_MASTER_DPM_DPLIST_STATUS); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_DPM_PROACTIVE_PIM_SPEC: ",EUR_CR_MASTER_DPM_PROACTIVE_PIM_SPEC); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_PAGE_MANAGEOP: ",EUR_CR_MASTER_DPM_PAGE_MANAGEOP); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_CONTEXT_STORE_SNAPSHOT: ",EUR_CR_MASTER_VDM_CONTEXT_STORE_SNAPSHOT); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_CONTEXT_LOAD_STATUS: ",EUR_CR_MASTER_VDM_CONTEXT_LOAD_STATUS); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_CONTEXT_STORE_STREAM: ",EUR_CR_MASTER_VDM_CONTEXT_STORE_STREAM); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_CONTEXT_STORE_STATUS: ",EUR_CR_MASTER_VDM_CONTEXT_STORE_STATUS); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_CONTEXT_STORE_STATE0: ",EUR_CR_MASTER_VDM_CONTEXT_STORE_STATE0); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_CONTEXT_STORE_STATE1: ",EUR_CR_MASTER_VDM_CONTEXT_STORE_STATE1); - SGXDumpMasterDebugReg(psDevInfo, "EUR_CR_MASTER_VDM_WAIT_FOR_KICK: ",EUR_CR_MASTER_VDM_WAIT_FOR_KICK); -#endif + for (ui32CoreNum = 0; ui32CoreNum < SGX_FEATURE_MP_CORE_COUNT_3D; ui32CoreNum++) { - /* Dump HW event status */ SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_STATUS: ", EUR_CR_EVENT_STATUS); SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_STATUS2: ", EUR_CR_EVENT_STATUS2); SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_BIF_CTRL: ", EUR_CR_BIF_CTRL); @@ -1329,37 +1365,6 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, #if defined(EUR_CR_PDS_PC_BASE) SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_PDS_PC_BASE: ", EUR_CR_PDS_PC_BASE); #endif -#if defined(RESTRICTED_REGISTERS) - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_BIF_BANK_SET: ", EUR_CR_BIF_BANK_SET); - - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_CLKGATECTL: ", EUR_CR_CLKGATECTL); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_CLKGATESTATUS: ", EUR_CR_CLKGATESTATUS); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_MTE_CTRL: ", EUR_CR_MTE_CTRL); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_OTHER_PDS_EXEC: ", EUR_CR_EVENT_OTHER_PDS_EXEC); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_OTHER_PDS_DATA: ", EUR_CR_EVENT_OTHER_PDS_DATA); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_OTHER_PDS_INFO: ", EUR_CR_EVENT_OTHER_PDS_INFO); - - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_ZLS_PAGE_THRESHOLD: ", EUR_CR_DPM_ZLS_PAGE_THRESHOLD); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_TA_GLOBAL_LIST: ", EUR_CR_DPM_TA_GLOBAL_LIST); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_STATE_CONTEXT_ID: ", EUR_CR_DPM_STATE_CONTEXT_ID); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_CONTEXT_PB_BASE: ", EUR_CR_DPM_CONTEXT_PB_BASE); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_TA_ALLOC_FREE_LIST_STATUS1: ", EUR_CR_DPM_TA_ALLOC_FREE_LIST_STATUS1); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_3D_FREE_LIST_STATUS1: ", EUR_CR_DPM_3D_FREE_LIST_STATUS1); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_TA_ALLOC_FREE_LIST_STATUS2: ", EUR_CR_DPM_TA_ALLOC_FREE_LIST_STATUS2); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_3D_FREE_LIST_STATUS2: ", EUR_CR_DPM_3D_FREE_LIST_STATUS2); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_ABORT_STATUS_MTILE: ", EUR_CR_DPM_ABORT_STATUS_MTILE); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_PAGE_STATUS: ", EUR_CR_DPM_PAGE_STATUS); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_PAGE: ", EUR_CR_DPM_PAGE); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_GLOBAL_PAGE_STATUS: ", EUR_CR_DPM_GLOBAL_PAGE_STATUS); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_VDM_CONTEXT_LOAD_STATUS: ", EUR_CR_VDM_CONTEXT_LOAD_STATUS); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_VDM_CONTEXT_STORE_STATUS: ", EUR_CR_VDM_CONTEXT_STORE_STATUS); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_VDM_TASK_KICK_STATUS: ", EUR_CR_VDM_TASK_KICK_STATUS); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_VDM_CONTEXT_STORE_STATE0: ", EUR_CR_VDM_CONTEXT_STORE_STATE0); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_VDM_CONTEXT_STORE_STATE1: ", EUR_CR_VDM_CONTEXT_STORE_STATE1); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_REQUESTING: ", EUR_CR_DPM_REQUESTING); - SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_DPM_REQUESTING: ", EUR_CR_DPM_REQUESTING); - -#endif } #if !defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) && !defined(FIX_HW_BRN_31620) @@ -1387,67 +1392,149 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, IMG_UINT32 ui32Bank0; IMG_UINT32 ui32DirListIndex; IMG_UINT32 ui32PDDevPAddr; + IMG_UINT32 ui32RegVal; + +#if defined(SGX_FEATURE_MP) + ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_BIF_INT_STAT); +#if defined(EUR_CR_BIF_INT_STAT_FAULT_TYPE_MASK) + if( ui32RegVal & EUR_CR_BIF_INT_STAT_FAULT_TYPE_MASK) +#else + if( ui32RegVal & EUR_CR_BIF_INT_STAT_PF_N_RW_MASK) +#endif + { + ui32FaultAddress = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_BIF_FAULT); + if(ui32FaultAddress) + { + ui32Bank0 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0); + + /* Check the EDM's's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_EDM_MASK) >> EUR_CR_BIF_BANK0_INDEX_EDM_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking EDM memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + /* Check the TA's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_TA_MASK) >> EUR_CR_BIF_BANK0_INDEX_TA_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking TA memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + /* Check the 3D's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_3D_MASK) >> EUR_CR_BIF_BANK0_INDEX_3D_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking 3D memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + #if defined(EUR_CR_BIF_BANK0_INDEX_2D_MASK) + /* Check the 2D's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_2D_MASK) >> EUR_CR_BIF_BANK0_INDEX_2D_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking 2D memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + #endif + + #if defined(EUR_CR_BIF_BANK0_INDEX_PTLA_MASK) + /* Check the 2D's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_PTLA_MASK) >> EUR_CR_BIF_BANK0_INDEX_PTLA_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking PTLA memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + #endif - ui32FaultAddress = OSReadHWReg(psDevInfo->pvRegsBaseKM, - EUR_CR_BIF_FAULT); - ui32FaultAddress = ui32FaultAddress & EUR_CR_BIF_FAULT_ADDR_MASK; - - ui32Bank0 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0); - - /* Check the EDM's's memory context */ - ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_EDM_MASK) >> EUR_CR_BIF_BANK0_INDEX_EDM_SHIFT; - ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, - GetDirListBaseReg(ui32DirListIndex)); - PVR_LOG(("Checking EDM memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); - MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); - - /* Check the TA's memory context */ - ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_TA_MASK) >> EUR_CR_BIF_BANK0_INDEX_TA_SHIFT; - ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, - GetDirListBaseReg(ui32DirListIndex)); - PVR_LOG(("Checking TA memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); - MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); - - /* Check the 3D's memory context */ - ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_3D_MASK) >> EUR_CR_BIF_BANK0_INDEX_3D_SHIFT; - ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, - GetDirListBaseReg(ui32DirListIndex)); - PVR_LOG(("Checking 3D memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); - MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); - - #if defined(EUR_CR_BIF_BANK0_INDEX_2D_MASK) - /* Check the 2D's memory context */ - ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_2D_MASK) >> EUR_CR_BIF_BANK0_INDEX_2D_SHIFT; - ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, - GetDirListBaseReg(ui32DirListIndex)); - PVR_LOG(("Checking 2D memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); - MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); - #endif - - #if defined(EUR_CR_BIF_BANK0_INDEX_PTLA_MASK) - /* Check the 2D's memory context */ - ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_PTLA_MASK) >> EUR_CR_BIF_BANK0_INDEX_PTLA_SHIFT; - ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, - GetDirListBaseReg(ui32DirListIndex)); - PVR_LOG(("Checking PTLA memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); - MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); - #endif - - #if defined(EUR_CR_BIF_BANK0_INDEX_HOST_MASK) - /* Check the Host's memory context */ - ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_HOST_MASK) >> EUR_CR_BIF_BANK0_INDEX_HOST_SHIFT; - ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, - GetDirListBaseReg(ui32DirListIndex)); - PVR_LOG(("Checking Host memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); - MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + #if defined(EUR_CR_BIF_BANK0_INDEX_HOST_MASK) + /* Check the Host's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_HOST_MASK) >> EUR_CR_BIF_BANK0_INDEX_HOST_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking Host memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + #endif + } + } +#endif + for (ui32CoreNum = 0; ui32CoreNum < SGX_FEATURE_MP_CORE_COUNT_3D; ui32CoreNum++) + { + + ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BIF_INT_STAT, ui32CoreNum)); + #if defined(EUR_CR_BIF_INT_STAT_FAULT_TYPE_MASK) + if( ui32RegVal & EUR_CR_BIF_INT_STAT_FAULT_TYPE_MASK) + #else + if( ui32RegVal & EUR_CR_BIF_INT_STAT_PF_N_RW_MASK) #endif + { + ui32FaultAddress = OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BIF_FAULT, ui32CoreNum)); + ui32FaultAddress &= EUR_CR_BIF_FAULT_ADDR_MASK; + if(ui32FaultAddress) + { + ui32Bank0 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0); + + /* Check the EDM's's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_EDM_MASK) >> EUR_CR_BIF_BANK0_INDEX_EDM_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking EDM memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + /* Check the TA's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_TA_MASK) >> EUR_CR_BIF_BANK0_INDEX_TA_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking TA memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + /* Check the 3D's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_3D_MASK) >> EUR_CR_BIF_BANK0_INDEX_3D_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking 3D memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + #if defined(EUR_CR_BIF_BANK0_INDEX_2D_MASK) + /* Check the 2D's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_2D_MASK) >> EUR_CR_BIF_BANK0_INDEX_2D_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking 2D memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + #endif + + #if defined(EUR_CR_BIF_BANK0_INDEX_PTLA_MASK) + /* Check the 2D's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_PTLA_MASK) >> EUR_CR_BIF_BANK0_INDEX_PTLA_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking PTLA memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + #endif + + #if defined(EUR_CR_BIF_BANK0_INDEX_HOST_MASK) + /* Check the Host's memory context */ + ui32DirListIndex = (ui32Bank0 & EUR_CR_BIF_BANK0_INDEX_HOST_MASK) >> EUR_CR_BIF_BANK0_INDEX_HOST_SHIFT; + ui32PDDevPAddr = OSReadHWReg(psDevInfo->pvRegsBaseKM, + GetDirListBaseReg(ui32DirListIndex)); + PVR_LOG(("Checking Host memory context (index = %d, PD = 0x%08x)", ui32DirListIndex, ui32PDDevPAddr)); + MMU_CheckFaultAddr(psDevInfo, ui32PDDevPAddr, ui32FaultAddress); + + #endif + } + } + } } #endif } + +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /* Dump out the outstanding queue items. */ QueueDumpDebugInfo(); +#endif { /* @@ -1456,7 +1543,25 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, SGXMKIF_HOST_CTL *psSGXHostCtl = psDevInfo->psSGXHostCtl; IMG_UINT32 *pui32HostCtlBuffer = (IMG_UINT32 *)psSGXHostCtl; IMG_UINT32 ui32LoopCounter; - + + /* Report which defines are enabled that affect the HostCTL structure being dumped-out here */ + { + IMG_UINT32 ui32CtlFlags = 0; + #if defined(PVRSRV_USSE_EDM_BREAKPOINTS) + ui32CtlFlags = ui32CtlFlags | 0x0001; + #endif + #if defined(FIX_HW_BRN_28889) + ui32CtlFlags = ui32CtlFlags | 0x0002; + #endif + #if defined(SUPPORT_HW_RECOVERY) + ui32CtlFlags = ui32CtlFlags | 0x0004; + #endif + #if defined(SGX_FEATURE_EXTENDED_PERF_COUNTERS) + ui32CtlFlags = ui32CtlFlags | 0x0008; + #endif + PVR_LOG((" Host Ctl flags= %08x", ui32CtlFlags)); + } + if (psSGXHostCtl->ui32AssertFail != 0) { PVR_LOG(("SGX Microkernel assert fail: 0x%08X", psSGXHostCtl->ui32AssertFail)); @@ -1469,7 +1574,8 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, ui32LoopCounter < sizeof(*psDevInfo->psSGXHostCtl) / sizeof(*pui32HostCtlBuffer); ui32LoopCounter += 4) { - PVR_LOG(("\t(HC-%X) 0x%08X 0x%08X 0x%08X 0x%08X", ui32LoopCounter * sizeof(*pui32HostCtlBuffer), + PVR_LOG(("\t(HC-%" SIZE_T_FMT_LEN "X) 0x%08X 0x%08X 0x%08X 0x%08X", + ui32LoopCounter * sizeof(*pui32HostCtlBuffer), pui32HostCtlBuffer[ui32LoopCounter + 0], pui32HostCtlBuffer[ui32LoopCounter + 1], pui32HostCtlBuffer[ui32LoopCounter + 2], pui32HostCtlBuffer[ui32LoopCounter + 3])); } @@ -1488,7 +1594,8 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, ui32LoopCounter < psDevInfo->psKernelSGXTA3DCtlMemInfo->uAllocSize / sizeof(*pui32TA3DCtlBuffer); ui32LoopCounter += 4) { - PVR_LOG(("\t(T3C-%X) 0x%08X 0x%08X 0x%08X 0x%08X", ui32LoopCounter * sizeof(*pui32TA3DCtlBuffer), + PVR_LOG(("\t(T3C-%" SIZE_T_FMT_LEN "X) 0x%08X 0x%08X 0x%08X 0x%08X", + ui32LoopCounter * sizeof(*pui32TA3DCtlBuffer), pui32TA3DCtlBuffer[ui32LoopCounter + 0], pui32TA3DCtlBuffer[ui32LoopCounter + 1], pui32TA3DCtlBuffer[ui32LoopCounter + 2], pui32TA3DCtlBuffer[ui32LoopCounter + 3])); } @@ -1561,6 +1668,24 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, PVRSRVDumpTimeTraceBuffers(); #endif + #if defined (SUPPORT_FORCE_SYNC_DUMP) + PVRSRVDumpSyncs(IMG_FALSE); + #else + PVRSRVDumpSyncs(IMG_TRUE); + #endif + + +#if defined (MEM_TRACK_INFO_DEBUG) + { + IMG_UINT32 ui32FaultAddress = OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BIF_FAULT, 0)); + PVRSRVPrintMemTrackInfo(ui32FaultAddress); + } +#endif + + +#if defined(PVRSRV_DEBUG_CCB_MAX) + PVRSRVDebugPrintfDumpCCB(); +#endif } @@ -1600,9 +1725,6 @@ IMG_VOID HWRecoveryResetSGX (PVRSRV_DEVICE_NODE *psDeviceNode, PVR_UNREFERENCED_PARAMETER(ui32Component); - /* Debug dumps associated with HWR can be long. Delay system suspend */ - SysLockSystemSuspend(); - /* Ensure that hardware recovery is serialised with any power transitions. */ @@ -1620,7 +1742,7 @@ IMG_VOID HWRecoveryResetSGX (PVRSRV_DEVICE_NODE *psDeviceNode, psSGXHostCtl->ui32InterruptClearFlags |= PVRSRV_USSE_EDM_INTERRUPT_HWR; PVR_LOG(("HWRecoveryResetSGX: SGX Hardware Recovery triggered")); - + #if defined(SUPPORT_HWRECOVERY_TRACE_LIMIT) /* * The following defines are system specific and should be defined in @@ -1658,13 +1780,13 @@ IMG_VOID HWRecoveryResetSGX (PVRSRV_DEVICE_NODE *psDeviceNode, PVRSRVPowerUnlock(ui32CallerID); - SysUnlockSystemSuspend(); - /* Send a dummy kick so that we start processing again */ SGXScheduleProcessQueuesKM(psDeviceNode); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /* Flush any old commands from the queues. */ PVRSRVProcessQueues(IMG_TRUE); +#endif } #endif /* #if defined(SYS_USING_INTERRUPTS) || defined(SUPPORT_HW_RECOVERY) */ @@ -1823,7 +1945,7 @@ IMG_BOOL SGX_ISRHandler (IMG_VOID *pvData) /* Real Hardware */ { - IMG_UINT32 ui32EventStatus = 0, ui32EventEnable = 0; + IMG_UINT32 ui32EventStatus, ui32EventEnable; IMG_UINT32 ui32EventClear = 0; #if defined(SGX_FEATURE_DATA_BREAKPOINTS) IMG_UINT32 ui32EventStatus2, ui32EventEnable2; @@ -1842,19 +1964,15 @@ IMG_BOOL SGX_ISRHandler (IMG_VOID *pvData) psDeviceNode = (PVRSRV_DEVICE_NODE *)pvData; psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; - if(!powering_down) { - ui32EventStatus = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_STATUS); - ui32EventEnable = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_ENABLE); - } + ui32EventStatus = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_STATUS); + ui32EventEnable = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_ENABLE); /* test only the unmasked bits */ ui32EventStatus &= ui32EventEnable; #if defined(SGX_FEATURE_DATA_BREAKPOINTS) - if(!powering_down) { - ui32EventStatus2 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_STATUS2); - ui32EventEnable2 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_ENABLE2); - } + ui32EventStatus2 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_STATUS2); + ui32EventEnable2 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_ENABLE2); /* test only the unmasked bits */ ui32EventStatus2 &= ui32EventEnable2; @@ -1888,17 +2006,86 @@ IMG_BOOL SGX_ISRHandler (IMG_VOID *pvData) /* Clear master interrupt bit */ ui32EventClear |= EUR_CR_EVENT_HOST_CLEAR_MASTER_INTERRUPT_MASK; - if(!powering_down) { - /* clear the events */ - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR, ui32EventClear); - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR2, ui32EventClear2); - } + /* clear the events */ + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR, ui32EventClear); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR2, ui32EventClear2); + + /* + Sample the current count from the uKernel _after_ we've cleared the + interrupt. + */ + g_ui32HostIRQCountSample = psDevInfo->psSGXHostCtl->ui32InterruptCount; } } return bInterruptProcessed; } +/* + SGX Systrace Handler +*/ +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) +static IMG_VOID SGXSystraceHandler(PVRSRV_DEVICE_NODE *psDeviceNode) +{ + PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; + IMG_UINT32 ui32SgxClockSpeed, ui32DataCount, ui32HostTimestamp; + + /* NOTE: Not thread safe. MISR should only run in one thread */ + static PVRSRV_SGX_HWPERF_CB_ENTRY asSGXHWPerf[8]; + + if(SystraceIsCapturingHWData() && psDevInfo->bSystraceInitialised) + { + SGXReadHWPerfCBKM((IMG_HANDLE) psDeviceNode, + 8, + asSGXHWPerf, + (IMG_UINT32 *)&ui32DataCount, + (IMG_UINT32 *)&ui32SgxClockSpeed, + (IMG_UINT32 *)&ui32HostTimestamp); + + SystraceHWPerfPackets(psDevInfo, asSGXHWPerf, ui32DataCount, ui32SgxClockSpeed); + } + else if(SystraceIsCapturingHWData() && !psDevInfo->bSystraceInitialised) + { + SGX_MISC_INFO sSGXMiscInfo; + + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_SYSTRACE_DATA), + (IMG_VOID **)&psDevInfo->psSystraceData, 0, + "Systrace data storage") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "SGXSystraceHandler: Failed to allocate systrace data")); + return; + } + + OSMemSet(psDevInfo->psSystraceData, 0, sizeof(PVRSRV_SYSTRACE_DATA)); + + /* Prepare the SGXMiscInfo request in order to stop recording data*/ + sSGXMiscInfo.eRequest = SGX_MISC_INFO_REQUEST_SET_HWPERF_STATUS; + sSGXMiscInfo.uData.sSetHWPerfStatus.ui32NewHWPerfStatus = PVRSRV_SGX_HWPERF_STATUS_GRAPHICS_ON | PVRSRV_SGX_HWPERF_STATUS_PERIODIC_ON; + + /* Call into SGX DDK KM Services*/ + SGXGetMiscInfoKM(psDevInfo, &sSGXMiscInfo, psDeviceNode, NULL); + + psDevInfo->bSystraceInitialised = IMG_TRUE; + + /* Initialize the first context to be 1 (0 is idle)*/ + psDevInfo->psSystraceData->ui32CurrentCtxID = 1; + } + else if(psDevInfo->bSystraceInitialised) + { + SGX_MISC_INFO sSGXMiscInfo; + + /* Prepare the SGXMiscInfo request in order to stop recording data*/ + sSGXMiscInfo.eRequest = SGX_MISC_INFO_REQUEST_SET_HWPERF_STATUS; + sSGXMiscInfo.uData.sSetHWPerfStatus.ui32NewHWPerfStatus = 0; + + /* Call into SGX DDK KM Services*/ + SGXGetMiscInfoKM(psDevInfo, &sSGXMiscInfo, psDeviceNode, NULL); + + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_SYSTRACE_DATA), psDevInfo->psSystraceData, NULL); + psDevInfo->bSystraceInitialised = IMG_FALSE; + } +} +#endif /* SGX MISR Handler @@ -1923,6 +2110,11 @@ static IMG_VOID SGX_MISRHandler (IMG_VOID *pvData) #endif SGXTestActivePowerEvent(psDeviceNode, ISR_ID); + +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + SGXSystraceHandler(psDeviceNode); +#endif + } #endif /* #if defined (SYS_USING_INTERRUPTS) */ @@ -2139,23 +2331,6 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) psDeviceMemoryHeap++;/* advance to the next heap */ #endif -#if defined(SUPPORT_ION) - /************* Ion Heap ***************/ - psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_ION_HEAP_ID); - psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_ION_HEAP_BASE; - psDeviceMemoryHeap->ui32HeapSize = SGX_ION_HEAP_SIZE; - psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE - | PVRSRV_HAP_SINGLE_PROCESS; - psDeviceMemoryHeap->pszName = "Ion"; - psDeviceMemoryHeap->pszBSName = "Ion BS"; - psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT; - /* specify the ion heap ID for this device */ - psDevMemoryInfo->ui32IonHeapID = SGX_ION_HEAP_ID; - /* set the default (4k). System can override these as required */ - psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE; - psDeviceMemoryHeap++;/* advance to the next heap */ -#endif - /************* TA data ***************/ psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_TADATA_HEAP_ID); psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_TADATA_HEAP_BASE; @@ -2498,8 +2673,7 @@ PVRSRV_ERROR SGXDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode) /* * 1. Check kernel-side and client-side build options - * 2. Ensure ukernel DDK version and driver DDK version are compatible - * 3. Check ukernel build options against kernel-side build options + * 2. Check ukernel build options against kernel-side build options */ /* @@ -2540,32 +2714,12 @@ PVRSRV_ERROR SGXDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode) psSGXMiscInfoInt->ui32MiscInfoFlags |= PVRSRV_USSE_MISCINFO_GET_STRUCT_SIZES; eError = SGXGetMiscInfoUkernel(psDevInfo, psDeviceNode, IMG_NULL); - /* - * Validate DDK version - */ if(eError != PVRSRV_OK) { - PVR_LOG(("(FAIL) SGXInit: Unable to validate device DDK version")); + PVR_LOG(("(FAIL) SGXInit: Unable to validate hardware core revision")); goto chk_exit; } psSGXFeatures = &((PVRSRV_SGX_MISCINFO_INFO*)(psMemInfo->pvLinAddrKM))->sSGXFeatures; - if( (psSGXFeatures->ui32DDKVersion != - ((PVRVERSION_MAJ << 16) | - (PVRVERSION_MIN << 8) | - PVRVERSION_BRANCH) ) || - (psSGXFeatures->ui32DDKBuild != PVRVERSION_BUILD) ) - { - PVR_LOG(("(FAIL) SGXInit: Incompatible driver DDK revision (%d)/device DDK revision (%d).", - PVRVERSION_BUILD, psSGXFeatures->ui32DDKBuild)); - eError = PVRSRV_ERROR_DDK_VERSION_MISMATCH; - goto chk_exit; - } - else - { - PVR_DPF((PVR_DBG_MESSAGE, "SGXInit: driver DDK (%d) and device DDK (%d) match. [ OK ]", - PVRVERSION_BUILD, psSGXFeatures->ui32DDKBuild)); - } - /* * Check hardware core revision is compatible with the one in software */ @@ -3099,6 +3253,17 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, return PVRSRV_OK; } + case SGX_MISC_INFO_REQUEST_CLOCKSPEED_SLCSIZE: + { + psMiscInfo->uData.sQueryClockSpeedSLCSize.ui32SGXClockSpeed = SYS_SGX_CLOCK_SPEED; +#if defined(SGX_FEATURE_SYSTEM_CACHE) && defined(SYS_SGX_SLC_SIZE) + psMiscInfo->uData.sQueryClockSpeedSLCSize.ui32SGXSLCSize = SYS_SGX_SLC_SIZE; +#else + psMiscInfo->uData.sQueryClockSpeedSLCSize.ui32SGXSLCSize = 0; +#endif /* defined(SGX_FEATURE_SYSTEM_CACHE) && defined(SYS_SGX_SLC_SIZE) */ + return PVRSRV_OK; + } + case SGX_MISC_INFO_REQUEST_ACTIVEPOWER: { psMiscInfo->uData.sActivePower.ui32NumActivePowerEvents = psDevInfo->psSGXHostCtl->ui32NumActivePowerEvents; @@ -3167,24 +3332,27 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, psSGXFeatures->ui32DDKVersion = (PVRVERSION_MAJ << 16) | - (PVRVERSION_MIN << 8) | - PVRVERSION_BRANCH; + (PVRVERSION_MIN << 8); psSGXFeatures->ui32DDKBuild = PVRVERSION_BUILD; /* Also report the kernel module build options -- used in SGXConnectionCheck() */ psSGXFeatures->ui32BuildOptions = (SGX_BUILD_OPTIONS); -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) - /* Report the EDM status buffer location in memory */ - psSGXFeatures->sDevVAEDMStatusBuffer = psDevInfo->psKernelEDMStatusBufferMemInfo->sDevVAddr; - psSGXFeatures->pvEDMStatusBuffer = psDevInfo->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; -#endif - /* Copy SGX features into misc info struct, to return to client */ psMiscInfo->uData.sSGXFeatures = *psSGXFeatures; return PVRSRV_OK; } +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + case SGX_MISC_INFO_REQUEST_EDM_STATUS_BUFFER_INFO: + { + /* Report the EDM status buffer location in memory */ + psMiscInfo->uData.sEDMStatusBufferInfo.sDevVAEDMStatusBuffer = psDevInfo->psKernelEDMStatusBufferMemInfo->sDevVAddr; + psMiscInfo->uData.sEDMStatusBufferInfo.pvEDMStatusBuffer = psDevInfo->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; + return PVRSRV_OK; + } +#endif + #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG) case SGX_MISC_INFO_REQUEST_MEMREAD: case SGX_MISC_INFO_REQUEST_MEMCOPY: @@ -3350,6 +3518,14 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, case SGX_MISC_INFO_DUMP_DEBUG_INFO_FORCE_REGS: { + if(!OSProcHasPrivSrvInit()) + { + PVR_DPF((PVR_DBG_ERROR, "Insufficient privileges to dump SGX " + "debug info with registers")); + + return PVRSRV_ERROR_INVALID_MISCINFO; + } + PVR_LOG(("User requested SGX debug info")); /* Dump SGX debug data to the kernel log. */ diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxkick.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxkick.c index 584f53899b1..a03f51a702c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxkick.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxkick.c @@ -53,6 +53,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sgxutils.h" #include "ttrace.h" +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include "pvr_sync.h" +#endif + +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) +#include "systrace.h" +#endif + /*! ****************************************************************************** @@ -68,11 +76,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ IMG_EXPORT -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK_KM *psCCBKick) -#else PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) -#endif { PVRSRV_ERROR eError; PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; @@ -80,6 +84,13 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) SGXMKIF_CMDTA_SHARED *psTACmd; IMG_UINT32 i; IMG_HANDLE hDevMemContext = IMG_NULL; +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + PVRSRV_DEVICE_NODE *psDeviceNode; + PVRSRV_SGXDEV_INFO *psDevInfo; + + psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevHandle; + psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; +#endif #if defined(FIX_HW_BRN_31620) hDevMemContext = psCCBKick->hDevMemContext; #endif @@ -97,6 +108,11 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_CMD_START, KICK_TOKEN_DOKICK); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FRAMENUM, KICK_TOKEN_FRAMENUM, psCCBKick->ui32FrameNum); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_NONE, KICK_TOKEN_RENDERCONTEXT, psCCBKick->sCommand.ui32Data[1]); + PVR_TTRACE_DEV_VIRTADDR(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_DEVVADDR, KICK_TOKEN_HWRTDATASET, psCCBKick->sHWRTDataSetDevAddr); + PVR_TTRACE_DEV_VIRTADDR(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_DEVVADDR, KICK_TOKEN_HWRTDATA, psCCBKick->sHWRTDataDevAddr); + #if defined(TTRACE) if (psCCBKick->bFirstKickOrResume) { @@ -129,7 +145,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) if (psCCBKick->bTADependency) { - psSyncInfo->psSyncData->ui32WriteOpsPending++; + SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } } @@ -143,7 +159,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) psTACmd->sTATQSyncReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; psTACmd->sTATQSyncWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - psTACmd->ui32TATQSyncReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; + psTACmd->ui32TATQSyncReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); psTACmd->ui32TATQSyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; } @@ -157,7 +173,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) psTACmd->s3DTQSyncReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; psTACmd->s3DTQSyncWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - psTACmd->ui323DTQSyncReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; + psTACmd->ui323DTQSyncReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); psTACmd->ui323DTQSyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; } @@ -205,7 +221,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) psTACmd->asTASrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; /* Get ui32ReadOpsPending snapshot and copy into the CCB - before incrementing. */ - psTACmd->asTASrcSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; + psTACmd->asTASrcSyncs[i].ui32ReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); /* Copy ui32WriteOpsPending snapshot into the CCB. */ psTACmd->asTASrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; } @@ -221,7 +237,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) /* Get ui32ReadOpsPending snapshot and copy into the CCB */ psTACmd->asTADstSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; /* Copy ui32WriteOpsPending snapshot into the CCB - before incrementing */ - psTACmd->asTADstSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + psTACmd->asTADstSyncs[i].ui32WriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } psTACmd->ui32Num3DSrcSyncs = psCCBKick->ui32Num3DSrcSyncs; @@ -233,13 +249,47 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) psTACmd->as3DSrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; /* Get ui32ReadOpsPending snapshot and copy into the CCB - before incrementing. */ - psTACmd->as3DSrcSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; + psTACmd->as3DSrcSyncs[i].ui32ReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); /* Copy ui32WriteOpsPending snapshot into the CCB. */ psTACmd->as3DSrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; } #else /* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */ /* texture dependencies */ - psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + eError = PVRSyncPatchCCBKickSyncInfos(psCCBKick->ahSrcKernelSyncInfo, + psTACmd->asSrcSyncs, + &psCCBKick->ui32NumSrcSyncs); + if(eError != PVRSRV_OK) + { + /* We didn't kick yet, or perform PDUMP processing, so we should + * be able to trivially roll back any changes made to the sync + * data. If we don't do this, we'll wedge services cleanup. + */ + + if (psCCBKick->h3DSyncInfo != IMG_NULL) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->h3DSyncInfo; + psSyncInfo->psSyncData->ui32ReadOpsPending--; + } + + if (psCCBKick->hTASyncInfo != IMG_NULL) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTASyncInfo; + psSyncInfo->psSyncData->ui32ReadOpsPending--; + } + + if (psCCBKick->hTA3DSyncInfo && psCCBKick->bTADependency) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo; + psSyncInfo->psSyncData->ui32WriteOpsPending--; + } + + PVR_DPF((PVR_DBG_ERROR, "SGXDoKickKM: PVRSyncPatchCCBKickSyncInfos failed.")); + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + KICK_TOKEN_DOKICK); + return eError; + } +#else /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; @@ -251,11 +301,13 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) psTACmd->asSrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; /* Get ui32ReadOpsPending snapshot and copy into the CCB - before incrementing. */ - psTACmd->asSrcSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; + psTACmd->asSrcSyncs[i].ui32ReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); /* Copy ui32WriteOpsPending snapshot into the CCB. */ psTACmd->asSrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; } -#endif/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */ +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs; +#endif /* defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */ if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0) { @@ -297,7 +349,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) psHWDeviceSyncList->asSyncData[i].sReadOps2CompleteDevVAddr = psSyncInfo->sReadOps2CompleteDevVAddr; psHWDeviceSyncList->asSyncData[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; - psHWDeviceSyncList->asSyncData[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + psHWDeviceSyncList->asSyncData[i].ui32WriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); psHWDeviceSyncList->asSyncData[i].ui32ReadOps2PendingVal = psSyncInfo->psSyncData->ui32ReadOps2Pending; #if defined(PDUMP) @@ -322,37 +374,17 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) 0, MAKEUNIQUETAG(psHWDstSyncListMemInfo)); - if ((psSyncInfo->psSyncData->ui32LastOpDumpVal == 0) && - (psSyncInfo->psSyncData->ui32LastReadOpDumpVal == 0)) - { - /* - * Init the ROpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT ROpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32ReadOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - /* - * Init the WOpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT WOpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32WriteOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - } - psSyncInfo->psSyncData->ui32LastOpDumpVal++; ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastOpDumpVal - 1; PDUMPCOMMENT("Modify RT %d WOpPendingVal in HWDevSyncList\r\n", i); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TA Dst: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + ui32ModifiedValue); +#endif PDUMPMEM(&ui32ModifiedValue, psHWDstSyncListMemInfo, ui32WOpsOffset, @@ -380,6 +412,11 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psHWDstSyncListMemInfo)); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TA Dst: PDump sync update: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif } #endif /* defined(PDUMP) */ } @@ -420,31 +457,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) IMG_UINT32 ui32ModifiedValue; psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTASrcKernelSyncInfo[i]; - if ((psSyncInfo->psSyncData->ui32LastOpDumpVal == 0) && - (psSyncInfo->psSyncData->ui32LastReadOpDumpVal == 0)) - { - /* - * Init the ROpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT TA-SRC ROpsComplete\r\n", i); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32ReadOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - /* - * Init the WOpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT TA-SRC WOpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32WriteOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - } - psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastReadOpDumpVal - 1; @@ -475,37 +487,18 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) IMG_UINT32 ui32ModifiedValue; psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTADstKernelSyncInfo[i]; - if ((psSyncInfo->psSyncData->ui32LastOpDumpVal == 0) && - (psSyncInfo->psSyncData->ui32LastReadOpDumpVal == 0)) - { - /* - * Init the ROpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT TA-DST ROpsComplete\r\n", i); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32ReadOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - /* - * Init the WOpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT TA-DST WOpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32WriteOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - } - psSyncInfo->psSyncData->ui32LastOpDumpVal++; ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastOpDumpVal - 1; PDUMPCOMMENT("Modify TA DstSync %d WOpPendingVal\r\n", i); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TA TADst: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr + ui32ModifiedValue; +#endif + PDUMPMEM(&ui32ModifiedValue, psCCBMemInfo, psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, asTADstSyncs) + @@ -523,6 +516,12 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psCCBMemInfo)); + +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TA TADst: PDump sync update: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif } for (i=0; i<psCCBKick->ui32Num3DSrcSyncs; i++) @@ -530,31 +529,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) IMG_UINT32 ui32ModifiedValue; psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ah3DSrcKernelSyncInfo[i]; - if ((psSyncInfo->psSyncData->ui32LastOpDumpVal == 0) && - (psSyncInfo->psSyncData->ui32LastReadOpDumpVal == 0)) - { - /* - * Init the ROpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT 3D-SRC ROpsComplete\r\n", i); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32ReadOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - /* - * Init the WOpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT 3D-SRC WOpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32WriteOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - } - psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastReadOpDumpVal - 1; @@ -585,41 +559,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) IMG_UINT32 ui32ModifiedValue; psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; - if ((psSyncInfo->psSyncData->ui32LastOpDumpVal == 0) && - (psSyncInfo->psSyncData->ui32LastReadOpDumpVal == 0)) - { - /* - * Init the ROpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT ROpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32ReadOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - /* - * Init the WOpsComplete value to 0. - */ - PDUMPCOMMENT("Init RT WOpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), - sizeof(psSyncInfo->psSyncData->ui32WriteOpsComplete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - /* - * Init the ROps2Complete value to 0. - */ - PDUMPCOMMENT("Init RT WOpsComplete\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOps2Complete), - sizeof(psSyncInfo->psSyncData->ui32ReadOps2Complete), - 0, - MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); - } - psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastReadOpDumpVal - 1; @@ -636,6 +575,12 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) PDUMPCOMMENT("Modify SrcSync %d WOpPendingVal\r\n", i); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TA Src: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, asSrcSyncs) + @@ -643,6 +588,43 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psCCBMemInfo)); + +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TA Src: PDump sync update: uiAddr = 0x%08x, ui32LastReadOpDumpVal = 0x%08x\r\n", + psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastReadOpDumpVal); +#endif + } + + if (psCCBKick->hTA3DSyncInfo != IMG_NULL) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo; + + PDUMPCOMMENT("Modify TA/3D dependency WOpPendingVal\r\n"); + +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TA TADep: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif + + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, + psCCBMemInfo, + psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, sTA3DDependency.ui32WriteOpsPendingVal), + sizeof(IMG_UINT32), + 0, + MAKEUNIQUETAG(psCCBMemInfo)); + + if (psCCBKick->bTADependency) + { + psSyncInfo->psSyncData->ui32LastOpDumpVal++; + +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TA TADep: PDump sync update: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif + } } if (psCCBKick->hTASyncInfo != IMG_NULL) @@ -657,6 +639,22 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psCCBMemInfo)); + + PDUMPCOMMENT("Modify TA/TQ WOpPendingVal\r\n"); + +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TA TATQ: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif + + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, + psCCBMemInfo, + psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, ui32TATQSyncWriteOpsPendingVal), + sizeof(IMG_UINT32), + 0, + MAKEUNIQUETAG(psCCBMemInfo)); + psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; } @@ -672,6 +670,22 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psCCBMemInfo)); + + PDUMPCOMMENT("Modify 3D/TQ WOpPendingVal\r\n"); + +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TA 3DTQ: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif + + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, + psCCBMemInfo, + psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, ui323DTQSyncWriteOpsPendingVal), + sizeof(IMG_UINT32), + 0, + MAKEUNIQUETAG(psCCBMemInfo)); + psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; } @@ -723,6 +737,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) if (psSyncInfo) { psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); #if defined(PDUMP) if (PDumpIsCaptureFrameKM()) { @@ -738,22 +753,26 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTASrcKernelSyncInfo[i]; psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } for (i=0; i<psCCBKick->ui32NumTADstSyncs; i++) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTADstKernelSyncInfo[i]; psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } for (i=0; i<psCCBKick->ui32Num3DSrcSyncs; i++) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ah3DSrcKernelSyncInfo[i]; psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } #else/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */ for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } #endif/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */ @@ -761,18 +780,21 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo; psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } if (psCCBKick->hTASyncInfo) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTASyncInfo; psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } if (psCCBKick->h3DSyncInfo) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->h3DSyncInfo; psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); } PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, @@ -891,6 +913,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) #endif PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, KICK_TOKEN_DOKICK); +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + SystraceTAKick(psDevInfo, psCCBKick->ui32FrameNum, psCCBKick->sHWRTDataDevAddr.uiAddr, psCCBKick->bIsFirstKick); +#endif return eError; } diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxpower.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxpower.c index 2acd28d4481..a4ef2761630 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxpower.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxpower.c @@ -48,8 +48,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sgxutils.h" #include "pdump_km.h" -int powering_down = 0; - +extern IMG_UINT32 g_ui32HostIRQCountSample; #if defined(SUPPORT_HW_RECOVERY) static PVRSRV_ERROR SGXAddTimer(PVRSRV_DEVICE_NODE *psDeviceNode, @@ -333,8 +332,6 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, PDUMPCOMMENT("SGX idle request"); } - powering_down = 1; - sCommand.ui32Data[1] = ui32PowerCmd; eError = SGXScheduleCCBCommand(psDeviceNode, SGXMKIF_CMD_POWER, &sCommand, KERNEL_ID, 0, IMG_NULL, IMG_FALSE); @@ -359,7 +356,11 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, } #endif /* NO_HARDWARE */ - psDevInfo->bSGXIdle = IMG_TRUE; + if (psDevInfo->bSGXIdle == IMG_FALSE) + { + psDevInfo->bSGXIdle = IMG_TRUE; + SysSGXIdleEntered(); + } #if defined(PDUMP) PDUMPCOMMENT("TA/3D CCB Control - Wait for power event on uKernel."); @@ -372,6 +373,20 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, MAKEUNIQUETAG(psDevInfo->psKernelSGXHostCtlMemInfo)); #endif /* PDUMP */ + /* Wait for the pending ukernel to host interrupts to come back. */ + #if !defined(NO_HARDWARE) && defined(SUPPORT_LISR_MISR_SYNC) + if (PollForValueKM(&g_ui32HostIRQCountSample, + psDevInfo->psSGXHostCtl->ui32InterruptCount, + 0xffffffff, + MAX_HW_TIME_US, + MAX_HW_TIME_US/WAIT_TRY_COUNT, + IMG_FALSE) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"SGXPrePowerState: Wait for pending interrupts failed.")); + SGXDumpDebugInfo(psDevInfo, IMG_FALSE); + PVR_DBG_BREAK; + } + #endif /* NO_HARDWARE && SUPPORT_LISR_MISR_SYNC*/ #if defined(SGX_FEATURE_MP) ui32CoresEnabled = ((OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE) & EUR_CR_MASTER_CORE_ENABLE_MASK) >> EUR_CR_MASTER_CORE_ENABLE_SHIFT) + 1; #else @@ -479,7 +494,6 @@ PVRSRV_ERROR SGXPostPowerState (IMG_HANDLE hDevHandle, PVR_DPF((PVR_DBG_ERROR,"SGXPostPowerState: SGXInitialise failed")); return eError; } - powering_down = 0; } else { @@ -548,6 +562,18 @@ PVRSRV_ERROR SGXPreClockSpeedChange (IMG_HANDLE hDevHandle, return eError; } } + else + { + #if defined(SUPPORT_HW_RECOVERY) + PVRSRV_ERROR eError; + + eError = OSDisableTimer(psDevInfo->hTimer); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"SGXStartTimer : Failed to enable host timer")); + } + #endif /* SUPPORT_HW_RECOVERY */ + } } PVR_DPF((PVR_DBG_MESSAGE,"SGXPreClockSpeedChange: SGX clock speed was %uHz", diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxreset.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxreset.c index dcdefae9a46..2b7aa4ce85c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxreset.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxreset.c @@ -191,7 +191,7 @@ static IMG_VOID SGXResetSetupBIFContexts(PVRSRV_SGXDEV_INFO *psDevInfo, ui32EDMDirListReg = EUR_CR_BIF_DIR_LIST_BASE1 + 4 * (SGX_BIF_DIR_LIST_INDEX_EDM - 1); #endif /* SGX_BIF_DIR_LIST_INDEX_EDM */ - ui32RegVal = psDevInfo->sKernelPDDevPAddr.uiAddr >> SGX_MMU_PDE_ADDR_ALIGNSHIFT; + ui32RegVal = (IMG_UINT32)(psDevInfo->sKernelPDDevPAddr.uiAddr >> SGX_MMU_PDE_ADDR_ALIGNSHIFT); #if defined(FIX_HW_BRN_28011) OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal); @@ -506,6 +506,16 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, /* enable 36bit addressing mode if the MMU supports it*/ OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_36BIT_ADDRESSING, EUR_CR_BIF_36BIT_ADDRESSING_ENABLE_MASK); PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_36BIT_ADDRESSING, EUR_CR_BIF_36BIT_ADDRESSING_ENABLE_MASK, ui32PDUMPFlags); +#else + #if defined(EUR_CR_BIF_36BIT_ADDRESSING) + OSWriteHWReg(psDevInfo->pvRegsBaseKM, + EUR_CR_BIF_36BIT_ADDRESSING, + 0); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, + EUR_CR_BIF_36BIT_ADDRESSING, + 0, + ui32PDUMPFlags); + #endif #endif SGXResetInitBIFContexts(psDevInfo, ui32PDUMPFlags); @@ -589,11 +599,11 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, SGXResetSoftReset(psDevInfo, IMG_TRUE, ui32PDUMPFlags, IMG_FALSE); /* Map in the dummy page. */ - psDevInfo->pui32BIFResetPD[ui32PDIndex] = (psDevInfo->sBIFResetPTDevPAddr.uiAddr + psDevInfo->pui32BIFResetPD[ui32PDIndex] = (IMG_UINT32)(psDevInfo->sBIFResetPTDevPAddr.uiAddr >>SGX_MMU_PDE_ADDR_ALIGNSHIFT) | SGX_MMU_PDE_PAGE_SIZE_4K | SGX_MMU_PDE_VALID; - psDevInfo->pui32BIFResetPT[ui32PTIndex] = (psDevInfo->sBIFResetPageDevPAddr.uiAddr + psDevInfo->pui32BIFResetPT[ui32PTIndex] = (IMG_UINT32)(psDevInfo->sBIFResetPageDevPAddr.uiAddr >>SGX_MMU_PTE_ADDR_ALIGNSHIFT) | SGX_MMU_PTE_VALID; @@ -715,7 +725,7 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, (4 << EUR_CR_MASTER_SLC_CTRL_ADDR_DECODE_MODE_SHIFT) | #endif #if defined(FIX_HW_BRN_33809) - (2 << EUR_CR_MASTER_SLC_CTRL_ADDR_DECODE_MODE_SHIFT) | + (1 << EUR_CR_MASTER_SLC_CTRL_ADDR_DECODE_MODE_SHIFT) | #endif (0xC << EUR_CR_MASTER_SLC_CTRL_ARB_PAGE_SIZE_SHIFT); OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SLC_CTRL, ui32RegVal); diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxtransfer.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxtransfer.c index 81f3b0742b7..74dbc9969e6 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxtransfer.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxtransfer.c @@ -58,11 +58,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sgxutils.h" #include "ttrace.h" -#if defined (SUPPORT_SID_INTERFACE) -IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK_KM *psKick) -#else -IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick) +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include "pvr_sync.h" #endif + +IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick) { PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; SGXMKIF_COMMAND sCommand = {0}; @@ -125,7 +125,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_TA_SYNC, psSyncInfo, PVRSRV_SYNCOP_SAMPLE); - psSharedTransferCmd->ui32TASyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + psSharedTransferCmd->ui32TASyncWriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); psSharedTransferCmd->ui32TASyncReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; psSharedTransferCmd->sTASyncWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; @@ -144,7 +144,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_3D_SYNC, psSyncInfo, PVRSRV_SYNCOP_SAMPLE); - psSharedTransferCmd->ui323DSyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + psSharedTransferCmd->ui323DSyncWriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo,SYNC_OP_CLASS_TQ_3D); psSharedTransferCmd->ui323DSyncReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; psSharedTransferCmd->s3DSyncWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; @@ -210,9 +210,6 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF } } - psSharedTransferCmd->ui32NumSrcSyncs = ui32RealSrcSyncNum; - psSharedTransferCmd->ui32NumDstSyncs = ui32RealDstSyncNum; - if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) { IMG_UINT32 i = 0; @@ -271,7 +268,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF if (abSrcSyncEnable[loop]) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; - psSyncInfo->psSyncData->ui32ReadOpsPending++; + SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); } } for (loop = 0; loop < psKick->ui32NumDstSync; loop++) @@ -279,15 +276,92 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF if (abDstSyncEnable[loop]) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; - psSyncInfo->psSyncData->ui32WriteOpsPending++; + SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); } } + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + if (ui32RealDstSyncNum < SGX_MAX_TRANSFER_SYNC_OPS - 2 && psKick->iFenceFd > 0) + { + IMG_HANDLE ahSyncInfo[SGX_MAX_SRC_SYNCS_TA]; + PVRSRV_DEVICE_SYNC_OBJECT *apsDevSyncs = &psSharedTransferCmd->asDstSyncs[ui32RealDstSyncNum]; + IMG_UINT32 ui32NumSrcSyncs = 1; + IMG_UINT32 i; + ahSyncInfo[0] = (IMG_HANDLE)(psKick->iFenceFd - 1); + + eError = PVRSyncPatchTransferSyncInfos(ahSyncInfo, apsDevSyncs, &ui32NumSrcSyncs); + if (eError != PVRSRV_OK) + { + /* We didn't kick yet, or perform PDUMP processing, so we should + * be able to trivially roll back any changes made to the sync + * data. If we don't do this, we'll wedge services cleanup. + */ + + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) + { + if (abDstSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; + psSyncInfo->psSyncData->ui32WriteOpsPending--; + } + } + + for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) + { + if (abSrcSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + psSyncInfo->psSyncData->ui32ReadOpsPending--; + } + } + + if (psKick->h3DSyncInfo != IMG_NULL) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->h3DSyncInfo; + psSyncInfo->psSyncData->ui32WriteOpsPending++; + } + + if (psKick->hTASyncInfo != IMG_NULL) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->hTASyncInfo; + psSyncInfo->psSyncData->ui32WriteOpsPending--; + } + + PVR_DPF((PVR_DBG_ERROR, "SGXSubmitTransferKM: PVRSyncPatchTransferKickSyncInfos failed.")); + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + TRANSFER_TOKEN_SUBMIT); + return eError; + } + + /* Find a free dst sync to slot in our extra sync */ + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) + { + if (abDstSyncEnable[loop]) + break; + } + + /* We shouldn't be in this code path if ui32RealDstSyncNum + * didn't allow for at least two free synchronization slots. + */ + PVR_ASSERT(loop + ui32NumSrcSyncs <= SGX_MAX_TRANSFER_SYNC_OPS); + + /* Slot in the extra dst syncs */ + for (i = 0; i < ui32NumSrcSyncs; i++) + { + psKick->ahDstSyncInfo[loop + i] = ahSyncInfo[i]; + abDstSyncEnable[loop + i] = IMG_TRUE; + psKick->ui32NumDstSync++; + ui32RealDstSyncNum++; + } + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ } + psSharedTransferCmd->ui32NumSrcSyncs = ui32RealSrcSyncNum; + psSharedTransferCmd->ui32NumDstSyncs = ui32RealDstSyncNum; + #if defined(PDUMP) - if ((PDumpIsCaptureFrameKM() - || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) - && (bPersistentProcess == IMG_FALSE) ) + if (PDumpWillCapture(psKick->ui32PDumpFlags)) { PDUMPCOMMENT("Shared part of transfer command\r\n"); PDUMPMEM(psSharedTransferCmd, @@ -305,9 +379,15 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF { if (abSrcSyncEnable[loop]) { + IMG_UINT32 ui32PDumpReadOp2 = 0; psSyncInfo = psKick->ahSrcSyncInfo[loop]; PDUMPCOMMENT("Tweak src surface write op in transfer cmd\r\n"); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TQ Src: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asSrcSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal)), @@ -322,6 +402,14 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); + + PDUMPCOMMENT("Tweak srv surface read op2 in transfer cmd\r\n"); + PDUMPMEM(&ui32PDumpReadOp2, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asSrcSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOps2PendingVal)), + sizeof(ui32PDumpReadOp2), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); i++; } } @@ -335,6 +423,11 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF psSyncInfo = psKick->ahDstSyncInfo[loop]; PDUMPCOMMENT("Tweak dest surface write op in transfer cmd\r\n"); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TQ Dst: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asDstSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal)), @@ -373,6 +466,12 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, + "TQ Src: PDump sync update: uiAddr = 0x%08x, ui32LastReadOpDumpVal = 0x%08x\r\n", + psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastReadOpDumpVal); +#endif } } @@ -380,8 +479,14 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF { if (abDstSyncEnable[loop]) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[0]; + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; psSyncInfo->psSyncData->ui32LastOpDumpVal++; +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, + "TQ Dst: PDump sync update: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif } } } @@ -391,6 +496,11 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF psSyncInfo = psKick->hTASyncInfo; PDUMPCOMMENT("Tweak TA/TQ surface write op in transfer cmd\r\n"); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TQ TA/TQ: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, ui32TASyncWriteOpsPendingVal)), @@ -398,6 +508,14 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); + PDUMPCOMMENT("Tweak TA/TQ surface read op in transfer cmd\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, ui32TASyncReadOpsPendingVal)), + sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + psSyncInfo->psSyncData->ui32LastOpDumpVal++; } @@ -406,6 +524,11 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF psSyncInfo = psKick->h3DSyncInfo; PDUMPCOMMENT("Tweak 3D/TQ surface write op in transfer cmd\r\n"); +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENT("TQ 3D/TQ: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, ui323DSyncWriteOpsPendingVal)), @@ -413,6 +536,14 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); + PDUMPCOMMENT("Tweak 3D/TQ surface read op in transfer cmd\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, ui323DSyncReadOpsPendingVal)), + sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + psSyncInfo->psSyncData->ui32LastOpDumpVal++; } } @@ -435,7 +566,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF if (abSrcSyncEnable[loop]) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; - psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); #if defined(PDUMP) if (PDumpIsCaptureFrameKM() || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) @@ -450,7 +581,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF if (abDstSyncEnable[loop]) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; - psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); #if defined(PDUMP) if (PDumpIsCaptureFrameKM() || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) @@ -466,14 +597,14 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF if (psKick->hTASyncInfo != IMG_NULL) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->hTASyncInfo; - psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); } /* Command needed to be synchronised with the 3D? */ if (psKick->h3DSyncInfo != IMG_NULL) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->h3DSyncInfo; - psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); } } @@ -529,11 +660,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF } #if defined(SGX_FEATURE_2D_HARDWARE) -#if defined (SUPPORT_SID_INTERFACE) -IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK_KM *psKick) -#else IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK *psKick) -#endif { PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; @@ -543,21 +670,6 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK PVRSRV_ERROR eError; IMG_UINT32 i; IMG_HANDLE hDevMemContext = IMG_NULL; -#if defined(PDUMP) - IMG_BOOL bPersistentProcess = IMG_FALSE; - /* - * For persistent processes, the HW kicks should not go into the - * extended init phase; only keep memory transactions from the - * window system which are necessary to run the client app. - */ - { - PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); - if(psPerProc != IMG_NULL) - { - bPersistentProcess = psPerProc->bPDumpPersistent; - } - } -#endif /* PDUMP */ #if defined(FIX_HW_BRN_31620) hDevMemContext = psKick->hDevMemContext; #endif @@ -571,31 +683,39 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK /* PRQA S 3305 1 */ ps2DCmd = CCB_DATA_FROM_OFFSET(SGXMKIF_2DCMD_SHARED, psCCBMemInfo, psKick, ui32SharedCmdCCBOffset); - OSMemSet(ps2DCmd, 0, sizeof(*ps2DCmd)); - /* Command needs to be synchronised with the TA? */ if (psKick->hTASyncInfo != IMG_NULL) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->hTASyncInfo; - ps2DCmd->sTASyncData.ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + ps2DCmd->sTASyncData.ui32WriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); ps2DCmd->sTASyncData.ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; ps2DCmd->sTASyncData.sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; ps2DCmd->sTASyncData.sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; } + else + { + ps2DCmd->sTASyncData.sWriteOpsCompleteDevVAddr.uiAddr = 0; + ps2DCmd->sTASyncData.sReadOpsCompleteDevVAddr.uiAddr = 0; + } /* Command needs to be synchronised with the 3D? */ if (psKick->h3DSyncInfo != IMG_NULL) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->h3DSyncInfo; - ps2DCmd->s3DSyncData.ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + ps2DCmd->s3DSyncData.ui32WriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); ps2DCmd->s3DSyncData.ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; ps2DCmd->s3DSyncData.sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; ps2DCmd->s3DSyncData.sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; } + else + { + ps2DCmd->s3DSyncData.sWriteOpsCompleteDevVAddr.uiAddr = 0; + ps2DCmd->s3DSyncData.sReadOpsCompleteDevVAddr.uiAddr = 0; + } /* * We allow the first source and destination sync objects to be the @@ -604,6 +724,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK * values from the objects. */ ps2DCmd->ui32NumSrcSync = psKick->ui32NumSrcSync; + for (i = 0; i < psKick->ui32NumSrcSync; i++) { psSyncInfo = psKick->ahSrcSyncInfo[i]; @@ -626,25 +747,26 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK ps2DCmd->sDstSyncData.sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; ps2DCmd->sDstSyncData.sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; ps2DCmd->sDstSyncData.sReadOps2CompleteDevVAddr = psSyncInfo->sReadOps2CompleteDevVAddr; + + /* We can do this immediately as we only have one */ + SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); + } + else + { + ps2DCmd->sDstSyncData.sWriteOpsCompleteDevVAddr.uiAddr = 0; + ps2DCmd->sDstSyncData.sReadOpsCompleteDevVAddr.uiAddr = 0; + ps2DCmd->sDstSyncData.sReadOps2CompleteDevVAddr.uiAddr = 0; } /* Read/Write ops pending updates, delayed from above */ for (i = 0; i < psKick->ui32NumSrcSync; i++) { psSyncInfo = psKick->ahSrcSyncInfo[i]; - psSyncInfo->psSyncData->ui32ReadOpsPending++; - } - - if (psKick->hDstSyncInfo != IMG_NULL) - { - psSyncInfo = psKick->hDstSyncInfo; - psSyncInfo->psSyncData->ui32WriteOpsPending++; + SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); } #if defined(PDUMP) - if ((PDumpIsCaptureFrameKM() - || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) - && (bPersistentProcess == IMG_FALSE) ) + if (PDumpWillCapture(psKick->ui32PDumpFlags)) { /* Pdump the command from the per context CCB */ PDUMPCOMMENT("Shared part of 2D command\r\n"); @@ -710,12 +832,24 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK { psSyncInfo = psKick->ahSrcSyncInfo[i]; psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, + "TQ2D Src: PDump sync update: uiAddr = 0x%08x, ui32LastReadOpDumpVal = 0x%08x\r\n", + psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastReadOpDumpVal); +#endif } if (psKick->hDstSyncInfo != IMG_NULL) { psSyncInfo = psKick->hDstSyncInfo; psSyncInfo->psSyncData->ui32LastOpDumpVal++; +#if defined(SUPPORT_PDUMP_SYNC_DEBUG) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, + "TQ2D Dst: PDump sync update: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32LastOpDumpVal); +#endif } } #endif @@ -749,13 +883,13 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK for (i = 0; i < psKick->ui32NumSrcSync; i++) { psSyncInfo = psKick->ahSrcSyncInfo[i]; - psSyncInfo->psSyncData->ui32ReadOpsPending--; + SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); } if (psKick->hDstSyncInfo != IMG_NULL) { psSyncInfo = psKick->hDstSyncInfo; - psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); } /* Command needed to be synchronised with the TA? */ @@ -763,7 +897,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->hTASyncInfo; - psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); } /* Command needed to be synchronised with the 3D? */ @@ -771,7 +905,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->h3DSyncInfo; - psSyncInfo->psSyncData->ui32WriteOpsPending--; + SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_2D); } } diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.c b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.c index 227675d1545..b1d2b1309e8 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.c +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.c @@ -57,6 +57,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pvr_debug.h" #include "sgxutils.h" #include "ttrace.h" +#include "sgxmmu.h" #ifdef __linux__ #include <linux/kernel.h> // sprintf @@ -172,9 +173,11 @@ IMG_VOID SGXTestActivePowerEvent (PVRSRV_DEVICE_NODE *psDeviceNode, ((psSGXHostCtl->ui32InterruptFlags & PVRSRV_USSE_EDM_INTERRUPT_IDLE) != 0)) { psSGXHostCtl->ui32InterruptClearFlags |= PVRSRV_USSE_EDM_INTERRUPT_IDLE; - psDevInfo->bSGXIdle = IMG_TRUE; - - SysSGXIdleEntered(); + if (psDevInfo->bSGXIdle == IMG_FALSE) + { + psDevInfo->bSGXIdle = IMG_TRUE; + SysSGXIdleEntered(); + } } /* @@ -284,7 +287,11 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode, #if defined(PDUMP) IMG_VOID *pvDumpCommand; IMG_BOOL bPDumpIsSuspended = PDumpIsSuspended(); - IMG_BOOL bPersistentProcess = IMG_FALSE; +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + IMG_BOOL bPDumpActive = _PDumpIsProcessActive(); +#else + IMG_BOOL bPDumpActive = IMG_TRUE; +#endif #else PVR_UNREFERENCED_PARAMETER(ui32CallerID); PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags); @@ -422,20 +429,6 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode, } } #endif -#if defined(PDUMP) - /* - * For persistent processes, the HW kicks should not go into the - * extended init phase; only keep memory transactions from the - * window system which are necessary to run the client app. - */ - { - PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); - if(psPerProc != IMG_NULL) - { - bPersistentProcess = psPerProc->bPDumpPersistent; - } - } -#endif /* PDUMP */ psKernelCCB = psDevInfo->psKernelCCBInfo; psSGXCommand = SGXAcquireKernelCCBSlot(psKernelCCB); @@ -496,7 +489,7 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode, #if defined(PDUMP) if ((ui32CallerID != ISR_ID) && (bPDumpIsSuspended == IMG_FALSE) && - (bPersistentProcess == IMG_FALSE) ) + (bPDumpActive == IMG_TRUE) ) { /* Poll for space in the CCB. */ PDUMPCOMMENTWITHFLAGS(ui32PDumpFlags, "Poll for space in the Kernel CCB\r\n"); @@ -559,7 +552,7 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode, #if defined(PDUMP) if ((ui32CallerID != ISR_ID) && (bPDumpIsSuspended == IMG_FALSE) && - (bPersistentProcess == IMG_FALSE) ) + (bPDumpActive == IMG_TRUE) ) { #if defined(FIX_HW_BRN_26620) && defined(SGX_FEATURE_SYSTEM_CACHE) && !defined(SGX_BYPASS_SYSTEM_CACHE) PDUMPCOMMENTWITHFLAGS(ui32PDumpFlags, "Poll for previous Kernel CCB CMD to be read\r\n"); @@ -709,9 +702,6 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, /* Note that a power-up has been dumped in the init phase. */ PDUMPSUSPEND(); - SysSGXCommandPending(psDevInfo->bSGXIdle); - psDevInfo->bSGXIdle = IMG_FALSE; - /* Ensure that SGX is powered up before kicking the ukernel. */ eError = PVRSRVSetDevicePowerStateKM(psDeviceNode->sDevId.ui32DeviceIndex, PVRSRV_DEV_POWER_STATE_ON); @@ -724,11 +714,15 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, } else { - PVR_DPF((PVR_DBG_ERROR,"SGXScheduleCCBCommandKM failed to acquire lock - " + PVR_DPF((PVR_DBG_ERROR,"SGXScheduleCCBCommandKM failed to power up device - " "ui32CallerID:%d eError:%u", ui32CallerID, eError)); + PVRSRVPowerUnlock(ui32CallerID); return eError; } + SysSGXCommandPending(psDevInfo->bSGXIdle); + psDevInfo->bSGXIdle = IMG_FALSE; + eError = SGXScheduleCCBCommand(psDeviceNode, eCmdType, psCommandData, ui32CallerID, ui32PDumpFlags, hDevMemContext, bLastInScene); PVRSRVPowerUnlock(ui32CallerID); @@ -750,10 +744,18 @@ PVRSRV_ERROR SGXScheduleProcessQueuesKM(PVRSRV_DEVICE_NODE *psDeviceNode) { PVRSRV_ERROR eError; PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; - SGXMKIF_HOST_CTL *psHostCtl = psDevInfo->psKernelSGXHostCtlMemInfo->pvLinAddrKM; + SGXMKIF_HOST_CTL *psHostCtl; IMG_UINT32 ui32PowerStatus; SGXMKIF_COMMAND sCommand = {0}; + if (psDevInfo->psKernelSGXHostCtlMemInfo == IMG_NULL) + { + /* Part2 hasn't run yet, we can't do anything */ + return PVRSRV_OK; + } + + psHostCtl = psDevInfo->psKernelSGXHostCtlMemInfo->pvLinAddrKM; + ui32PowerStatus = psHostCtl->ui32PowerStatus; if ((ui32PowerStatus & PVRSRV_USSE_EDM_POWMAN_NO_WORK) != 0) { @@ -809,11 +811,7 @@ IMG_BOOL SGXIsDevicePowered(PVRSRV_DEVICE_NODE *psDeviceNode) ******************************************************************************/ IMG_EXPORT PVRSRV_ERROR SGXGetInternalDevInfoKM(IMG_HANDLE hDevCookie, -#if defined (SUPPORT_SID_INTERFACE) - SGX_INTERNAL_DEVINFO_KM *psSGXInternalDevInfo) -#else SGX_INTERNAL_DEVINFO *psSGXInternalDevInfo) -#endif { PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookie)->pvDevice; @@ -1092,6 +1090,7 @@ IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE hDeviceNode, IMG_UINT8 *pSrc; IMG_UINT8 *pDst; PRESMAN_ITEM psResItem; + IMG_UINT32 ui32PDDevPAddrInDirListFormat; eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(SGX_HW_RENDER_CONTEXT_CLEANUP), @@ -1157,17 +1156,23 @@ IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE hDeviceNode, psMMUContext = BM_GetMMUContextFromMemContext(hDevMemContextInt); sPDDevPAddr = psDeviceNode->pfnMMUGetPDDevPAddr(psMMUContext); + /* + The PDDevPAddr needs to be shifted-down, as the uKernel expects it in the + format it will be inserted into the DirList registers in. + */ + ui32PDDevPAddrInDirListFormat = (IMG_UINT32)(sPDDevPAddr.uiAddr >> SGX_MMU_PTE_ADDR_ALIGNSHIFT); + /* patch-in the Page-Directory Device-Physical address. Note that this is copied-in one byte at a time, as we have no guarantee that the usermode- provided ui32OffsetToPDDevPAddr is a validly-aligned address for the current CPU architecture. */ - pSrc = (IMG_UINT8 *)&sPDDevPAddr; + pSrc = (IMG_UINT8 *)&ui32PDDevPAddrInDirListFormat; pDst = (IMG_UINT8 *)psCleanup->psHWRenderContextMemInfo->pvLinAddrKM; pDst += ui32OffsetToPDDevPAddr; - for (iPtrByte = 0; iPtrByte < sizeof(IMG_DEV_PHYADDR); iPtrByte++) + for (iPtrByte = 0; iPtrByte < sizeof(ui32PDDevPAddrInDirListFormat); iPtrByte++) { pDst[iPtrByte] = pSrc[iPtrByte]; } @@ -1272,6 +1277,7 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE hDeviceNode, IMG_UINT8 *pSrc; IMG_UINT8 *pDst; PRESMAN_ITEM psResItem; + IMG_UINT32 ui32PDDevPAddrInDirListFormat; eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(SGX_HW_TRANSFER_CONTEXT_CLEANUP), @@ -1288,6 +1294,7 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE hDeviceNode, psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; psHeapInfo = &psDevMemoryInfo->psDeviceMemoryHeap[SGX_KERNEL_DATA_HEAP_ID]; + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "Allocate HW Transfer context"); eError = PVRSRVAllocDeviceMemKM(hDeviceNode, psPerProc, psHeapInfo->hDevMemHeap, @@ -1337,17 +1344,23 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE hDeviceNode, psMMUContext = BM_GetMMUContextFromMemContext(hDevMemContextInt); sPDDevPAddr = psDeviceNode->pfnMMUGetPDDevPAddr(psMMUContext); + /* + The PDDevPAddr needs to be shifted-down, as the uKernel expects it in the + format it will be inserted into the DirList registers in. + */ + ui32PDDevPAddrInDirListFormat = (IMG_UINT32)(sPDDevPAddr.uiAddr >> SGX_MMU_PTE_ADDR_ALIGNSHIFT); + /* patch-in the Page-Directory Device-Physical address. Note that this is copied-in one byte at a time, as we have no guarantee that the usermode- provided ui32OffsetToPDDevPAddr is a validly-aligned address for the current CPU architecture. */ - pSrc = (IMG_UINT8 *)&sPDDevPAddr; + pSrc = (IMG_UINT8 *)&ui32PDDevPAddrInDirListFormat; pDst = (IMG_UINT8 *)psCleanup->psHWTransferContextMemInfo->pvLinAddrKM; pDst += ui32OffsetToPDDevPAddr; - for (iPtrByte = 0; iPtrByte < sizeof(IMG_DEV_PHYADDR); iPtrByte++) + for (iPtrByte = 0; iPtrByte < sizeof(ui32PDDevPAddrInDirListFormat); iPtrByte++) { pDst[iPtrByte] = pSrc[iPtrByte]; } @@ -1605,6 +1618,7 @@ IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE hDeviceNode, IMG_UINT8 *pSrc; IMG_UINT8 *pDst; PRESMAN_ITEM psResItem; + IMG_UINT32 ui32PDDevPAddrInDirListFormat; eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(SGX_HW_2D_CONTEXT_CLEANUP), @@ -1669,17 +1683,23 @@ IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE hDeviceNode, psMMUContext = BM_GetMMUContextFromMemContext(hDevMemContextInt); sPDDevPAddr = psDeviceNode->pfnMMUGetPDDevPAddr(psMMUContext); + /* + The PDDevPAddr needs to be shifted-down, as the uKernel expects it in the + format it will be inserted into the DirList registers in. + */ + ui32PDDevPAddrInDirListFormat = sPDDevPAddr.uiAddr >> SGX_MMU_PTE_ADDR_ALIGNSHIFT; + /* patch-in the Page-Directory Device-Physical address. Note that this is copied-in one byte at a time, as we have no guarantee that the usermode- provided ui32OffsetToPDDevPAddr is a validly-aligned address for the current CPU architecture. */ - pSrc = (IMG_UINT8 *)&sPDDevPAddr; + pSrc = (IMG_UINT8 *)&ui32PDDevPAddrInDirListFormat; pDst = (IMG_UINT8 *)psCleanup->psHW2DContextMemInfo->pvLinAddrKM; pDst += ui32OffsetToPDDevPAddr; - for (iPtrByte = 0; iPtrByte < sizeof(IMG_DEV_PHYADDR); iPtrByte++) + for (iPtrByte = 0; iPtrByte < sizeof(ui32PDDevPAddrInDirListFormat); iPtrByte++) { pDst[iPtrByte] = pSrc[iPtrByte]; } @@ -1848,8 +1868,8 @@ PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(PVRSRV_SGXDEV_INFO *psDevInfo, { PVRSRV_SYNC_DATA *psSyncData = psSyncInfo->psSyncData; - PVR_TRACE(("SGX2DQueryBlitsCompleteKM: Syncinfo: 0x%x, Syncdata: 0x%x", - (IMG_UINTPTR_T)psSyncInfo, (IMG_UINTPTR_T)psSyncData)); + PVR_TRACE(("SGX2DQueryBlitsCompleteKM: Syncinfo: 0x%p, Syncdata: 0x%p", + psSyncInfo, psSyncData)); PVR_TRACE(("SGX2DQueryBlitsCompleteKM: Read ops complete: %d, Read ops pending: %d", psSyncData->ui32ReadOpsComplete, psSyncData->ui32ReadOpsPending)); PVR_TRACE(("SGX2DQueryBlitsCompleteKM: Write ops complete: %d, Write ops pending: %d", psSyncData->ui32WriteOpsComplete, psSyncData->ui32WriteOpsPending)); diff --git a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.h b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.h index fc2ef6f34c3..fc2ef6f34c3 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.h +++ b/drivers/gpu/pvr/services4/srvkm/devices/sgx/sgxutils.h diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/Kbuild.mk b/drivers/gpu/pvr/services4/srvkm/env/linux/Kbuild.mk index 25e35e934b7..10064d69c06 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/Kbuild.mk +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/Kbuild.mk @@ -38,7 +38,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ### ########################################################################### -pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-y += \ +pvrsrvkm-y += \ services4/srvkm/env/linux/osfunc.o \ services4/srvkm/env/linux/mutils.o \ services4/srvkm/env/linux/mmap.o \ @@ -51,10 +51,8 @@ pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-y += \ services4/srvkm/env/linux/mutex.o \ services4/srvkm/env/linux/event.o \ services4/srvkm/env/linux/osperproc.o \ - services4/srvkm/env/linux/sysfs.o \ services4/srvkm/common/buffer_manager.o \ services4/srvkm/common/devicemem.o \ - services4/srvkm/common/deviceclass.o \ services4/srvkm/common/handle.o \ services4/srvkm/common/hash.o \ services4/srvkm/common/lists.o \ @@ -66,7 +64,6 @@ pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-y += \ services4/srvkm/common/perproc.o \ services4/srvkm/common/power.o \ services4/srvkm/common/pvrsrv.o \ - services4/srvkm/common/queue.o \ services4/srvkm/common/ra.o \ services4/srvkm/common/refcount.o \ services4/srvkm/common/resman.o \ @@ -75,21 +72,32 @@ pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-y += \ services4/system/$(PVR_SYSTEM)/sysconfig.o \ services4/system/$(PVR_SYSTEM)/sysutils.o -pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-$(CONFIG_ION_OMAP) += \ - services4/srvkm/env/linux/ion.o -pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-$(CONFIG_GCBV) += \ - services4/srvkm/env/linux/gc_bvmapping.o +ifeq ($(SUPPORT_PVRSRV_DEVICE_CLASS),1) +pvrsrvkm-y += \ + services4/srvkm/common/deviceclass.o \ + services4/srvkm/common/queue.o +endif ifeq ($(SUPPORT_ION),1) pvrsrvkm-y += \ services4/srvkm/env/linux/ion.o endif +ifeq ($(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC),1) +pvrsrvkm-y += \ + services4/srvkm/env/linux/pvr_sync.o +endif + ifeq ($(TTRACE),1) pvrsrvkm-y += \ services4/srvkm/common/ttrace.o endif +ifeq ($(SUPPORT_PVRSRV_ANDROID_SYSTRACE),1) +pvrsrvkm-y += \ + services4/srvkm/env/linux/systrace.o +endif + ifneq ($(W),1) CFLAGS_osfunc.o := -Werror CFLAGS_mutils.o := -Werror @@ -127,7 +135,7 @@ endif # SUPPORT_SGX==1 only -pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-y += \ +pvrsrvkm-y += \ services4/srvkm/bridged/sgx/bridged_sgx_bridge.o \ services4/srvkm/devices/sgx/sgxinit.o \ services4/srvkm/devices/sgx/sgxpower.o \ @@ -152,11 +160,11 @@ endif ifeq ($(SUPPORT_DRI_DRM),1) -pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV)-y += \ +pvrsrvkm-y += \ services4/srvkm/env/linux/pvr_drm.o ccflags-y += \ - -I$(KERNELDIR)/include/drm \ + -Iinclude/drm \ -I$(TOP)/services4/include/env/linux \ ifeq ($(PVR_DRI_DRM_NOT_PCI),1) diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/Linux.mk b/drivers/gpu/pvr/services4/srvkm/env/linux/Linux.mk index 7e3d0fb2e96..535a1f91150 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/Linux.mk +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/Linux.mk @@ -41,5 +41,5 @@ modules := srvkm srvkm_type := kernel_module -srvkm_target := pvrsrvkm_sgx$(SGXCORE)_$(SGX_CORE_REV).ko +srvkm_target := pvrsrvkm.ko srvkm_makefile := $(THIS_DIR)/Kbuild.mk diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/env_data.h b/drivers/gpu/pvr/services4/srvkm/env/linux/env_data.h index b8388098c7d..b8388098c7d 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/env_data.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/env_data.h diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/env_perproc.h b/drivers/gpu/pvr/services4/srvkm/env/linux/env_perproc.h index 8a37a7f44f9..788e80fc005 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/env_perproc.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/env_perproc.h @@ -43,8 +43,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define __ENV_PERPROC_H__ #include <linux/list.h> -#include <linux/proc_fs.h> +#include "proc.h" #include "services.h" #include "handle.h" @@ -56,7 +56,7 @@ typedef struct _PVRSRV_ENV_PER_PROCESS_DATA_ #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) struct list_head sDRMAuthListHead; #endif -#if defined (SUPPORT_ION) +#if defined(SUPPORT_ION) struct ion_client *psIONClient; IMG_CHAR azIonClientName[ION_CLIENT_NAME_SIZE]; #endif diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/event.c b/drivers/gpu/pvr/services4/srvkm/env/linux/event.c index b70a79dfc39..c60f2d5c1a6 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/event.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/event.c @@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <asm/io.h> #include <asm/page.h> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) #include <asm/system.h> #endif #include <linux/mm.h> @@ -74,7 +74,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pvrmmap.h" #include "mmap.h" #include "env_data.h" -#include "proc.h" #include "mutex.h" #include "lock.h" #include "event.h" @@ -396,7 +395,7 @@ PVRSRV_ERROR LinuxEventObjectWait(IMG_HANDLE hOSEventObject, IMG_UINT32 ui32MSTi ui32TimeOutJiffies = (IMG_UINT32)schedule_timeout((IMG_INT32)ui32TimeOutJiffies); - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); #if defined(DEBUG) psLinuxEventObject->ui32Stats++; #endif diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/event.h b/drivers/gpu/pvr/services4/srvkm/env/linux/event.h index 5c1451cd342..5c1451cd342 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/event.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/event.h diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/gc_bvmapping.c b/drivers/gpu/pvr/services4/srvkm/env/linux/gc_bvmapping.c deleted file mode 100644 index 6c5d17a0e84..00000000000 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/gc_bvmapping.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ -#include <linux/bltsville.h> -#include <linux/bvinternal.h> -#include <linux/gcbv-iface.h> - -#include "gc_bvmapping.h" -#include "services_headers.h" - -void gc_bvmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - int i; - IMG_CPU_PHYADDR phy_addr; - unsigned long *page_addrs; - struct bvbuffdesc *buffdesc; - struct bvphysdesc *physdesc; - int num_pages; - struct bventry bv_entry; - enum bverror bv_error; - - gcbv_init(&bv_entry); - if (!bv_entry.bv_map) { - psMemInfo->bvmap_handle = NULL; - return; - } - - num_pages = (psMemInfo->uAllocSize + - PAGE_SIZE - 1) >> PAGE_SHIFT; - - page_addrs = kzalloc(sizeof(*page_addrs) * num_pages, GFP_KERNEL); - if (!page_addrs) { - printk(KERN_ERR "%s: Out of memory\n", __func__); - return; - } - - physdesc = kzalloc(sizeof(*physdesc), GFP_KERNEL); - buffdesc = kzalloc(sizeof(*buffdesc), GFP_KERNEL); - if (!buffdesc || !physdesc) { - printk(KERN_ERR "%s: Out of memory\n", __func__); - kfree(page_addrs); - kfree(physdesc); - kfree(buffdesc); - return; - } - - for (i = 0; i < num_pages; i++) { - phy_addr = OSMemHandleToCpuPAddr( - psMemInfo->sMemBlk.hOSMemHandle, i << PAGE_SHIFT); - page_addrs[i] = (u32)phy_addr.uiAddr; - } - - buffdesc->structsize = sizeof(*buffdesc); - buffdesc->map = NULL; - buffdesc->length = psMemInfo->uAllocSize; - buffdesc->auxtype = BVAT_PHYSDESC; - buffdesc->auxptr = physdesc; - physdesc->structsize = sizeof(*physdesc); - physdesc->pagesize = PAGE_SIZE; - physdesc->pagearray = page_addrs; - physdesc->pagecount = num_pages; - - /* - * For ion allocated buffers let's verify how many planes this - * meminfo consist of - */ - if(psMemInfo->ui32Flags & PVRSRV_MEM_ION) { - IMG_UINT32 num_addr_offsets = 0; - OSGetMemMultiPlaneInfo(psMemInfo->sMemBlk.hOSMemHandle, - NULL, &num_addr_offsets); - - /* - * Account for this meminfo plane offset (relative to the base - * address) if necessary - */ - if(num_addr_offsets > 0) - physdesc->pageoffset = psMemInfo->planeOffsets[0]; - - /* - * In BV there is no way to specify multiple offsets, check - * all planes have the same offset and report any discrepancy - */ - for (i = 1; i < num_addr_offsets; i++) { - IMG_UINT32 plane_offset = - psMemInfo->planeOffsets[i] % PAGE_SIZE; - if (psMemInfo->planeOffsets[0] != plane_offset) { - printk(KERN_WARNING "%s: meminfo %p offset 0 %d" - " != offset %d %d, coalignment is " - "missing\n", __func__, psMemInfo, - psMemInfo->planeOffsets[0], - i, plane_offset); - } - } - } - - bv_error = bv_entry.bv_map(buffdesc); - if (bv_error) { - printk(KERN_ERR "%s: Failed to map meminfo %p, bverror %d\n", - __func__, psMemInfo, bv_error); - psMemInfo->bvmap_handle = NULL; - } else - psMemInfo->bvmap_handle = buffdesc; - -} - -void gc_bvunmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - struct bvbuffdesc *buffdesc; - struct bvphysdesc *physdesc; - struct bventry bv_entry; - enum bverror bv_error; - - gcbv_init(&bv_entry); - if (!bv_entry.bv_map || !psMemInfo || !psMemInfo->bvmap_handle) - return; - - buffdesc = psMemInfo->bvmap_handle; - physdesc = (struct bvphysdesc*) buffdesc->auxptr; - bv_error = bv_entry.bv_unmap(buffdesc); - if (bv_error) { - printk(KERN_ERR "%s: Failed to unmap bvhandle %p from meminfo " - "%p, bverror %d\n", __func__, buffdesc, psMemInfo, - bv_error); - } - - kfree(physdesc->pagearray); - kfree(physdesc); - kfree(psMemInfo->bvmap_handle); - psMemInfo->bvmap_handle = NULL; -} - -IMG_VOID *gc_meminfo_to_hndl(PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - return psMemInfo->bvmap_handle; -} diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/gc_bvmapping.h b/drivers/gpu/pvr/services4/srvkm/env/linux/gc_bvmapping.h deleted file mode 100644 index 6a3a2b1ced0..00000000000 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/gc_bvmapping.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef GC_BVMAPPING_H -#define GC_BVMAPPING_H - -#include "services_headers.h" - -void gc_bvunmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo); - -void gc_bvmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo); - -IMG_VOID *gc_meminfo_to_hndl(PVRSRV_KERNEL_MEM_INFO *psMemInfo); - -#endif diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/ion.c b/drivers/gpu/pvr/services4/srvkm/env/linux/ion.c index 3e772bca13e..036f1bd7cbe 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/ion.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/ion.c @@ -41,323 +41,417 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "ion.h" -#include "services.h" -#include "servicesint.h" -#include "mutex.h" -#include "lock.h" -#include "mm.h" -#include "handle.h" -#include "perproc.h" -#include "env_perproc.h" -#include "private_data.h" -#include "pvr_debug.h" +/* Three possible configurations: + * + * - SUPPORT_ION && CONFIG_ION_OMAP + * Real ion support, but sharing with an SOC ion device. We need + * to co-share the heaps too. + * + * - SUPPORT_ION && !CONFIG_ION_OMAP + * "Reference" ion implementation. Creates its own ion device + * and heaps for the driver to use. + */ -#include <linux/module.h> -#include <linux/file.h> -#include <linux/fs.h> +#if defined(SUPPORT_ION) -#if defined (CONFIG_ION_OMAP) -#define MAX_HANDLES_PER_FD 2 -extern struct ion_client *gpsIONClient; +#include <linux/scatterlist.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/err.h> -int PVRSRVExportFDToIONHandles(int fd, struct ion_client **client, - struct ion_handle **handles, - unsigned int *num_handles) -{ - PVRSRV_FILE_PRIVATE_DATA *psPrivateData; - PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - LinuxMemArea *psLinuxMemArea; - PVRSRV_ERROR eError; - struct file *psFile; - int i; - unsigned int ui32NumHandles = *num_handles; - int ret = -EINVAL; +#if defined(CONFIG_ION_OMAP) - /* Take the bridge mutex so the handle won't be freed underneath us */ - LinuxLockMutex(&gPVRSRVLock); +/* Real ion with sharing */ - psFile = fget(fd); - if(!psFile) - goto err_unlock; +extern struct ion_device *omap_ion_device; +struct ion_device *gpsIonDev; - 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; - } +PVRSRV_ERROR IonInit(IMG_VOID) +{ + gpsIonDev = omap_ion_device; + return PVRSRV_OK; +} - psLinuxMemArea = (LinuxMemArea *)psKernelMemInfo->sMemBlk.hOSMemHandle; - BUG_ON(psLinuxMemArea == IMG_NULL); +IMG_VOID IonDeinit(IMG_VOID) +{ + gpsIonDev = 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; - } +#else /* defined(CONFIG_ION_OMAP) */ - /* Client is requesting fewer handles then we have */ - if(ui32NumHandles < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes) { +#if defined(CONFIG_ION_S5P) - PVR_DPF((PVR_DBG_ERROR, "%s: Client requested %u handles, but we have %u", - __func__, - ui32NumHandles, - psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes)); +/* Real ion with sharing (s5pv210) */ - /* Clear client handles */ - for (i = 0; i < ui32NumHandles; i++) - handles[i] = NULL; +extern struct ion_device *s5p_ion_device; +struct ion_device *gpsIonDev; - /* Return number of handles to client */ - *num_handles = psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; - goto err_fput; - } +PVRSRV_ERROR IonInit(IMG_VOID) +{ + gpsIonDev = s5p_ion_device; + return PVRSRV_OK; +} - for (i = 0; (i < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes) && (i < MAX_HANDLES_PER_FD); i++) - handles[i] = psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i]; +IMG_VOID IonDeinit(IMG_VOID) +{ + gpsIonDev = IMG_NULL; +} - *num_handles = i; +#else /* defined(CONFIG_ION_S5P) */ - if(client) - *client = gpsIONClient; +#if defined(CONFIG_ION_SUNXI) - ret = 0; +/* Real ion with sharing (sunxi) */ -err_fput: - fput(psFile); -err_unlock: - /* Allow PVRSRV clients to communicate with srvkm again */ - LinuxUnLockMutex(&gPVRSRVLock); +extern struct ion_device *sunxi_ion_device; +struct ion_device *gpsIonDev; - return ret; +PVRSRV_ERROR IonInit(IMG_VOID) +{ + gpsIonDev = sunxi_ion_device; + return PVRSRV_OK; } -struct ion_handle * -PVRSRVExportFDToIONHandle(int fd, struct ion_client **client) +IMG_VOID IonDeinit(IMG_VOID) { - unsigned int num_handles = 1; - struct ion_handle *psHandle = IMG_NULL; - PVRSRVExportFDToIONHandles(fd, client, &psHandle, &num_handles); - return psHandle; + gpsIonDev = IMG_NULL; } -EXPORT_SYMBOL(PVRSRVExportFDToIONHandles); -EXPORT_SYMBOL(PVRSRVExportFDToIONHandle); -#endif +#else /* defined(CONFIG_ION_SUNXI) */ + +/* "Reference" ion implementation */ -#if defined (SUPPORT_ION) -#include "syscommon.h" -#include "env_data.h" #include "../drivers/gpu/ion/ion_priv.h" -#include "linux/kernel.h" -struct ion_heap **apsIonHeaps; -struct ion_device *psIonDev; +static struct ion_heap **gapsIonHeaps; +struct ion_device *gpsIonDev; -static struct ion_platform_data generic_config = { - .nr = 2, - .heaps = { - { - .type = ION_HEAP_TYPE_SYSTEM_CONTIG, - .name = "System contig", - .id = ION_HEAP_TYPE_SYSTEM_CONTIG, - }, - { - .type = ION_HEAP_TYPE_SYSTEM, - .name = "System", - .id = ION_HEAP_TYPE_SYSTEM, - } - } +#ifndef ION_CARVEOUT_MEM_BASE +#define ION_CARVEOUT_MEM_BASE 0 +#endif + +#ifndef ION_CARVEOUT_MEM_SIZE +#define ION_CARVEOUT_MEM_SIZE 0 +#endif + +static struct ion_platform_data gsGenericConfig = +{ + .nr = 3, + .heaps = + { + { + .type = ION_HEAP_TYPE_SYSTEM_CONTIG, + .name = "system_contig", + .id = ION_HEAP_TYPE_SYSTEM_CONTIG, + }, + { + .type = ION_HEAP_TYPE_SYSTEM, + .name = "system", + .id = ION_HEAP_TYPE_SYSTEM, + }, + { + .type = ION_HEAP_TYPE_CARVEOUT, + .name = "carveout", + .id = ION_HEAP_TYPE_CARVEOUT, + .base = ION_CARVEOUT_MEM_BASE, + .size = ION_CARVEOUT_MEM_SIZE, + }, + } }; PVRSRV_ERROR IonInit(IMG_VOID) { - int uiHeapCount = generic_config.nr; + int uiHeapCount = gsGenericConfig.nr; int uiError; int i; - apsIonHeaps = kzalloc(sizeof(struct ion_heap *) * uiHeapCount, GFP_KERNEL); + gapsIonHeaps = kzalloc(sizeof(struct ion_heap *) * uiHeapCount, GFP_KERNEL); /* Create the ion devicenode */ - psIonDev = ion_device_create(NULL); - if (IS_ERR_OR_NULL(psIonDev)) { - kfree(apsIonHeaps); + gpsIonDev = ion_device_create(NULL); + if (IS_ERR_OR_NULL(gpsIonDev)) { + kfree(gapsIonHeaps); return PVRSRV_ERROR_OUT_OF_MEMORY; } /* Register all the heaps */ - for (i = 0; i < generic_config.nr; i++) + for (i = 0; i < gsGenericConfig.nr; i++) { - struct ion_platform_heap *psPlatHeapData = &generic_config.heaps[i]; + struct ion_platform_heap *psPlatHeapData = &gsGenericConfig.heaps[i]; - apsIonHeaps[i] = ion_heap_create(psPlatHeapData); - if (IS_ERR_OR_NULL(apsIonHeaps[i])) + gapsIonHeaps[i] = ion_heap_create(psPlatHeapData); + if (IS_ERR_OR_NULL(gapsIonHeaps[i])) { - uiError = PTR_ERR(apsIonHeaps[i]); + uiError = PTR_ERR(gapsIonHeaps[i]); goto failHeapCreate; } - ion_device_add_heap(psIonDev, apsIonHeaps[i]); + ion_device_add_heap(gpsIonDev, gapsIonHeaps[i]); } return PVRSRV_OK; failHeapCreate: - for (i = 0; i < uiHeapCount; i++) { - if (apsIonHeaps[i]) + for (i = 0; i < uiHeapCount; i++) + { + if (gapsIonHeaps[i]) { - ion_heap_destroy(apsIonHeaps[i]); + ion_heap_destroy(gapsIonHeaps[i]); } } - kfree(apsIonHeaps); + kfree(gapsIonHeaps); return PVRSRV_ERROR_OUT_OF_MEMORY; } IMG_VOID IonDeinit(IMG_VOID) { - int uiHeapCount = generic_config.nr; + int uiHeapCount = gsGenericConfig.nr; int i; - for (i = 0; i < uiHeapCount; i++) { - if (apsIonHeaps[i]) + for (i = 0; i < uiHeapCount; i++) + { + if (gapsIonHeaps[i]) { - ion_heap_destroy(apsIonHeaps[i]); + ion_heap_destroy(gapsIonHeaps[i]); } } - kfree(apsIonHeaps); - ion_device_destroy(psIonDev); + kfree(gapsIonHeaps); + ion_device_destroy(gpsIonDev); } +#endif /* defined(CONFIG_ION_SUNXI) */ + +#endif /* defined(CONFIG_ION_S5P) */ + +#endif /* defined(CONFIG_ION_OMAP) */ + +#define MAX_IMPORT_ION_FDS 3 + typedef struct _ION_IMPORT_DATA_ { + /* ion client handles are imported into */ struct ion_client *psIonClient; - struct ion_handle *psIonHandle; - IMG_PVOID pvKernAddr; -} ION_IMPORT_DATA; -PVRSRV_ERROR IonImportBufferAndAquirePhysAddr(IMG_HANDLE hIonDev, - IMG_HANDLE hIonFD, - IMG_UINT32 *pui32PageCount, - IMG_SYS_PHYADDR **ppasSysPhysAddr, - IMG_PVOID *ppvKernAddr, - IMG_HANDLE *phPriv) + /* Number of ion handles represented by this import */ + IMG_UINT32 ui32NumIonHandles; + + /* Array of ion handles in use by services */ + struct ion_handle *apsIonHandle[MAX_IMPORT_ION_FDS]; + + /* Array of physical addresses represented by these buffers */ + IMG_SYS_PHYADDR *psSysPhysAddr; + +#if defined(PDUMP) + /* If ui32NumBuffers is 1 and ion_map_kernel() is implemented by the + * allocator, this may be non-NULL. Otherwise it will be NULL. + */ + IMG_PVOID pvKernAddr0; +#endif /* defined(PDUMP) */ +} +ION_IMPORT_DATA; + +PVRSRV_ERROR IonImportBufferAndAcquirePhysAddr(IMG_HANDLE hIonDev, + IMG_UINT32 ui32NumFDs, + IMG_INT32 *pai32BufferFDs, + IMG_UINT32 *pui32PageCount, + IMG_SYS_PHYADDR **ppsSysPhysAddr, + IMG_PVOID *ppvKernAddr0, + IMG_HANDLE *phPriv, + IMG_HANDLE *phUnique) { + struct scatterlist *psTemp, *psScatterList[MAX_IMPORT_ION_FDS] = {}; + PVRSRV_ERROR eError = PVRSRV_ERROR_OUT_OF_MEMORY; struct ion_client *psIonClient = hIonDev; - struct ion_handle *psIonHandle; - struct scatterlist *psScatterList; - struct scatterlist *psTemp; - IMG_SYS_PHYADDR *pasSysPhysAddr = NULL; + IMG_UINT32 i, k, ui32PageCount = 0; ION_IMPORT_DATA *psImportData; - PVRSRV_ERROR eError; - IMG_UINT32 ui32PageCount = 0; - IMG_UINT32 i; - IMG_PVOID pvKernAddr; - int fd = (int) hIonFD; - psImportData = kmalloc(sizeof(ION_IMPORT_DATA), GFP_KERNEL); - if (psImportData == NULL) + if(ui32NumFDs > MAX_IMPORT_ION_FDS) { - return PVRSRV_ERROR_OUT_OF_MEMORY; + printk(KERN_ERR "%s: More ion export fds passed in than supported " + "(%d provided, %d max)", __func__, ui32NumFDs, + MAX_IMPORT_ION_FDS); + return PVRSRV_ERROR_INVALID_PARAMS; } - /* Get the buffer handle */ - psIonHandle = ion_import_fd(psIonClient, fd); - if (psIonHandle == IMG_NULL) + psImportData = kzalloc(sizeof(ION_IMPORT_DATA), GFP_KERNEL); + if (psImportData == NULL) { - eError = PVRSRV_ERROR_BAD_MAPPING; - goto exitFailImport; + goto exitFailKMallocImportData; } - /* Create data for free callback */ + /* Set up import data for free call */ psImportData->psIonClient = psIonClient; - psImportData->psIonHandle = psIonHandle; + psImportData->ui32NumIonHandles = ui32NumFDs; - psScatterList = ion_map_dma(psIonClient, psIonHandle); - if (psScatterList == NULL) + for(i = 0; i < ui32NumFDs; i++) { - eError = PVRSRV_ERROR_INVALID_PARAMS; - goto exitFailMap; - } + int fd = (int)pai32BufferFDs[i]; + struct sg_table *psSgTable; - /* - We do a two pass process, 1st workout how many pages there - are, 2nd fill in the data. - */ - for (i=0;i<2;i++) - { - psTemp = psScatterList; - if (i == 1) + psImportData->apsIonHandle[i] = ion_import_dma_buf(psIonClient, fd); + if (psImportData->apsIonHandle[i] == IMG_NULL) { - pasSysPhysAddr = kmalloc(sizeof(IMG_SYS_PHYADDR) * ui32PageCount, GFP_KERNEL); - if (pasSysPhysAddr == NULL) - { - eError = PVRSRV_ERROR_OUT_OF_MEMORY; - goto exitFailAlloc; - } - ui32PageCount = 0; /* Reset the page count a we use if for the index */ + eError = PVRSRV_ERROR_BAD_MAPPING; + goto exitFailImport; } - while(psTemp) + psSgTable = ion_sg_table(psIonClient, psImportData->apsIonHandle[i]); + psScatterList[i] = psSgTable->sgl; + if (psScatterList[i] == NULL) { - IMG_UINT32 j; + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto exitFailImport; + } - for (j=0;j<psTemp->length;j+=PAGE_SIZE) + /* Although all heaps will provide an sg_table, the tables cannot + * always be trusted because sg_lists are just pointers to "struct + * page" values, and some memory e.g. carveout may not have valid + * "struct page" values. In particular, on ARM, carveout is + * generally reserved with memblock_remove(), which leaves the + * "struct page" entries uninitialized when SPARSEMEM is enabled. + * The effect of this is that page_to_pfn(pfn_to_page(pfn)) != pfn. + * + * There's more discussion on this mailing list thread: + * http://lists.linaro.org/pipermail/linaro-mm-sig/2012-August/002440.html + * + * If the heap this buffer comes from implements ->phys(), it's + * probably a contiguous allocator. If the phys() function is + * implemented, we'll use it to check sg_table->sgl[0]. If we find + * they don't agree, we'll assume phys() is more reliable and use + * that. + * + * Some heaps out there will implement phys() even though they are + * not for physically contiguous allocations (so the sg_table must + * be used). Therefore use the sg_table if the phys() and first + * sg_table entry match. This should be reliable because for most + * contiguous allocators, the sg_table should be a single span + * from 'start' to 'start+size'. + * + * Also, ion prints out an error message if the heap doesn't implement + * ->phys(), which we want to avoid, so only use ->phys() if the + * sg_table contains a single span and therefore could plausibly + * be a contiguous allocator. + */ + if(!sg_next(psScatterList[i])) + { + ion_phys_addr_t sPhyAddr; + size_t sLength; + + if(!ion_phys(psIonClient, psImportData->apsIonHandle[i], + &sPhyAddr, &sLength)) { - if (i == 1) + BUG_ON(sLength & ~PAGE_MASK); + + if(sg_phys(psScatterList[i]) != sPhyAddr) { - /* Pass 2: Get the page data */ - pasSysPhysAddr[ui32PageCount].uiAddr = sg_phys(psTemp); + psScatterList[i] = IMG_NULL; + ui32PageCount += sLength / PAGE_SIZE; } + } + } + + for(psTemp = psScatterList[i]; psTemp; psTemp = sg_next(psTemp)) + { + IMG_UINT32 j; + for (j = 0; j < psTemp->length; j += PAGE_SIZE) + { ui32PageCount++; } - psTemp = sg_next(psTemp); } } - pvKernAddr = ion_map_kernel(psIonClient, psIonHandle); - if (IS_ERR(pvKernAddr)) + BUG_ON(ui32PageCount == 0); + + psImportData->psSysPhysAddr = kmalloc(sizeof(IMG_SYS_PHYADDR) * ui32PageCount, GFP_KERNEL); + if (psImportData->psSysPhysAddr == NULL) { - pvKernAddr = IMG_NULL; + goto exitFailImport; } - psImportData->pvKernAddr = pvKernAddr; + for(i = 0, k = 0; i < ui32NumFDs; i++) + { + if(psScatterList[i]) + { + for(psTemp = psScatterList[i]; psTemp; psTemp = sg_next(psTemp)) + { + IMG_UINT32 j; + for (j = 0; j < psTemp->length; j += PAGE_SIZE) + { + psImportData->psSysPhysAddr[k].uiAddr = sg_phys(psTemp) + j; + k++; + } + } + } + else + { + ion_phys_addr_t sPhyAddr; + size_t sLength, j; + + ion_phys(psIonClient, psImportData->apsIonHandle[i], + &sPhyAddr, &sLength); + + for(j = 0; j < sLength; j += PAGE_SIZE) + { + psImportData->psSysPhysAddr[k].uiAddr = sPhyAddr + j; + k++; + } + } + } - *ppvKernAddr = pvKernAddr; *pui32PageCount = ui32PageCount; - *ppasSysPhysAddr = pasSysPhysAddr; + *ppsSysPhysAddr = psImportData->psSysPhysAddr; + +#if defined(PDUMP) + if(ui32NumFDs == 1) + { + IMG_PVOID pvKernAddr0; + + pvKernAddr0 = ion_map_kernel(psIonClient, psImportData->apsIonHandle[0]); + if (IS_ERR(pvKernAddr0)) + { + pvKernAddr0 = IMG_NULL; + } + + psImportData->pvKernAddr0 = pvKernAddr0; + *ppvKernAddr0 = pvKernAddr0; + } + else +#endif /* defined(PDUMP) */ + { + *ppvKernAddr0 = NULL; + } + *phPriv = psImportData; + *phUnique = (IMG_HANDLE)psImportData->psSysPhysAddr[0].uiAddr; + return PVRSRV_OK; -exitFailAlloc: - ion_unmap_dma(psIonClient, psIonHandle); -exitFailMap: - ion_free(psIonClient, psIonHandle); exitFailImport: + for(i = 0; psImportData->apsIonHandle[i] != NULL; i++) + { + ion_free(psIonClient, psImportData->apsIonHandle[i]); + } kfree(psImportData); +exitFailKMallocImportData: return eError; } - IMG_VOID IonUnimportBufferAndReleasePhysAddr(IMG_HANDLE hPriv) { ION_IMPORT_DATA *psImportData = hPriv; + IMG_UINT32 i; + +#if defined(PDUMP) + if (psImportData->pvKernAddr0) + { + ion_unmap_kernel(psImportData->psIonClient, psImportData->apsIonHandle[0]); + } +#endif /* defined(PDUMP) */ - ion_unmap_dma(psImportData->psIonClient, psImportData->psIonHandle); - if (psImportData->pvKernAddr) + for(i = 0; i < psImportData->ui32NumIonHandles; i++) { - ion_unmap_kernel(psImportData->psIonClient, psImportData->psIonHandle); + ion_free(psImportData->psIonClient, psImportData->apsIonHandle[i]); } - ion_free(psImportData->psIonClient, psImportData->psIonHandle); + + kfree(psImportData->psSysPhysAddr); kfree(psImportData); } -#endif + +#endif /* defined(SUPPORT_ION) */ diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/ion.h b/drivers/gpu/pvr/services4/srvkm/env/linux/ion.h index 1cf385dfd8e..042d3c4c49c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/ion.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/ion.h @@ -42,33 +42,28 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __IMG_LINUX_ION_H__ #define __IMG_LINUX_ION_H__ +#if defined(SUPPORT_ION) + #include <linux/ion.h> -#if defined (CONFIG_ION_OMAP) -#include <linux/omap_ion.h> -#endif -#if defined (SUPPORT_ION) + #include "img_types.h" #include "servicesext.h" -#endif - -int PVRSRVExportFDToIONHandles(int fd, struct ion_client **client, - struct ion_handle **handles, - unsigned int *num_handles); - -struct ion_handle *PVRSRVExportFDToIONHandle(int fd, - struct ion_client **client); -#if defined (SUPPORT_ION) PVRSRV_ERROR IonInit(IMG_VOID); + IMG_VOID IonDeinit(IMG_VOID); -PVRSRV_ERROR IonImportBufferAndAquirePhysAddr(IMG_HANDLE hIonDev, - IMG_HANDLE hIonFD, - IMG_UINT32 *pui32PageCount, - IMG_SYS_PHYADDR **ppasSysPhysAddr, - IMG_PVOID *ppvKernAddr, - IMG_HANDLE *phPriv); +PVRSRV_ERROR IonImportBufferAndAcquirePhysAddr(IMG_HANDLE hIonDev, + IMG_UINT32 ui32NumFDs, + IMG_INT32 *pi32BufferFDs, + IMG_UINT32 *pui32PageCount, + IMG_SYS_PHYADDR **ppsSysPhysAddr, + IMG_PVOID *ppvKernAddr0, + IMG_HANDLE *phPriv, + IMG_HANDLE *phUnique); IMG_VOID IonUnimportBufferAndReleasePhysAddr(IMG_HANDLE hPriv); -#endif + +#endif /* defined(SUPPORT_ION) */ + #endif /* __IMG_LINUX_ION_H__ */ diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/linkage.h b/drivers/gpu/pvr/services4/srvkm/env/linux/linkage.h index 55cd4f08436..55cd4f08436 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/linkage.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/linkage.h diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/lock.h b/drivers/gpu/pvr/services4/srvkm/env/linux/lock.h index 11adcaaf21a..11adcaaf21a 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/lock.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/lock.h diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c b/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c index 0815e464597..c5a9b9b0bf6 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mm.c @@ -89,12 +89,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lists.h" #endif -/* If there is no explicit definition - * for the minimum DMM alignment size, - * then set it to "0" and let ION/DMM - * set the minimum value. */ -#ifndef CONFIG_TILER_GRANULARITY -#define CONFIG_TILER_GRANULARITY 0 +/* Decide whether or not DevMem allocs need __GFP_DMA32 */ +#ifndef SGX_FEATURE_36BIT_MMU +# ifdef CONFIG_ZONE_DMA32 +# if defined CONFIG_X86_PAE || defined CONFIG_ARM_LPAE || defined CONFIG_64BIT +# define PVR_USE_DMA32_FOR_DEVMEM_ALLOCS +# endif +# endif #endif /* @@ -106,7 +107,7 @@ static atomic_t g_sPagePoolEntryCount = ATOMIC_INIT(0); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) typedef enum { - DEBUG_MEM_ALLOC_TYPE_KMALLOC, + DEBUG_MEM_ALLOC_TYPE_KMALLOC = 0, DEBUG_MEM_ALLOC_TYPE_VMALLOC, DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, DEBUG_MEM_ALLOC_TYPE_IOREMAP, @@ -122,11 +123,11 @@ typedef enum { typedef struct _DEBUG_MEM_ALLOC_REC { DEBUG_MEM_ALLOC_TYPE eAllocType; - IMG_VOID *pvKey; /* Some unique value (private to the eAllocType) */ + IMG_UINTPTR_T uiKey; /* Some unique value (private to the eAllocType) */ IMG_VOID *pvCpuVAddr; - IMG_UINT32 ulCpuPAddr; + IMG_CPU_PHYADDR sCpuPAddr; IMG_VOID *pvPrivateData; - IMG_UINT32 ui32Bytes; + IMG_SIZE_T uiBytes; pid_t pid; IMG_CHAR *pszFileName; IMG_UINT32 ui32Line; @@ -162,20 +163,20 @@ static IMG_UINT32 g_IOMemWaterMark; static IMG_UINT32 g_IOMemHighWaterMark; static IMG_VOID DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType, - IMG_VOID *pvKey, + IMG_UINTPTR_T uiKey, IMG_VOID *pvCpuVAddr, - IMG_UINT32 ulCpuPAddr, + IMG_CPU_PHYADDR sCpuPAddr, IMG_VOID *pvPrivateData, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); -static IMG_VOID DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_VOID *pvKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); +static IMG_VOID DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_UINTPTR_T uiKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); static IMG_CHAR *DebugMemAllocRecordTypeToString(DEBUG_MEM_ALLOC_TYPE eAllocType); -static struct proc_dir_entry *g_SeqFileMemoryRecords; +static struct pvr_proc_dir_entry *g_SeqFileMemoryRecords; static void* ProcSeqNextMemoryRecords(struct seq_file *sfile,void* el,loff_t off); static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el); static void* ProcSeqOff2ElementMemoryRecords(struct seq_file * sfile, loff_t off); @@ -209,12 +210,11 @@ static IMG_UINT32 g_LinuxMemAreaWaterMark; static IMG_UINT32 g_LinuxMemAreaHighWaterMark; -static struct proc_dir_entry *g_SeqFileMemArea; +static struct pvr_proc_dir_entry *g_SeqFileMemArea; static void* ProcSeqNextMemArea(struct seq_file *sfile,void* el,loff_t off); static void ProcSeqShowMemArea(struct seq_file *sfile,void* el); static void* ProcSeqOff2ElementMemArea(struct seq_file *sfile, loff_t off); - #endif #if defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) @@ -240,8 +240,8 @@ static LIST_HEAD(g_sPagePoolList); static int g_iPagePoolMaxEntries; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) -static IMG_VOID ReservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length); -static IMG_VOID UnreservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length); +static IMG_VOID ReservePages(IMG_VOID *pvAddress, IMG_SIZE_T uiLength); +static IMG_VOID UnreservePages(IMG_VOID *pvAddress, IMG_SIZE_T uiLength); #endif static LinuxMemArea *LinuxMemAreaStructAlloc(IMG_VOID); @@ -266,19 +266,22 @@ CanFreeToPool(LinuxMemArea *psLinuxMemArea) } IMG_VOID * -_KMallocWrapper(IMG_UINT32 ui32ByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) +_KMallocWrapper(IMG_SIZE_T uiByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { IMG_VOID *pvRet; - pvRet = kmalloc(ui32ByteSize, uFlags); + pvRet = kmalloc(uiByteSize, uFlags); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) if (pvRet) { + IMG_CPU_PHYADDR sCpuPAddr; + sCpuPAddr.uiAddr = 0; + DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_KMALLOC, + (IMG_UINTPTR_T)pvRet, pvRet, - pvRet, - 0, + sCpuPAddr, NULL, - ui32ByteSize, + uiByteSize, pszFileName, ui32Line ); @@ -295,7 +298,11 @@ IMG_VOID _KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_KMALLOC, pvCpuVAddr, pszFileName, ui32Line); + DebugMemAllocRecordRemove( + DEBUG_MEM_ALLOC_TYPE_KMALLOC, + (IMG_UINTPTR_T)pvCpuVAddr, + pszFileName, + ui32Line); #else PVR_UNREFERENCED_PARAMETER(pszFileName); PVR_UNREFERENCED_PARAMETER(ui32Line); @@ -307,33 +314,33 @@ _KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) static IMG_VOID DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType, - IMG_VOID *pvKey, + IMG_UINTPTR_T uiKey, IMG_VOID *pvCpuVAddr, - IMG_UINT32 ulCpuPAddr, + IMG_CPU_PHYADDR sCpuPAddr, IMG_VOID *pvPrivateData, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { DEBUG_MEM_ALLOC_REC *psRecord; - LinuxLockMutex(&g_sDebugMutex); + LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); psRecord = kmalloc(sizeof(DEBUG_MEM_ALLOC_REC), GFP_KERNEL); psRecord->eAllocType = eAllocType; - psRecord->pvKey = pvKey; + psRecord->uiKey = uiKey; psRecord->pvCpuVAddr = pvCpuVAddr; - psRecord->ulCpuPAddr = ulCpuPAddr; + psRecord->sCpuPAddr.uiAddr = sCpuPAddr.uiAddr; psRecord->pvPrivateData = pvPrivateData; psRecord->pid = OSGetCurrentProcessIDKM(); - psRecord->ui32Bytes = ui32Bytes; + psRecord->uiBytes = uiBytes; psRecord->pszFileName = pszFileName; psRecord->ui32Line = ui32Line; List_DEBUG_MEM_ALLOC_REC_Insert(&g_MemoryRecords, psRecord); - g_WaterMarkData[eAllocType] += ui32Bytes; + g_WaterMarkData[eAllocType] += uiBytes; if (g_WaterMarkData[eAllocType] > g_HighWaterMarkData[eAllocType]) { g_HighWaterMarkData[eAllocType] = g_WaterMarkData[eAllocType]; @@ -344,20 +351,20 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType, || eAllocType == DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES || eAllocType == DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE) { - IMG_UINT32 ui32SysRAMTrueWaterMark; + IMG_SIZE_T uSysRAMTrueWaterMark; - g_SysRAMWaterMark += ui32Bytes; - ui32SysRAMTrueWaterMark = SysRAMTrueWaterMark(); + g_SysRAMWaterMark += uiBytes; + uSysRAMTrueWaterMark = SysRAMTrueWaterMark(); - if (ui32SysRAMTrueWaterMark > g_SysRAMHighWaterMark) + if (uSysRAMTrueWaterMark > g_SysRAMHighWaterMark) { - g_SysRAMHighWaterMark = ui32SysRAMTrueWaterMark; + g_SysRAMHighWaterMark = uSysRAMTrueWaterMark; } } else if (eAllocType == DEBUG_MEM_ALLOC_TYPE_IOREMAP || eAllocType == DEBUG_MEM_ALLOC_TYPE_IO) { - g_IOMemWaterMark += ui32Bytes; + g_IOMemWaterMark += uiBytes; if (g_IOMemWaterMark > g_IOMemHighWaterMark) { g_IOMemHighWaterMark = g_IOMemWaterMark; @@ -371,28 +378,28 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType, static IMG_BOOL DebugMemAllocRecordRemove_AnyVaCb(DEBUG_MEM_ALLOC_REC *psCurrentRecord, va_list va) { DEBUG_MEM_ALLOC_TYPE eAllocType; - IMG_VOID *pvKey; + IMG_UINTPTR_T uiKey; eAllocType = va_arg(va, DEBUG_MEM_ALLOC_TYPE); - pvKey = va_arg(va, IMG_VOID*); + uiKey = va_arg(va, IMG_UINTPTR_T); if (psCurrentRecord->eAllocType == eAllocType - && psCurrentRecord->pvKey == pvKey) + && psCurrentRecord->uiKey == uiKey) { eAllocType = psCurrentRecord->eAllocType; - g_WaterMarkData[eAllocType] -= psCurrentRecord->ui32Bytes; + g_WaterMarkData[eAllocType] -= psCurrentRecord->uiBytes; if (eAllocType == DEBUG_MEM_ALLOC_TYPE_KMALLOC || eAllocType == DEBUG_MEM_ALLOC_TYPE_VMALLOC || eAllocType == DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES || eAllocType == DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE) { - g_SysRAMWaterMark -= psCurrentRecord->ui32Bytes; + g_SysRAMWaterMark -= psCurrentRecord->uiBytes; } else if (eAllocType == DEBUG_MEM_ALLOC_TYPE_IOREMAP || eAllocType == DEBUG_MEM_ALLOC_TYPE_IO) { - g_IOMemWaterMark -= psCurrentRecord->ui32Bytes; + g_IOMemWaterMark -= psCurrentRecord->uiBytes; } List_DEBUG_MEM_ALLOC_REC_Remove(psCurrentRecord); @@ -408,20 +415,20 @@ static IMG_BOOL DebugMemAllocRecordRemove_AnyVaCb(DEBUG_MEM_ALLOC_REC *psCurrent static IMG_VOID -DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_VOID *pvKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) +DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_UINTPTR_T uiKey, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { /* DEBUG_MEM_ALLOC_REC **ppsCurrentRecord;*/ - LinuxLockMutex(&g_sDebugMutex); + LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); /* Locate the corresponding allocation entry */ if (!List_DEBUG_MEM_ALLOC_REC_IMG_BOOL_Any_va(g_MemoryRecords, DebugMemAllocRecordRemove_AnyVaCb, eAllocType, - pvKey)) + uiKey)) { - PVR_DPF((PVR_DBG_ERROR, "%s: couldn't find an entry for type=%s with pvKey=%p (called from %s, line %d\n", - __FUNCTION__, DebugMemAllocRecordTypeToString(eAllocType), pvKey, + PVR_DPF((PVR_DBG_ERROR, "%s: couldn't find an entry for type=%s with uiKey=" UINTPTR_FMT " (called from %s, line %d\n", + __FUNCTION__, DebugMemAllocRecordTypeToString(eAllocType), uiKey, pszFileName, ui32Line)); } @@ -439,8 +446,9 @@ DebugMemAllocRecordTypeToString(DEBUG_MEM_ALLOC_TYPE eAllocType) "IOREMAP", "IO", "KMEM_CACHE_ALLOC", + "ION", #if defined(PVR_LINUX_MEM_AREA_USE_VMAP) - "VMAP" + "VMAP", #endif }; return apszDebugMemoryRecordTypes[eAllocType]; @@ -478,31 +486,43 @@ AllocFlagsToPGProt(pgprot_t *pPGProtFlags, IMG_UINT32 ui32AllocFlags) } IMG_VOID * -_VMallocWrapper(IMG_UINT32 ui32Bytes, +_VMallocWrapper(IMG_SIZE_T uiBytes, IMG_UINT32 ui32AllocFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { pgprot_t PGProtFlags; IMG_VOID *pvRet; + gfp_t gfp_mask; if (!AllocFlagsToPGProt(&PGProtFlags, ui32AllocFlags)) { return NULL; } + gfp_mask = GFP_KERNEL; + +#if defined(PVR_USE_DMA32_FOR_DEVMEM_ALLOCS) + gfp_mask |= __GFP_DMA32; +#else + gfp_mask |= __GFP_HIGHMEM; +#endif + /* Allocate virtually contiguous pages */ - pvRet = __vmalloc(ui32Bytes, GFP_KERNEL | __GFP_HIGHMEM, PGProtFlags); + pvRet = __vmalloc(uiBytes, gfp_mask, PGProtFlags); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) if (pvRet) { + IMG_CPU_PHYADDR sCpuPAddr; + sCpuPAddr.uiAddr = 0; + DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_VMALLOC, + (IMG_UINTPTR_T)pvRet, pvRet, - pvRet, - 0, + sCpuPAddr, NULL, - PAGE_ALIGN(ui32Bytes), + PAGE_ALIGN(uiBytes), pszFileName, ui32Line ); @@ -520,7 +540,11 @@ IMG_VOID _VFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_VMALLOC, pvCpuVAddr, pszFileName, ui32Line); + DebugMemAllocRecordRemove( + DEBUG_MEM_ALLOC_TYPE_VMALLOC, + (IMG_UINTPTR_T)pvCpuVAddr, + pszFileName, + ui32Line); #else PVR_UNREFERENCED_PARAMETER(pszFileName); PVR_UNREFERENCED_PARAMETER(ui32Line); @@ -546,10 +570,13 @@ _VMapWrapper(struct page **ppsPageList, IMG_UINT32 ui32NumPages, IMG_UINT32 ui32 #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) if (pvRet) { + IMG_CPU_PHYADDR sCpuPAddr; + sCpuPAddr.uiAddr = 0; + DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_VMAP, + (IMG_UINTPTR_T)pvRet, pvRet, - pvRet, - 0, + sCpuPAddr, NULL, PAGES_TO_BYTES(ui32NumPages), pszFileName, @@ -565,9 +592,9 @@ _VMapWrapper(struct page **ppsPageList, IMG_UINT32 ui32NumPages, IMG_UINT32 ui32 } #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -#define VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags) _VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags, __FILE__, __LINE__) +#define VMapWrapper(ppsPageList, uBytes, ui32AllocFlags) _VMapWrapper(ppsPageList, uBytes, ui32AllocFlags, __FILE__, __LINE__) #else -#define VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags) _VMapWrapper(ppsPageList, ui32Bytes, ui32AllocFlags, NULL, 0) +#define VMapWrapper(ppsPageList, uBytes, ui32AllocFlags) _VMapWrapper(ppsPageList, uBytes, ui32AllocFlags, NULL, 0) #endif @@ -575,7 +602,8 @@ static IMG_VOID _VUnmapWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_VMAP, pvCpuVAddr, pszFileName, ui32Line); + DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_VMAP, + (IMG_UINTPTR_T)pvCpuVAddr, pszFileName, ui32Line); #else PVR_UNREFERENCED_PARAMETER(pszFileName); PVR_UNREFERENCED_PARAMETER(ui32Line); @@ -596,7 +624,11 @@ IMG_VOID _KMemCacheFreeWrapper(LinuxKMemCache *psCache, IMG_VOID *pvObject, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE, pvObject, pszFileName, ui32Line); + DebugMemAllocRecordRemove( + DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE, + (IMG_UINTPTR_T)pvObject, + pszFileName, + ui32Line); #else PVR_UNREFERENCED_PARAMETER(pszFileName); PVR_UNREFERENCED_PARAMETER(ui32Line); @@ -634,13 +666,22 @@ static struct page * AllocPageFromLinux(void) { struct page *psPage; + gfp_t gfp_mask; - psPage = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, 0); - if (!psPage) - { - return NULL; + gfp_mask = GFP_KERNEL; - } +#if defined(PVR_USE_DMA32_FOR_DEVMEM_ALLOCS) + gfp_mask |= __GFP_DMA32; +#else + gfp_mask |= __GFP_HIGHMEM; +#endif + + psPage = alloc_pages(gfp_mask, 0); + if (!psPage) + { + return NULL; + + } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) /* Reserve those pages to allow them to be re-mapped to user space */ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)) @@ -812,7 +853,7 @@ FreePagePool(IMG_VOID) PagePoolLock(); #if (PVR_LINUX_MEM_AREA_POOL_MAX_PAGES != 0) - PVR_DPF((PVR_DBG_MESSAGE,"%s: Freeing %d pages from pool", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); + PVR_TRACE(("%s: Freeing %d pages from pool", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); #else PVR_ASSERT(atomic_read(&g_sPagePoolEntryCount) == 0); PVR_ASSERT(list_empty(&g_sPagePoolList)); @@ -848,8 +889,8 @@ ShrinkPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkContr { LinuxPagePoolEntry *psPagePoolEntry, *psTempPoolEntry; - PVR_DPF((PVR_DBG_MESSAGE,"%s: Number to scan: %ld", __FUNCTION__, uNumToScan)); - PVR_DPF((PVR_DBG_MESSAGE,"%s: Pages in pool before scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); + PVR_TRACE(("%s: Number to scan: %ld", __FUNCTION__, uNumToScan)); + PVR_TRACE(("%s: Pages in pool before scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); if (!PagePoolTrylock()) { @@ -877,7 +918,7 @@ ShrinkPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkContr PagePoolUnlock(); - PVR_DPF((PVR_DBG_MESSAGE,"%s: Pages in pool after scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); + PVR_TRACE(("%s: Pages in pool after scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); } return atomic_read(&g_sPagePoolEntryCount); @@ -893,6 +934,10 @@ AllocPages(IMG_UINT32 ui32AreaFlags, struct page ***pppsPageList, IMG_HANDLE *ph PVRSRV_ERROR eError; IMG_BOOL bFromPagePool = IMG_FALSE; +#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) + IMG_CPU_PHYADDR sCpuPAddr; +#endif + eError = OSAllocMem(0, sizeof(*ppsPageList) * ui32NumPages, (IMG_VOID **)&ppsPageList, &hBlockPageList, "Array of pages"); if (eError != PVRSRV_OK) @@ -915,10 +960,12 @@ AllocPages(IMG_UINT32 ui32AreaFlags, struct page ***pppsPageList, IMG_HANDLE *ph *phBlockPageList = hBlockPageList; #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) + sCpuPAddr.uiAddr = 0; + DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, - ppsPageList, - 0, + (IMG_UINTPTR_T)ppsPageList, 0, + sCpuPAddr, NULL, PAGES_TO_BYTES(ui32NumPages), "unknown", @@ -951,7 +998,11 @@ FreePages(IMG_BOOL bToPagePool, struct page **ppsPageList, IMG_HANDLE hBlockPage } #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, ppsPageList, __FILE__, __LINE__); + DebugMemAllocRecordRemove( + DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, + (IMG_UINTPTR_T)ppsPageList, + __FILE__, + __LINE__); #endif (IMG_VOID) OSFreeMem(0, sizeof(*ppsPageList) * ui32NumPages, ppsPageList, hBlockPageList); @@ -959,7 +1010,7 @@ FreePages(IMG_BOOL bToPagePool, struct page **ppsPageList, IMG_HANDLE hBlockPage LinuxMemArea * -NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) +NewVMallocLinuxMemArea(IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags) { LinuxMemArea *psLinuxMemArea = NULL; IMG_VOID *pvCpuVAddr; @@ -977,7 +1028,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) } #if defined(PVR_LINUX_MEM_AREA_USE_VMAP) - ui32NumPages = RANGE_TO_PAGES(ui32Bytes); + ui32NumPages = RANGE_TO_PAGES(uBytes); if (!AllocPages(ui32AreaFlags, &ppsPageList, &hBlockPageList, ui32NumPages, &bFromPagePool)) { @@ -986,7 +1037,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) pvCpuVAddr = VMapWrapper(ppsPageList, ui32NumPages, ui32AreaFlags); #else /* defined(PVR_LINUX_MEM_AREA_USE_VMAP) */ - pvCpuVAddr = VMallocWrapper(ui32Bytes, ui32AreaFlags); + pvCpuVAddr = VMallocWrapper(uBytes, ui32AreaFlags); if (!pvCpuVAddr) { goto failed; @@ -994,7 +1045,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) /* PG_reserved was deprecated in linux-2.6.15 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) /* Reserve those pages to allow them to be re-mapped to user space */ - ReservePages(pvCpuVAddr, ui32Bytes); + ReservePages(pvCpuVAddr, uBytes); #endif #endif /* defined(PVR_LINUX_MEM_AREA_USE_VMAP) */ @@ -1004,7 +1055,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) psLinuxMemArea->uData.sVmalloc.ppsPageList = ppsPageList; psLinuxMemArea->uData.sVmalloc.hBlockPageList = hBlockPageList; #endif - psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->uiByteSize = uBytes; psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); @@ -1029,7 +1080,7 @@ NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) */ if (AreaIsUncached(ui32AreaFlags) && !bFromPagePool) { - OSInvalidateCPUCacheRangeKM(psLinuxMemArea, 0, pvCpuVAddr, ui32Bytes); + OSInvalidateCPUCacheRangeKM(psLinuxMemArea, 0, pvCpuVAddr, uBytes); } return psLinuxMemArea; @@ -1074,7 +1125,7 @@ FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea) #if defined(PVR_LINUX_MEM_AREA_USE_VMAP) VUnmapWrapper(psLinuxMemArea->uData.sVmalloc.pvVmallocAddress); - ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->ui32ByteSize); + ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->uiByteSize); ppsPageList = psLinuxMemArea->uData.sVmalloc.ppsPageList; hBlockPageList = psLinuxMemArea->uData.sVmalloc.hBlockPageList; @@ -1083,7 +1134,7 @@ FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea) /* PG_reserved was deprecated in linux-2.6.15 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) UnreservePages(psLinuxMemArea->uData.sVmalloc.pvVmallocAddress, - psLinuxMemArea->ui32ByteSize); + psLinuxMemArea->uiByteSize); #endif VFreeWrapper(psLinuxMemArea->uData.sVmalloc.pvVmallocAddress); @@ -1097,10 +1148,10 @@ FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea) /* Reserve pages of memory in order that they're not automatically deallocated after the last user reference dies. */ static IMG_VOID -ReservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length) +ReservePages(IMG_VOID *pvAddress, IMG_SIZE_T uLength) { IMG_VOID *pvPage; - IMG_VOID *pvEnd = pvAddress + ui32Length; + IMG_VOID *pvEnd = pvAddress + uLength; for(pvPage = pvAddress; pvPage < pvEnd; pvPage += PAGE_SIZE) { @@ -1115,10 +1166,10 @@ ReservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length) /* Un-reserve pages of memory in order that they can be freed. */ static IMG_VOID -UnreservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length) +UnreservePages(IMG_VOID *pvAddress, IMG_SIZE_T uLength) { IMG_VOID *pvPage; - IMG_VOID *pvEnd = pvAddress + ui32Length; + IMG_VOID *pvEnd = pvAddress + uLength; for(pvPage = pvAddress; pvPage < pvEnd; pvPage += PAGE_SIZE) { @@ -1134,7 +1185,7 @@ UnreservePages(IMG_VOID *pvAddress, IMG_UINT32 ui32Length) IMG_VOID * _IORemapWrapper(IMG_CPU_PHYADDR BasePAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32MappingFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) @@ -1144,13 +1195,13 @@ _IORemapWrapper(IMG_CPU_PHYADDR BasePAddr, switch (ui32MappingFlags & PVRSRV_HAP_CACHETYPE_MASK) { case PVRSRV_HAP_CACHED: - pvIORemapCookie = (IMG_VOID *)IOREMAP(BasePAddr.uiAddr, ui32Bytes); + pvIORemapCookie = (IMG_VOID *)IOREMAP(BasePAddr.uiAddr, uBytes); break; case PVRSRV_HAP_WRITECOMBINE: - pvIORemapCookie = (IMG_VOID *)IOREMAP_WC(BasePAddr.uiAddr, ui32Bytes); + pvIORemapCookie = (IMG_VOID *)IOREMAP_WC(BasePAddr.uiAddr, uBytes); break; case PVRSRV_HAP_UNCACHED: - pvIORemapCookie = (IMG_VOID *)IOREMAP_UC(BasePAddr.uiAddr, ui32Bytes); + pvIORemapCookie = (IMG_VOID *)IOREMAP_UC(BasePAddr.uiAddr, uBytes); break; default: PVR_DPF((PVR_DBG_ERROR, "IORemapWrapper: unknown mapping flags")); @@ -1161,11 +1212,11 @@ _IORemapWrapper(IMG_CPU_PHYADDR BasePAddr, if (pvIORemapCookie) { DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_IOREMAP, + (IMG_UINTPTR_T)pvIORemapCookie, pvIORemapCookie, - pvIORemapCookie, - BasePAddr.uiAddr, + BasePAddr, NULL, - ui32Bytes, + uBytes, pszFileName, ui32Line ); @@ -1183,7 +1234,11 @@ IMG_VOID _IOUnmapWrapper(IMG_VOID *pvIORemapCookie, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IOREMAP, pvIORemapCookie, pszFileName, ui32Line); + DebugMemAllocRecordRemove( + DEBUG_MEM_ALLOC_TYPE_IOREMAP, + (IMG_UINTPTR_T)pvIORemapCookie, + pszFileName, + ui32Line); #else PVR_UNREFERENCED_PARAMETER(pszFileName); PVR_UNREFERENCED_PARAMETER(ui32Line); @@ -1194,7 +1249,7 @@ _IOUnmapWrapper(IMG_VOID *pvIORemapCookie, IMG_CHAR *pszFileName, IMG_UINT32 ui3 LinuxMemArea * NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags) { LinuxMemArea *psLinuxMemArea; @@ -1206,7 +1261,7 @@ NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, return NULL; } - pvIORemapCookie = IORemapWrapper(BasePAddr, ui32Bytes, ui32AreaFlags); + pvIORemapCookie = IORemapWrapper(BasePAddr, uBytes, ui32AreaFlags); if (!pvIORemapCookie) { LinuxMemAreaStructFree(psLinuxMemArea); @@ -1216,7 +1271,7 @@ NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, psLinuxMemArea->eAreaType = LINUX_MEM_AREA_IOREMAP; psLinuxMemArea->uData.sIORemap.pvIORemapCookie = pvIORemapCookie; psLinuxMemArea->uData.sIORemap.CPUPhysAddr = BasePAddr; - psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->uiByteSize = uBytes; psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); @@ -1255,11 +1310,11 @@ FreeIORemapLinuxMemArea(LinuxMemArea *psLinuxMemArea) * using memory wrapping, which ends up creating an external KV memory area. */ static IMG_BOOL -TreatExternalPagesAsContiguous(IMG_SYS_PHYADDR *psSysPhysAddr, IMG_UINT32 ui32Bytes, IMG_BOOL bPhysContig) +TreatExternalPagesAsContiguous(IMG_SYS_PHYADDR *psSysPhysAddr, IMG_SIZE_T uBytes, IMG_BOOL bPhysContig) { IMG_UINT32 ui32; IMG_UINT32 ui32AddrChk; - IMG_UINT32 ui32NumPages = RANGE_TO_PAGES(ui32Bytes); + IMG_UINT32 ui32NumPages = RANGE_TO_PAGES(uBytes); /* * If bPhysContig is IMG_TRUE, we must assume psSysPhysAddr points @@ -1296,7 +1351,7 @@ TreatExternalPagesAsContiguous(IMG_SYS_PHYADDR *psSysPhysAddr, IMG_UINT32 ui32By } #endif -LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_UINT32 ui32Bytes, IMG_BOOL bPhysContig, IMG_UINT32 ui32AreaFlags) +LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_SIZE_T uBytes, IMG_BOOL bPhysContig, IMG_UINT32 ui32AreaFlags) { LinuxMemArea *psLinuxMemArea; @@ -1310,7 +1365,7 @@ LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *p psLinuxMemArea->uData.sExternalKV.pvExternalKV = pvCPUVAddr; psLinuxMemArea->uData.sExternalKV.bPhysContig = #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) - (bPhysContig || TreatExternalPagesAsContiguous(pBasePAddr, ui32Bytes, bPhysContig)) + (bPhysContig || TreatExternalPagesAsContiguous(pBasePAddr, uBytes, bPhysContig)) ? IMG_TRUE : IMG_FALSE; #else bPhysContig; @@ -1323,7 +1378,7 @@ LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *p { psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr = pBasePAddr; } - psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->uiByteSize = uBytes; psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); @@ -1350,7 +1405,7 @@ FreeExternalKVLinuxMemArea(LinuxMemArea *psLinuxMemArea) LinuxMemArea * NewIOLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags) { LinuxMemArea *psLinuxMemArea = LinuxMemAreaStructAlloc(); @@ -1362,17 +1417,17 @@ NewIOLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, /* Nothing to activly do. We just keep a record of the physical range. */ psLinuxMemArea->eAreaType = LINUX_MEM_AREA_IO; psLinuxMemArea->uData.sIO.CPUPhysAddr.uiAddr = BasePAddr.uiAddr; - psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->uiByteSize = uBytes; psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_IO, - (IMG_VOID *)BasePAddr.uiAddr, - 0, BasePAddr.uiAddr, + 0, + BasePAddr, NULL, - ui32Bytes, + uBytes, "unknown", 0 ); @@ -1397,7 +1452,9 @@ FreeIOLinuxMemArea(LinuxMemArea *psLinuxMemArea) #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IO, - (IMG_VOID *)psLinuxMemArea->uData.sIO.CPUPhysAddr.uiAddr, __FILE__, __LINE__); + psLinuxMemArea->uData.sIO.CPUPhysAddr.uiAddr, + __FILE__, + __LINE__); #endif /* Nothing more to do than free the LinuxMemArea struct */ @@ -1407,7 +1464,7 @@ FreeIOLinuxMemArea(LinuxMemArea *psLinuxMemArea) LinuxMemArea * -NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) +NewAllocPagesLinuxMemArea(IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags) { LinuxMemArea *psLinuxMemArea; IMG_UINT32 ui32NumPages; @@ -1421,7 +1478,7 @@ NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) goto failed_area_alloc; } - ui32NumPages = RANGE_TO_PAGES(ui32Bytes); + ui32NumPages = RANGE_TO_PAGES(uBytes); if (!AllocPages(ui32AreaFlags, &ppsPageList, &hBlockPageList, ui32NumPages, &bFromPagePool)) { @@ -1431,7 +1488,7 @@ NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags) psLinuxMemArea->eAreaType = LINUX_MEM_AREA_ALLOC_PAGES; psLinuxMemArea->uData.sPageList.ppsPageList = ppsPageList; psLinuxMemArea->uData.sPageList.hBlockPageList = hBlockPageList; - psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->uiByteSize = uBytes; psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); @@ -1467,7 +1524,7 @@ FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea) DebugLinuxMemAreaRecordRemove(psLinuxMemArea); #endif - ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->ui32ByteSize); + ui32NumPages = RANGE_TO_PAGES(psLinuxMemArea->uiByteSize); ppsPageList = psLinuxMemArea->uData.sPageList.ppsPageList; hBlockPageList = psLinuxMemArea->uData.sPageList.hBlockPageList; @@ -1476,315 +1533,29 @@ FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea) LinuxMemAreaStructFree(psLinuxMemArea); } -#if defined(CONFIG_ION_OMAP) - -#include "env_perproc.h" - -#include <linux/ion.h> -#include <linux/omap_ion.h> -#include <linux/scatterlist.h> - -extern struct ion_client *gpsIONClient; - -LinuxMemArea * -NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags, - IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength) -{ - const IMG_UINT32 ui32AllocDataLen = - offsetof(struct omap_ion_tiler_alloc_data, handle); - struct omap_ion_tiler_alloc_data asAllocData[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - u32 *pu32PageAddrs[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES] = { NULL, NULL, NULL}; - IMG_UINT32 i, j, ui32NumHandlesPerFd; - IMG_BYTE *pbPrivData = pvPrivData; - IMG_CPU_PHYADDR *pCPUPhysAddrs; - IMG_UINT32 iNumPages[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES] = { 0, 0, 0}; - LinuxMemArea *psLinuxMemArea; - IMG_UINT32 ui32ProcID; - IMG_UINT32 ui32TotalPagesSizeInBytes = 0, ui32TotalPages = 0; - - psLinuxMemArea = LinuxMemAreaStructAlloc(); - if (!psLinuxMemArea) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate LinuxMemArea struct", __func__)); - goto err_out; - } - - /* Depending on the UM config, userspace might give us info for - * one, two or three ION allocations. Divide the total size of data we - * were given by this ui32AllocDataLen, and check it's 1 or 2. - * Otherwise abort. - */ - BUG_ON(ui32PrivDataLength != ui32AllocDataLen && - ui32PrivDataLength != ui32AllocDataLen * 2 && - ui32PrivDataLength != ui32AllocDataLen * 3); - /* This is bad !- change this logic to pass in the size or - * use uniformed API */ - ui32NumHandlesPerFd = ui32PrivDataLength / ui32AllocDataLen; - - ui32ProcID = OSGetCurrentProcessIDKM(); - - memset(asAllocData, 0x00, sizeof(asAllocData)); - - /* We do not care about what the first (Y) buffer offset would be, - * but we do care for the UV buffers to be co-aligned with Y - * This for SGX to find the UV offset solely based on the height - * and stride of the YUV buffer.This is very important for OMAP4470 - * and later chipsets, where SGX version is 544. 544 and later use - * non-shader based YUV to RGB conversion unit that require - * contiguous GPU virtual space */ - for(i = 0; i < ui32NumHandlesPerFd; i++) - { - memcpy(&asAllocData[i], &pbPrivData[i * ui32AllocDataLen], ui32AllocDataLen); - asAllocData[i].token = ui32ProcID; - -#ifndef SGX_DISABLE_DMM_OFFSET_BUFFER_ALLOCATIONS - if(i == 0) - { - /* Tiler API says: - * Allocate first buffer with the required alignment - * and an offset of 0 ... */ - asAllocData[i].out_align = CONFIG_TILER_GRANULARITY; - asAllocData[i].offset = 0; - } - else - { /* .. Then for the second buffer, use the offset from the first - * buffer with alignment of PAGE_SIZE */ - asAllocData[i].out_align = PAGE_SIZE; - asAllocData[i].offset = asAllocData[0].offset; - } -#else - asAllocData[i].offset = 0; - asAllocData[i].out_align = PAGE_SIZE; -#endif - - if(asAllocData[i].fmt == TILER_PIXEL_FMT_PAGE) - { - /* 1D DMM Buffers */ - struct scatterlist *sg, *sglist; - IMG_UINT32 ui32Num1dPages; - - asAllocData[i].handle = ion_alloc (gpsIONClient, - ui32Bytes, - PAGE_SIZE, (1 << OMAP_ION_HEAP_SYSTEM)); - - if (asAllocData[i].handle == NULL) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate via ion_alloc", - __func__)); - goto err_free; - } - - sglist = ion_map_dma (gpsIONClient, asAllocData[i].handle); - if (sglist == NULL) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to compute pages", - __func__)); - goto err_free; - } - - ui32Num1dPages = (ui32Bytes >> PAGE_SHIFT); - pu32PageAddrs[i] = kmalloc (sizeof(u32) * ui32Num1dPages, GFP_KERNEL); - if (pu32PageAddrs[i] == NULL) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate page array", - __func__)); - goto err_free; - } - - for_each_sg (sglist, sg, ui32Num1dPages, j) - { - pu32PageAddrs[i][j] = sg_phys (sg); - } - - iNumPages[i] = ui32Num1dPages; - } - else /* 2D DMM Buffers */ - { - if (omap_ion_tiler_alloc(gpsIONClient, &asAllocData[i]) < 0) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate via ion_tiler", - __func__)); - goto err_free; - } - - if (omap_tiler_pages(gpsIONClient, asAllocData[i].handle, &iNumPages[i], - &pu32PageAddrs[i]) < 0) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to compute tiler pages", - __func__)); - goto err_free; - } - } - } - - /* Basic sanity check on plane co-alignment */ - if((ui32NumHandlesPerFd > 1) && - (asAllocData[0].offset != asAllocData[1].offset)) - { - pr_err("%s: Y and UV offsets do not match for tiler handles " - "%p,%p: %d != %d \n " - "Expect issues with SGX544xx and later chipsets\n", - __func__, asAllocData[0].handle, asAllocData[1].handle, - (int)asAllocData[0].offset, (int)asAllocData[1].offset); - } - - /* Assume the user-allocator has already done the tiler math and that the - * number of tiler pages allocated matches any other allocation type. - */ - for(i = 0; i < ui32NumHandlesPerFd; i++) - { - ui32TotalPages += iNumPages[i]; - } - - BUG_ON(ui32Bytes != (ui32TotalPages * PAGE_SIZE)); - BUG_ON(sizeof(IMG_CPU_PHYADDR) != sizeof(int)); - - /* Glue the page lists together */ - pCPUPhysAddrs = vmalloc(sizeof(IMG_CPU_PHYADDR) * ui32TotalPages); - if (!pCPUPhysAddrs) - { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate page list", __func__)); - goto err_free; - } - - j = 0; - for(i = 0; i < ui32NumHandlesPerFd; i++) - { - IMG_UINT32 ui32PageIndx; - for(ui32PageIndx = 0; ui32PageIndx < iNumPages[i]; ui32PageIndx++) - { - pCPUPhysAddrs[j++].uiAddr = pu32PageAddrs[i][ui32PageIndx]; - } - - psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i] = - asAllocData[i].handle; - psLinuxMemArea->uData.sIONTilerAlloc.planeOffsets[i] = - ui32TotalPagesSizeInBytes + asAllocData[i].offset; - /* Add the number of pages this plane consists of */ - ui32TotalPagesSizeInBytes += (iNumPages[i] * PAGE_SIZE); - } - - psLinuxMemArea->eAreaType = LINUX_MEM_AREA_ION; - psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs = pCPUPhysAddrs; - psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes = - ui32NumHandlesPerFd; - psLinuxMemArea->ui32ByteSize = ui32TotalPagesSizeInBytes; - psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; - INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); - - /* We defer the cache flush to the first user mapping of this memory */ - psLinuxMemArea->bNeedsCacheInvalidate = AreaIsUncached(ui32AreaFlags); - -#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_ION, - asAllocData[0].handle, - 0, - 0, - NULL, - PAGE_ALIGN(ui32Bytes), - "unknown", - 0 - ); -#endif - -#if defined(DEBUG_LINUX_MEM_AREAS) - DebugLinuxMemAreaRecordAdd(psLinuxMemArea, ui32AreaFlags); -#endif - -err_out: - return psLinuxMemArea; - -err_free: - LinuxMemAreaStructFree(psLinuxMemArea); - psLinuxMemArea = IMG_NULL; - goto err_out; -} - -IMG_INT32 -GetIONLinuxMemAreaInfo(LinuxMemArea *psLinuxMemArea, IMG_UINT32* pui32AddressOffsets, - IMG_UINT32* ui32NumAddrOffsets) -{ - IMG_UINT32 i; - - if(!ui32NumAddrOffsets) - return -1; - - if(*ui32NumAddrOffsets < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes) - { - *ui32NumAddrOffsets = psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; - return -1; - } - - if(!pui32AddressOffsets) - return -1; - - for(i = 0; i < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; i++) - { - if(psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i]) - pui32AddressOffsets[i] = - psLinuxMemArea->uData.sIONTilerAlloc.planeOffsets[i]; - } - - *ui32NumAddrOffsets = psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; - - return psLinuxMemArea->ui32ByteSize; -} - -IMG_VOID -FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea) -{ - IMG_UINT32 i; - -#if defined(DEBUG_LINUX_MEM_AREAS) - DebugLinuxMemAreaRecordRemove(psLinuxMemArea); -#endif - -#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ION, - psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[0], - __FILE__, __LINE__); -#endif - - for(i = 0; i < psLinuxMemArea->uData.sIONTilerAlloc.ui32NumValidPlanes; i++) - { - if (!psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i]) - break; - ion_free(gpsIONClient, psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i]); - psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle[i] = IMG_NULL; - } - - /* free copy of page list, originals are freed by ion_free */ - vfree(psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs); - psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs = IMG_NULL; - - LinuxMemAreaStructFree(psLinuxMemArea); -} - -#endif /* defined(CONFIG_ION_OMAP) */ - struct page* LinuxMemAreaOffsetToPage(LinuxMemArea *psLinuxMemArea, - IMG_UINT32 ui32ByteOffset) + IMG_UINTPTR_T uByteOffset) { - IMG_UINT32 ui32PageIndex; + IMG_UINTPTR_T uPageIndex; IMG_CHAR *pui8Addr; switch (psLinuxMemArea->eAreaType) { case LINUX_MEM_AREA_ALLOC_PAGES: - ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset); - return psLinuxMemArea->uData.sPageList.ppsPageList[ui32PageIndex]; + uPageIndex = PHYS_TO_PFN(uByteOffset); + return psLinuxMemArea->uData.sPageList.ppsPageList[uPageIndex]; case LINUX_MEM_AREA_VMALLOC: pui8Addr = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress; - pui8Addr += ui32ByteOffset; + pui8Addr += uByteOffset; return vmalloc_to_page(pui8Addr); case LINUX_MEM_AREA_SUB_ALLOC: /* PRQA S 3670 3 */ /* ignore recursive warning */ return LinuxMemAreaOffsetToPage(psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea, - psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset - + ui32ByteOffset); + psLinuxMemArea->uData.sSubAlloc.uiByteOffset + + uByteOffset); default: PVR_DPF((PVR_DBG_ERROR, "%s: Unsupported request for struct page from LinuxMemArea with type=%s", @@ -1829,14 +1600,19 @@ _KMemCacheAllocWrapper(LinuxKMemCache *psCache, IMG_UINT32 ui32Line) { IMG_VOID *pvRet; - + +#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) + IMG_CPU_PHYADDR sCpuPAddr; +#endif + pvRet = kmem_cache_zalloc(psCache, Flags); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) + sCpuPAddr.uiAddr = 0; DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE, + (IMG_UINTPTR_T)pvRet, pvRet, - pvRet, - 0, + sCpuPAddr, psCache, kmem_cache_size(psCache), pszFileName, @@ -1853,12 +1629,12 @@ _KMemCacheAllocWrapper(LinuxKMemCache *psCache, LinuxMemArea * NewSubLinuxMemArea(LinuxMemArea *psParentLinuxMemArea, - IMG_UINT32 ui32ByteOffset, - IMG_UINT32 ui32Bytes) + IMG_UINTPTR_T uiByteOffset, + IMG_SIZE_T uBytes) { LinuxMemArea *psLinuxMemArea; - PVR_ASSERT((ui32ByteOffset+ui32Bytes) <= psParentLinuxMemArea->ui32ByteSize); + PVR_ASSERT((uiByteOffset + uBytes) <= psParentLinuxMemArea->uiByteSize); psLinuxMemArea = LinuxMemAreaStructAlloc(); if (!psLinuxMemArea) @@ -1868,8 +1644,8 @@ NewSubLinuxMemArea(LinuxMemArea *psParentLinuxMemArea, psLinuxMemArea->eAreaType = LINUX_MEM_AREA_SUB_ALLOC; psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea = psParentLinuxMemArea; - psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset = ui32ByteOffset; - psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->uData.sSubAlloc.uiByteOffset = uiByteOffset; + psLinuxMemArea->uiByteSize = uBytes; psLinuxMemArea->ui32AreaFlags = psParentLinuxMemArea->ui32AreaFlags; psLinuxMemArea->bNeedsCacheInvalidate = psParentLinuxMemArea->bNeedsCacheInvalidate; INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); @@ -1949,9 +1725,6 @@ LinuxMemAreaDeepFree(LinuxMemArea *psLinuxMemArea) case LINUX_MEM_AREA_SUB_ALLOC: FreeSubLinuxMemArea(psLinuxMemArea); break; - case LINUX_MEM_AREA_ION: - FreeIONLinuxMemArea(psLinuxMemArea); - break; default: PVR_DPF((PVR_DBG_ERROR, "%s: Unknown are type (%d)\n", __FUNCTION__, psLinuxMemArea->eAreaType)); @@ -1967,11 +1740,11 @@ DebugLinuxMemAreaRecordAdd(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32Flags) DEBUG_LINUX_MEM_AREA_REC *psNewRecord; const IMG_CHAR *pi8FlagsString; - LinuxLockMutex(&g_sDebugMutex); + LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_SUB_ALLOC) { - g_LinuxMemAreaWaterMark += psLinuxMemArea->ui32ByteSize; + g_LinuxMemAreaWaterMark += psLinuxMemArea->uiByteSize; if (g_LinuxMemAreaWaterMark > g_LinuxMemAreaHighWaterMark) { g_LinuxMemAreaHighWaterMark = g_LinuxMemAreaWaterMark; @@ -2036,7 +1809,7 @@ DebugLinuxMemAreaRecordFind(LinuxMemArea *psLinuxMemArea) { DEBUG_LINUX_MEM_AREA_REC *psCurrentRecord; - LinuxLockMutex(&g_sDebugMutex); + LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); psCurrentRecord = List_DEBUG_LINUX_MEM_AREA_REC_Any_va(g_LinuxMemAreaRecords, MatchLinuxMemArea_AnyVaCb, psLinuxMemArea); @@ -2053,11 +1826,11 @@ DebugLinuxMemAreaRecordRemove(LinuxMemArea *psLinuxMemArea) { DEBUG_LINUX_MEM_AREA_REC *psCurrentRecord; - LinuxLockMutex(&g_sDebugMutex); + LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_SUB_ALLOC) { - g_LinuxMemAreaWaterMark -= psLinuxMemArea->ui32ByteSize; + g_LinuxMemAreaWaterMark -= psLinuxMemArea->uiByteSize; } g_LinuxMemAreaCount--; @@ -2101,7 +1874,7 @@ LinuxMemAreaToCpuVAddr(LinuxMemArea *psLinuxMemArea) { return NULL; } - return pAddr + psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset; + return pAddr + psLinuxMemArea->uData.sSubAlloc.uiByteOffset; } default: return NULL; @@ -2110,7 +1883,7 @@ LinuxMemAreaToCpuVAddr(LinuxMemArea *psLinuxMemArea) IMG_CPU_PHYADDR -LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset) +LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINTPTR_T uiByteOffset) { IMG_CPU_PHYADDR CpuPAddr; @@ -2121,7 +1894,7 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset) case LINUX_MEM_AREA_IOREMAP: { CpuPAddr = psLinuxMemArea->uData.sIORemap.CPUPhysAddr; - CpuPAddr.uiAddr += ui32ByteOffset; + CpuPAddr.uiAddr += uiByteOffset; break; } case LINUX_MEM_AREA_EXTERNAL_KV: @@ -2129,22 +1902,22 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset) if (psLinuxMemArea->uData.sExternalKV.bPhysContig) { CpuPAddr = SysSysPAddrToCpuPAddr(psLinuxMemArea->uData.sExternalKV.uPhysAddr.SysPhysAddr); - CpuPAddr.uiAddr += ui32ByteOffset; + CpuPAddr.uiAddr += uiByteOffset; } else { - IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset); - IMG_SYS_PHYADDR SysPAddr = psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr[ui32PageIndex]; + IMG_UINTPTR_T uiPageIndex = PHYS_TO_PFN(uiByteOffset); + IMG_SYS_PHYADDR SysPAddr = psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr[uiPageIndex]; CpuPAddr = SysSysPAddrToCpuPAddr(SysPAddr); - CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset); + CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(uiByteOffset); } break; } case LINUX_MEM_AREA_IO: { CpuPAddr = psLinuxMemArea->uData.sIO.CPUPhysAddr; - CpuPAddr.uiAddr += ui32ByteOffset; + CpuPAddr.uiAddr += uiByteOffset; break; } case LINUX_MEM_AREA_VMALLOC: @@ -2152,32 +1925,25 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset) IMG_CHAR *pCpuVAddr; pCpuVAddr = (IMG_CHAR *)psLinuxMemArea->uData.sVmalloc.pvVmallocAddress; - pCpuVAddr += ui32ByteOffset; + pCpuVAddr += uiByteOffset; CpuPAddr.uiAddr = VMallocToPhys(pCpuVAddr); break; } - case LINUX_MEM_AREA_ION: - { - IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset); - CpuPAddr = psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs[ui32PageIndex]; - CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset); - break; - } case LINUX_MEM_AREA_ALLOC_PAGES: { struct page *page; - IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset); - page = psLinuxMemArea->uData.sPageList.ppsPageList[ui32PageIndex]; + IMG_UINTPTR_T uiPageIndex = PHYS_TO_PFN(uiByteOffset); + page = psLinuxMemArea->uData.sPageList.ppsPageList[uiPageIndex]; CpuPAddr.uiAddr = page_to_phys(page); - CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset); + CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(uiByteOffset); break; } case LINUX_MEM_AREA_SUB_ALLOC: { CpuPAddr = OSMemHandleToCpuPAddr(psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea, - psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset - + ui32ByteOffset); + psLinuxMemArea->uData.sSubAlloc.uiByteOffset + + uiByteOffset); break; } default: @@ -2205,7 +1971,6 @@ LinuxMemAreaPhysIsContig(LinuxMemArea *psLinuxMemArea) case LINUX_MEM_AREA_EXTERNAL_KV: return psLinuxMemArea->uData.sExternalKV.bPhysContig; - case LINUX_MEM_AREA_ION: case LINUX_MEM_AREA_VMALLOC: case LINUX_MEM_AREA_ALLOC_PAGES: return IMG_FALSE; @@ -2243,8 +2008,6 @@ LinuxMemAreaTypeToString(LINUX_MEM_AREA_TYPE eMemAreaType) return "LINUX_MEM_AREA_SUB_ALLOC"; case LINUX_MEM_AREA_ALLOC_PAGES: return "LINUX_MEM_AREA_ALLOC_PAGES"; - case LINUX_MEM_AREA_ION: - return "LINUX_MEM_AREA_ION"; default: PVR_ASSERT(0); } @@ -2258,7 +2021,7 @@ static void ProcSeqStartstopDebugMutex(struct seq_file *sfile, IMG_BOOL start) { if (start) { - LinuxLockMutex(&g_sDebugMutex); + LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); } else { @@ -2350,14 +2113,14 @@ static void ProcSeqShowMemArea(struct seq_file *sfile,void* el) seq_printf(sfile, #if !defined(DEBUG_LINUX_XML_PROC_FILES) - "%8p %-24s %8p %08x %-8d %-5u %08x=(%s)\n", + "%p %-24s %p " CPUPADDR_FMT " %" SIZE_T_FMT_LEN "u %-5u %08x=(%s)\n", #else "<linux_mem_area>\n" - "\t<pointer>%8p</pointer>\n" + "\t<pointer>%p</pointer>\n" "\t<type>%s</type>\n" - "\t<cpu_virtual>%8p</cpu_virtual>\n" - "\t<cpu_physical>%08x</cpu_physical>\n" - "\t<bytes>%d</bytes>\n" + "\t<cpu_virtual>%p</cpu_virtual>\n" + "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n" + "\t<bytes>%" SIZE_T_FMT_LEN "d</bytes>\n" "\t<pid>%u</pid>\n" "\t<flags>%08x</flags>\n" "\t<flags_string>%s</flags_string>\n" @@ -2367,14 +2130,13 @@ static void ProcSeqShowMemArea(struct seq_file *sfile,void* el) LinuxMemAreaTypeToString(psRecord->psLinuxMemArea->eAreaType), LinuxMemAreaToCpuVAddr(psRecord->psLinuxMemArea), LinuxMemAreaToCpuPAddr(psRecord->psLinuxMemArea,0).uiAddr, - psRecord->psLinuxMemArea->ui32ByteSize, + psRecord->psLinuxMemArea->uiByteSize, psRecord->pid, psRecord->ui32Flags, HAPFlagsToString(psRecord->ui32Flags) ); } - #endif /* DEBUG_LINUX_MEM_AREAS */ @@ -2393,7 +2155,6 @@ static IMG_VOID* DecOffMemAllocRec_AnyVaCb(DEBUG_MEM_ALLOC_REC *psNode, va_list } } - /* seq_file version of generating output, for reference check proc.c:CreateProcReadEntrySeq */ static void* ProcSeqNextMemoryRecords(struct seq_file *sfile,void* el,loff_t off) { @@ -2598,13 +2359,13 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el) { seq_printf(sfile, #if !defined(DEBUG_LINUX_XML_PROC_FILES) - "%-16s %-8p %08x %-10d %-5d %-10s %s:%d\n", + "%-16s %p " CPUPADDR_FMT " %" SIZE_T_FMT_LEN "u %-5d %-10s %s:%d\n", #else "<allocation>\n" "\t<type>%s</type>\n" - "\t<cpu_virtual>%-8p</cpu_virtual>\n" - "\t<cpu_physical>%08x</cpu_physical>\n" - "\t<bytes>%d</bytes>\n" + "\t<cpu_virtual>%p</cpu_virtual>\n" + "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n" + "\t<bytes>%" SIZE_T_FMT_LEN "u</bytes>\n" "\t<pid>%d</pid>\n" "\t<private>%s</private>\n" "\t<filename>%s</filename>\n" @@ -2613,8 +2374,8 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el) #endif DebugMemAllocRecordTypeToString(psRecord->eAllocType), psRecord->pvCpuVAddr, - psRecord->ulCpuPAddr, - psRecord->ui32Bytes, + psRecord->sCpuPAddr.uiAddr, + psRecord->uiBytes, psRecord->pid, "NULL", psRecord->pszFileName, @@ -2624,13 +2385,13 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el) { seq_printf(sfile, #if !defined(DEBUG_LINUX_XML_PROC_FILES) - "%-16s %-8p %08x %-10d %-5d %-10s %s:%d\n", + "%-16s %p " CPUPADDR_FMT " %" SIZE_T_FMT_LEN "u %-5d %-10s %s:%d\n", #else "<allocation>\n" "\t<type>%s</type>\n" - "\t<cpu_virtual>%-8p</cpu_virtual>\n" - "\t<cpu_physical>%08x</cpu_physical>\n" - "\t<bytes>%d</bytes>\n" + "\t<cpu_virtual>%p</cpu_virtual>\n" + "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n" + "\t<bytes>%" SIZE_T_FMT_LEN "u</bytes>\n" "\t<pid>%d</pid>\n" "\t<private>%s</private>\n" "\t<filename>%s</filename>\n" @@ -2639,15 +2400,14 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el) #endif DebugMemAllocRecordTypeToString(psRecord->eAllocType), psRecord->pvCpuVAddr, - psRecord->ulCpuPAddr, - psRecord->ui32Bytes, + psRecord->sCpuPAddr.uiAddr, + psRecord->uiBytes, psRecord->pid, KMemCacheNameWrapper(psRecord->pvPrivateData), psRecord->pszFileName, psRecord->ui32Line); } } - #endif /* defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) */ @@ -2730,11 +2490,11 @@ static IMG_VOID LinuxMMCleanup_MemAreas_ForEachCb(DEBUG_LINUX_MEM_AREA_REC *psCu LinuxMemArea *psLinuxMemArea; psLinuxMemArea = psCurrentRecord->psLinuxMemArea; - PVR_DPF((PVR_DBG_ERROR, "%s: BUG!: Cleaning up Linux memory area (%p), type=%s, size=%d bytes", + PVR_DPF((PVR_DBG_ERROR, "%s: BUG!: Cleaning up Linux memory area (%p), type=%s, size=%"SIZE_T_FMT_LEN"d bytes", __FUNCTION__, psCurrentRecord->psLinuxMemArea, LinuxMemAreaTypeToString(psCurrentRecord->psLinuxMemArea->eAreaType), - psCurrentRecord->psLinuxMemArea->ui32ByteSize)); + psCurrentRecord->psLinuxMemArea->uiByteSize)); /* Note this will also remove psCurrentRecord from g_LinuxMemAreaRecords * but that's ok since we have already got a pointer to the next area. */ LinuxMemAreaDeepFree(psLinuxMemArea); @@ -2751,12 +2511,12 @@ static IMG_VOID LinuxMMCleanup_MemRecords_ForEachVa(DEBUG_MEM_ALLOC_REC *psCurre PVR_DPF((PVR_DBG_ERROR, "%s: BUG!: Cleaning up memory: " "type=%s " "CpuVAddr=%p " - "CpuPAddr=0x%08x, " + "CpuPAddr=0x" CPUPADDR_FMT ", " "allocated @ file=%s,line=%d", __FUNCTION__, DebugMemAllocRecordTypeToString(psCurrentRecord->eAllocType), psCurrentRecord->pvCpuVAddr, - psCurrentRecord->ulCpuPAddr, + psCurrentRecord->sCpuPAddr.uiAddr, psCurrentRecord->pszFileName, psCurrentRecord->ui32Line)); switch (psCurrentRecord->eAllocType) @@ -2769,13 +2529,13 @@ static IMG_VOID LinuxMMCleanup_MemRecords_ForEachVa(DEBUG_MEM_ALLOC_REC *psCurre break; case DEBUG_MEM_ALLOC_TYPE_IO: /* Nothing needed except to free the record */ - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IO, psCurrentRecord->pvKey, __FILE__, __LINE__); + DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_IO, psCurrentRecord->uiKey, __FILE__, __LINE__); break; case DEBUG_MEM_ALLOC_TYPE_VMALLOC: VFreeWrapper(psCurrentRecord->pvCpuVAddr); break; case DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES: - DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, psCurrentRecord->pvKey, __FILE__, __LINE__); + DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ALLOC_PAGES, psCurrentRecord->uiKey, __FILE__, __LINE__); break; case DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE: KMemCacheFreeWrapper(psCurrentRecord->pvPrivateData, psCurrentRecord->pvCpuVAddr); diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mm.h b/drivers/gpu/pvr/services4/srvkm/env/linux/mm.h index 6801df466e7..933420deb40 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mm.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mm.h @@ -88,7 +88,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #endif -static inline IMG_UINT32 VMallocToPhys(IMG_VOID *pCpuVAddr) +static inline IMG_UINTPTR_T VMallocToPhys(IMG_VOID *pCpuVAddr) { return (page_to_phys(vmalloc_to_page(pCpuVAddr)) + ADDR_TO_PAGE_OFFSET(pCpuVAddr)); @@ -101,7 +101,6 @@ typedef enum { LINUX_MEM_AREA_VMALLOC, LINUX_MEM_AREA_ALLOC_PAGES, LINUX_MEM_AREA_SUB_ALLOC, - LINUX_MEM_AREA_ION, #if defined(PVR_LINUX_MEM_AREA_USE_VMAP) LINUX_MEM_AREA_VMAP, #endif @@ -161,25 +160,16 @@ struct _LinuxMemArea { struct page **ppsPageList; IMG_HANDLE hBlockPageList; }sPageList; - struct _sIONTilerAlloc - { - /* Note the memory this represents _is_ implicitly - * page aligned _and_ so is its size */ - IMG_CPU_PHYADDR *pCPUPhysAddrs; - IMG_UINT32 ui32NumValidPlanes; - struct ion_handle *psIONHandle[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_UINT32 planeOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - }sIONTilerAlloc; struct _sSubAlloc { /* Note: The memory this represents is _not_ implicitly * page aligned, neither is its size */ LinuxMemArea *psParentLinuxMemArea; - IMG_UINT32 ui32ByteOffset; + IMG_UINTPTR_T uiByteOffset; }sSubAlloc; }uData; - IMG_UINT32 ui32ByteSize; /* Size of memory area */ + IMG_SIZE_T uiByteSize; /* Size of memory area */ IMG_UINT32 ui32AreaFlags; /* Flags passed at creation time */ @@ -241,16 +231,16 @@ IMG_VOID LinuxMMCleanup(IMG_VOID); * They can also be used as more concise replacements for OSAllocMem * in Linux specific code. * - * @param ui32ByteSize + * @param uByteSize * * @return ******************************************************************************/ #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -#define KMallocWrapper(ui32ByteSize, uFlags) _KMallocWrapper(ui32ByteSize, uFlags, __FILE__, __LINE__) +#define KMallocWrapper(uByteSize, uFlags) _KMallocWrapper(uByteSize, uFlags, __FILE__, __LINE__) #else -#define KMallocWrapper(ui32ByteSize, uFlags) _KMallocWrapper(ui32ByteSize, uFlags, NULL, 0) +#define KMallocWrapper(uByteSize, uFlags) _KMallocWrapper(uByteSize, uFlags, NULL, 0) #endif -IMG_VOID *_KMallocWrapper(IMG_UINT32 ui32ByteSize, gfp_t uFlags, IMG_CHAR *szFileName, IMG_UINT32 ui32Line); +IMG_VOID *_KMallocWrapper(IMG_SIZE_T uByteSize, gfp_t uFlags, IMG_CHAR *szFileName, IMG_UINT32 ui32Line); /*! @@ -273,17 +263,17 @@ IMG_VOID _KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 u ******************************************************************************* * @brief * - * @param ui32Bytes + * @param uBytes * @param ui32AllocFlags * * @return ******************************************************************************/ #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -#define VMallocWrapper(ui32Bytes, ui32AllocFlags) _VMallocWrapper(ui32Bytes, ui32AllocFlags, __FILE__, __LINE__) +#define VMallocWrapper(uiBytes, ui32AllocFlags) _VMallocWrapper(uiBytes, ui32AllocFlags, __FILE__, __LINE__) #else -#define VMallocWrapper(ui32Bytes, ui32AllocFlags) _VMallocWrapper(ui32Bytes, ui32AllocFlags, NULL, 0) +#define VMallocWrapper(uiBytes, ui32AllocFlags) _VMallocWrapper(uiBytes, ui32AllocFlags, NULL, 0) #endif -IMG_VOID *_VMallocWrapper(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AllocFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); +IMG_VOID *_VMallocWrapper(IMG_SIZE_T uiBytes, IMG_UINT32 ui32AllocFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); /*! @@ -306,12 +296,12 @@ IMG_VOID _VFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 u ******************************************************************************* * @brief Allocates virtually contiguous pages * - * @param ui32Bytes number of bytes to reserve + * @param uBytes number of bytes to reserve * @param ui32AreaFlags Heap caching and mapping Flags * * @return Page-aligned address of virtual allocation or NULL on error ******************************************************************************/ -LinuxMemArea *NewVMallocLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags); +LinuxMemArea *NewVMallocLinuxMemArea(IMG_SIZE_T uBytes, IMG_UINT32 ui32AreaFlags); /*! @@ -329,20 +319,20 @@ IMG_VOID FreeVMallocLinuxMemArea(LinuxMemArea *psLinuxMemArea); * @brief Reserve physical IO memory and create a CPU virtual mapping for it * * @param BasePAddr - * @param ui32Bytes + * @param uiBytes * @param ui32MappingFlags * * @return ******************************************************************************/ #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -#define IORemapWrapper(BasePAddr, ui32Bytes, ui32MappingFlags) \ - _IORemapWrapper(BasePAddr, ui32Bytes, ui32MappingFlags, __FILE__, __LINE__) +#define IORemapWrapper(BasePAddr, uiBytes, ui32MappingFlags) \ + _IORemapWrapper(BasePAddr, uiBytes, ui32MappingFlags, __FILE__, __LINE__) #else -#define IORemapWrapper(BasePAddr, ui32Bytes, ui32MappingFlags) \ - _IORemapWrapper(BasePAddr, ui32Bytes, ui32MappingFlags, NULL, 0) +#define IORemapWrapper(BasePAddr, uiBytes, ui32MappingFlags) \ + _IORemapWrapper(BasePAddr, uiBytes, ui32MappingFlags, NULL, 0) #endif IMG_VOID *_IORemapWrapper(IMG_CPU_PHYADDR BasePAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); @@ -353,12 +343,12 @@ IMG_VOID *_IORemapWrapper(IMG_CPU_PHYADDR BasePAddr, * @brief Reserve physical IO memory and create a CPU virtual mapping for it * * @param BasePAddr - * @param ui32Bytes + * @param uiBytes * @param ui32AreaFlags Heap caching and mapping Flags * * @return ******************************************************************************/ -LinuxMemArea *NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags); +LinuxMemArea *NewIORemapLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T uiBytes, IMG_UINT32 ui32AreaFlags); /*! @@ -378,12 +368,12 @@ IMG_VOID FreeIORemapLinuxMemArea(LinuxMemArea *psLinuxMemArea); * @param pBasePAddr * @param pvCPUVAddr * @param bPhysContig - * @param ui32Bytes + * @param uBytes * @param ui32AreaFlags Heap caching and mapping Flags * * @return ******************************************************************************/ -LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_UINT32 ui32Bytes, IMG_BOOL bPhysContig, IMG_UINT32 ui32AreaFlags); +LinuxMemArea *NewExternalKVLinuxMemArea(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_SIZE_T uBytes, IMG_BOOL bPhysContig, IMG_UINT32 ui32AreaFlags); /*! @@ -420,11 +410,11 @@ IMG_VOID _IOUnmapWrapper(IMG_VOID *pvIORemapCookie, IMG_CHAR *pszFileName, IMG_U * @brief * * @param psLinuxMemArea - * @param ui32ByteOffset + * @param uByteOffset * * @return ******************************************************************************/ -struct page *LinuxMemAreaOffsetToPage(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset); +struct page *LinuxMemAreaOffsetToPage(LinuxMemArea *psLinuxMemArea, IMG_UINTPTR_T uByteOffset); /*! @@ -506,12 +496,12 @@ const IMG_CHAR *KMemCacheNameWrapper(LinuxKMemCache *psCache); * @brief * * @param BasePAddr - * @param ui32Bytes + * @param uiBytes * @param ui32AreaFlags Heap caching and mapping Flags * * @return ******************************************************************************/ -LinuxMemArea *NewIOLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags); +LinuxMemArea *NewIOLinuxMemArea(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T uiBytes, IMG_UINT32 ui32AreaFlags); /*! @@ -529,12 +519,12 @@ IMG_VOID FreeIOLinuxMemArea(LinuxMemArea *psLinuxMemArea); ******************************************************************************* * @brief * - * @param ui32Bytes + * @param uiBytes * @param ui32AreaFlags E.g Heap caching and mapping Flags * * @return ******************************************************************************/ -LinuxMemArea *NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags); +LinuxMemArea *NewAllocPagesLinuxMemArea(IMG_SIZE_T uiBytes, IMG_UINT32 ui32AreaFlags); /*! @@ -548,83 +538,19 @@ LinuxMemArea *NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32Are IMG_VOID FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea); -#if defined(CONFIG_ION_OMAP) - -/*! - ******************************************************************************* - * @brief - * - * @param ui32Bytes - * @param ui32AreaFlags E.g Heap caching and mapping Flags - * - * @return - ******************************************************************************/ -LinuxMemArea * -NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags, - IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength); - - -/*! - ******************************************************************************* - * @brief - * - * @param psLinuxMemArea - * - * @return - ******************************************************************************/ -IMG_VOID FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea); - -IMG_INT32 -GetIONLinuxMemAreaInfo(LinuxMemArea *psLinuxMemArea, IMG_UINT32* ui32AddressOffsets, - IMG_UINT32* ui32NumAddr); - -#else /* defined(CONFIG_ION_OMAP) */ - -static inline LinuxMemArea * -NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags, - IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength) -{ - PVR_UNREFERENCED_PARAMETER(ui32Bytes); - PVR_UNREFERENCED_PARAMETER(ui32AreaFlags); - PVR_UNREFERENCED_PARAMETER(pvPrivData); - PVR_UNREFERENCED_PARAMETER(ui32PrivDataLength); - BUG(); - return IMG_NULL; -} - -static inline IMG_VOID FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea) -{ - PVR_UNREFERENCED_PARAMETER(psLinuxMemArea); - BUG(); -} - -static inline IMG_INT32 -GetIONLinuxMemAreaInfo(LinuxMemArea *psLinuxMemArea, IMG_UINT32* ui32AddressOffsets, - IMG_UINT32* ui32NumAddr) -{ - PVR_UNREFERENCED_PARAMETER(psLinuxMemArea); - PVR_UNREFERENCED_PARAMETER(ui32AddressOffsets); - PVR_UNREFERENCED_PARAMETER(ui32NumAddr); - BUG(); - return -1; -} - -#endif /* defined(CONFIG_ION_OMAP) */ - - /*! ******************************************************************************* * @brief * * @param psParentLinuxMemArea - * @param ui32ByteOffset - * @param ui32Bytes + * @param uByteOffset + * @param uBytes * * @return ******************************************************************************/ LinuxMemArea *NewSubLinuxMemArea(LinuxMemArea *psParentLinuxMemArea, - IMG_UINT32 ui32ByteOffset, - IMG_UINT32 ui32Bytes); + IMG_UINTPTR_T uByteOffset, + IMG_SIZE_T uBytes); /*! @@ -668,14 +594,14 @@ IMG_VOID *LinuxMemAreaToCpuVAddr(LinuxMemArea *psLinuxMemArea); * @brief * * @param psLinuxMemArea - * @param ui32ByteOffset + * @param uByteOffset * * @return ******************************************************************************/ -IMG_CPU_PHYADDR LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset); +IMG_CPU_PHYADDR LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINTPTR_T uByteOffset); -#define LinuxMemAreaToCpuPFN(psLinuxMemArea, ui32ByteOffset) PHYS_TO_PFN(LinuxMemAreaToCpuPAddr(psLinuxMemArea, ui32ByteOffset).uiAddr) +#define LinuxMemAreaToCpuPFN(psLinuxMemArea, uByteOffset) PHYS_TO_PFN(LinuxMemAreaToCpuPAddr(psLinuxMemArea, uByteOffset).uiAddr) /*! ******************************************************************************* diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.c b/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.c index 3eb2cbad2bf..a0b821117ff 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.c @@ -69,6 +69,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <drm/drmP.h> #endif +#ifdef CONFIG_ARCH_OMAP5 +#ifdef CONFIG_DSSCOMP +#include <../drivers/staging/omapdrm/omap_dmm_tiler.h> +#endif +#endif + #include "services_headers.h" #include "pvrmmap.h" @@ -85,7 +91,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pvr_drm.h" #endif -#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) +#if !defined(PVR_SECURE_HANDLES) #error "The mmap code requires PVR_SECURE_HANDLES" #endif @@ -108,12 +114,12 @@ static LIST_HEAD(g_sMMapAreaList); static LIST_HEAD(g_sMMapOffsetStructList); #if defined(DEBUG_LINUX_MMAP_AREAS) static IMG_UINT32 g_ui32RegisteredAreas = 0; -static IMG_UINT32 g_ui32TotalByteSize = 0; +static IMG_SIZE_T g_uiTotalByteSize = 0; #endif #if defined(DEBUG_LINUX_MMAP_AREAS) -static struct proc_dir_entry *g_ProcMMap; +static struct pvr_proc_dir_entry *g_ProcMMap; #endif /* defined(DEBUG_LINUX_MMAP_AREAS) */ #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) @@ -201,14 +207,10 @@ MMapOffsetToHandle(IMG_UINT32 pfn) } #endif -static inline IMG_UINT32 -#if defined (SUPPORT_SID_INTERFACE) -HandleToMMapOffset(IMG_SID hHandle) -#else +static inline IMG_UINTPTR_T HandleToMMapOffset(IMG_HANDLE hHandle) -#endif { - IMG_UINT32 ulHandle = (IMG_UINT32)hHandle; + IMG_UINTPTR_T ulHandle = (IMG_UINTPTR_T)hHandle; #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) if (PFNIsSpecial(ulHandle)) @@ -255,7 +257,7 @@ GetCurrentThreadID(IMG_VOID) * mmap data. */ static PKV_OFFSET_STRUCT -CreateOffsetStruct(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32Offset, IMG_UINT32 ui32RealByteSize) +CreateOffsetStruct(LinuxMemArea *psLinuxMemArea, IMG_UINTPTR_T uiOffset, IMG_SIZE_T uiRealByteSize) { PKV_OFFSET_STRUCT psOffsetStruct; #if defined(DEBUG) || defined(DEBUG_LINUX_MMAP_AREAS) @@ -279,11 +281,11 @@ CreateOffsetStruct(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32Offset, IMG_UINT return IMG_NULL; } - psOffsetStruct->ui32MMapOffset = ui32Offset; + psOffsetStruct->uiMMapOffset = uiOffset; psOffsetStruct->psLinuxMemArea = psLinuxMemArea; - psOffsetStruct->ui32RealByteSize = ui32RealByteSize; + psOffsetStruct->uiRealByteSize = uiRealByteSize; /* * We store the TID in case two threads within a process @@ -327,7 +329,8 @@ DestroyOffsetStruct(PKV_OFFSET_STRUCT psOffsetStruct) #ifdef DEBUG PVR_DPF((PVR_DBG_MESSAGE, "%s: Table entry: " - "psLinuxMemArea=%p, CpuPAddr=0x%08X", __FUNCTION__, + "psLinuxMemArea=%p, CpuPAddr=0x" CPUPADDR_FMT, + __FUNCTION__, psOffsetStruct->psLinuxMemArea, CpuPAddr.uiAddr)); #endif @@ -349,18 +352,18 @@ DestroyOffsetStruct(PKV_OFFSET_STRUCT psOffsetStruct) */ static inline IMG_VOID DetermineUsersSizeAndByteOffset(LinuxMemArea *psLinuxMemArea, - IMG_UINT32 *pui32RealByteSize, - IMG_UINT32 *pui32ByteOffset) + IMG_SIZE_T *puiRealByteSize, + IMG_UINTPTR_T *puiByteOffset) { - IMG_UINT32 ui32PageAlignmentOffset; + IMG_UINTPTR_T uiPageAlignmentOffset; IMG_CPU_PHYADDR CpuPAddr; CpuPAddr = LinuxMemAreaToCpuPAddr(psLinuxMemArea, 0); - ui32PageAlignmentOffset = ADDR_TO_PAGE_OFFSET(CpuPAddr.uiAddr); + uiPageAlignmentOffset = ADDR_TO_PAGE_OFFSET(CpuPAddr.uiAddr); - *pui32ByteOffset = ui32PageAlignmentOffset; + *puiByteOffset = uiPageAlignmentOffset; - *pui32RealByteSize = PAGE_ALIGN(psLinuxMemArea->ui32ByteSize + ui32PageAlignmentOffset); + *puiRealByteSize = PAGE_ALIGN(psLinuxMemArea->uiByteSize + uiPageAlignmentOffset); } @@ -376,16 +379,16 @@ DetermineUsersSizeAndByteOffset(LinuxMemArea *psLinuxMemArea, @input psPerProc : Per-process data. @input hMHandle : Memory handle. - @input pui32MMapOffset : pointer to location for returned mmap offset. - @input pui32ByteOffset : pointer to location for returned byte offset. - @input pui32RealByteSize : pointer to location for returned real byte size. - @input pui32UserVaddr : pointer to location for returned user mode address. + @input puiMMapOffset : pointer to location for returned mmap offset. + @input puiByteOffset : pointer to location for returned byte offset. + @input puiRealByteSize : pointer to location for returned real byte size. + @input puiUserVaddr : pointer to location for returned user mode address. - @output pui32MMapOffset : points to mmap offset to be used in mmap2 sys call. - @output pui32ByteOffset : points to byte offset of start of memory + @output puiMMapOffset : points to mmap offset to be used in mmap2 sys call. + @output puiByteOffset : points to byte offset of start of memory within mapped area returned by mmap2. - @output pui32RealByteSize : points to size of area to be mapped. - @output pui32UserVAddr : points to user mode address of start of + @output puiRealByteSize : points to size of area to be mapped. + @output puiUserVAddr : points to user mode address of start of mapping, or 0 if it hasn't been mapped yet. @Return PVRSRV_ERROR : PVRSRV_OK, or error code. @@ -393,64 +396,43 @@ DetermineUsersSizeAndByteOffset(LinuxMemArea *psLinuxMemArea, ******************************************************************************/ PVRSRV_ERROR PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMHandle, -#else IMG_HANDLE hMHandle, -#endif - IMG_UINT32 *pui32MMapOffset, - IMG_UINT32 *pui32ByteOffset, - IMG_UINT32 *pui32RealByteSize, - IMG_UINT32 *pui32UserVAddr) + IMG_UINTPTR_T *puiMMapOffset, + IMG_UINTPTR_T *puiByteOffset, + IMG_SIZE_T *puiRealByteSize, + IMG_UINTPTR_T *puiUserVAddr) { LinuxMemArea *psLinuxMemArea; PKV_OFFSET_STRUCT psOffsetStruct; IMG_HANDLE hOSMemHandle; PVRSRV_ERROR eError; - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); PVR_ASSERT(PVRSRVGetMaxHandle(psPerProc->psHandleBase) <= MAX_MMAP_HANDLE); eError = PVRSRVLookupOSMemHandle(psPerProc->psHandleBase, &hOSMemHandle, hMHandle); if (eError != PVRSRV_OK) { -#if defined (SUPPORT_SID_INTERFACE) - PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %x failed", __FUNCTION__, hMHandle)); -#else PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %p failed", __FUNCTION__, hMHandle)); -#endif goto exit_unlock; } psLinuxMemArea = (LinuxMemArea *)hOSMemHandle; - if (psLinuxMemArea && (psLinuxMemArea->eAreaType == LINUX_MEM_AREA_ION)) - { - *pui32RealByteSize = psLinuxMemArea->ui32ByteSize; - *pui32ByteOffset = psLinuxMemArea->uData.sIONTilerAlloc.planeOffsets[0]; - /* The offsets for the subsequent planes must be co-aligned for user - * space mapping and sgx 544 and later. I.e. - * psLinuxMemArea->uData.sIONTilerAlloc.planeOffsets[n]; - */ - } - else - { - /* Sparse mappings have to ask the BM for the virtual size */ if (psLinuxMemArea->hBMHandle) { - *pui32RealByteSize = BM_GetVirtualSize(psLinuxMemArea->hBMHandle); - *pui32ByteOffset = 0; + *puiRealByteSize = BM_GetVirtualSize(psLinuxMemArea->hBMHandle); + *puiByteOffset = 0; } else { DetermineUsersSizeAndByteOffset(psLinuxMemArea, - pui32RealByteSize, - pui32ByteOffset); + puiRealByteSize, + puiByteOffset); } - } /* Check whether this memory area has already been mapped */ list_for_each_entry(psOffsetStruct, &psLinuxMemArea->sMMapOffsetStructList, sAreaItem) @@ -459,7 +441,7 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, { if (!psLinuxMemArea->hBMHandle) { - PVR_ASSERT(*pui32RealByteSize == psOffsetStruct->ui32RealByteSize); + PVR_ASSERT(*puiRealByteSize == psOffsetStruct->uiRealByteSize); } /* * User mode locking is required to stop two threads racing to @@ -469,8 +451,8 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, * Without locking, both threads may attempt the mmap, * and one of them will fail. */ - *pui32MMapOffset = psOffsetStruct->ui32MMapOffset; - *pui32UserVAddr = psOffsetStruct->ui32UserVAddr; + *puiMMapOffset = psOffsetStruct->uiMMapOffset; + *puiUserVAddr = psOffsetStruct->uiUserVAddr; PVRSRVOffsetStructIncRef(psOffsetStruct); eError = PVRSRV_OK; @@ -479,24 +461,24 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, } /* Memory area won't have been mapped yet */ - *pui32UserVAddr = 0; + *puiUserVAddr = 0; #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) if (LinuxMemAreaUsesPhysicalMap(psLinuxMemArea)) { - *pui32MMapOffset = LinuxMemAreaToCpuPFN(psLinuxMemArea, 0); - PVR_ASSERT(PFNIsPhysical(*pui32MMapOffset)); + *puiMMapOffset = LinuxMemAreaToCpuPFN(psLinuxMemArea, 0); + PVR_ASSERT(PFNIsPhysical(*puiMMapOffset)); } else #endif { - *pui32MMapOffset = HandleToMMapOffset(hMHandle); + *puiMMapOffset = HandleToMMapOffset(hMHandle); #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) - PVR_ASSERT(PFNIsSpecial(*pui32MMapOffset)); + PVR_ASSERT(PFNIsSpecial(*puiMMapOffset)); #endif } - psOffsetStruct = CreateOffsetStruct(psLinuxMemArea, *pui32MMapOffset, *pui32RealByteSize); + psOffsetStruct = CreateOffsetStruct(psLinuxMemArea, *puiMMapOffset, *puiRealByteSize); if (psOffsetStruct == IMG_NULL) { eError = PVRSRV_ERROR_OUT_OF_MEMORY; @@ -519,7 +501,7 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, is done in the mmap2() syscall, as it expects the pgoff argument to be in units of 4,096 bytes irrespective of page size */ - *pui32MMapOffset = *pui32MMapOffset << (PAGE_SHIFT - 12); + *puiMMapOffset = *puiMMapOffset << (PAGE_SHIFT - 12); exit_unlock: LinuxUnLockMutex(&g_sMMapMutex); @@ -540,26 +522,22 @@ exit_unlock: @input psPerProc : Per-process data. @input hMHandle : Memory handle. @input pbMUnmap : pointer to location for munmap flag. - @input pui32UserVAddr : pointer to location for user mode address of mapping. - @input pui32ByteSize : pointer to location for size of mapping. + @input puiUserVAddr : pointer to location for user mode address of mapping. + @input puiByteSize : pointer to location for size of mapping. @Output pbMUnmap : points to flag that indicates whether an munmap is required. - @output pui32UserVAddr : points to user mode address to munmap. + @output puiUserVAddr : points to user mode address to munmap. @Return PVRSRV_ERROR : PVRSRV_OK, or error code. ******************************************************************************/ PVRSRV_ERROR PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMHandle, -#else IMG_HANDLE hMHandle, -#endif IMG_BOOL *pbMUnmap, - IMG_UINT32 *pui32RealByteSize, - IMG_UINT32 *pui32UserVAddr) + IMG_SIZE_T *puiRealByteSize, + IMG_UINTPTR_T *puiUserVAddr) { LinuxMemArea *psLinuxMemArea; PKV_OFFSET_STRUCT psOffsetStruct; @@ -567,18 +545,14 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, PVRSRV_ERROR eError; IMG_UINT32 ui32PID = OSGetCurrentProcessIDKM(); - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); PVR_ASSERT(PVRSRVGetMaxHandle(psPerProc->psHandleBase) <= MAX_MMAP_HANDLE); eError = PVRSRVLookupOSMemHandle(psPerProc->psHandleBase, &hOSMemHandle, hMHandle); if (eError != PVRSRV_OK) { -#if defined (SUPPORT_SID_INTERFACE) - PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %x failed", __FUNCTION__, hMHandle)); -#else PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %p failed", __FUNCTION__, hMHandle)); -#endif goto exit_unlock; } @@ -599,10 +573,10 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, PVRSRVOffsetStructDecRef(psOffsetStruct); - *pbMUnmap = (IMG_BOOL)((psOffsetStruct->ui32RefCount == 0) && (psOffsetStruct->ui32UserVAddr != 0)); + *pbMUnmap = (IMG_BOOL)((psOffsetStruct->ui32RefCount == 0) && (psOffsetStruct->uiUserVAddr != 0)); - *pui32UserVAddr = (*pbMUnmap) ? psOffsetStruct->ui32UserVAddr : 0; - *pui32RealByteSize = (*pbMUnmap) ? psOffsetStruct->ui32RealByteSize : 0; + *puiUserVAddr = (*pbMUnmap) ? psOffsetStruct->uiUserVAddr : 0; + *puiRealByteSize = (*pbMUnmap) ? psOffsetStruct->uiRealByteSize : 0; eError = PVRSRV_OK; goto exit_unlock; @@ -610,11 +584,7 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, } /* MMap data not found */ -#if defined (SUPPORT_SID_INTERFACE) - PVR_DPF((PVR_DBG_ERROR, "%s: Mapping data not found for handle %x (memory area %p)", __FUNCTION__, hMHandle, psLinuxMemArea)); -#else PVR_DPF((PVR_DBG_ERROR, "%s: Mapping data not found for handle %p (memory area %p)", __FUNCTION__, hMHandle, psLinuxMemArea)); -#endif eError = PVRSRV_ERROR_MAPPING_NOT_FOUND; @@ -625,7 +595,7 @@ exit_unlock: } static inline PKV_OFFSET_STRUCT -FindOffsetStructByOffset(IMG_UINT32 ui32Offset, IMG_UINT32 ui32RealByteSize) +FindOffsetStructByOffset(IMG_UINTPTR_T uiOffset, IMG_SIZE_T uiRealByteSize) { PKV_OFFSET_STRUCT psOffsetStruct; #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) @@ -635,7 +605,7 @@ FindOffsetStructByOffset(IMG_UINT32 ui32Offset, IMG_UINT32 ui32RealByteSize) list_for_each_entry(psOffsetStruct, &g_sMMapOffsetStructList, sMMapItem) { - if (ui32Offset == psOffsetStruct->ui32MMapOffset && ui32RealByteSize == psOffsetStruct->ui32RealByteSize && psOffsetStruct->ui32PID == ui32PID) + if (uiOffset == psOffsetStruct->uiMMapOffset && uiRealByteSize == psOffsetStruct->uiRealByteSize && psOffsetStruct->ui32PID == ui32PID) { #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) /* @@ -643,7 +613,7 @@ FindOffsetStructByOffset(IMG_UINT32 ui32Offset, IMG_UINT32 ui32RealByteSize) * as different threads may be mapping different memory areas * with the same offset. */ - if (!PFNIsPhysical(ui32Offset) || psOffsetStruct->ui32TID == ui32TID) + if (!PFNIsPhysical(uiOffset) || psOffsetStruct->ui32TID == ui32TID) #endif { return psOffsetStruct; @@ -663,11 +633,11 @@ FindOffsetStructByOffset(IMG_UINT32 ui32Offset, IMG_UINT32 ui32RealByteSize) static IMG_BOOL DoMapToUser(LinuxMemArea *psLinuxMemArea, struct vm_area_struct* ps_vma, - IMG_UINT32 ui32ByteOffset) + IMG_UINTPTR_T uiByteOffset) { - IMG_UINT32 ui32ByteSize; + IMG_SIZE_T uiByteSize; - if ((psLinuxMemArea->hBMHandle) && (ui32ByteOffset != 0)) + if ((psLinuxMemArea->hBMHandle) && (uiByteOffset != 0)) { /* Partial mapping of sparse allocations should never happen */ return IMG_FALSE; @@ -677,15 +647,15 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, { return DoMapToUser(LinuxMemAreaRoot(psLinuxMemArea), /* PRQA S 3670 */ /* allow recursion */ ps_vma, - psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset + ui32ByteOffset); + psLinuxMemArea->uData.sSubAlloc.uiByteOffset + uiByteOffset); } /* * Note that ui32ByteSize may be larger than the size of the memory * area being mapped, as the former is a multiple of the page size. */ - ui32ByteSize = ps_vma->vm_end - ps_vma->vm_start; - PVR_ASSERT(ADDR_TO_PAGE_OFFSET(ui32ByteSize) == 0); + uiByteSize = ps_vma->vm_end - ps_vma->vm_start; + PVR_ASSERT(ADDR_TO_PAGE_OFFSET(uiByteSize) == 0); #if defined (__sparc__) /* @@ -700,10 +670,10 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) if (PFNIsPhysical(ps_vma->vm_pgoff)) { - IMG_INT result; + IMG_INT result; - PVR_ASSERT(LinuxMemAreaPhysIsContig(psLinuxMemArea)); - PVR_ASSERT(LinuxMemAreaToCpuPFN(psLinuxMemArea, ui32ByteOffset) == ps_vma->vm_pgoff); + PVR_ASSERT(LinuxMemAreaPhysIsContig(psLinuxMemArea)); + PVR_ASSERT(LinuxMemAreaToCpuPFN(psLinuxMemArea, uiByteOffset) == ps_vma->vm_pgoff); /* * Since the memory is contiguous, we can map the whole range in one * go . @@ -711,7 +681,7 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, PVR_ASSERT(psLinuxMemArea->hBMHandle == IMG_NULL); - result = IO_REMAP_PFN_RANGE(ps_vma, ps_vma->vm_start, ps_vma->vm_pgoff, ui32ByteSize, ps_vma->vm_page_prot); + result = IO_REMAP_PFN_RANGE(ps_vma, ps_vma->vm_start, ps_vma->vm_pgoff, uiByteSize, ps_vma->vm_page_prot); if(result == 0) { @@ -723,7 +693,7 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, #endif { - /* + /* * Memory may be non-contiguous, so we map the range page, * by page. Since VM_PFNMAP mappings are assumed to be physically * contiguous, we can't legally use REMAP_PFN_RANGE (that is, we @@ -733,22 +703,22 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, * finding the page structure corresponding to each page, or * if mixed maps are supported (VM_MIXEDMAP), vm_insert_mixed. */ - IMG_UINT32 ulVMAPos; - IMG_UINT32 ui32ByteEnd = ui32ByteOffset + ui32ByteSize; - IMG_UINT32 ui32PA; - IMG_UINT32 ui32AdjustedPA = ui32ByteOffset; + IMG_UINTPTR_T ulVMAPos; + IMG_UINTPTR_T uiByteEnd = uiByteOffset + uiByteSize; + IMG_UINTPTR_T uiPA; + IMG_UINTPTR_T uiAdjustedPA = uiByteOffset; #if defined(PVR_MAKE_ALL_PFNS_SPECIAL) - IMG_BOOL bMixedMap = IMG_FALSE; + IMG_BOOL bMixedMap = IMG_FALSE; #endif /* First pass, validate the page frame numbers */ - for(ui32PA = ui32ByteOffset; ui32PA < ui32ByteEnd; ui32PA += PAGE_SIZE) + for(uiPA = uiByteOffset; uiPA < uiByteEnd; uiPA += PAGE_SIZE) { - IMG_UINT32 pfn; + IMG_UINTPTR_T pfn; IMG_BOOL bMapPage = IMG_TRUE; if (psLinuxMemArea->hBMHandle) { - if (!BM_MapPageAtOffset(psLinuxMemArea->hBMHandle, ui32PA)) + if (!BM_MapPageAtOffset(psLinuxMemArea->hBMHandle, uiPA)) { bMapPage = IMG_FALSE; } @@ -756,39 +726,45 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, if (bMapPage) { - pfn = LinuxMemAreaToCpuPFN(psLinuxMemArea, ui32AdjustedPA); + pfn = LinuxMemAreaToCpuPFN(psLinuxMemArea, uiAdjustedPA); if (!pfn_valid(pfn)) { #if !defined(PVR_MAKE_ALL_PFNS_SPECIAL) - PVR_DPF((PVR_DBG_ERROR,"%s: Error - PFN invalid: 0x%x", __FUNCTION__, pfn)); + PVR_DPF((PVR_DBG_ERROR,"%s: Error - PFN invalid: 0x" UINTPTR_FMT, __FUNCTION__, pfn)); return IMG_FALSE; #else bMixedMap = IMG_TRUE; #endif } - ui32AdjustedPA += PAGE_SIZE; + else if (0 == page_count(pfn_to_page(pfn))) + { +#if defined(PVR_MAKE_ALL_PFNS_SPECIAL) + bMixedMap = IMG_TRUE; +#endif + } + uiAdjustedPA += PAGE_SIZE; } } #if defined(PVR_MAKE_ALL_PFNS_SPECIAL) - if (bMixedMap) - { - ps_vma->vm_flags |= VM_MIXEDMAP; - } + if (bMixedMap) + { + ps_vma->vm_flags |= VM_MIXEDMAP; + } #endif /* Second pass, get the page structures and insert the pages */ ulVMAPos = ps_vma->vm_start; - ui32AdjustedPA = ui32ByteOffset; - for(ui32PA = ui32ByteOffset; ui32PA < ui32ByteEnd; ui32PA += PAGE_SIZE) + uiAdjustedPA = uiByteOffset; + for(uiPA = uiByteOffset; uiPA < uiByteEnd; uiPA += PAGE_SIZE) { - IMG_UINT32 pfn; + IMG_UINTPTR_T pfn; IMG_INT result; IMG_BOOL bMapPage = IMG_TRUE; if (psLinuxMemArea->hBMHandle) { /* We have a sparse allocation, check if this page should be mapped */ - if (!BM_MapPageAtOffset(psLinuxMemArea->hBMHandle, ui32PA)) + if (!BM_MapPageAtOffset(psLinuxMemArea->hBMHandle, uiPA)) { bMapPage = IMG_FALSE; } @@ -796,7 +772,7 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, if (bMapPage) { - pfn = LinuxMemAreaToCpuPFN(psLinuxMemArea, ui32AdjustedPA); + pfn = LinuxMemAreaToCpuPFN(psLinuxMemArea, uiAdjustedPA); #if defined(PVR_MAKE_ALL_PFNS_SPECIAL) if (bMixedMap) @@ -811,7 +787,7 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, else #endif { - struct page *psPage; + struct page *psPage; PVR_ASSERT(pfn_valid(pfn)); @@ -824,11 +800,11 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea, return IMG_FALSE; } } - ui32AdjustedPA += PAGE_SIZE; + uiAdjustedPA += PAGE_SIZE; + } + ulVMAPos += PAGE_SIZE; } - ulVMAPos += PAGE_SIZE; - } - } + } return IMG_TRUE; } @@ -853,11 +829,11 @@ MMapVOpenNoLock(struct vm_area_struct* ps_vma) #if defined(DEBUG_LINUX_MMAP_AREAS) PVR_DPF((PVR_DBG_MESSAGE, - "%s: psLinuxMemArea 0x%p, KVAddress 0x%p MMapOffset %d, ui32Mapped %d", + "%s: psLinuxMemArea 0x%p, KVAddress 0x%p MMapOffset " UINTPTR_FMT ", ui32Mapped %d", __FUNCTION__, psOffsetStruct->psLinuxMemArea, LinuxMemAreaToCpuVAddr(psOffsetStruct->psLinuxMemArea), - psOffsetStruct->ui32MMapOffset, + psOffsetStruct->uiMMapOffset, psOffsetStruct->ui32Mapped)); #endif } @@ -869,7 +845,7 @@ MMapVOpenNoLock(struct vm_area_struct* ps_vma) static void MMapVOpen(struct vm_area_struct* ps_vma) { - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); MMapVOpenNoLock(ps_vma); @@ -885,11 +861,11 @@ MMapVCloseNoLock(struct vm_area_struct* ps_vma) #if defined(DEBUG_LINUX_MMAP_AREAS) PVR_DPF((PVR_DBG_MESSAGE, - "%s: psLinuxMemArea %p, CpuVAddr %p ui32MMapOffset %d, ui32Mapped %d", + "%s: psLinuxMemArea %p, CpuVAddr %p uiMMapOffset " UINTPTR_FMT ", ui32Mapped %d", __FUNCTION__, psOffsetStruct->psLinuxMemArea, LinuxMemAreaToCpuVAddr(psOffsetStruct->psLinuxMemArea), - psOffsetStruct->ui32MMapOffset, + psOffsetStruct->uiMMapOffset, psOffsetStruct->ui32Mapped)); #endif @@ -899,7 +875,13 @@ MMapVCloseNoLock(struct vm_area_struct* ps_vma) { if (psOffsetStruct->ui32RefCount != 0) { - PVR_DPF((PVR_DBG_MESSAGE, "%s: psOffsetStruct %p has non-zero reference count (ui32RefCount = %u). User mode address of start of mapping: 0x%x", __FUNCTION__, psOffsetStruct, psOffsetStruct->ui32RefCount, psOffsetStruct->ui32UserVAddr)); + PVR_DPF(( + PVR_DBG_MESSAGE, + "%s: psOffsetStruct %p has non-zero reference count (ui32RefCount = %u). User mode address of start of mapping: 0x" UINTPTR_FMT, + __FUNCTION__, + psOffsetStruct, + psOffsetStruct->ui32RefCount, + psOffsetStruct->uiUserVAddr)); } DestroyOffsetStruct(psOffsetStruct); @@ -914,7 +896,7 @@ MMapVCloseNoLock(struct vm_area_struct* ps_vma) static void MMapVClose(struct vm_area_struct* ps_vma) { - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); MMapVCloseNoLock(ps_vma); @@ -936,13 +918,13 @@ static int MMapVAccess(struct vm_area_struct *ps_vma, unsigned long addr, int iRetVal = -EINVAL; IMG_VOID *pvKernelAddr; - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); psOffsetStruct = (PKV_OFFSET_STRUCT)ps_vma->vm_private_data; psLinuxMemArea = psOffsetStruct->psLinuxMemArea; ulOffset = addr - ps_vma->vm_start; - if (ulOffset+len > psLinuxMemArea->ui32ByteSize) + if (ulOffset+len > psLinuxMemArea->uiByteSize) /* Out of range. We shouldn't get here, because the kernel will do the necessary checks before calling access_process_vm. */ goto exit_unlock; @@ -956,7 +938,7 @@ static int MMapVAccess(struct vm_area_struct *ps_vma, unsigned long addr, } else { - IMG_UINT32 pfn, ui32OffsetInPage; + IMG_UINTPTR_T pfn, uiOffsetInPage; struct page *page; pfn = LinuxMemAreaToCpuPFN(psLinuxMemArea, ulOffset); @@ -965,14 +947,14 @@ static int MMapVAccess(struct vm_area_struct *ps_vma, unsigned long addr, goto exit_unlock; page = pfn_to_page(pfn); - ui32OffsetInPage = ADDR_TO_PAGE_OFFSET(ulOffset); + uiOffsetInPage = ADDR_TO_PAGE_OFFSET(ulOffset); - if (ui32OffsetInPage+len > PAGE_SIZE) + if (uiOffsetInPage + len > PAGE_SIZE) /* The region crosses a page boundary */ goto exit_unlock; pvKernelAddr = kmap(page); - memcpy(buf, pvKernelAddr+ui32OffsetInPage, len); + memcpy(buf, pvKernelAddr + uiOffsetInPage, len); kunmap(page); iRetVal = len; @@ -1014,34 +996,35 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) { LinuxMemArea *psFlushMemArea = IMG_NULL; PKV_OFFSET_STRUCT psOffsetStruct; - IMG_UINT32 ui32ByteSize; + IMG_SIZE_T uiByteSize; IMG_VOID *pvBase = IMG_NULL; int iRetVal = 0; - IMG_UINT32 ui32ByteOffset = 0; /* Keep compiler happy */ - IMG_UINT32 ui32FlushSize = 0; + IMG_UINTPTR_T uiByteOffset = 0; /* Keep compiler happy */ + IMG_SIZE_T uiFlushSize = 0; PVR_UNREFERENCED_PARAMETER(pFile); - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); - ui32ByteSize = ps_vma->vm_end - ps_vma->vm_start; + uiByteSize = ps_vma->vm_end - ps_vma->vm_start; - PVR_DPF((PVR_DBG_MESSAGE, "%s: Received mmap(2) request with ui32MMapOffset 0x%08lx," - " and ui32ByteSize %d(0x%08x)", + PVR_DPF((PVR_DBG_MESSAGE, "%s: Received mmap(2) request with ui32MMapOffset 0x" UINTPTR_FMT "," + " and uiByteSize %" SIZE_T_FMT_LEN "u(0x%" SIZE_T_FMT_LEN "x)", __FUNCTION__, ps_vma->vm_pgoff, - ui32ByteSize, ui32ByteSize)); + uiByteSize, + uiByteSize)); - psOffsetStruct = FindOffsetStructByOffset(ps_vma->vm_pgoff, ui32ByteSize); + psOffsetStruct = FindOffsetStructByOffset(ps_vma->vm_pgoff, uiByteSize); if (psOffsetStruct == IMG_NULL) { #if defined(SUPPORT_DRI_DRM) - LinuxUnLockMutex(&g_sMMapMutex); + LinuxUnLockMutex(&g_sMMapMutex); #if !defined(SUPPORT_DRI_DRM_EXT) - /* Pass unknown requests onto the DRM module */ - return drm_mmap(pFile, ps_vma); + /* Pass unknown requests onto the DRM module */ + return drm_mmap(pFile, ps_vma); #else /* * Indicate to caller that the request is not for us. @@ -1078,9 +1061,10 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) __FUNCTION__, psOffsetStruct->psLinuxMemArea)); #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) + /* This is probably superfluous and implied by VM_IO */ ps_vma->vm_flags |= VM_RESERVED; #else - ps_vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; /* Don't swap */ + ps_vma->vm_flags |= VM_DONTDUMP; #endif ps_vma->vm_flags |= VM_IO; @@ -1112,16 +1096,22 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) goto unlock_and_return; } -#if defined(SGX544) && defined(SGX_FEATURE_MP) - /* In OMAP5, the A15 no longer masks an issue with the interconnect. - writecombined access to the Tiler 2D memory will encounter errors due to - interconect bus accesses. This will result in a SIGBUS error with a - "non-line fetch abort". The workaround is to use a shared device - access. */ - if (psOffsetStruct->psLinuxMemArea->eAreaType == LINUX_MEM_AREA_ION) - ps_vma->vm_page_prot = __pgprot_modify(ps_vma->vm_page_prot, - L_PTE_MT_MASK, L_PTE_MT_DEV_SHARED); -#endif +#ifdef CONFIG_ARCH_OMAP5 + { + IMG_BOOL bModPageProt = IMG_FALSE; + +#ifdef CONFIG_DSSCOMP + bModPageProt |= is_tiler_addr(LinuxMemAreaToCpuPAddr(psOffsetStruct->psLinuxMemArea, 0).uiAddr); +#endif /* CONFIG_DSSCOMP */ + + if (bModPageProt) + { + ps_vma->vm_page_prot = __pgprot_modify(ps_vma->vm_page_prot, + L_PTE_MT_MASK, + L_PTE_MT_DEV_SHARED); + } + } +#endif /* CONFIG_ARCH_OMAP5 */ /* Install open and close handlers for ref-counting */ ps_vma->vm_ops = &MMapIOOps; @@ -1132,13 +1122,9 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) goto unlock_and_return; } - PVR_ASSERT(psOffsetStruct->ui32UserVAddr == 0); - - psOffsetStruct->ui32UserVAddr = ps_vma->vm_start; + PVR_ASSERT(psOffsetStruct->uiUserVAddr == 0); - /* Invalidate for the ION memory is performed during the mapping */ - if(psOffsetStruct->psLinuxMemArea->eAreaType == LINUX_MEM_AREA_ION) - psOffsetStruct->psLinuxMemArea->bNeedsCacheInvalidate = IMG_FALSE; + psOffsetStruct->uiUserVAddr = ps_vma->vm_start; /* Compute the flush region (if necessary) inside the mmap mutex */ if(psOffsetStruct->psLinuxMemArea->bNeedsCacheInvalidate) @@ -1149,19 +1135,19 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) if (psFlushMemArea->hBMHandle) { pvBase = (IMG_VOID *)ps_vma->vm_start; - ui32ByteOffset = 0; - ui32FlushSize = BM_GetVirtualSize(psFlushMemArea->hBMHandle); + uiByteOffset = 0; + uiFlushSize = BM_GetVirtualSize(psFlushMemArea->hBMHandle); } else { - IMG_UINT32 ui32DummyByteSize; + IMG_SIZE_T uiDummyByteSize; DetermineUsersSizeAndByteOffset(psFlushMemArea, - &ui32DummyByteSize, - &ui32ByteOffset); + &uiDummyByteSize, + &uiByteOffset); - pvBase = (IMG_VOID *)ps_vma->vm_start + ui32ByteOffset; - ui32FlushSize = psFlushMemArea->ui32ByteSize; + pvBase = (IMG_VOID *)ps_vma->vm_start + uiByteOffset; + uiFlushSize = psFlushMemArea->uiByteSize; } psFlushMemArea->bNeedsCacheInvalidate = IMG_FALSE; @@ -1170,8 +1156,8 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) /* Call the open routine to increment the usage count */ MMapVOpenNoLock(ps_vma); - PVR_DPF((PVR_DBG_MESSAGE, "%s: Mapped area at offset 0x%08lx\n", - __FUNCTION__, ps_vma->vm_pgoff)); + PVR_DPF((PVR_DBG_MESSAGE, "%s: Mapped area at offset 0x" UINTPTR_FMT "\n", + __FUNCTION__, (IMG_UINTPTR_T)ps_vma->vm_pgoff)); unlock_and_return: if (iRetVal != 0 && psOffsetStruct != IMG_NULL) @@ -1183,8 +1169,8 @@ unlock_and_return: if(psFlushMemArea) { - OSInvalidateCPUCacheRangeKM(psFlushMemArea, ui32ByteOffset, pvBase, - ui32FlushSize); + OSInvalidateCPUCacheRangeKM(psFlushMemArea, uiByteOffset, pvBase, + uiFlushSize); } return iRetVal; @@ -1204,7 +1190,7 @@ static void ProcSeqStartstopMMapRegistations(struct seq_file *sfile,IMG_BOOL sta { if(start) { - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); } else { @@ -1262,7 +1248,6 @@ static void* ProcSeqNextMMapRegistrations(struct seq_file *sfile,void* el,loff_t return ProcSeqOff2ElementMMapRegistrations(sfile,off); } - /* * Show MMap element (called when reading /proc/mmap file) @@ -1274,15 +1259,15 @@ static void ProcSeqShowMMapRegistrations(struct seq_file *sfile, void *el) { KV_OFFSET_STRUCT *psOffsetStruct = (KV_OFFSET_STRUCT*)el; LinuxMemArea *psLinuxMemArea; - IMG_UINT32 ui32RealByteSize; - IMG_UINT32 ui32ByteOffset; + IMG_SIZE_T uiRealByteSize; + IMG_UINTPTR_T uiByteOffset; if(el == PVR_PROC_SEQ_START_TOKEN) { seq_printf( sfile, #if !defined(DEBUG_LINUX_XML_PROC_FILES) "Allocations registered for mmap: %u\n" - "In total these areas correspond to %u bytes\n" + "In total these areas correspond to %" SIZE_T_FMT_LEN "u bytes\n" "psLinuxMemArea " "UserVAddr " "KernelVAddr " @@ -1294,11 +1279,11 @@ static void ProcSeqShowMMapRegistrations(struct seq_file *sfile, void *el) #else "<mmap_header>\n" "\t<count>%u</count>\n" - "\t<bytes>%u</bytes>\n" + "\t<bytes>%" SIZE_T_FMT_LEN "u</bytes>\n" "</mmap_header>\n", #endif g_ui32RegisteredAreas, - g_ui32TotalByteSize + g_uiTotalByteSize ); return; } @@ -1306,20 +1291,20 @@ static void ProcSeqShowMMapRegistrations(struct seq_file *sfile, void *el) psLinuxMemArea = psOffsetStruct->psLinuxMemArea; DetermineUsersSizeAndByteOffset(psLinuxMemArea, - &ui32RealByteSize, - &ui32ByteOffset); + &uiRealByteSize, + &uiByteOffset); seq_printf( sfile, #if !defined(DEBUG_LINUX_XML_PROC_FILES) - "%-8p %08x %-8p %08x %08x %-8d %-24s %-5u %-8s %08x(%s)\n", + "%p %p %p " CPUPADDR_FMT " " UINTPTR_FMT " %" SIZE_T_FMT_LEN "u %-24s %-5u %-8s %08x(%s)\n", #else "<mmap_record>\n" - "\t<pointer>%-8p</pointer>\n" - "\t<user_virtual>%-8x</user_virtual>\n" - "\t<kernel_virtual>%-8p</kernel_virtual>\n" - "\t<cpu_physical>%08x</cpu_physical>\n" - "\t<mmap_offset>%08x</mmap_offset>\n" - "\t<bytes>%-8d</bytes>\n" + "\t<pointer>%p</pointer>\n" + "\t<user_virtual>%p</user_virtual>\n" + "\t<kernel_virtual>%p</kernel_virtual>\n" + "\t<cpu_physical>" CPUPADDR_FMT "</cpu_physical>\n" + "\t<mmap_offset>" UINTPTR_FMT "</mmap_offset>\n" + "\t<bytes>%" SIZE_T_FMT_LEN "u</bytes>\n" "\t<linux_mem_area_type>%-24s</linux_mem_area_type>\n" "\t<pid>%-5u</pid>\n" "\t<name>%-8s</name>\n" @@ -1328,11 +1313,11 @@ static void ProcSeqShowMMapRegistrations(struct seq_file *sfile, void *el) "</mmap_record>\n", #endif psLinuxMemArea, - psOffsetStruct->ui32UserVAddr + ui32ByteOffset, + (IMG_PVOID)(psOffsetStruct->uiUserVAddr + uiByteOffset), LinuxMemAreaToCpuVAddr(psLinuxMemArea), LinuxMemAreaToCpuPAddr(psLinuxMemArea,0).uiAddr, - psOffsetStruct->ui32MMapOffset, - psLinuxMemArea->ui32ByteSize, + (IMG_UINTPTR_T)psOffsetStruct->uiMMapOffset, + psLinuxMemArea->uiByteSize, LinuxMemAreaTypeToString(psLinuxMemArea->eAreaType), psOffsetStruct->ui32PID, psOffsetStruct->pszName, @@ -1365,7 +1350,7 @@ PVRMMapRegisterArea(LinuxMemArea *psLinuxMemArea) const IMG_CHAR *pszName = LinuxMemAreaTypeToString(LinuxMemAreaRootType(psLinuxMemArea)); #endif - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); #if defined(DEBUG) || defined(DEBUG_LINUX_MMAP_AREAS) PVR_DPF((PVR_DBG_MESSAGE, @@ -1397,7 +1382,7 @@ PVRMMapRegisterArea(LinuxMemArea *psLinuxMemArea) */ if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_SUB_ALLOC) { - g_ui32TotalByteSize += psLinuxMemArea->ui32ByteSize; + g_uiTotalByteSize += psLinuxMemArea->uiByteSize; } #endif @@ -1430,7 +1415,7 @@ PVRMMapRemoveRegisteredArea(LinuxMemArea *psLinuxMemArea) PVRSRV_ERROR eError; PKV_OFFSET_STRUCT psOffsetStruct, psTmpOffsetStruct; - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); PVR_ASSERT(psLinuxMemArea->bMMapRegistered); @@ -1468,7 +1453,7 @@ PVRMMapRemoveRegisteredArea(LinuxMemArea *psLinuxMemArea) g_ui32RegisteredAreas--; if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_SUB_ALLOC) { - g_ui32TotalByteSize -= psLinuxMemArea->ui32ByteSize; + g_uiTotalByteSize -= psLinuxMemArea->uiByteSize; } #endif @@ -1523,7 +1508,7 @@ LinuxMMapPerProcessDisconnect(PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc) PVR_UNREFERENCED_PARAMETER(psEnvPerProc); - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); list_for_each_entry_safe(psOffsetStruct, psTmpOffsetStruct, &g_sMMapOffsetStructList, sMMapItem) { diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.h b/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.h index 7140c13a8d2..72640e32e01 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mmap.h @@ -77,9 +77,9 @@ typedef struct KV_OFFSET_STRUCT_TAG * contiguous), or it may represent the secure handle associated * with the area. */ - IMG_UINT32 ui32MMapOffset; - - IMG_UINT32 ui32RealByteSize; + IMG_UINTPTR_T uiMMapOffset; + + IMG_SIZE_T uiRealByteSize; /* Memory area associated with this offset structure */ LinuxMemArea *psLinuxMemArea; @@ -107,7 +107,7 @@ typedef struct KV_OFFSET_STRUCT_TAG * User mode address of start of mapping. This is not necessarily the * first user mode address of the memory area. */ - IMG_UINT32 ui32UserVAddr; + IMG_UINTPTR_T uiUserVAddr; /* Extra entries to support proc filesystem debug info */ #if defined(DEBUG_LINUX_MMAP_AREAS) @@ -187,15 +187,11 @@ PVRSRV_ERROR PVRMMapRemoveRegisteredArea(LinuxMemArea *psLinuxMemArea); * @Return PVRSRV_ERROR ******************************************************************************/ PVRSRV_ERROR PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMHandle, -#else IMG_HANDLE hMHandle, -#endif - IMG_UINT32 *pui32MMapOffset, - IMG_UINT32 *pui32ByteOffset, - IMG_UINT32 *pui32RealByteSize, - IMG_UINT32 *pui32UserVAddr); + IMG_UINTPTR_T *puiMMapOffset, + IMG_UINTPTR_T *puiByteOffset, + IMG_SIZE_T *puiRealByteSize, + IMG_UINTPTR_T *puiUserVAddr); /*! ******************************************************************************* @@ -214,14 +210,10 @@ PVRSRV_ERROR PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, ******************************************************************************/ PVRSRV_ERROR PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hMHandle, -#else IMG_HANDLE hMHandle, -#endif IMG_BOOL *pbMUnmap, - IMG_UINT32 *pui32RealByteSize, - IMG_UINT32 *pui32UserVAddr); + IMG_SIZE_T *puiRealByteSize, + IMG_UINTPTR_T *puiUserVAddr); /*! ******************************************************************************* diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/module.c b/drivers/gpu/pvr/services4/srvkm/env/linux/module.c index 487069daf46..a86de684c0a 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/module.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/module.c @@ -83,7 +83,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> -#include <linux/proc_fs.h> + +#ifdef CONFIG_OF +#include <linux/of.h> +#endif #if defined(SUPPORT_DRI_DRM) #include <drm/drmP.h> @@ -129,6 +132,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lock.h" #include "linkage.h" #include "buffer_manager.h" +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include "pvr_sync.h" +#endif + +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) +#include "systrace.h" +#endif #if defined(SUPPORT_DRI_DRM) #include "pvr_drm.h" @@ -160,19 +170,16 @@ module_param(gPVRDebugLevel, uint, 0644); MODULE_PARM_DESC(gPVRDebugLevel, "Sets the level of debug output (default 0x7)"); #endif /* defined(PVRSRV_NEED_PVR_DPF) */ -#if defined(CONFIG_ION_OMAP) -#include <linux/ion.h> -#include <linux/omap_ion.h> -#include "ion.h" -extern void omap_ion_register_pvr_export(void *); -extern struct ion_device *omap_ion_device; -struct ion_client *gpsIONClient; -EXPORT_SYMBOL(gpsIONClient); -#endif /* defined(CONFIG_ION_OMAP) */ +/* Newer kernels no longer support __devinitdata */ +#if !defined(__devinitdata) +#define __devinitdata +#endif +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /* PRQA S 3207 2 */ /* ignore 'not used' warning */ EXPORT_SYMBOL(PVRGetDisplayClassJTable); EXPORT_SYMBOL(PVRGetBufferClassJTable); +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ #if defined(PVR_LDM_DEVICE_CLASS) && !defined(SUPPORT_DRI_DRM) /* @@ -262,10 +269,21 @@ static struct platform_device_id powervr_id_table[] __devinitdata = { }; #endif +#ifdef CONFIG_OF +static const struct of_device_id omap_gpu_id_table[] = { + { .compatible = "ti,omap4-gpu" }, + {} +}; +MODULE_DEVICE_TABLE(of, omap_gpu_id_table); +#endif + static LDM_DRV powervr_driver = { #if defined(PVR_LDM_PLATFORM_MODULE) .driver = { .name = DRVNAME, +#ifdef CONFIG_OF + .of_match_table = of_match_ptr(omap_gpu_id_table), +#endif }, #endif #if defined(PVR_LDM_PCI_MODULE) @@ -355,20 +373,6 @@ static int __devinit PVRSRVDriverProbe(LDM_DEV *pDevice, const struct pci_device } } -#if defined(CONFIG_ION_OMAP) - gpsIONClient = ion_client_create(omap_ion_device, - 1 << ION_HEAP_TYPE_CARVEOUT | - 1 << OMAP_ION_HEAP_TYPE_TILER | - 1 << ION_HEAP_TYPE_SYSTEM, - "pvr"); - if (IS_ERR_OR_NULL(gpsIONClient)) - { - PVR_DPF((PVR_DBG_ERROR, "PVRSRVDriverProbe: Couldn't create ion client")); - return PTR_ERR(gpsIONClient); - } - omap_ion_register_pvr_export(&PVRSRVExportFDToIONHandles); -#endif /* defined(CONFIG_ION_OMAP) */ - return 0; } @@ -403,11 +407,6 @@ static void __devexit PVRSRVDriverRemove(LDM_DEV *pDevice) PVR_TRACE(("PVRSRVDriverRemove(pDevice=%p)", pDevice)); -#if defined(CONFIG_ION_OMAP) - ion_client_destroy(gpsIONClient); - gpsIONClient = IMG_NULL; -#endif - SysAcquireData(&psSysData); #if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) @@ -473,7 +472,7 @@ PVR_MOD_STATIC void PVRSRVDriverShutdown(LDM_DEV *pDevice) { PVR_TRACE(("PVRSRVDriverShutdown(pDevice=%p)", pDevice)); - LinuxLockMutex(&gsPMMutex); + LinuxLockMutexNested(&gsPMMutex, PVRSRV_LOCK_CLASS_POWER); if (!bDriverIsShutdown && !bDriverIsSuspended) { @@ -482,7 +481,7 @@ PVR_MOD_STATIC void PVRSRVDriverShutdown(LDM_DEV *pDevice) * processes trying to use the driver after it has been * shutdown. */ - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); (void) PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3); } @@ -539,11 +538,11 @@ PVR_MOD_STATIC int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state) #if !(defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM)) PVR_TRACE(( "PVRSRVDriverSuspend(pDevice=%p)", pDevice)); - LinuxLockMutex(&gsPMMutex); + LinuxLockMutexNested(&gsPMMutex, PVRSRV_LOCK_CLASS_POWER); if (!bDriverIsSuspended && !bDriverIsShutdown) { - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3) == PVRSRV_OK) { @@ -596,7 +595,7 @@ PVR_MOD_STATIC int PVRSRVDriverResume(LDM_DEV *pDevice) #if !(defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM)) PVR_TRACE(("PVRSRVDriverResume(pDevice=%p)", pDevice)); - LinuxLockMutex(&gsPMMutex); + LinuxLockMutexNested(&gsPMMutex, PVRSRV_LOCK_CLASS_POWER); if (bDriverIsSuspended && !bDriverIsShutdown) { @@ -709,10 +708,10 @@ void ProcSeqShowPowerLevel(struct seq_file *sfile,void* el) @Description - Release access the PVR services node - called when a file is closed, whether - at exit or using close(2) system call. + Open the PVR services node - called when the relevant device node is open()ed. @input pInode - the inode for the file being openeded + @input dev - the DRM device corresponding to this driver. @input pFile - the file handle data for the actual file being opened @@ -734,7 +733,7 @@ static int PVRSRVOpen(struct inode unref__ * pInode, struct file *pFile) PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc; #endif - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); ui32PID = OSGetCurrentProcessIDKM(); @@ -759,11 +758,7 @@ static int PVRSRVOpen(struct inode unref__ * pInode, struct file *pFile) if(eError != PVRSRV_OK) goto err_unlock; -#if defined (SUPPORT_SID_INTERFACE) - psPrivateData->hKernelMemInfo = 0; -#else psPrivateData->hKernelMemInfo = NULL; -#endif #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) psPrivateData->psDRMFile = pFile; @@ -805,7 +800,7 @@ static int PVRSRVRelease(struct inode unref__ * pInode, struct file *pFile) PVRSRV_FILE_PRIVATE_DATA *psPrivateData; int err = 0; - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); #if defined(SUPPORT_DRI_DRM) psPrivateData = (PVRSRV_FILE_PRIVATE_DATA *)pvPrivData; @@ -925,6 +920,8 @@ static int __init PVRCore_Init(void) struct device *psDev; #endif + + #if !defined(SUPPORT_DRI_DRM) /* * Must come before attempting to print anything via Services. @@ -960,6 +957,7 @@ static int __init PVRCore_Init(void) } LinuxBridgeInit(); + PVRMMapInit(); @@ -1054,6 +1052,13 @@ static int __init PVRCore_Init(void) #endif /* defined(PVR_LDM_DEVICE_CLASS) */ #endif /* !defined(SUPPORT_DRI_DRM) */ +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + SystraceCreateFS(); +#endif + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + PVRSyncDeviceInit(); +#endif return 0; #if !defined(SUPPORT_DRI_DRM) @@ -1063,6 +1068,8 @@ destroy_class: unregister_device: unregister_chrdev((IMG_UINT)AssignedMajorNumber, DEVNAME); #endif +#endif +#if !defined(SUPPORT_DRI_DRM) sys_deinit: #endif #if defined(PVR_LDM_MODULE) @@ -1095,7 +1102,6 @@ init_failed: LinuxBridgeDeInit(); PVROSFuncDeInit(); RemoveProcEntries(); - return error; } /*PVRCore_Init*/ @@ -1141,6 +1147,10 @@ static void __exit PVRCore_Cleanup(void) SysAcquireData(&psSysData); #endif +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + PVRSyncDeviceDeInit(); +#endif + #if !defined(SUPPORT_DRI_DRM) #if defined(PVR_LDM_DEVICE_CLASS) @@ -1199,6 +1209,10 @@ static void __exit PVRCore_Cleanup(void) RemoveProcEntries(); +#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) + SystraceDestroyFS(); +#endif + PVR_TRACE(("PVRCore_Cleanup: unloading")); } diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.c b/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.c index 2cd666f5ca4..56422d6ecd5 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.c @@ -66,6 +66,11 @@ IMG_VOID LinuxLockMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex) mutex_lock(psPVRSRVMutex); } +IMG_VOID LinuxLockMutexNested(PVRSRV_LINUX_MUTEX *psPVRSRVMutex, unsigned int uiLockClass) +{ + mutex_lock_nested(psPVRSRVMutex, uiLockClass); +} + PVRSRV_ERROR LinuxLockMutexInterruptible(PVRSRV_LINUX_MUTEX *psPVRSRVMutex) { if(mutex_lock_interruptible(psPVRSRVMutex) == -EINTR) @@ -109,6 +114,11 @@ IMG_VOID LinuxLockMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex) atomic_dec(&psPVRSRVMutex->Count); } +IMG_VOID LinuxLockMutexNested(PVRSRV_LINUX_MUTEX *psPVRSRVMutex, unsigned int uiLockClass) +{ + LinuxLockMutex(psPVRSRVMutex); +} + PVRSRV_ERROR LinuxLockMutexInterruptible(PVRSRV_LINUX_MUTEX *psPVRSRVMutex) { if(down_interruptible(&psPVRSRVMutex->sSemaphore) == -EINTR) @@ -131,7 +141,7 @@ IMG_INT32 LinuxTryLockMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex) atomic_dec(&psPVRSRVMutex->Count); } - return Status; + return Status == 0; } IMG_VOID LinuxUnLockMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex) diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.h b/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.h index c590da15c69..09ae46d4183 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mutex.h @@ -72,11 +72,21 @@ typedef struct { #endif +enum PVRSRV_MUTEX_LOCK_CLASS +{ + PVRSRV_LOCK_CLASS_POWER, + PVRSRV_LOCK_CLASS_BRIDGE, + PVRSRV_LOCK_CLASS_MMAP, + PVRSRV_LOCK_CLASS_MM_DEBUG, + PVRSRV_LOCK_CLASS_PVR_DEBUG, +}; extern IMG_VOID LinuxInitMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex); extern IMG_VOID LinuxLockMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex); +extern IMG_VOID LinuxLockMutexNested(PVRSRV_LINUX_MUTEX *psPVRSRVMutex, unsigned int uiLockClass); + extern PVRSRV_ERROR LinuxLockMutexInterruptible(PVRSRV_LINUX_MUTEX *psPVRSRVMutex); extern IMG_INT32 LinuxTryLockMutex(PVRSRV_LINUX_MUTEX *psPVRSRVMutex); diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.c b/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.c index 8e57476fd9b..8e57476fd9b 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.c diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.h b/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.h index 891598c28b7..6bcee26e3eb 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/mutils.h @@ -63,13 +63,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #else #if defined(__arm__) || defined(__sh__) #define PGPROT_WC(pv) pgprot_writecombine(pv) + #elif defined(__mips__) + #define PGPROT_WC(pv) pgprot_noncached_wa(pv) + #elif defined(__i386__) || defined(__x86_64) + /* PAT support supersedes this */ + #define PGPROT_WC(pv) pgprot_noncached(pv) #else - #if defined(__i386__) || defined(__mips__) - #define PGPROT_WC(pv) pgprot_noncached(pv) - #else - #define PGPROT_WC(pv) pgprot_noncached(pv) - #error Unsupported architecture! - #endif + #define PGPROT_WC(pv) pgprot_noncached(pv) + #error Unsupported architecture! #endif #endif diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/osfunc.c b/drivers/gpu/pvr/services4/srvkm/env/linux/osfunc.c index ca405828173..f2803abc024 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/osfunc.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/osfunc.c @@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <asm/io.h> #include <asm/page.h> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) #include <asm/system.h> #endif #include <asm/cacheflush.h> @@ -66,6 +66,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/interrupt.h> #include <asm/hardirq.h> #include <linux/timer.h> +#if defined(MEM_TRACK_INFO_DEBUG) +#include <linux/time.h> +#endif #include <linux/capability.h> #include <asm/uaccess.h> #include <linux/spinlock.h> @@ -83,22 +86,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pvrmmap.h" #include "mmap.h" #include "env_data.h" -#include "proc.h" #include "mutex.h" #include "event.h" #include "linkage.h" #include "pvr_uaccess.h" #include "lock.h" -#include <syslocal.h> +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include "pvr_sync.h" +#endif #if defined (SUPPORT_ION) #include "ion.h" #endif -#if defined (CONFIG_X86_PAE) -#error Physical Address Extension not supported with the driver -#endif - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) #define ON_EACH_CPU(func, info, wait) on_each_cpu(func, info, wait) #else @@ -123,21 +123,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif /* EMULATOR */ #if !defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID *ppvCpuVAddr, IMG_HANDLE *phBlockAlloc) +PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uiSize, IMG_PVOID *ppvCpuVAddr, IMG_HANDLE *phBlockAlloc) #else -PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID *ppvCpuVAddr, IMG_HANDLE *phBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line) +PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uiSize, IMG_PVOID *ppvCpuVAddr, IMG_HANDLE *phBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line) #endif { PVR_UNREFERENCED_PARAMETER(ui32Flags); PVR_UNREFERENCED_PARAMETER(phBlockAlloc); - if (ui32Size > PAGE_SIZE) + if (uiSize > PAGE_SIZE) { /* Try to allocate the memory using vmalloc */ #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - *ppvCpuVAddr = _VMallocWrapper(ui32Size, PVRSRV_HAP_CACHED, pszFilename, ui32Line); + *ppvCpuVAddr = _VMallocWrapper(uiSize, PVRSRV_HAP_CACHED, pszFilename, ui32Line); #else - *ppvCpuVAddr = VMallocWrapper(ui32Size, PVRSRV_HAP_CACHED); + *ppvCpuVAddr = VMallocWrapper(uiSize, PVRSRV_HAP_CACHED); #endif if (*ppvCpuVAddr) { @@ -146,9 +146,9 @@ PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOI } #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - *ppvCpuVAddr = _KMallocWrapper(ui32Size, GFP_KERNEL | __GFP_NOWARN, pszFilename, ui32Line); + *ppvCpuVAddr = _KMallocWrapper(uiSize, GFP_KERNEL | __GFP_NOWARN, pszFilename, ui32Line); #else - *ppvCpuVAddr = KMallocWrapper(ui32Size, GFP_KERNEL | __GFP_NOWARN); + *ppvCpuVAddr = KMallocWrapper(uiSize, GFP_KERNEL | __GFP_NOWARN); #endif if (!*ppvCpuVAddr) { @@ -169,13 +169,13 @@ static inline int is_vmalloc_addr(const void *pvCpuVAddr) #endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24)) */ #if !defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID pvCpuVAddr, IMG_HANDLE hBlockAlloc) +PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uiSize, IMG_PVOID pvCpuVAddr, IMG_HANDLE hBlockAlloc) #else -PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID pvCpuVAddr, IMG_HANDLE hBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line) +PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uiSize, IMG_PVOID pvCpuVAddr, IMG_HANDLE hBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line) #endif { PVR_UNREFERENCED_PARAMETER(ui32Flags); - PVR_UNREFERENCED_PARAMETER(ui32Size); + PVR_UNREFERENCED_PARAMETER(uiSize); PVR_UNREFERENCED_PARAMETER(hBlockAlloc); if (is_vmalloc_addr(pvCpuVAddr)) @@ -201,7 +201,7 @@ PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID PVRSRV_ERROR OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, - IMG_UINT32 ui32Size, + IMG_SIZE_T uiSize, IMG_UINT32 ui32PageSize, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, @@ -223,27 +223,11 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, } #endif - if(ui32AllocFlags & PVRSRV_MEM_ION) - { - /* We'll only see HAP_SINGLE_PROCESS with MEM_ION */ - BUG_ON((ui32AllocFlags & PVRSRV_HAP_MAPTYPE_MASK) != PVRSRV_HAP_SINGLE_PROCESS); - - psLinuxMemArea = NewIONLinuxMemArea(ui32Size, ui32AllocFlags, - pvPrivData, ui32PrivDataLength); - if(!psLinuxMemArea) - { - return PVRSRV_ERROR_OUT_OF_MEMORY; - } - - PVRMMapRegisterArea(psLinuxMemArea); - goto ExitSkipSwitch; - } - switch(ui32AllocFlags & PVRSRV_HAP_MAPTYPE_MASK) { case PVRSRV_HAP_KERNEL_ONLY: { - psLinuxMemArea = NewVMallocLinuxMemArea(ui32Size, ui32AllocFlags); + psLinuxMemArea = NewVMallocLinuxMemArea(uiSize, ui32AllocFlags); if(!psLinuxMemArea) { return PVRSRV_ERROR_OUT_OF_MEMORY; @@ -255,7 +239,7 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, /* Currently PVRSRV_HAP_SINGLE_PROCESS implies that we dont need a * kernel virtual mapping, but will need a user space virtual mapping */ - psLinuxMemArea = NewAllocPagesLinuxMemArea(ui32Size, ui32AllocFlags); + psLinuxMemArea = NewAllocPagesLinuxMemArea(uiSize, ui32AllocFlags); if(!psLinuxMemArea) { return PVRSRV_ERROR_OUT_OF_MEMORY; @@ -279,7 +263,7 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, * VIPT architectures. */ ui32AllocFlags &= ~PVRSRV_HAP_CACHED; #endif - psLinuxMemArea = NewVMallocLinuxMemArea(ui32Size, ui32AllocFlags); + psLinuxMemArea = NewVMallocLinuxMemArea(uiSize, ui32AllocFlags); if(!psLinuxMemArea) { return PVRSRV_ERROR_OUT_OF_MEMORY; @@ -303,7 +287,6 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, psLinuxMemArea->hBMHandle = hBMHandle; } -ExitSkipSwitch: *ppvCpuVAddr = LinuxMemAreaToCpuVAddr(psLinuxMemArea); *phOSMemHandle = psLinuxMemArea; @@ -314,12 +297,12 @@ ExitSkipSwitch: PVRSRV_ERROR -OSFreePages(IMG_UINT32 ui32AllocFlags, IMG_UINT32 ui32Bytes, IMG_VOID *pvCpuVAddr, IMG_HANDLE hOSMemHandle) +OSFreePages(IMG_UINT32 ui32AllocFlags, IMG_SIZE_T uiBytes, IMG_VOID *pvCpuVAddr, IMG_HANDLE hOSMemHandle) { LinuxMemArea *psLinuxMemArea; PVRSRV_ERROR eError; - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uiBytes); PVR_UNREFERENCED_PARAMETER(pvCpuVAddr); psLinuxMemArea = (LinuxMemArea *)hOSMemHandle; @@ -334,9 +317,9 @@ OSFreePages(IMG_UINT32 ui32AllocFlags, IMG_UINT32 ui32Bytes, IMG_VOID *pvCpuVAdd if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "OSFreePages(ui32AllocFlags=0x%08X, ui32Bytes=%d, " + "OSFreePages(ui32AllocFlags=0x%08X, ui32Bytes=%" SIZE_T_FMT_LEN "u, " "pvCpuVAddr=%p, hOSMemHandle=%p) FAILED!", - ui32AllocFlags, ui32Bytes, pvCpuVAddr, hOSMemHandle)); + ui32AllocFlags, uiBytes, pvCpuVAddr, hOSMemHandle)); return eError; } break; @@ -351,31 +334,11 @@ OSFreePages(IMG_UINT32 ui32AllocFlags, IMG_UINT32 ui32Bytes, IMG_VOID *pvCpuVAdd return PVRSRV_OK; } -IMG_INT32 -OSGetMemMultiPlaneInfo(IMG_HANDLE hOSMemHandle, IMG_UINT32* pui32AddressOffsets, - IMG_UINT32* ui32NumAddrOffsets) -{ - LinuxMemArea *psLinuxMemArea = (LinuxMemArea *)hOSMemHandle; - - if(!ui32NumAddrOffsets) - return -1; - - if(psLinuxMemArea->eAreaType == LINUX_MEM_AREA_ION) - return GetIONLinuxMemAreaInfo(psLinuxMemArea, pui32AddressOffsets, ui32NumAddrOffsets); - - if(!pui32AddressOffsets) - return -1; - - *pui32AddressOffsets = 0; - *ui32NumAddrOffsets = 1; - - return psLinuxMemArea->ui32ByteSize; -} PVRSRV_ERROR OSGetSubMemHandle(IMG_HANDLE hOSMemHandle, - IMG_UINT32 ui32ByteOffset, - IMG_UINT32 ui32Bytes, + IMG_UINTPTR_T uiByteOffset, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandleRet) { @@ -384,7 +347,7 @@ OSGetSubMemHandle(IMG_HANDLE hOSMemHandle, psParentLinuxMemArea = (LinuxMemArea *)hOSMemHandle; - psLinuxMemArea = NewSubLinuxMemArea(psParentLinuxMemArea, ui32ByteOffset, ui32Bytes); + psLinuxMemArea = NewSubLinuxMemArea(psParentLinuxMemArea, uiByteOffset, uiBytes); if(!psLinuxMemArea) { *phOSMemHandleRet = NULL; @@ -436,11 +399,11 @@ OSReleaseSubMemHandle(IMG_VOID *hOSMemHandle, IMG_UINT32 ui32Flags) IMG_CPU_PHYADDR -OSMemHandleToCpuPAddr(IMG_VOID *hOSMemHandle, IMG_UINT32 ui32ByteOffset) +OSMemHandleToCpuPAddr(IMG_VOID *hOSMemHandle, IMG_UINTPTR_T uiByteOffset) { PVR_ASSERT(hOSMemHandle); - return LinuxMemAreaToCpuPAddr(hOSMemHandle, ui32ByteOffset); + return LinuxMemAreaToCpuPAddr(hOSMemHandle, uiByteOffset); } @@ -471,7 +434,7 @@ IMG_BOOL OSMemHandleIsPhysContig(IMG_VOID *hOSMemHandle) @Return none ******************************************************************************/ -IMG_VOID OSMemCopy(IMG_VOID *pvDst, IMG_VOID *pvSrc, IMG_UINT32 ui32Size) +IMG_VOID OSMemCopy(IMG_VOID *pvDst, IMG_VOID *pvSrc, IMG_SIZE_T uiSize) { #if defined(USE_UNOPTIMISED_MEMCPY) IMG_UINT8 *Src,*Dst; @@ -479,12 +442,12 @@ IMG_VOID OSMemCopy(IMG_VOID *pvDst, IMG_VOID *pvSrc, IMG_UINT32 ui32Size) Src=(IMG_UINT8 *)pvSrc; Dst=(IMG_UINT8 *)pvDst; - for(i=0;i<ui32Size;i++) + for(i=0;i<uiSize;i++) { Dst[i]=Src[i]; } #else - memcpy(pvDst, pvSrc, ui32Size); + memcpy(pvDst, pvSrc, uiSize); #endif } @@ -505,19 +468,19 @@ IMG_VOID OSMemCopy(IMG_VOID *pvDst, IMG_VOID *pvSrc, IMG_UINT32 ui32Size) @Return IMG_VOID ******************************************************************************/ -IMG_VOID OSMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_UINT32 ui32Size) +IMG_VOID OSMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T uiSize) { #if defined(USE_UNOPTIMISED_MEMSET) IMG_UINT8 *Buff; IMG_INT i; Buff=(IMG_UINT8 *)pvDest; - for(i=0;i<ui32Size;i++) + for(i=0;i<uiSize;i++) { Buff[i]=ui8Value; } #else - memset(pvDest, (IMG_INT) ui8Value, (size_t) ui32Size); + memset(pvDest, (IMG_INT) ui8Value, (size_t) uiSize); #endif } @@ -537,13 +500,13 @@ IMG_CHAR *OSStringCopy(IMG_CHAR *pszDest, const IMG_CHAR *pszSrc) @Function OSSNPrintf @Description snprintf ******************************************************************************/ -IMG_INT32 OSSNPrintf(IMG_CHAR *pStr, IMG_UINT32 ui32Size, const IMG_CHAR *pszFormat, ...) +IMG_INT32 OSSNPrintf(IMG_CHAR *pStr, IMG_SIZE_T uiSize, const IMG_CHAR *pszFormat, ...) { va_list argList; IMG_INT32 iCount; va_start(argList, pszFormat); - iCount = vsnprintf(pStr, (size_t)ui32Size, pszFormat, argList); + iCount = vsnprintf(pStr, (size_t)uiSize, pszFormat, argList); va_end(argList); return iCount; @@ -839,59 +802,22 @@ IMG_UINT32 OSGetCurrentProcessIDKM(IMG_VOID) #endif } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) -int OSGetProcCmdline(IMG_UINT32 ui32PID, char * buffer, int buff_size) -{ - int res = 0; - unsigned int len; - struct task_struct *task = pid_task(find_vpid(ui32PID), PIDTYPE_PID); - struct mm_struct *mm = task ? get_task_mm(task) : IMG_NULL; - if (!mm) - goto out; - if (!mm->arg_end) - goto out_mm; /* Shh! No looking before we're done */ - - len = mm->arg_end - mm->arg_start; - - if (len > buff_size) - len = buff_size; +#if defined(MEM_TRACK_INFO_DEBUG) +/*! +****************************************************************************** - res = pvr_access_process_vm(task, mm->arg_start, buffer, len, 0); + @Function OSGetCurrentTimeInUSecsKM + + @Description Returns current time in usecs - // If the nul at the end of args has been overwritten, then - // assume application is using setproctitle(3). - if (res > 0 && buffer[res-1] != '\0' && len < buff_size) { - len = strnlen(buffer, res); - if (len < res) { - res = len; - } else { - len = mm->env_end - mm->env_start; - if (len > buff_size - res) - len = buff_size - res; - res += pvr_access_process_vm(task, mm->env_start, buffer+res, len, 0); - res = strnlen(buffer, res); - } - } -out_mm: - mmput(mm); -out: - return res; -} + @Return ID of current process -const char* OSGetPathBaseName(char * buffer, int buff_size) +*****************************************************************************/ +IMG_UINT32 OSGetCurrentTimeInUSecsKM(IMG_VOID) { - const char *base_name = buffer; - while (1) - { - const char *next = strnchr(base_name, buff_size, '/'); - if (!next) - break; - - buff_size -= (next - base_name -1); - base_name = (next + 1); - - } - return base_name; + struct timeval tv; + do_gettimeofday(&tv); + return (tv.tv_sec * 1000000 + tv.tv_usec); } #endif @@ -1197,6 +1123,10 @@ static void MISRWrapper( SYS_DATA *psSysData = (SYS_DATA *)psEnvData->pvMISRData; PVRSRVMISR(psSysData); + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + PVRSyncUpdateAllSyncs(); +#endif } @@ -1703,7 +1633,7 @@ IMG_CPU_PHYADDR OSMapLinToCPUPhys(IMG_HANDLE hOSMemHandle, ******************************************************************************/ IMG_VOID * OSMapPhysToLin(IMG_CPU_PHYADDR BasePAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE *phOSMemHandle) { @@ -1717,7 +1647,7 @@ OSMapPhysToLin(IMG_CPU_PHYADDR BasePAddr, if(phOSMemHandle == IMG_NULL) { IMG_VOID *pvIORemapCookie; - pvIORemapCookie = IORemapWrapper(BasePAddr, ui32Bytes, ui32MappingFlags); + pvIORemapCookie = IORemapWrapper(BasePAddr, uiBytes, ui32MappingFlags); if(pvIORemapCookie == IMG_NULL) { return IMG_NULL; @@ -1726,7 +1656,7 @@ OSMapPhysToLin(IMG_CPU_PHYADDR BasePAddr, } else { - LinuxMemArea *psLinuxMemArea = NewIORemapLinuxMemArea(BasePAddr, ui32Bytes, ui32MappingFlags); + LinuxMemArea *psLinuxMemArea = NewIORemapLinuxMemArea(BasePAddr, uiBytes, ui32MappingFlags); if(psLinuxMemArea == IMG_NULL) { @@ -1752,9 +1682,9 @@ OSMapPhysToLin(IMG_CPU_PHYADDR BasePAddr, @Return TRUE on success, else FALSE ******************************************************************************/ IMG_BOOL -OSUnMapPhysToLin(IMG_VOID *pvLinAddr, IMG_UINT32 ui32Bytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE hOSMemHandle) +OSUnMapPhysToLin(IMG_VOID *pvLinAddr, IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE hOSMemHandle) { - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uiBytes); if(ui32MappingFlags & PVRSRV_HAP_KERNEL_ONLY) { @@ -1868,19 +1798,19 @@ RegisterExternalMem(IMG_SYS_PHYADDR *pBasePAddr, PVRSRV_ERROR OSRegisterMem(IMG_CPU_PHYADDR BasePAddr, IMG_VOID *pvCPUVAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE *phOSMemHandle) { IMG_SYS_PHYADDR SysPAddr = SysCpuPAddrToSysPAddr(BasePAddr); - return RegisterExternalMem(&SysPAddr, pvCPUVAddr, ui32Bytes, IMG_TRUE, ui32MappingFlags, phOSMemHandle); + return RegisterExternalMem(&SysPAddr, pvCPUVAddr, uiBytes, IMG_TRUE, ui32MappingFlags, phOSMemHandle); } -PVRSRV_ERROR OSRegisterDiscontigMem(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_UINT32 ui32Bytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE *phOSMemHandle) +PVRSRV_ERROR OSRegisterDiscontigMem(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPUVAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE *phOSMemHandle) { - return RegisterExternalMem(pBasePAddr, pvCPUVAddr, ui32Bytes, IMG_FALSE, ui32MappingFlags, phOSMemHandle); + return RegisterExternalMem(pBasePAddr, pvCPUVAddr, uBytes, IMG_FALSE, ui32MappingFlags, phOSMemHandle); } @@ -1892,7 +1822,7 @@ PVRSRV_ERROR OSRegisterDiscontigMem(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCPU ******************************************************************************/ PVRSRV_ERROR OSUnRegisterMem (IMG_VOID *pvCpuVAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE hOSMemHandle) { @@ -1900,7 +1830,7 @@ OSUnRegisterMem (IMG_VOID *pvCpuVAddr, PVRSRV_ERROR eError; PVR_UNREFERENCED_PARAMETER(pvCpuVAddr); - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uiBytes); switch(ui32MappingFlags & PVRSRV_HAP_MAPTYPE_MASK) { @@ -1912,8 +1842,8 @@ OSUnRegisterMem (IMG_VOID *pvCpuVAddr, eError = PVRMMapRemoveRegisteredArea(psLinuxMemArea); if (eError != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "%s(%p, %d, 0x%08X, %p) FAILED!", - __FUNCTION__, pvCpuVAddr, ui32Bytes, + PVR_DPF((PVR_DBG_ERROR, "%s(%p, %" SIZE_T_FMT_LEN "u, 0x%08X, %p) FAILED!", + __FUNCTION__, pvCpuVAddr, uiBytes, ui32MappingFlags, hOSMemHandle)); return eError; } @@ -1931,9 +1861,9 @@ OSUnRegisterMem (IMG_VOID *pvCpuVAddr, return PVRSRV_OK; } -PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, IMG_UINT32 ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) +PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) { - return OSUnRegisterMem(pvCpuVAddr, ui32Bytes, ui32Flags, hOSMemHandle); + return OSUnRegisterMem(pvCpuVAddr, uBytes, ui32Flags, hOSMemHandle); } /*! @@ -1946,7 +1876,7 @@ PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, IMG_UINT32 ui32Bytes ******************************************************************************/ PVRSRV_ERROR OSReservePhys(IMG_CPU_PHYADDR BasePAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE hBMHandle, IMG_VOID **ppvCpuVAddr, @@ -1972,7 +1902,7 @@ OSReservePhys(IMG_CPU_PHYADDR BasePAddr, * mapping is required for the allocation and no user virtual * mappings are allowed: Note these eat into our limited kernel * virtual address space */ - psLinuxMemArea = NewIORemapLinuxMemArea(BasePAddr, ui32Bytes, ui32MappingFlags); + psLinuxMemArea = NewIORemapLinuxMemArea(BasePAddr, uiBytes, ui32MappingFlags); if(!psLinuxMemArea) { return PVRSRV_ERROR_BAD_MAPPING; @@ -1983,7 +1913,7 @@ OSReservePhys(IMG_CPU_PHYADDR BasePAddr, { /* Currently this implies that we dont need a kernel virtual * mapping, but will need a user space virtual mapping */ - psLinuxMemArea = NewIOLinuxMemArea(BasePAddr, ui32Bytes, ui32MappingFlags); + psLinuxMemArea = NewIOLinuxMemArea(BasePAddr, uiBytes, ui32MappingFlags); if(!psLinuxMemArea) { return PVRSRV_ERROR_BAD_MAPPING; @@ -2007,7 +1937,7 @@ OSReservePhys(IMG_CPU_PHYADDR BasePAddr, */ ui32MappingFlags &= ~PVRSRV_HAP_CACHED; #endif - psLinuxMemArea = NewIORemapLinuxMemArea(BasePAddr, ui32Bytes, ui32MappingFlags); + psLinuxMemArea = NewIORemapLinuxMemArea(BasePAddr, uiBytes, ui32MappingFlags); if(!psLinuxMemArea) { return PVRSRV_ERROR_BAD_MAPPING; @@ -2048,7 +1978,7 @@ OSReservePhys(IMG_CPU_PHYADDR BasePAddr, ******************************************************************************/ PVRSRV_ERROR OSUnReservePhys(IMG_VOID *pvCpuVAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_UINT32 ui32MappingFlags, IMG_HANDLE hOSMemHandle) { @@ -2056,7 +1986,7 @@ OSUnReservePhys(IMG_VOID *pvCpuVAddr, PVRSRV_ERROR eError; PVR_UNREFERENCED_PARAMETER(pvCpuVAddr); - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uiBytes); psLinuxMemArea = (LinuxMemArea *)hOSMemHandle; @@ -2070,8 +2000,8 @@ OSUnReservePhys(IMG_VOID *pvCpuVAddr, eError = PVRMMapRemoveRegisteredArea(psLinuxMemArea); if (eError != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "%s(%p, %d, 0x%08X, %p) FAILED!", - __FUNCTION__, pvCpuVAddr, ui32Bytes, + PVR_DPF((PVR_DBG_ERROR, "%s(%p, %" SIZE_T_FMT_LEN "u, 0x%08X, %p) FAILED!", + __FUNCTION__, pvCpuVAddr, uiBytes, ui32MappingFlags, hOSMemHandle)); return eError; } @@ -2098,10 +2028,10 @@ OSUnReservePhys(IMG_VOID *pvCpuVAddr, @Output ppvLinAddr - pointer to variable that will receive the linear address of buffer @Return PVRSRV_OK if allocation successed else returns PVRSRV_ERROR_OUT_OF_MEMORY **************************************************************************/ -PVRSRV_ERROR OSBaseAllocContigMemory(IMG_UINT32 ui32Size, IMG_CPU_VIRTADDR *pvLinAddr, IMG_CPU_PHYADDR *psPhysAddr) +PVRSRV_ERROR OSBaseAllocContigMemory(IMG_SIZE_T uiSize, IMG_CPU_VIRTADDR *pvLinAddr, IMG_CPU_PHYADDR *psPhysAddr) { #if !defined(NO_HARDWARE) - PVR_UNREFERENCED_PARAMETER(ui32Size); + PVR_UNREFERENCED_PARAMETER(uiSize); PVR_UNREFERENCED_PARAMETER(pvLinAddr); PVR_UNREFERENCED_PARAMETER(psPhysAddr); PVR_DPF((PVR_DBG_ERROR, "%s: Not available", __FUNCTION__)); @@ -2118,9 +2048,9 @@ PVRSRV_ERROR OSBaseAllocContigMemory(IMG_UINT32 ui32Size, IMG_CPU_VIRTADDR *pvLi IMG_VOID *pvKernLinAddr; #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - pvKernLinAddr = _KMallocWrapper(ui32Size, GFP_KERNEL, __FILE__, __LINE__); + pvKernLinAddr = _KMallocWrapper(uiSize, GFP_KERNEL, __FILE__, __LINE__); #else - pvKernLinAddr = KMallocWrapper(ui32Size, GFP_KERNEL); + pvKernLinAddr = KMallocWrapper(uiSize, GFP_KERNEL); #endif if (!pvKernLinAddr) { @@ -2142,16 +2072,16 @@ PVRSRV_ERROR OSBaseAllocContigMemory(IMG_UINT32 ui32Size, IMG_CPU_VIRTADDR *pvLi @Description Frees memory allocated with OSBaseAllocContigMemory @Input LinAddr - pointer to buffer allocated with OSBaseAllocContigMemory **************************************************************************/ -PVRSRV_ERROR OSBaseFreeContigMemory(IMG_UINT32 ui32Size, IMG_CPU_VIRTADDR pvLinAddr, IMG_CPU_PHYADDR psPhysAddr) +PVRSRV_ERROR OSBaseFreeContigMemory(IMG_SIZE_T uiSize, IMG_CPU_VIRTADDR pvLinAddr, IMG_CPU_PHYADDR psPhysAddr) { #if !defined(NO_HARDWARE) - PVR_UNREFERENCED_PARAMETER(ui32Size); + PVR_UNREFERENCED_PARAMETER(uiSize); PVR_UNREFERENCED_PARAMETER(pvLinAddr); PVR_UNREFERENCED_PARAMETER(psPhysAddr.uiAddr); PVR_DPF((PVR_DBG_WARNING, "%s: Not available", __FUNCTION__)); #else - PVR_UNREFERENCED_PARAMETER(ui32Size); + PVR_UNREFERENCED_PARAMETER(uiSize); PVR_UNREFERENCED_PARAMETER(psPhysAddr.uiAddr); KFreeWrapper(pvLinAddr); @@ -2762,9 +2692,9 @@ static void OSTimerCallbackBody(TIMER_CALLBACK_DATA *psTimerCBData) @Return NONE ******************************************************************************/ -static IMG_VOID OSTimerCallbackWrapper(IMG_UINT32 ui32Data) +static IMG_VOID OSTimerCallbackWrapper(IMG_UINTPTR_T uiData) { - TIMER_CALLBACK_DATA *psTimerCBData = (TIMER_CALLBACK_DATA*)ui32Data; + TIMER_CALLBACK_DATA *psTimerCBData = (TIMER_CALLBACK_DATA*)uiData; #if defined(PVR_LINUX_TIMERS_USING_WORKQUEUES) || defined(PVR_LINUX_TIMERS_USING_SHARED_WORKQUEUE) int res; @@ -2814,7 +2744,7 @@ static void OSTimerWorkQueueCallBack(struct work_struct *psWork) IMG_HANDLE OSAddTimer(PFN_TIMER_FUNC pfnTimerFunc, IMG_VOID *pvData, IMG_UINT32 ui32MsTimeout) { TIMER_CALLBACK_DATA *psTimerCBData; - IMG_UINT32 ui32i; + IMG_UINTPTR_T ui; #if !(defined(PVR_LINUX_TIMERS_USING_WORKQUEUES) || defined(PVR_LINUX_TIMERS_USING_SHARED_WORKQUEUE)) unsigned long ulLockFlags; #endif @@ -2832,9 +2762,9 @@ IMG_HANDLE OSAddTimer(PFN_TIMER_FUNC pfnTimerFunc, IMG_VOID *pvData, IMG_UINT32 #else spin_lock_irqsave(&sTimerStructLock, ulLockFlags); #endif - for (ui32i = 0; ui32i < OS_MAX_TIMERS; ui32i++) + for (ui = 0; ui < OS_MAX_TIMERS; ui++) { - psTimerCBData = &sTimers[ui32i]; + psTimerCBData = &sTimers[ui]; if (!psTimerCBData->bInUse) { psTimerCBData->bInUse = IMG_TRUE; @@ -2846,7 +2776,7 @@ IMG_HANDLE OSAddTimer(PFN_TIMER_FUNC pfnTimerFunc, IMG_VOID *pvData, IMG_UINT32 #else spin_unlock_irqrestore(&sTimerStructLock, ulLockFlags); #endif - if (ui32i >= OS_MAX_TIMERS) + if (ui >= OS_MAX_TIMERS) { PVR_DPF((PVR_DBG_ERROR, "OSAddTimer: all timers are in use")); return IMG_NULL; @@ -2870,19 +2800,19 @@ IMG_HANDLE OSAddTimer(PFN_TIMER_FUNC pfnTimerFunc, IMG_VOID *pvData, IMG_UINT32 /* setup timer object */ /* PRQA S 0307,0563 1 */ /* ignore warning about inconpartible ptr casting */ psTimerCBData->sTimer.function = (IMG_VOID *)OSTimerCallbackWrapper; - psTimerCBData->sTimer.data = (IMG_UINT32)psTimerCBData; + psTimerCBData->sTimer.data = (IMG_UINTPTR_T)psTimerCBData; - return (IMG_HANDLE)(ui32i + 1); + return (IMG_HANDLE)(ui + 1); } static inline TIMER_CALLBACK_DATA *GetTimerStructure(IMG_HANDLE hTimer) { - IMG_UINT32 ui32i = ((IMG_UINT32)hTimer) - 1; + IMG_UINTPTR_T ui = ((IMG_UINTPTR_T)hTimer) - 1; - PVR_ASSERT(ui32i < OS_MAX_TIMERS); + PVR_ASSERT(ui < OS_MAX_TIMERS); - return &sTimers[ui32i]; + return &sTimers[ui]; } /*! @@ -3016,11 +2946,7 @@ PVRSRV_ERROR OSDisableTimer (IMG_HANDLE hTimer) @Return PVRSRV_ERROR : ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT_KM *psEventObject) -#else PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *psEventObject) -#endif { PVRSRV_ERROR eError = PVRSRV_OK; @@ -3036,11 +2962,7 @@ PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT * { /* autogenerate a name */ static IMG_UINT16 ui16NameIndex = 0; -#if defined (SUPPORT_SID_INTERFACE) - snprintf(psEventObject->szName, EVENTOBJNAME_MAXLENGTH, "PVRSRV_EVENTOBJECT_KM_%d", ui16NameIndex++); -#else snprintf(psEventObject->szName, EVENTOBJNAME_MAXLENGTH, "PVRSRV_EVENTOBJECT_%d", ui16NameIndex++); -#endif } if(LinuxEventObjectListCreate(&psEventObject->hOSEventKM) != PVRSRV_OK) @@ -3074,11 +2996,7 @@ PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT * @Return PVRSRV_ERROR : ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT_KM *psEventObject) -#else PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT *psEventObject) -#endif { PVRSRV_ERROR eError = PVRSRV_OK; @@ -3149,11 +3067,7 @@ PVRSRV_ERROR OSEventObjectWaitKM(IMG_HANDLE hOSEventKM) @Return PVRSRV_ERROR : ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT_KM *psEventObject, -#else PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT *psEventObject, -#endif IMG_HANDLE *phOSEvent) { PVRSRV_ERROR eError = PVRSRV_OK; @@ -3192,11 +3106,7 @@ PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT *psEventObject, @Return PVRSRV_ERROR : ******************************************************************************/ -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT_KM *psEventObject, -#else PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT *psEventObject, -#endif IMG_HANDLE hOSEventKM) { PVRSRV_ERROR eError = PVRSRV_OK; @@ -3291,11 +3201,11 @@ IMG_BOOL OSProcHasPrivSrvInit(IMG_VOID) PVRSRV_ERROR OSCopyToUser(IMG_PVOID pvProcess, IMG_VOID *pvDest, IMG_VOID *pvSrc, - IMG_UINT32 ui32Bytes) + IMG_SIZE_T uiBytes) { PVR_UNREFERENCED_PARAMETER(pvProcess); - if(pvr_copy_to_user(pvDest, pvSrc, ui32Bytes)==0) + if(pvr_copy_to_user(pvDest, pvSrc, uiBytes)==0) return PVRSRV_OK; else return PVRSRV_ERROR_FAILED_TO_COPY_VIRT_MEMORY; @@ -3322,11 +3232,11 @@ PVRSRV_ERROR OSCopyToUser(IMG_PVOID pvProcess, PVRSRV_ERROR OSCopyFromUser( IMG_PVOID pvProcess, IMG_VOID *pvDest, IMG_VOID *pvSrc, - IMG_UINT32 ui32Bytes) + IMG_SIZE_T uiBytes) { PVR_UNREFERENCED_PARAMETER(pvProcess); - if(pvr_copy_from_user(pvDest, pvSrc, ui32Bytes)==0) + if(pvr_copy_from_user(pvDest, pvSrc, uiBytes)==0) return PVRSRV_OK; else return PVRSRV_ERROR_FAILED_TO_COPY_VIRT_MEMORY; @@ -3350,7 +3260,7 @@ PVRSRV_ERROR OSCopyFromUser( IMG_PVOID pvProcess, @Return IMG_BOOL : ******************************************************************************/ -IMG_BOOL OSAccessOK(IMG_VERIFY_TEST eVerification, IMG_VOID *pvUserPtr, IMG_UINT32 ui32Bytes) +IMG_BOOL OSAccessOK(IMG_VERIFY_TEST eVerification, IMG_VOID *pvUserPtr, IMG_SIZE_T uiBytes) { IMG_INT linuxType; @@ -3364,7 +3274,7 @@ IMG_BOOL OSAccessOK(IMG_VERIFY_TEST eVerification, IMG_VOID *pvUserPtr, IMG_UINT linuxType = VERIFY_WRITE; } - return access_ok(linuxType, pvUserPtr, ui32Bytes); + return access_ok(linuxType, pvUserPtr, uiBytes); } typedef enum _eWrapMemType_ @@ -3383,8 +3293,8 @@ typedef struct _sWrapMemInfo_ IMG_SYS_PHYADDR *psPhysAddr; IMG_INT iPageOffset; #if defined(DEBUG) - IMG_UINT32 ulStartAddr; - IMG_UINT32 ulBeyondEndAddr; + IMG_UINTPTR_T uStartAddr; + IMG_UINTPTR_T uBeyondEndAddr; struct vm_area_struct *psVMArea; #endif } sWrapMemInfo; @@ -3403,16 +3313,16 @@ typedef struct _sWrapMemInfo_ and must be writable. A get_page is done on the returned page structure. @Input psVMArea - pointer to VM area structure - ulCPUVAddr - CPU virtual address - pulPFN - Pointer to returned PFN. + uCPUVAddr - CPU virtual address + pui32PFN - Pointer to returned PFN. ppsPAge - Pointer to returned page structure pointer. - @Output *pulPFN - Set to PFN + @Output *pui32PFN - Set to PFN *ppsPage - Pointer to the page structure if present, else NULL. @Return IMG_TRUE if PFN lookup was succesful. ******************************************************************************/ -static IMG_BOOL CPUVAddrToPFN(struct vm_area_struct *psVMArea, IMG_UINT32 ulCPUVAddr, IMG_UINT32 *pulPFN, struct page **ppsPage) +static IMG_BOOL CPUVAddrToPFN(struct vm_area_struct *psVMArea, IMG_UINTPTR_T uCPUVAddr, IMG_UINT32 *pui32PFN, struct page **ppsPage) { #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) pgd_t *psPGD; @@ -3423,31 +3333,31 @@ static IMG_BOOL CPUVAddrToPFN(struct vm_area_struct *psVMArea, IMG_UINT32 ulCPUV spinlock_t *psPTLock; IMG_BOOL bRet = IMG_FALSE; - *pulPFN = 0; + *pui32PFN = 0; *ppsPage = NULL; - psPGD = pgd_offset(psMM, ulCPUVAddr); + psPGD = pgd_offset(psMM, uCPUVAddr); if (pgd_none(*psPGD) || pgd_bad(*psPGD)) return bRet; - psPUD = pud_offset(psPGD, ulCPUVAddr); + psPUD = pud_offset(psPGD, uCPUVAddr); if (pud_none(*psPUD) || pud_bad(*psPUD)) return bRet; - psPMD = pmd_offset(psPUD, ulCPUVAddr); + psPMD = pmd_offset(psPUD, uCPUVAddr); if (pmd_none(*psPMD) || pmd_bad(*psPMD)) return bRet; - psPTE = (pte_t *)pte_offset_map_lock(psMM, psPMD, ulCPUVAddr, &psPTLock); + psPTE = (pte_t *)pte_offset_map_lock(psMM, psPMD, uCPUVAddr, &psPTLock); if ((pte_none(*psPTE) == 0) && (pte_present(*psPTE) != 0) && (pte_write(*psPTE) != 0)) { - *pulPFN = pte_pfn(*psPTE); + *pui32PFN = pte_pfn(*psPTE); bRet = IMG_TRUE; - if (pfn_valid(*pulPFN)) + if (pfn_valid(*pui32PFN)) { - *ppsPage = pfn_to_page(*pulPFN); + *ppsPage = pfn_to_page(*pui32PFN); get_page(*ppsPage); } @@ -3600,7 +3510,7 @@ err_out: return ui32PhysAddr; } -#endif /* defined(CONFIG_TI_TILER) || defined(CONFIG_DRM_OMAP_DMM_TILER) */ +#endif /* defined(CONFIG_TI_TILER) && defined(CONFIG_DRM_OMAP_DMM_TILER) */ /*! ****************************************************************************** @@ -3613,17 +3523,17 @@ err_out: ******************************************************************************/ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, - IMG_UINT32 ui32Bytes, + IMG_SIZE_T uiBytes, IMG_SYS_PHYADDR *psSysPAddr, IMG_HANDLE *phOSWrapMem) { - IMG_UINT32 ulStartAddrOrig = (IMG_UINT32) pvCPUVAddr; - IMG_UINT32 ulAddrRangeOrig = (IMG_UINT32) ui32Bytes; - IMG_UINT32 ulBeyondEndAddrOrig = ulStartAddrOrig + ulAddrRangeOrig; - IMG_UINT32 ulStartAddr; - IMG_UINT32 ulAddrRange; - IMG_UINT32 ulBeyondEndAddr; - IMG_UINT32 ulAddr; + IMG_UINTPTR_T uStartAddrOrig = (IMG_UINTPTR_T) pvCPUVAddr; + IMG_SIZE_T uAddrRangeOrig = uiBytes; + IMG_UINTPTR_T uBeyondEndAddrOrig = uStartAddrOrig + uAddrRangeOrig; + IMG_UINTPTR_T uStartAddr; + IMG_SIZE_T uAddrRange; + IMG_UINTPTR_T uBeyondEndAddr; + IMG_UINTPTR_T uAddr; IMG_INT i; struct vm_area_struct *psVMArea; sWrapMemInfo *psInfo = NULL; @@ -3633,19 +3543,19 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, PVRSRV_ERROR eError = PVRSRV_ERROR_OUT_OF_MEMORY; /* Align start and end addresses to page boundaries */ - ulStartAddr = ulStartAddrOrig & PAGE_MASK; - ulBeyondEndAddr = PAGE_ALIGN(ulBeyondEndAddrOrig); - ulAddrRange = ulBeyondEndAddr - ulStartAddr; + uStartAddr = uStartAddrOrig & PAGE_MASK; + uBeyondEndAddr = PAGE_ALIGN(uBeyondEndAddrOrig); + uAddrRange = uBeyondEndAddr - uStartAddr; /* * Check for address range calculation overflow, and attempts to wrap * zero bytes. */ - if (ulBeyondEndAddr <= ulStartAddr) + if (uBeyondEndAddr <= uStartAddr) { PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: Invalid address range (start %x, length %x)", - ulStartAddrOrig, ulAddrRangeOrig)); + "OSAcquirePhysPageAddr: Invalid address range (start " UINTPTR_FMT ", length %" SIZE_T_FMT_LEN "x)", + uStartAddrOrig, uAddrRangeOrig)); goto error; } @@ -3660,12 +3570,12 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, memset(psInfo, 0, sizeof(*psInfo)); #if defined(DEBUG) - psInfo->ulStartAddr = ulStartAddrOrig; - psInfo->ulBeyondEndAddr = ulBeyondEndAddrOrig; + psInfo->uStartAddr = uStartAddrOrig; + psInfo->uBeyondEndAddr = uBeyondEndAddrOrig; #endif - psInfo->iNumPages = (IMG_INT)(ulAddrRange >> PAGE_SHIFT); - psInfo->iPageOffset = (IMG_INT)(ulStartAddrOrig & ~PAGE_MASK); + psInfo->iNumPages = (IMG_INT)(uAddrRange >> PAGE_SHIFT); + psInfo->iPageOffset = (IMG_INT)(uStartAddrOrig & ~PAGE_MASK); /* Allocate physical address array */ psInfo->psPhysAddr = kmalloc((size_t)psInfo->iNumPages * sizeof(*psInfo->psPhysAddr), GFP_KERNEL); @@ -3698,7 +3608,7 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, bMMapSemHeld = IMG_TRUE; /* Get page list */ - psInfo->iNumPagesMapped = get_user_pages(current, current->mm, ulStartAddr, psInfo->iNumPages, 1, 0, psInfo->ppsPages, NULL); + psInfo->iNumPagesMapped = get_user_pages(current, current->mm, uStartAddr, psInfo->iNumPages, 1, 0, psInfo->ppsPages, NULL); if (psInfo->iNumPagesMapped >= 0) { @@ -3714,14 +3624,14 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, for (i = 0; i < psInfo->iNumPages; i++) { IMG_CPU_PHYADDR CPUPhysAddr; - IMG_UINT32 ulPFN; + IMG_UINT32 ui32PFN; - ulPFN = page_to_pfn(psInfo->ppsPages[i]); - CPUPhysAddr.uiAddr = ulPFN << PAGE_SHIFT; - if ((CPUPhysAddr.uiAddr >> PAGE_SHIFT) != ulPFN) + ui32PFN = page_to_pfn(psInfo->ppsPages[i]); + CPUPhysAddr.uiAddr = ui32PFN << PAGE_SHIFT; + if ((CPUPhysAddr.uiAddr >> PAGE_SHIFT) != ui32PFN) { PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: Page frame number out of range (%x)", ulPFN)); + "OSAcquirePhysPageAddr: Page frame number out of range (%x)", ui32PFN)); goto error; } @@ -3749,11 +3659,12 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, /* Set the mapping type to aid clean up */ psInfo->eType = WRAP_TYPE_FIND_VMA; - psVMArea = find_vma(current->mm, ulStartAddrOrig); + psVMArea = find_vma(current->mm, uStartAddrOrig); if (psVMArea == NULL) { PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: Couldn't find memory region containing start address %x", ulStartAddrOrig)); + "OSAcquirePhysPageAddr: Couldn't find memory region containing start address " UINTPTR_FMT, + uStartAddrOrig)); goto error; } @@ -3765,27 +3676,24 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, * find_vma locates a region with an end point past a given * virtual address. So check the address is actually in the region. */ - if (ulStartAddrOrig < psVMArea->vm_start) + if (uStartAddrOrig < psVMArea->vm_start) { PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: Start address %x is outside of the region returned by find_vma", ulStartAddrOrig)); + "OSAcquirePhysPageAddr: Start address " UINTPTR_FMT " is outside of the region returned by find_vma", + uStartAddrOrig)); goto error; } /* Now check the end address is in range */ - if (ulBeyondEndAddrOrig > psVMArea->vm_end) + if (uBeyondEndAddrOrig > psVMArea->vm_end) { PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: End address %x is outside of the region returned by find_vma", ulBeyondEndAddrOrig)); + "OSAcquirePhysPageAddr: End address " UINTPTR_FMT " is outside of the region returned by find_vma", uBeyondEndAddrOrig)); goto error; } /* Does the region represent memory mapped I/O? */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - if ((psVMArea->vm_flags & (VM_IO | VM_RESERVED)) != (VM_IO | VM_RESERVED)) -#else - if ((psVMArea->vm_flags & (VM_IO | VM_DONTEXPAND | VM_DONTDUMP)) != (VM_IO | VM_DONTEXPAND | VM_DONTDUMP)) -#endif + if (!(psVMArea->vm_flags & VM_IO)) { PVR_DPF((PVR_DBG_ERROR, "OSAcquirePhysPageAddr: Memory region does not represent memory mapped I/O (VMA flags: 0x%lx)", psVMArea->vm_flags)); @@ -3800,14 +3708,14 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, goto error; } - for (ulAddr = ulStartAddrOrig, i = 0; ulAddr < ulBeyondEndAddrOrig; ulAddr += PAGE_SIZE, i++) + for (uAddr = uStartAddrOrig, i = 0; uAddr < uBeyondEndAddrOrig; uAddr += PAGE_SIZE, i++) { IMG_CPU_PHYADDR CPUPhysAddr; - IMG_UINT32 ulPFN = 0; + IMG_UINT32 ui32PFN = 0; PVR_ASSERT(i < psInfo->iNumPages); - if (!CPUVAddrToPFN(psVMArea, ulAddr, &ulPFN, &psInfo->ppsPages[i])) + if (!CPUVAddrToPFN(psVMArea, uAddr, &ui32PFN, &psInfo->ppsPages[i])) { PVR_DPF((PVR_DBG_ERROR, "OSAcquirePhysPageAddr: Invalid CPU virtual address")); @@ -3818,7 +3726,7 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, { #if defined(CONFIG_TI_TILER) || defined(CONFIG_DRM_OMAP_DMM_TILER) /* This could be tiler memory.*/ - IMG_UINT32 ui32TilerAddr = CPUAddrToTilerPhy(ulAddr); + IMG_UINT32 ui32TilerAddr = CPUAddrToTilerPhy(uAddr); if (ui32TilerAddr) { bHavePageStructs = IMG_TRUE; @@ -3837,14 +3745,14 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, psInfo->iNumPagesMapped++; - PVR_ASSERT(ulPFN == page_to_pfn(psInfo->ppsPages[i])); + PVR_ASSERT(ui32PFN == page_to_pfn(psInfo->ppsPages[i])); } - CPUPhysAddr.uiAddr = ulPFN << PAGE_SHIFT; - if ((CPUPhysAddr.uiAddr >> PAGE_SHIFT) != ulPFN) + CPUPhysAddr.uiAddr = ui32PFN << PAGE_SHIFT; + if ((CPUPhysAddr.uiAddr >> PAGE_SHIFT) != ui32PFN) { PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: Page frame number out of range (%x)", ulPFN)); + "OSAcquirePhysPageAddr: Page frame number out of range (%x)", ui32PFN)); goto error; } @@ -3912,64 +3820,105 @@ error: return eError; } -typedef void (*InnerCacheOp_t)(const void *pvStart, const void *pvEnd); - -#if defined(__arm__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) -typedef void (*OuterCacheOp_t)(phys_addr_t uStart, phys_addr_t uEnd); +#if ! defined(__arm__) +# define USE_VIRTUAL_CACHE_OP +#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) +# define USE_VIRTUAL_CACHE_OP +# if defined(CONFIG_OUTER_CACHE) +# define USE_PHYSICAL_CACHE_OP +# endif #else -typedef void (*OuterCacheOp_t)(unsigned long ulStart, unsigned long ulEnd); +# define USE_PHYSICAL_CACHE_OP #endif -#if defined(CONFIG_OUTER_CACHE) +extern PVRSRV_LINUX_MUTEX g_sMMapMutex; + +/* g_sMMapMutex must be held while this function is called */ +static +IMG_VOID *FindMMapBaseVAddr(struct list_head *psMMapOffsetStructList, + IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) +{ + PKV_OFFSET_STRUCT psOffsetStruct; + IMG_VOID *pvMinVAddr; + + /* There's no kernel-virtual for this type of allocation, so if + * we're flushing it, it must be user-virtual, and therefore + * have a mapping. + */ + list_for_each_entry(psOffsetStruct, psMMapOffsetStructList, sAreaItem) + { + if(OSGetCurrentProcessIDKM() != psOffsetStruct->ui32PID) + continue; + + pvMinVAddr = (IMG_VOID *)psOffsetStruct->uiUserVAddr; + /* Within permissible range */ + if(pvRangeAddrStart >= pvMinVAddr && + ui32Length <= psOffsetStruct->uiRealByteSize) + return pvMinVAddr; + } + + return IMG_NULL; +} + +#if defined(USE_PHYSICAL_CACHE_OP) + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +typedef void (*PhysicalCacheOp_t)(phys_addr_t uStart, phys_addr_t uEnd); +#else +typedef void (*PhysicalCacheOp_t)(unsigned long ulStart, unsigned long ulEnd); +#endif + +/* + Note: use IMG_CPU_PHYADDR to return CPU Phys Addresses, and not just 'unsigned long', + as this is not big enough to hold physical addresses on 32-bit PAE devices. +*/ typedef IMG_BOOL (*MemAreaToPhys_t)(LinuxMemArea *psLinuxMemArea, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32PageNumOffset, - IMG_UINT32 ui32PageNum, - unsigned long *pulStart); + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32PageNumOffset, + IMG_UINT32 ui32PageNum, + IMG_CPU_PHYADDR *psStart); static IMG_BOOL VMallocAreaToPhys(LinuxMemArea *psLinuxMemArea, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32PageNumOffset, - IMG_UINT32 ui32PageNum, - unsigned long *pulStart) + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32PageNumOffset, + IMG_UINT32 ui32PageNum, + IMG_CPU_PHYADDR *psStart) { - *pulStart = vmalloc_to_pfn(pvRangeAddrStart + ui32PageNum * PAGE_SIZE) << PAGE_SHIFT; + psStart->uiAddr = vmalloc_to_pfn(pvRangeAddrStart + ui32PageNum * PAGE_SIZE) << PAGE_SHIFT; return IMG_TRUE; } static IMG_BOOL ExternalKVAreaToPhys(LinuxMemArea *psLinuxMemArea, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32PageNumOffset, - IMG_UINT32 ui32PageNum, - unsigned long *pulStart) + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32PageNumOffset, + IMG_UINT32 ui32PageNum, + IMG_CPU_PHYADDR *psStart) { IMG_SYS_PHYADDR SysPAddr; - IMG_CPU_PHYADDR CpuPAddr; SysPAddr = psLinuxMemArea->uData.sExternalKV.uPhysAddr.pSysPhysAddr[ui32PageNumOffset + ui32PageNum]; - CpuPAddr = SysSysPAddrToCpuPAddr(SysPAddr); - *pulStart = CpuPAddr.uiAddr; + *psStart = SysSysPAddrToCpuPAddr(SysPAddr); return IMG_TRUE; } static IMG_BOOL AllocPagesAreaToPhys(LinuxMemArea *psLinuxMemArea, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32PageNumOffset, - IMG_UINT32 ui32PageNum, - unsigned long *pulStart) + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32PageNumOffset, + IMG_UINT32 ui32PageNum, + IMG_CPU_PHYADDR *psStart) { struct page *pPage; pPage = psLinuxMemArea->uData.sPageList.ppsPageList[ui32PageNumOffset + ui32PageNum]; - *pulStart = page_to_pfn(pPage) << PAGE_SHIFT; + psStart->uiAddr = page_to_pfn(pPage) << PAGE_SHIFT; return IMG_TRUE; } static IMG_BOOL AllocPagesSparseAreaToPhys(LinuxMemArea *psLinuxMemArea, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32PageNumOffset, - IMG_UINT32 ui32PageNum, - unsigned long *pulStart) + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32PageNumOffset, + IMG_UINT32 ui32PageNum, + IMG_CPU_PHYADDR *psStart) { IMG_UINT32 ui32VirtOffset = (ui32PageNumOffset + ui32PageNum) << PAGE_SHIFT; IMG_UINT32 ui32PhysOffset; @@ -3979,82 +3928,80 @@ static IMG_BOOL AllocPagesSparseAreaToPhys(LinuxMemArea *psLinuxMemArea, { PVR_ASSERT(ui32PhysOffset <= ui32VirtOffset); pPage = psLinuxMemArea->uData.sPageList.ppsPageList[ui32PhysOffset >> PAGE_SHIFT]; - *pulStart = page_to_pfn(pPage) << PAGE_SHIFT; + psStart->uiAddr = page_to_pfn(pPage) << PAGE_SHIFT; return IMG_TRUE; } return IMG_FALSE; } - -static IMG_BOOL IONAreaToPhys(LinuxMemArea *psLinuxMemArea, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32PageNumOffset, - IMG_UINT32 ui32PageNum, - unsigned long *pulStart) +static inline void DoPhysicalCacheOp(LinuxMemArea *psLinuxMemArea, + IMG_VOID *pvRangeAddrStart, + IMG_SIZE_T uiLength, + IMG_UINTPTR_T uPageNumOffset, + MemAreaToPhys_t pfnMemAreaToPhys, + PhysicalCacheOp_t pfnPhysicalCacheOp) { - IMG_CPU_PHYADDR CpuPAddr; - CpuPAddr = psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs[ui32PageNumOffset + ui32PageNum]; - *pulStart = CpuPAddr.uiAddr; - return IMG_TRUE; -} - -#endif /* defined(CONFIG_OUTER_CACHE) */ + IMG_CPU_PHYADDR sStart, sEnd; + unsigned long ulLength, ulStartOffset, ulEndOffset; + IMG_UINT32 i, ui32NumPages; + IMG_BOOL bValidPage; -/* g_sMMapMutex must be held while this function is called */ + /* Length and offsets of flush region WRT page alignment */ + ulLength = (unsigned long)uiLength; + ulStartOffset = ((unsigned long)pvRangeAddrStart) & (PAGE_SIZE - 1); + ulEndOffset = ((unsigned long)pvRangeAddrStart + ulLength) & (PAGE_SIZE - 1); -static -IMG_VOID *FindMMapBaseVAddr(struct list_head *psMMapOffsetStructList, - IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) -{ - PKV_OFFSET_STRUCT psOffsetStruct; - IMG_VOID *pvMinVAddr; + /* The affected pages, rounded up */ + ui32NumPages = (ulStartOffset + ulLength + PAGE_SIZE - 1) >> PAGE_SHIFT; - /* There's no kernel-virtual for this type of allocation, so if - * we're flushing it, it must be user-virtual, and therefore - * have a mapping. - */ - list_for_each_entry(psOffsetStruct, psMMapOffsetStructList, sAreaItem) + for(i = 0; i < ui32NumPages; i++) { - if(OSGetCurrentProcessIDKM() != psOffsetStruct->ui32PID) - continue; + bValidPage = pfnMemAreaToPhys(psLinuxMemArea, pvRangeAddrStart, + uPageNumOffset, i, &sStart); + if (bValidPage) + { + sEnd.uiAddr = sStart.uiAddr + PAGE_SIZE; - pvMinVAddr = (IMG_VOID *)psOffsetStruct->ui32UserVAddr; + if(i == ui32NumPages - 1 && ulEndOffset != 0) + sEnd.uiAddr = sStart.uiAddr + ulEndOffset; - /* Within permissible range */ - if(pvRangeAddrStart >= pvMinVAddr && - ui32Length <= psOffsetStruct->ui32RealByteSize) - return pvMinVAddr; - } + if(i == 0) + sStart.uiAddr += ulStartOffset; - return IMG_NULL; + pfnPhysicalCacheOp(sStart.uiAddr, sEnd.uiAddr); + } + } } -extern PVRSRV_LINUX_MUTEX g_sMMapMutex; +#endif /* defined(USE_PHYSICAL_CACHE_OP) */ -static inline void DoInnerCacheOp(IMG_HANDLE hOSMemHandle, - IMG_UINT32 ui32ByteOffset, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32Length, - InnerCacheOp_t pfnInnerCacheOp) +#if defined(USE_VIRTUAL_CACHE_OP) +typedef void (*VirtualCacheOp_t)(const void *pvStart, const void *pvEnd); + +static inline void DoVirtualCacheOp(IMG_HANDLE hOSMemHandle, + IMG_UINT32 ui32ByteOffset, + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32Length, + VirtualCacheOp_t pfnVirtualCacheOp) { LinuxMemArea *psLinuxMemArea = hOSMemHandle; if (!psLinuxMemArea->hBMHandle) { - pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); + pfnVirtualCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); } else { IMG_UINT32 ui32ByteRemain = ui32Length; - IMG_UINT32 ui32BytesToDo = PAGE_SIZE - (((IMG_UINT32) pvRangeAddrStart) & (~PAGE_MASK)); + IMG_UINT32 ui32BytesToDo = PAGE_SIZE - (((IMG_UINTPTR_T) pvRangeAddrStart) & (~PAGE_MASK)); IMG_UINT8 *pbDo = (IMG_UINT8 *) pvRangeAddrStart; while(ui32ByteRemain) { if (BM_MapPageAtOffset(psLinuxMemArea->hBMHandle, ui32ByteOffset + (ui32Length - ui32ByteRemain))) { - pfnInnerCacheOp(pbDo, pbDo + ui32BytesToDo); + pfnVirtualCacheOp(pbDo, pbDo + ui32BytesToDo); } pbDo += ui32BytesToDo; ui32ByteRemain -= ui32BytesToDo; @@ -4062,31 +4009,36 @@ static inline void DoInnerCacheOp(IMG_HANDLE hOSMemHandle, } } } +#endif /* defined(USE_VIRTUAL_CACHE_OP) */ static IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, - IMG_UINT32 ui32ByteOffset, - IMG_VOID *pvRangeAddrStart, - IMG_UINT32 ui32Length, - InnerCacheOp_t pfnInnerCacheOp, - OuterCacheOp_t pfnOuterCacheOp) + IMG_UINT32 ui32ByteOffset, + IMG_VOID *pvVirtRangeStart, + IMG_SIZE_T uiLength +#if defined(USE_VIRTUAL_CACHE_OP) + , VirtualCacheOp_t pfnVirtualCacheOp +#endif +#if defined(USE_PHYSICAL_CACHE_OP) + , PhysicalCacheOp_t pfnPhysicalCacheOp +#endif + ) { LinuxMemArea *psLinuxMemArea = (LinuxMemArea *)hOSMemHandle; - IMG_UINT32 ui32AreaLength, ui32AreaOffset = 0; + IMG_UINTPTR_T uiAreaOffset = 0; struct list_head *psMMapOffsetStructList; IMG_VOID *pvMinVAddr; - -#if defined(CONFIG_OUTER_CACHE) +#if defined(USE_PHYSICAL_CACHE_OP) MemAreaToPhys_t pfnMemAreaToPhys = IMG_NULL; - IMG_UINT32 ui32PageNumOffset = 0; + IMG_UINTPTR_T uPageNumOffset = 0; + IMG_VOID *pvPhysRangeStart = pvVirtRangeStart; #endif PVR_ASSERT(psLinuxMemArea != IMG_NULL); - LinuxLockMutex(&g_sMMapMutex); + LinuxLockMutexNested(&g_sMMapMutex, PVRSRV_LOCK_CLASS_MMAP); psMMapOffsetStructList = &psLinuxMemArea->sMMapOffsetStructList; - ui32AreaLength = psLinuxMemArea->ui32ByteSize; /* Don't check the length in the case of sparse mappings as @@ -4094,12 +4046,12 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, */ if (!psLinuxMemArea->hBMHandle) { - PVR_ASSERT(ui32Length <= ui32AreaLength); + PVR_ASSERT(uiLength <= psLinuxMemArea->uiByteSize); } if(psLinuxMemArea->eAreaType == LINUX_MEM_AREA_SUB_ALLOC) { - ui32AreaOffset = psLinuxMemArea->uData.sSubAlloc.ui32ByteOffset; + uiAreaOffset = psLinuxMemArea->uData.sSubAlloc.uiByteOffset; psLinuxMemArea = psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea; } @@ -4110,19 +4062,13 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, { case LINUX_MEM_AREA_VMALLOC: { - if(is_vmalloc_addr(pvRangeAddrStart)) + if(is_vmalloc_addr(pvVirtRangeStart)) { - pvMinVAddr = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + ui32AreaOffset; + pvMinVAddr = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + uiAreaOffset; /* Outside permissible range */ - if(pvRangeAddrStart < pvMinVAddr) + if(pvVirtRangeStart < pvMinVAddr) goto err_blocked; - - DoInnerCacheOp(hOSMemHandle, - ui32ByteOffset, - pvRangeAddrStart, - ui32Length, - pfnInnerCacheOp); } else { @@ -4132,17 +4078,11 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, */ pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, - pvRangeAddrStart, ui32Length); + pvVirtRangeStart, uiLength); if(!pvMinVAddr) goto err_blocked; - DoInnerCacheOp(hOSMemHandle, - ui32ByteOffset, - pvRangeAddrStart, - ui32Length, - pfnInnerCacheOp); - -#if defined(CONFIG_OUTER_CACHE) +#if defined(USE_PHYSICAL_CACHE_OP) /* * We don't need to worry about cache aliasing here because * we have already flushed the virtually-indexed caches (L1 @@ -4151,14 +4091,10 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, * The vmalloc address will only be used to determine * affected physical pages for outer cache flushing. */ - pvRangeAddrStart = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + - (ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr); - } - - pfnMemAreaToPhys = VMallocAreaToPhys; -#else /* defined(CONFIG_OUTER_CACHE) */ + pvPhysRangeStart = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + + (uiAreaOffset & PAGE_MASK) + (pvVirtRangeStart - pvMinVAddr); +#endif } -#endif /* defined(CONFIG_OUTER_CACHE) */ break; } @@ -4183,111 +4119,80 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, } pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, - pvRangeAddrStart, ui32Length); + pvVirtRangeStart, uiLength); if(!pvMinVAddr) goto err_blocked; - DoInnerCacheOp(hOSMemHandle, - ui32ByteOffset, - pvRangeAddrStart, - ui32Length, - pfnInnerCacheOp); - -#if defined(CONFIG_OUTER_CACHE) - ui32PageNumOffset = ((ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr)) >> PAGE_SHIFT; - pfnMemAreaToPhys = ExternalKVAreaToPhys; -#endif break; } - case LINUX_MEM_AREA_ION: + case LINUX_MEM_AREA_ALLOC_PAGES: { pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, - pvRangeAddrStart, ui32Length); + pvVirtRangeStart, uiLength); if(!pvMinVAddr) goto err_blocked; - DoInnerCacheOp(hOSMemHandle, - ui32ByteOffset, - pvRangeAddrStart, - ui32Length, - pfnInnerCacheOp); + break; + } -#if defined(CONFIG_OUTER_CACHE) - ui32PageNumOffset = ((ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr)) >> PAGE_SHIFT; - pfnMemAreaToPhys = IONAreaToPhys; -#endif + default: + PVR_DBG_BREAK; + goto err_blocked; + } + +#if defined(USE_PHYSICAL_CACHE_OP) + switch(psLinuxMemArea->eAreaType) + { + case LINUX_MEM_AREA_VMALLOC: + { + pfnMemAreaToPhys = VMallocAreaToPhys; break; } - case LINUX_MEM_AREA_ALLOC_PAGES: + case LINUX_MEM_AREA_EXTERNAL_KV: { - pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, - pvRangeAddrStart, ui32Length); - if(!pvMinVAddr) - goto err_blocked; + uPageNumOffset = ((uiAreaOffset & PAGE_MASK) + (pvPhysRangeStart - pvMinVAddr)) >> PAGE_SHIFT; + pfnMemAreaToPhys = ExternalKVAreaToPhys; + break; + } - DoInnerCacheOp(hOSMemHandle, - ui32ByteOffset, - pvRangeAddrStart, - ui32Length, - pfnInnerCacheOp); + case LINUX_MEM_AREA_ALLOC_PAGES: + { + uPageNumOffset = ((uiAreaOffset & PAGE_MASK) + (pvPhysRangeStart - pvMinVAddr)) >> PAGE_SHIFT; -#if defined(CONFIG_OUTER_CACHE) - ui32PageNumOffset = ((ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr)) >> PAGE_SHIFT; if (psLinuxMemArea->hBMHandle) - { pfnMemAreaToPhys = AllocPagesSparseAreaToPhys; - } else - { pfnMemAreaToPhys = AllocPagesAreaToPhys; - } -#endif + break; } default: PVR_DBG_BREAK; } +#endif + +#if defined(USE_VIRTUAL_CACHE_OP) + DoVirtualCacheOp(hOSMemHandle, + ui32ByteOffset, + pvVirtRangeStart, + uiLength, + pfnVirtualCacheOp); +#endif LinuxUnLockMutex(&g_sMMapMutex); -#if defined(CONFIG_OUTER_CACHE) +#if defined(USE_PHYSICAL_CACHE_OP) PVR_ASSERT(pfnMemAreaToPhys != IMG_NULL); - /* Outer caches need some more work, to get a list of physical addresses */ - { - unsigned long ulStart, ulEnd, ulLength, ulStartOffset, ulEndOffset; - IMG_UINT32 i, ui32NumPages; - IMG_BOOL bValidPage; - - /* Length and offsets of flush region WRT page alignment */ - ulLength = (unsigned long)ui32Length; - ulStartOffset = ((unsigned long)pvRangeAddrStart) & (PAGE_SIZE - 1); - ulEndOffset = ((unsigned long)pvRangeAddrStart + ulLength) & (PAGE_SIZE - 1); - - /* The affected pages, rounded up */ - ui32NumPages = (ulStartOffset + ulLength + PAGE_SIZE - 1) >> PAGE_SHIFT; - - for(i = 0; i < ui32NumPages; i++) - { - bValidPage = pfnMemAreaToPhys(psLinuxMemArea, pvRangeAddrStart, - ui32PageNumOffset, i, &ulStart); - if (bValidPage) - { - ulEnd = ulStart + PAGE_SIZE; - - if(i == ui32NumPages - 1 && ulEndOffset != 0) - ulEnd = ulStart + ulEndOffset; - - if(i == 0) - ulStart += ulStartOffset; - - pfnOuterCacheOp(ulStart, ulEnd); - } - } - } + DoPhysicalCacheOp(psLinuxMemArea, + pvPhysRangeStart, + uiLength, + uPageNumOffset, + pfnMemAreaToPhys, + pfnPhysicalCacheOp); #endif return IMG_TRUE; @@ -4295,13 +4200,13 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, err_blocked: PVR_DPF((PVR_DBG_WARNING, "%s: Blocked cache op on virtual range " "%p-%p (type %d)", __func__, - pvRangeAddrStart, pvRangeAddrStart + ui32Length, + pvVirtRangeStart, pvVirtRangeStart + uiLength, psLinuxMemArea->eAreaType)); LinuxUnLockMutex(&g_sMMapMutex); return IMG_FALSE; } -#if defined(__i386__) +#if defined(__i386__) || defined (__x86_64__) #define ROUND_UP(x,a) (((x) + (a) - 1) & ~((a) - 1)) @@ -4346,7 +4251,7 @@ IMG_BOOL OSFlushCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, { /* Write-back and invalidate */ return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, pvRangeAddrStart, ui32Length, - x86_flush_cache_range, IMG_NULL); + x86_flush_cache_range); } IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -4356,7 +4261,7 @@ IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, { /* No clean feature on x86 */ return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, pvRangeAddrStart, ui32Length, - x86_flush_cache_range, IMG_NULL); + x86_flush_cache_range); } IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -4366,12 +4271,10 @@ IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, { /* No invalidate-only support */ return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, pvRangeAddrStart, ui32Length, - x86_flush_cache_range, IMG_NULL); + x86_flush_cache_range); } -#else /* defined(__i386__) */ - -#if defined(__arm__) +#elif defined(__arm__) static void per_cpu_cache_flush(void *arg) { @@ -4411,6 +4314,8 @@ static inline size_t pvr_dmac_range_len(const void *pvStart, const void *pvEnd) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) + static void pvr_dmac_inv_range(const void *pvStart, const void *pvEnd) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) @@ -4429,14 +4334,41 @@ static void pvr_dmac_clean_range(const void *pvStart, const void *pvEnd) #endif } +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */ + +static void pvr_flush_range(phys_addr_t pStart, phys_addr_t pEnd) +{ + arm_dma_ops.sync_single_for_device(NULL, pStart, pEnd - pStart, DMA_TO_DEVICE); + arm_dma_ops.sync_single_for_cpu(NULL, pStart, pEnd - pStart, DMA_FROM_DEVICE); +} + +static void pvr_clean_range(phys_addr_t pStart, phys_addr_t pEnd) +{ + arm_dma_ops.sync_single_for_device(NULL, pStart, pEnd - pStart, DMA_TO_DEVICE); +} + +static void pvr_invalidate_range(phys_addr_t pStart, phys_addr_t pEnd) +{ + arm_dma_ops.sync_single_for_cpu(NULL, pStart, pEnd - pStart, DMA_FROM_DEVICE); +} + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */ + IMG_BOOL OSFlushCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32ByteOffset, IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) { return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, - pvRangeAddrStart, ui32Length, - dmac_flush_range, outer_flush_range); + pvRangeAddrStart, ui32Length, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + pvr_flush_range +#elif defined(CONFIG_OUTER_CACHE) + dmac_flush_range, outer_flush_range +#else + dmac_flush_range +#endif + ); } IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -4445,8 +4377,15 @@ IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Length) { return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, - pvRangeAddrStart, ui32Length, - pvr_dmac_clean_range, outer_clean_range); + pvRangeAddrStart, ui32Length, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + pvr_clean_range +#elif defined(CONFIG_OUTER_CACHE) + pvr_dmac_clean_range, outer_clean_range +#else + pvr_dmac_clean_range +#endif + ); } IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -4455,13 +4394,18 @@ IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Length) { return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, - pvRangeAddrStart, ui32Length, - pvr_dmac_inv_range, outer_inv_range); + pvRangeAddrStart, ui32Length, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + pvr_invalidate_range +#elif defined(CONFIG_OUTER_CACHE) + pvr_dmac_inv_range, outer_inv_range +#else + pvr_dmac_inv_range +#endif + ); } -#else /* defined(__arm__) */ - -#if defined(__mips__) +#elif defined(__mips__) /* * dmac cache functions are supposed to be used for dma * memory which comes from dma-able memory. However examining @@ -4524,7 +4468,7 @@ IMG_BOOL OSFlushCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, { return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, pvRangeAddrStart, ui32Length, - pvr_dma_cache_wback_inv, IMG_NULL); + pvr_dma_cache_wback_inv); } IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -4534,7 +4478,7 @@ IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, { return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, pvRangeAddrStart, ui32Length, - pvr_dma_cache_wback, IMG_NULL); + pvr_dma_cache_wback); } IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -4544,18 +4488,14 @@ IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, { return CheckExecuteCacheOp(hOSMemHandle, ui32ByteOffset, pvRangeAddrStart, ui32Length, - pvr_dma_cache_inv, IMG_NULL); + pvr_dma_cache_inv); } -#else /* defined(__mips__) */ +#else #error "Implement CPU cache flush/clean/invalidate primitives for this CPU!" -#endif /* defined(__mips__) */ - -#endif /* defined(__arm__) */ - -#endif /* defined(__i386__) */ +#endif typedef struct _AtomicStruct { @@ -4613,7 +4553,7 @@ IMG_VOID OSReleaseBridgeLock(IMG_VOID) IMG_VOID OSReacquireBridgeLock(IMG_VOID) { - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); } typedef struct _OSTime @@ -4631,7 +4571,7 @@ PVRSRV_ERROR OSTimeCreateWithUSOffset(IMG_PVOID *pvRet, IMG_UINT32 ui32USOffset) return PVRSRV_ERROR_OUT_OF_MEMORY; } - psOSTime->ulTime = usecs_to_jiffies(jiffies_to_usecs(jiffies) + ui32USOffset); + psOSTime->ulTime = jiffies + usecs_to_jiffies(ui32USOffset); *pvRet = psOSTime; return PVRSRV_OK; } diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c b/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c index a22b4614993..3485d8ae61c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/osperproc.c @@ -43,12 +43,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "osperproc.h" #include "env_perproc.h" -#include "proc.h" -#if defined (SUPPORT_ION) -#include "linux/ion.h" -extern struct ion_device *psIonDev; +#if defined (SUPPORT_ION) +#include <linux/err.h> +#include "ion.h" +extern struct ion_device *gpsIonDev; #endif + extern IMG_UINT32 gui32ReleasePID; PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData) @@ -83,12 +84,11 @@ PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData) /* Linked list of PVRSRV_FILE_PRIVATE_DATA structures */ INIT_LIST_HEAD(&psEnvPerProc->sDRMAuthListHead); #endif + #if defined(SUPPORT_ION) OSSNPrintf(psEnvPerProc->azIonClientName, ION_CLIENT_NAME_SIZE, "pvr_ion_client-%d", OSGetCurrentProcessIDKM()); psEnvPerProc->psIONClient = - ion_client_create(psIonDev, - 1 << ION_HEAP_TYPE_SYSTEM_CONTIG | - 1 << ION_HEAP_TYPE_SYSTEM, + ion_client_create(gpsIonDev, psEnvPerProc->azIonClientName); if (IS_ERR_OR_NULL(psEnvPerProc->psIONClient)) @@ -97,7 +97,8 @@ PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData) "ion client for per process data")); return PVRSRV_ERROR_OUT_OF_MEMORY; } -#endif /* SUPPORT_ION */ +#endif /* defined(SUPPORT_ION) */ + return PVRSRV_OK; } diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pdump.c b/drivers/gpu/pvr/services4/srvkm/env/linux/pdump.c index 01247374185..548e8dce0f7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/pdump.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pdump.c @@ -62,6 +62,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/kernel.h> // sprintf #include <linux/string.h> // strncpy, strlen +#include <linux/mutex.h> static IMG_BOOL PDumpWriteString2 (IMG_CHAR * pszString, IMG_UINT32 ui32Flags); static IMG_BOOL PDumpWriteILock (PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32Count, IMG_UINT32 ui32Flags); @@ -80,7 +81,8 @@ static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); static PDBGKM_SERVICE_TABLE gpfnDbgDrv = IMG_NULL; - +DEFINE_MUTEX(sPDumpLock); +DEFINE_MUTEX(sPDumpMsgLock); IMG_CHAR *pszStreamName[PDUMP_NUM_STREAMS] = { "ParamStream2", "ScriptStream2", @@ -391,7 +393,7 @@ IMG_VOID PDumpOSCPUVAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Offset, IMG_PUINT8 pui8LinAddr, - IMG_UINT32 ui32DataPageMask, + IMG_UINTPTR_T ui32DataPageMask, IMG_UINT32 *pui32PageOffset) { if(hOSMemHandle) @@ -411,7 +413,7 @@ IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, PVR_UNREFERENCED_PARAMETER(hOSMemHandle); PVR_UNREFERENCED_PARAMETER(ui32Offset); - *pui32PageOffset = ((IMG_UINT32)pui8LinAddr & ui32DataPageMask); + *pui32PageOffset = ((IMG_UINTPTR_T)pui8LinAddr & ui32DataPageMask); } } @@ -724,7 +726,7 @@ static IMG_BOOL PDumpWriteILock(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_U IMG_UINT32 ui32Written = 0; if ((psStream == IMG_NULL) || PDumpSuspended() || ((ui32Flags & PDUMP_FLAGS_NEVER) != 0)) { - PVR_DPF((PVR_DBG_MESSAGE, "PDumpWriteILock: Failed to write 0x%x bytes to stream 0x%x", ui32Count, (IMG_UINT32)psStream)); + PVR_DPF((PVR_DBG_MESSAGE, "PDumpWriteILock: Failed to write 0x%x bytes to stream 0x%p", ui32Count, psStream)); return IMG_TRUE; } @@ -797,6 +799,55 @@ IMG_VOID PDumpResumeKM(IMG_VOID) atomic_dec(&gsPDumpSuspended); } +/* Set to 1 if you want to debug PDump locking issues */ +#define DEBUG_PDUMP_LOCKS 0 + +#if DEBUG_PDUMP_LOCKS +static IMG_UINT32 ui32Count=0; +static IMG_UINT32 aui32LockLine[2] = {0}; +static IMG_UINT32 aui32UnlockLine[2] = {0}; +static IMG_UINT32 ui32LockLineCount = 0; +static IMG_UINT32 ui32UnlockLineCount = 0; +#endif + +IMG_VOID PDumpOSLock(IMG_UINT32 ui32Line) +{ +#if DEBUG_PDUMP_LOCKS + aui32LockLine[ui32LockLineCount++ % 2] = ui32Line; + ui32Count++; + if (ui32Count == 2) + { + IMG_UINT32 i; + printk(KERN_ERR "Double lock\n"); + dump_stack(); + for (i=0;i<2;i++) + { + printk(KERN_ERR "Lock[%d] = %d, Unlock[%d] = %d\n", i, aui32LockLine[i],i, aui32UnlockLine[i]); + } + } +#endif + mutex_lock(&sPDumpLock); +} + +IMG_VOID PDumpOSUnlock(IMG_UINT32 ui32Line) +{ + mutex_unlock(&sPDumpLock); +#if DEBUG_PDUMP_LOCKS + aui32UnlockLine[ui32UnlockLineCount++ % 2] = ui32Line; + ui32Count--; +#endif +} + +IMG_VOID PDumpOSLockMessageBuffer(IMG_VOID) +{ + mutex_lock(&sPDumpMsgLock); +} + +IMG_VOID PDumpOSUnlockMessageBuffer(IMG_VOID) +{ + mutex_unlock(&sPDumpMsgLock); +} + #endif /* #if defined (PDUMP) */ #endif /* #if defined (SUPPORT_SGX) */ /***************************************************************************** diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/private_data.h b/drivers/gpu/pvr/services4/srvkm/env/linux/private_data.h index 6b097052ba4..e2a6c74d35d 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/private_data.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/private_data.h @@ -64,11 +64,7 @@ typedef struct IMG_UINT32 ui32OpenPID; /* Global kernel MemInfo handle */ -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hKernelMemInfo; -#else IMG_HANDLE hKernelMemInfo; -#endif #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) /* The private data is on a list in the per-process data structure */ diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/proc.c b/drivers/gpu/pvr/services4/srvkm/env/linux/proc.c index 4a6e2fedc42..788757ba2a4 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/proc.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/proc.c @@ -52,11 +52,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/init.h> #include <linux/module.h> -#include <linux/mm.h> #include <linux/fs.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> -#include <linux/sched.h> #include "services_headers.h" @@ -72,16 +70,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lists.h" +struct pvr_proc_dir_entry { + struct proc_dir_entry *pde; + + pvr_next_proc_seq_t *next; + pvr_show_proc_seq_t *show; + pvr_off2element_proc_seq_t *off2element; + pvr_startstop_proc_seq_t *startstop; + + pvr_proc_write_t *write; + + IMG_VOID *data; +}; + // The proc entry for our /proc/pvr directory static struct proc_dir_entry * dir; static const IMG_CHAR PVRProcDirRoot[] = "pvr"; static IMG_INT pvr_proc_open(struct inode *inode,struct file *file); -static void *pvr_proc_seq_start (struct seq_file *m, loff_t *pos); -static void pvr_proc_seq_stop (struct seq_file *m, void *v); -static void *pvr_proc_seq_next (struct seq_file *m, void *v, loff_t *pos); -static int pvr_proc_seq_show (struct seq_file *m, void *v); static ssize_t pvr_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos); static struct file_operations pvr_proc_operations = @@ -93,17 +100,10 @@ static struct file_operations pvr_proc_operations = .release = seq_release, }; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) -static ssize_t pvr_proc_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos); -static struct file_operations pvr_read_proc_operations = -{ - .open = pvr_proc_open, - .read = pvr_proc_read, - .write = pvr_proc_write, - .llseek = seq_lseek, - .release = seq_release, -}; -#endif +static void *pvr_proc_seq_start (struct seq_file *m, loff_t *pos); +static void *pvr_proc_seq_next (struct seq_file *m, void *v, loff_t *pos); +static void pvr_proc_seq_stop (struct seq_file *m, void *v); +static int pvr_proc_seq_show (struct seq_file *m, void *v); static struct seq_operations pvr_proc_seq_operations = { @@ -113,16 +113,18 @@ static struct seq_operations pvr_proc_seq_operations = .show = pvr_proc_seq_show, }; -static struct proc_dir_entry* g_pProcQueue; -static struct proc_dir_entry* g_pProcVersion; -static struct proc_dir_entry* g_pProcSysNodes; +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) +static struct pvr_proc_dir_entry* g_pProcQueue; +#endif +static struct pvr_proc_dir_entry* g_pProcVersion; +static struct pvr_proc_dir_entry* g_pProcSysNodes; #ifdef DEBUG -static struct proc_dir_entry* g_pProcDebugLevel; +static struct pvr_proc_dir_entry* g_pProcDebugLevel; #endif #ifdef PVR_MANUAL_POWER_CONTROL -static struct proc_dir_entry* g_pProcPowerLevel; +static struct pvr_proc_dir_entry* g_pProcPowerLevel; #endif @@ -131,55 +133,12 @@ static void ProcSeqShowVersion(struct seq_file *sfile,void* el); static void ProcSeqShowSysNodes(struct seq_file *sfile,void* el); static void* ProcSeqOff2ElementSysNodes(struct seq_file * sfile, loff_t off); -/*! -****************************************************************************** - - @Function : printAppend - - @Description - - Print into the supplied buffer at the specified offset remaining within - the specified total buffer size. - @Input size : the total size of the buffer - - @Input off : the offset into the buffer to start printing - - @Input format : the printf format string - - @Input ... : format args - - @Return : The number of chars now in the buffer (original value of 'off' - plus number of chars added); 'size' if full. - -*****************************************************************************/ -off_t printAppend(IMG_CHAR * buffer, size_t size, off_t off, const IMG_CHAR * format, ...) -{ - IMG_INT n; - size_t space = size - (size_t)off; - va_list ap; - - va_start (ap, format); - - n = vsnprintf (buffer+off, space, format, ap); - - va_end (ap); - /* According to POSIX, n is greater than or equal to the size available if - * the print would have overflowed the buffer. Other platforms may - * return -1 if printing was truncated. - */ - if (n >= (IMG_INT)space || n < 0) - { - /* Ensure final string is terminated */ - buffer[size - 1] = 0; - return (off_t)(size - 1); - } - else - { - return (off + (off_t)n); - } -} +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) +#define PDE_DATA(x) PDE(x)->data; +#endif +#ifdef DEBUG /*! ****************************************************************************** @@ -198,7 +157,7 @@ off_t printAppend(IMG_CHAR * buffer, size_t size, off_t off, const IMG_CHAR * fo @Return : Pointer to element to be shown. *****************************************************************************/ -void* ProcSeq1ElementOff2Element(struct seq_file *sfile, loff_t off) +static void* ProcSeq1ElementOff2Element(struct seq_file *sfile, loff_t off) { PVR_UNREFERENCED_PARAMETER(sfile); // Return anything that is not PVR_RPOC_SEQ_START_TOKEN and NULL @@ -207,6 +166,7 @@ void* ProcSeq1ElementOff2Element(struct seq_file *sfile, loff_t off) return NULL; } +#endif /*! ****************************************************************************** @@ -225,7 +185,7 @@ void* ProcSeq1ElementOff2Element(struct seq_file *sfile, loff_t off) @Return : Pointer to element to be shown. *****************************************************************************/ -void* ProcSeq1ElementHeaderOff2Element(struct seq_file *sfile, loff_t off) +static void* ProcSeq1ElementHeaderOff2Element(struct seq_file *sfile, loff_t off) { PVR_UNREFERENCED_PARAMETER(sfile); @@ -263,15 +223,10 @@ static IMG_INT pvr_proc_open(struct inode *inode,struct file *file) IMG_INT ret = seq_open(file, &pvr_proc_seq_operations); struct seq_file *seq = (struct seq_file*)file->private_data; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - struct proc_dir_entry* pvr_proc_entry = PDE(inode); + struct pvr_proc_dir_entry* ppde = PDE_DATA(inode); /* Add pointer to handlers to seq_file structure */ - seq->private = pvr_proc_entry->data; -#else - PVR_PROC_SEQ_HANDLERS *data = (PVR_PROC_SEQ_HANDLERS *)PDE_DATA(inode); - seq->private = data; -#endif + seq->private = ppde; return ret; } @@ -290,23 +245,15 @@ static ssize_t pvr_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { struct inode *inode = file->f_path.dentry->d_inode; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - struct proc_dir_entry * dp; + struct pvr_proc_dir_entry * ppde; PVR_UNREFERENCED_PARAMETER(ppos); - dp = PDE(inode); + ppde = PDE_DATA(inode); - if (!dp->write_proc) + if (!ppde->write) return -EIO; - return dp->write_proc(file, buffer, count, dp->data); -#else - PVR_PROC_SEQ_HANDLERS *data = (PVR_PROC_SEQ_HANDLERS *)PDE_DATA(inode); - PVR_UNREFERENCED_PARAMETER(ppos); - if (!data->write_proc) - return -EIO; - return data->write_proc(file, buffer, count, data); -#endif + return ppde->write(file, buffer, count, ppde->data); } @@ -329,10 +276,10 @@ static ssize_t pvr_proc_write(struct file *file, const char __user *buffer, *****************************************************************************/ static void *pvr_proc_seq_start (struct seq_file *proc_seq_file, loff_t *pos) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)proc_seq_file->private; - if(handlers->startstop != NULL) - handlers->startstop(proc_seq_file, IMG_TRUE); - return handlers->off2element(proc_seq_file, *pos); + struct pvr_proc_dir_entry *ppde = (struct pvr_proc_dir_entry*)proc_seq_file->private; + if(ppde->startstop != NULL) + ppde->startstop(proc_seq_file, IMG_TRUE); + return ppde->off2element(proc_seq_file, *pos); } /*! @@ -351,11 +298,11 @@ static void *pvr_proc_seq_start (struct seq_file *proc_seq_file, loff_t *pos) *****************************************************************************/ static void pvr_proc_seq_stop (struct seq_file *proc_seq_file, void *v) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)proc_seq_file->private; + struct pvr_proc_dir_entry *ppde = (struct pvr_proc_dir_entry*)proc_seq_file->private; PVR_UNREFERENCED_PARAMETER(v); - if(handlers->startstop != NULL) - handlers->startstop(proc_seq_file, IMG_FALSE); + if(ppde->startstop != NULL) + ppde->startstop(proc_seq_file, IMG_FALSE); } /*! @@ -379,11 +326,11 @@ static void pvr_proc_seq_stop (struct seq_file *proc_seq_file, void *v) *****************************************************************************/ static void *pvr_proc_seq_next (struct seq_file *proc_seq_file, void *v, loff_t *pos) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)proc_seq_file->private; + struct pvr_proc_dir_entry *ppde = (struct pvr_proc_dir_entry*)proc_seq_file->private; (*pos)++; - if( handlers->next != NULL) - return handlers->next( proc_seq_file, v, *pos ); - return handlers->off2element(proc_seq_file, *pos); + if(ppde->next != NULL) + return ppde->next( proc_seq_file, v, *pos ); + return ppde->off2element(proc_seq_file, *pos); } /*! @@ -405,9 +352,9 @@ static void *pvr_proc_seq_next (struct seq_file *proc_seq_file, void *v, loff_t *****************************************************************************/ static int pvr_proc_seq_show (struct seq_file *proc_seq_file, void *v) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)proc_seq_file->private; - handlers->show( proc_seq_file,v ); - return 0; + struct pvr_proc_dir_entry *ppde = (struct pvr_proc_dir_entry*)proc_seq_file->private; + ppde->show( proc_seq_file,v ); + return 0; } @@ -444,90 +391,60 @@ static int pvr_proc_seq_show (struct seq_file *proc_seq_file, void *v) *****************************************************************************/ -static struct proc_dir_entry* CreateProcEntryInDirSeq( - struct proc_dir_entry *pdir, - const IMG_CHAR * name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler, - write_proc_t whandler - ) +static struct pvr_proc_dir_entry* CreateProcEntryInDirSeq(struct proc_dir_entry *pdir, + const IMG_CHAR * name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler, + pvr_proc_write_t whandler) { - struct proc_dir_entry * file; + struct pvr_proc_dir_entry * ppde; mode_t mode; - if (!dir) - { - PVR_DPF((PVR_DBG_ERROR, "CreateProcEntryInDirSeq: cannot make proc entry /proc/%s/%s: no parent", PVRProcDirRoot, name)); - return NULL; - } + if (!dir) + { + PVR_DPF((PVR_DBG_ERROR, "CreateProcEntryInDirSeq: cannot make proc entry /proc/%s/%s: no parent", PVRProcDirRoot, name)); + return NULL; + } mode = S_IFREG; - if (show_handler) - { + if (show_handler) + { mode |= S_IRUGO; - } + } - if (whandler) - { + if (whandler) + { mode |= S_IWUSR; - } - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - file=create_proc_entry(name, mode, pdir); - - if (file) - { - PVR_PROC_SEQ_HANDLERS *seq_handlers; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - file->owner = THIS_MODULE; -#endif + } - file->proc_fops = &pvr_proc_operations; - file->write_proc = whandler; + ppde = kmalloc(sizeof(struct pvr_proc_dir_entry), GFP_KERNEL); + if (!ppde) + { + PVR_DPF((PVR_DBG_ERROR, "CreateProcEntryInDirSeq: cannot make proc entry /proc/%s/%s: no memory", PVRProcDirRoot, name)); + return NULL; + } + + ppde->next = next_handler; + ppde->show = show_handler; + ppde->off2element = off2element_handler; + ppde->startstop = startstop_handler; + ppde->write = whandler; + ppde->data = data; - /* Pass the handlers */ - file->data = kmalloc(sizeof(PVR_PROC_SEQ_HANDLERS), GFP_KERNEL); - if(file->data) - { - seq_handlers = (PVR_PROC_SEQ_HANDLERS*)file->data; - seq_handlers->next = next_handler; - seq_handlers->show = show_handler; - seq_handlers->off2element = off2element_handler; - seq_handlers->startstop = startstop_handler; - seq_handlers->data = data; + ppde->pde=proc_create_data(name, mode, pdir, &pvr_proc_operations, ppde); - return file; - } - } -#else - /* Pass the handlers */ + if (!ppde->pde) { - PVR_PROC_SEQ_HANDLERS *seq_handlers; - seq_handlers = (PVR_PROC_SEQ_HANDLERS *)kmalloc(sizeof(PVR_PROC_SEQ_HANDLERS), GFP_KERNEL); - if (seq_handlers) - { - seq_handlers->next = next_handler; - seq_handlers->show = show_handler; - seq_handlers->off2element = off2element_handler; - seq_handlers->startstop = startstop_handler; - seq_handlers->data = data; - seq_handlers->write_proc = whandler; - file = proc_create_data(name, mode, pdir, &pvr_proc_operations,seq_handlers); - if (file) - return file; - kfree(seq_handlers); - } + PVR_DPF((PVR_DBG_ERROR, "CreateProcEntryInDirSeq: cannot make proc entry /proc/%s/%s: proc_create_data failed", PVRProcDirRoot, name)); + kfree(ppde); + return NULL; } -#endif - - PVR_DPF((PVR_DBG_ERROR, "CreateProcEntryInDirSeq: cannot make proc entry /proc/%s/%s: no memory", PVRProcDirRoot, name)); - return NULL; + return ppde; } @@ -560,22 +477,20 @@ static struct proc_dir_entry* CreateProcEntryInDirSeq( @Return Ptr to proc entry , 0 for failure *****************************************************************************/ -struct proc_dir_entry* CreateProcReadEntrySeq ( - const IMG_CHAR * name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler - ) +struct pvr_proc_dir_entry* CreateProcReadEntrySeq (const IMG_CHAR * name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler) { return CreateProcEntrySeq(name, - data, - next_handler, - show_handler, - off2element_handler, - startstop_handler, - NULL); + data, + next_handler, + show_handler, + off2element_handler, + startstop_handler, + NULL); } /*! @@ -612,26 +527,22 @@ struct proc_dir_entry* CreateProcReadEntrySeq ( @Return Ptr to proc entry , 0 for failure *****************************************************************************/ -struct proc_dir_entry* CreateProcEntrySeq ( - const IMG_CHAR * name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler, - write_proc_t whandler - ) +struct pvr_proc_dir_entry* CreateProcEntrySeq (const IMG_CHAR * name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler, + pvr_proc_write_t whandler) { - return CreateProcEntryInDirSeq( - dir, - name, - data, - next_handler, - show_handler, - off2element_handler, - startstop_handler, - whandler - ); + return CreateProcEntryInDirSeq(dir, + name, + data, + next_handler, + show_handler, + off2element_handler, + startstop_handler, + whandler); } @@ -667,15 +578,13 @@ struct proc_dir_entry* CreateProcEntrySeq ( @Return Ptr to proc entry , 0 for failure *****************************************************************************/ -struct proc_dir_entry* CreatePerProcessProcEntrySeq ( - const IMG_CHAR * name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler, - write_proc_t whandler - ) +struct pvr_proc_dir_entry* CreatePerProcessProcEntrySeq (const IMG_CHAR * name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler, + pvr_proc_write_t whandler) { PVRSRV_ENV_PER_PROCESS_DATA *psPerProc; IMG_UINT32 ui32PID; @@ -692,444 +601,35 @@ struct proc_dir_entry* CreatePerProcessProcEntrySeq ( if (!psPerProc) { PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntrySeq: no per process data")); - return NULL; } if (!psPerProc->psProcDir) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - IMG_CHAR dirname_buffer[256]; - IMG_CHAR dirname[256]; - IMG_INT ret; - const IMG_CHAR *proc_basename = dirname_buffer; - dirname_buffer[255] = dirname[255] = '\0'; - - OSGetProcCmdline(ui32PID, dirname_buffer, sizeof(dirname_buffer)); - PVR_DPF((PVR_DBG_MESSAGE, "Command Line of the process with ID %u is %s", ui32PID, dirname_buffer)); - - proc_basename = OSGetPathBaseName(dirname_buffer, sizeof(dirname_buffer)); - PVR_DPF((PVR_DBG_MESSAGE, "Base Name of the process with ID %u is %s\n", ui32PID, proc_basename)); - - ret = snprintf(dirname, sizeof(dirname), "%u-%s", ui32PID, proc_basename); - PVR_DPF((PVR_DBG_MESSAGE, "Creating a new process entry for %s with ID %u\n", proc_basename, ui32PID)); -#else IMG_CHAR dirname[16]; IMG_INT ret; ret = snprintf(dirname, sizeof(dirname), "%u", ui32PID); -#endif - - if (ret <=0 || ret >= (IMG_INT)sizeof(dirname)) - { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: couldn't generate per process proc directory name \"%u\"", ui32PID)); - return NULL; - } - else - { - psPerProc->psProcDir = proc_mkdir(dirname, dir); - if (!psPerProc->psProcDir) - { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: couldn't create per process proc directory /proc/%s/%u", - PVRProcDirRoot, ui32PID)); - return NULL; - } - } - } - - return CreateProcEntryInDirSeq(psPerProc->psProcDir, name, data, next_handler, - show_handler,off2element_handler,startstop_handler,whandler); -} - - -/*! -****************************************************************************** - - @Function : RemoveProcEntrySeq - - @Description - - Remove a single node (created using *Seq function) under /proc/pvr. - - @Input proc_entry : structure returned by Create function. - @Return nothing - -*****************************************************************************/ -IMG_VOID RemoveProcEntrySeq( struct proc_dir_entry* proc_entry ) -{ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - if (dir) - { - void* data = proc_entry->data ; - PVR_DPF((PVR_DBG_MESSAGE, "Removing /proc/%s/%s", PVRProcDirRoot, proc_entry->name)); - - remove_proc_entry(proc_entry->name, dir); - if( data) - kfree( data ); - - } -#endif -} - -/*! -****************************************************************************** - - @Function : RemovePerProcessProcEntry Seq - - @Description - - Remove a single node under the per process proc directory (created by *Seq function). - - Remove a single node (created using *Seq function) under /proc/pvr. - - @Input proc_entry : structure returned by Create function. - - @Return nothing - -*****************************************************************************/ -IMG_VOID RemovePerProcessProcEntrySeq(struct proc_dir_entry* proc_entry) -{ - PVRSRV_ENV_PER_PROCESS_DATA *psPerProc; - - psPerProc = LinuxTerminatingProcessPrivateData(); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - if (!psPerProc) - { - psPerProc = PVRSRVFindPerProcessPrivateData(); - if (!psPerProc) + if (ret <=0 || ret >= (IMG_INT)sizeof(dirname)) { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: can't " - "remove %s, no per process data", proc_entry->name)); - return; + PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: couldn't generate per process proc directory name \"%u\"", ui32PID)); + return NULL; } - } - - if (psPerProc->psProcDir) - { - void* data = proc_entry->data ; - PVR_DPF((PVR_DBG_MESSAGE, "Removing proc entry %s from %s", proc_entry->name, psPerProc->psProcDir->name)); - - remove_proc_entry(proc_entry->name, psPerProc->psProcDir); - if(data) - kfree( data ); - } -#endif -} - -/*! -****************************************************************************** - - @Function : pvr_read_proc_vm - - @Description - - When the user accesses the proc filesystem entry for the device, we are - called here to create the content for the 'file'. We can print anything we - want here. If the info we want to return is too big for one page ('count' - chars), we return successive chunks on each call. For a number of ways of - achieving this, refer to proc_file_read() in linux/fs/proc/generic.c. - - Here, as we are accessing lists of information, we output '1' in '*start' to - instruct proc to advance 'off' by 1 on each call. The number of chars placed - in the buffer is returned. Multiple calls are made here by the proc - filesystem until we set *eof. We can return zero without setting eof to - instruct proc to flush 'page' (causing it to be printed) if there is not - enough space left (eg for a complete line). - - @Input page : where to write the output - - @Input start : memory location into which should be written next offset - to read from. - - @Input off : the offset into the /proc file being read - - @Input count : the size of the buffer 'page' - - @Input eof : memory location into which 1 should be written when at EOF - - @Input data : data specific to this /proc file entry - - @Return : length of string written to page - -*****************************************************************************/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) -static IMG_INT pvr_read_proc(IMG_CHAR *page, IMG_CHAR **start, off_t off, - IMG_INT count, IMG_INT *eof, IMG_VOID *data) -{ - /* PRQA S 0307 1 */ /* ignore warning about casting to different pointer type */ - pvr_read_proc_t *pprn = (pvr_read_proc_t *)data; - - off_t len = pprn (page, (size_t)count, off); - - if (len == END_OF_FILE) - { - len = 0; - *eof = 1; - } - else if (!len) /* not enough space in the buffer */ - { - *start = (IMG_CHAR *) 0; /* don't advance the offset */ - } - else - { - *start = (IMG_CHAR *) 1; - } - - return len; -} -#else -static ssize_t pvr_proc_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) -{ - struct inode *inode = file->f_path.dentry->d_inode; - PVR_PROC_SEQ_HANDLERS *data = (PVR_PROC_SEQ_HANDLERS *)PDE_DATA(inode); - PVR_UNREFERENCED_PARAMETER(ppos); - if (!data->read_proc) - return -EIO; - return -EIO; - -} -#endif - - -/*! -****************************************************************************** - - @Function : CreateProcEntryInDir - - @Description - - Create a file under the given directory. These dynamic files can be used at - runtime to get or set information about the device. - - @Input pdir : parent directory - - @Input name : the name of the file to create - - @Input rhandler : the function to supply the content - - @Input whandler : the function to interpret writes from the user - - @Return success code : 0 or -errno. - -*****************************************************************************/ -static IMG_INT CreateProcEntryInDir(struct proc_dir_entry *pdir, const IMG_CHAR * name, read_proc_t rhandler, write_proc_t whandler, IMG_VOID *data) -{ - struct proc_dir_entry * file; - mode_t mode; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) - PVR_PROC_SEQ_HANDLERS *handlers; -#endif - - if (!pdir) - { - PVR_DPF((PVR_DBG_ERROR, "CreateProcEntryInDir: parent directory doesn't exist")); - - return -ENOMEM; - } - - mode = S_IFREG; - - if (rhandler) - { - mode |= S_IRUGO; - } - - if (whandler) - { - mode |= S_IWUSR; - } - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - file = create_proc_entry(name, mode, pdir); - - if (file) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - file->owner = THIS_MODULE; -#endif - file->read_proc = rhandler; - file->write_proc = whandler; - file->data = data; - - PVR_DPF((PVR_DBG_MESSAGE, "Created proc entry %s in %s", name, pdir->name)); - - return 0; - } - - PVR_DPF((PVR_DBG_ERROR, "CreateProcEntry: cannot create proc entry %s in %s", name, pdir->name)); -#else - handlers = (PVR_PROC_SEQ_HANDLERS *)kmalloc(sizeof(PVR_PROC_SEQ_HANDLERS), GFP_KERNEL); - if (handlers) - { - handlers->data = data; - handlers->read_proc = rhandler; - handlers->write_proc = whandler; - file = proc_create_data(name, mode, pdir, &pvr_read_proc_operations, handlers); - if (file) - { - PVR_DPF((PVR_DBG_MESSAGE, "Created proc entry %s in %s", name, "?" /*pdir->name*/)); - return 0; - } - kfree (handlers); + else + { + psPerProc->psProcDir = proc_mkdir(dirname, dir); + if (!psPerProc->psProcDir) + { + PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: couldn't create per process proc directory /proc/%s/%u", + PVRProcDirRoot, ui32PID)); + return NULL; + } } - PVR_DPF((PVR_DBG_ERROR, "CreateProcEntry: cannot create proc entry %s in %s", name, "?" /*pdir->name*/)); -#endif - - return -ENOMEM; -} - - -/*! -****************************************************************************** - - @Function : CreateProcEntry - - @Description - - Create a file under /proc/pvr. These dynamic files can be used at runtime - to get or set information about the device. - - This interface is fuller than CreateProcReadEntry, and supports write access; - it is really just a wrapper for the native linux functions. - - @Input name : the name of the file to create under /proc/pvr - - @Input rhandler : the function to supply the content - - @Input whandler : the function to interpret writes from the user - - @Return success code : 0 or -errno. - -*****************************************************************************/ -IMG_INT CreateProcEntry(const IMG_CHAR * name, read_proc_t rhandler, write_proc_t whandler, IMG_VOID *data) -{ - return CreateProcEntryInDir(dir, name, rhandler, whandler, data); -} - - -/*! -****************************************************************************** - - @Function : CreatePerProcessProcEntry - - @Description - - Create a file under /proc/pvr/<current process ID>. Apart from the - directory where the file is created, this works the same way as - CreateProcEntry. - - @Input name : the name of the file to create under the per process /proc directory - - @Input rhandler : the function to supply the content - - @Input whandler : the function to interpret writes from the user - - @Return success code : 0 or -errno. - -*****************************************************************************/ -IMG_INT CreatePerProcessProcEntry(const IMG_CHAR * name, read_proc_t rhandler, write_proc_t whandler, IMG_VOID *data) -{ - PVRSRV_ENV_PER_PROCESS_DATA *psPerProc; - IMG_UINT32 ui32PID; - - if (!dir) - { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: /proc/%s doesn't exist", PVRProcDirRoot)); - - return -ENOMEM; - } - - ui32PID = OSGetCurrentProcessIDKM(); - - psPerProc = PVRSRVPerProcessPrivateData(ui32PID); - if (!psPerProc) - { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: no per process data")); - - return -ENOMEM; - } - - if (!psPerProc->psProcDir) - { - IMG_CHAR dirname[16]; - IMG_INT ret; - - ret = snprintf(dirname, sizeof(dirname), "%u", ui32PID); - - if (ret <=0 || ret >= (IMG_INT)sizeof(dirname)) - { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: couldn't generate per process proc directory name \"%u\"", ui32PID)); - - return -ENOMEM; - } - else - { - psPerProc->psProcDir = proc_mkdir(dirname, dir); - if (!psPerProc->psProcDir) - { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: couldn't create per process proc directory /proc/%s/%u", PVRProcDirRoot, ui32PID)); - - return -ENOMEM; - } - } - } - - return CreateProcEntryInDir(psPerProc->psProcDir, name, rhandler, whandler, data); -} - - -/*! -****************************************************************************** - - @Function : CreateProcReadEntry - - @Description - - Create a file under /proc/pvr. These dynamic files can be used at runtime - to get information about the device. Creation WILL fail if proc support is - not compiled into the kernel. That said, the Linux kernel is not even happy - to build without /proc support these days. - - @Input name : the name of the file to create - - @Input handler : the function to call to provide the content - - @Return 0 for success, -errno for failure - -*****************************************************************************/ -IMG_INT CreateProcReadEntry(const IMG_CHAR * name, pvr_read_proc_t handler) -{ - struct proc_dir_entry * file; - - if (!dir) - { - PVR_DPF((PVR_DBG_ERROR, "CreateProcReadEntry: cannot make proc entry /proc/%s/%s: no parent", PVRProcDirRoot, name)); - - return -ENOMEM; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - /* PRQA S 0307 1 */ /* ignore warning about casting to different pointer type */ - file = create_proc_read_entry (name, S_IFREG | S_IRUGO, dir, pvr_read_proc, (IMG_VOID *)handler); - - if (file) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - file->owner = THIS_MODULE; -#endif - return 0; - } -#else - /* use file_ops pointing to pvr_read_proc */ - file = proc_create_data(name, S_IFREG | S_IRUGO, dir, &pvr_read_proc_operations, handler); - if (file) - return 0; -#endif - - PVR_DPF((PVR_DBG_ERROR, "CreateProcReadEntry: cannot make proc entry /proc/%s/%s: no memory", PVRProcDirRoot, name)); - - return -ENOMEM; + return CreateProcEntryInDirSeq(psPerProc->psProcDir, name, data, next_handler, + show_handler,off2element_handler,startstop_handler,whandler); } @@ -1161,11 +661,17 @@ IMG_INT CreateProcEntries(IMG_VOID) return -ENOMEM; } +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) g_pProcQueue = CreateProcReadEntrySeq("queue", NULL, NULL, ProcSeqShowQueue, ProcSeqOff2ElementQueue, NULL); +#endif g_pProcVersion = CreateProcReadEntrySeq("version", NULL, NULL, ProcSeqShowVersion, ProcSeq1ElementHeaderOff2Element, NULL); g_pProcSysNodes = CreateProcReadEntrySeq("nodes", NULL, NULL, ProcSeqShowSysNodes, ProcSeqOff2ElementSysNodes, NULL); - if(!g_pProcQueue || !g_pProcVersion || !g_pProcSysNodes) + if(!g_pProcVersion || !g_pProcSysNodes +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + || !g_pProcQueue +#endif + ) { PVR_DPF((PVR_DBG_ERROR, "CreateProcEntries: couldn't make /proc/%s files", PVRProcDirRoot)); @@ -1207,44 +713,45 @@ IMG_INT CreateProcEntries(IMG_VOID) /*! ****************************************************************************** - @Function : RemoveProcEntry + @Function : RemoveProcEntrySeq @Description - Remove a single node under /proc/pvr. + Remove a single node (created using *Seq function) under /proc/pvr. - @Input name : the name of the node to remove + @Input proc_entry : structure returned by Create function. @Return nothing *****************************************************************************/ -IMG_VOID RemoveProcEntry(const IMG_CHAR * name) +IMG_VOID RemoveProcEntrySeq(struct pvr_proc_dir_entry* ppde) { - if (dir) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - remove_proc_entry(name, dir); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) + remove_proc_entry(ppde->pde->name, dir); +#else + proc_remove(ppde->pde); #endif - PVR_DPF((PVR_DBG_MESSAGE, "Removing /proc/%s/%s", PVRProcDirRoot, name)); - } + kfree(ppde); } /*! ****************************************************************************** - @Function : RemovePerProcessProcEntry + @Function : RemovePerProcessProcEntrySeq @Description - Remove a single node under the per process proc directory. + Remove a single node under the per process proc directory (created by *Seq function). - @Input name : the name of the node to remove + Remove a single node (created using *Seq function) under /proc/pvr. + + @Input proc_entry : structure returned by Create function. @Return nothing *****************************************************************************/ -IMG_VOID RemovePerProcessProcEntry(const IMG_CHAR *name) +IMG_VOID RemovePerProcessProcEntrySeq(struct pvr_proc_dir_entry* ppde) { PVRSRV_ENV_PER_PROCESS_DATA *psPerProc; @@ -1254,19 +761,44 @@ IMG_VOID RemovePerProcessProcEntry(const IMG_CHAR *name) psPerProc = PVRSRVFindPerProcessPrivateData(); if (!psPerProc) { - PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: can't " - "remove %s, no per process data", name)); + PVR_DPF((PVR_DBG_ERROR, "CreatePerProcessProcEntries: can't remove proc entry, no per process data")); return; } } if (psPerProc->psProcDir) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - remove_proc_entry(name, psPerProc->psProcDir); - - PVR_DPF((PVR_DBG_MESSAGE, "Removing proc entry %s from %s", name, psPerProc->psProcDir->name)); + PVR_DPF((PVR_DBG_MESSAGE, "Removing per-process proc entry")); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) + remove_proc_entry(ppde->pde->name, psPerProc->psProcDir); +#else + proc_remove(ppde->pde); #endif + kfree(ppde); + } +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) +/*! +****************************************************************************** + + @Function : RemoveProcEntry + + @Description + + Remove a single node under /proc/pvr. + + @Input name : the name of the node to remove + + @Return nothing + +*****************************************************************************/ +static IMG_VOID RemoveProcEntry(const IMG_CHAR * name) +{ + if (dir) + { + remove_proc_entry(name, dir); + PVR_DPF((PVR_DBG_MESSAGE, "Removing /proc/%s/%s", PVRProcDirRoot, name)); } } @@ -1289,7 +821,6 @@ IMG_VOID RemovePerProcessProcDir(PVRSRV_ENV_PER_PROCESS_DATA *psPerProc) { if (psPerProc->psProcDir) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) while (psPerProc->psProcDir->subdir) { PVR_DPF((PVR_DBG_WARNING, "Belatedly removing /proc/%s/%s/%s", PVRProcDirRoot, psPerProc->psProcDir->name, psPerProc->psProcDir->subdir->name)); @@ -1297,10 +828,14 @@ IMG_VOID RemovePerProcessProcDir(PVRSRV_ENV_PER_PROCESS_DATA *psPerProc) RemoveProcEntry(psPerProc->psProcDir->subdir->name); } RemoveProcEntry(psPerProc->psProcDir->name); -#endif } } - +#else +IMG_VOID RemovePerProcessProcDir(PVRSRV_ENV_PER_PROCESS_DATA *psPerProc) +{ + proc_remove(psPerProc->psProcDir); +} +#endif /*! ****************************************************************************** @@ -1318,7 +853,6 @@ IMG_VOID RemovePerProcessProcDir(PVRSRV_ENV_PER_PROCESS_DATA *psPerProc) *****************************************************************************/ IMG_VOID RemoveProcEntries(IMG_VOID) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) #ifdef DEBUG RemoveProcEntrySeq( g_pProcDebugLevel ); #ifdef PVR_MANUAL_POWER_CONTROL @@ -1326,21 +860,35 @@ IMG_VOID RemoveProcEntries(IMG_VOID) #endif /* PVR_MANUAL_POWER_CONTROL */ #endif +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) RemoveProcEntrySeq(g_pProcQueue); +#endif RemoveProcEntrySeq(g_pProcVersion); RemoveProcEntrySeq(g_pProcSysNodes); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) while (dir->subdir) { PVR_DPF((PVR_DBG_WARNING, "Belatedly removing /proc/%s/%s", PVRProcDirRoot, dir->subdir->name)); RemoveProcEntry(dir->subdir->name); } - remove_proc_entry(PVRProcDirRoot, NULL); #else proc_remove(dir); #endif + +} + +/*************************************************************************/ /*! +@Function PVRProcGetData +@Description Extract data from PVR proc object. +@Input pointer to pvr_proc_dir_entr object +@Return pointer to data object passed in to Proc create function. +*/ /**************************************************************************/ +void *PVRProcGetData(struct pvr_proc_dir_entry *ppde) +{ + return ppde->data; } /***************************************************************************** @@ -1351,7 +899,7 @@ IMG_VOID RemoveProcEntries(IMG_VOID) PARAMETERS : sfile - /proc seq_file el - Element to print *****************************************************************************/ -static void ProcSeqShowVersion(struct seq_file *sfile,void* el) +static void ProcSeqShowVersion(struct seq_file *sfile, void* el) { SYS_DATA *psSysData; IMG_CHAR *pszSystemVersionString = "None"; @@ -1374,24 +922,6 @@ static void ProcSeqShowVersion(struct seq_file *sfile,void* el) seq_printf( sfile, "System Version String: %s\n", pszSystemVersionString); } -/*! -****************************************************************************** - - @Function procDumpSysNodes (plus deviceTypeToString and deviceClassToString) - - @Description - - Format the contents of /proc/pvr/nodes - - @Input buf : where to place format contents data. - - @Input size : the size of the buffer into which to place data - - @Input off : how far into the file we are. - - @Return amount of data placed in buffer, 0, or END_OF_FILE : - -******************************************************************************/ static const IMG_CHAR *deviceTypeToString(PVRSRV_DEVICE_TYPE deviceType) { switch (deviceType) diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/proc.h b/drivers/gpu/pvr/services4/srvkm/env/linux/proc.h index 62c6dafc0ad..e3abec2bb33 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/proc.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/proc.h @@ -44,18 +44,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __SERVICES_PROC_H__ #define __SERVICES_PROC_H__ -#include <asm/system.h> // va_list etc -#include <linux/proc_fs.h> // read_proc_t etc -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) -typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data); -typedef int (write_proc_t)(struct file *file, const char __user *buffer, unsigned long count, void *data); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) +#include <asm/system.h> #endif -#include <linux/seq_file.h> // seq_file - -#define END_OF_FILE (off_t) -1 - -typedef off_t (pvr_read_proc_t)(IMG_CHAR *, size_t, off_t); +#include <linux/seq_file.h> +#include "img_defs.h" +struct pvr_proc_dir_entry; #define PVR_PROC_SEQ_START_TOKEN (void*)1 typedef void* (pvr_next_proc_seq_t)(struct seq_file *,void*,loff_t); @@ -63,73 +58,38 @@ typedef void* (pvr_off2element_proc_seq_t)(struct seq_file *, loff_t); typedef void (pvr_show_proc_seq_t)(struct seq_file *,void*); typedef void (pvr_startstop_proc_seq_t)(struct seq_file *, IMG_BOOL start); -typedef struct _PVR_PROC_SEQ_HANDLERS_ { - pvr_next_proc_seq_t *next; - pvr_show_proc_seq_t *show; - pvr_off2element_proc_seq_t *off2element; - pvr_startstop_proc_seq_t *startstop; - IMG_VOID *data; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) - read_proc_t *read_proc; - write_proc_t *write_proc; -#endif -} PVR_PROC_SEQ_HANDLERS; - - -/** off2element function for elements with only ONE element (no header) */ -void* ProcSeq1ElementOff2Element(struct seq_file *sfile, loff_t off); - -/** off2element function for elements with only ONE element (+ header) */ -void* ProcSeq1ElementHeaderOff2Element(struct seq_file *sfile, loff_t off); - -off_t printAppend(IMG_CHAR * buffer, size_t size, off_t off, const IMG_CHAR * format, ...) - __attribute__((format(printf, 4, 5))); - -IMG_INT CreateProcEntries(IMG_VOID); - -IMG_INT CreateProcReadEntry (const IMG_CHAR * name, pvr_read_proc_t handler); - -IMG_INT CreateProcEntry(const IMG_CHAR * name, read_proc_t rhandler, write_proc_t whandler, IMG_VOID *data); - -IMG_INT CreatePerProcessProcEntry(const IMG_CHAR * name, read_proc_t rhandler, write_proc_t whandler, IMG_VOID *data); - -IMG_VOID RemoveProcEntry(const IMG_CHAR * name); - -IMG_VOID RemovePerProcessProcEntry(const IMG_CHAR * name); +typedef int (pvr_proc_write_t)(struct file *file, const char __user *buffer, + unsigned long count, void *data); -IMG_VOID RemoveProcEntries(IMG_VOID); +IMG_INT CreateProcEntries(void); +void RemoveProcEntries(void); -struct proc_dir_entry* CreateProcReadEntrySeq ( - const IMG_CHAR* name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler - ); +struct pvr_proc_dir_entry* CreateProcReadEntrySeq(const IMG_CHAR* name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler); -struct proc_dir_entry* CreateProcEntrySeq ( - const IMG_CHAR* name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler, - write_proc_t whandler - ); +struct pvr_proc_dir_entry* CreateProcEntrySeq(const IMG_CHAR* name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler, + pvr_proc_write_t whandler); -struct proc_dir_entry* CreatePerProcessProcEntrySeq ( - const IMG_CHAR* name, - IMG_VOID* data, - pvr_next_proc_seq_t next_handler, - pvr_show_proc_seq_t show_handler, - pvr_off2element_proc_seq_t off2element_handler, - pvr_startstop_proc_seq_t startstop_handler, - write_proc_t whandler - ); +struct pvr_proc_dir_entry* CreatePerProcessProcEntrySeq(const IMG_CHAR* name, + IMG_VOID* data, + pvr_next_proc_seq_t next_handler, + pvr_show_proc_seq_t show_handler, + pvr_off2element_proc_seq_t off2element_handler, + pvr_startstop_proc_seq_t startstop_handler, + pvr_proc_write_t whandler); +void RemoveProcEntrySeq(struct pvr_proc_dir_entry* proc_entry); +void RemovePerProcessProcEntrySeq(struct pvr_proc_dir_entry* proc_entry); -IMG_VOID RemoveProcEntrySeq(struct proc_dir_entry* proc_entry); -IMG_VOID RemovePerProcessProcEntrySeq(struct proc_dir_entry* proc_entry); +void *PVRProcGetData(struct pvr_proc_dir_entry* ppde); #endif diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_bridge_k.c b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_bridge_k.c index 5d1ad8c36b0..2a61e545015 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_bridge_k.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_bridge_k.c @@ -41,6 +41,8 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#include <linux/fs.h> + #include "img_defs.h" #include "services.h" #include "pvr_bridge.h" @@ -84,7 +86,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(DEBUG_BRIDGE_KM) -static struct proc_dir_entry *g_ProcBridgeStats =0; +static struct pvr_proc_dir_entry *g_ProcBridgeStats =0; static void* ProcSeqNextBridgeStats(struct seq_file *sfile,void* el,loff_t off); static void ProcSeqShowBridgeStats(struct seq_file *sfile,void* el); static void* ProcSeqOff2ElementBridgeStats(struct seq_file * sfile, loff_t off); @@ -95,7 +97,7 @@ static void ProcSeqStartstopBridgeStats(struct seq_file *sfile,IMG_BOOL start); extern PVRSRV_LINUX_MUTEX gPVRSRVLock; #if defined(SUPPORT_MEMINFO_IDS) -static IMG_UINT64 ui64Stamp; +IMG_UINT64 g_ui64MemInfoID; #endif /* defined(SUPPORT_MEMINFO_IDS) */ PVRSRV_ERROR @@ -141,7 +143,7 @@ static void ProcSeqStartstopBridgeStats(struct seq_file *sfile,IMG_BOOL start) { if(start) { - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); } else { @@ -231,7 +233,6 @@ static void ProcSeqShowBridgeStats(struct seq_file *sfile,void* el) psEntry->ui32CopyFromUserTotalBytes, psEntry->ui32CopyToUserTotalBytes); } - #endif /* DEBUG_BRIDGE_KM */ @@ -253,7 +254,7 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig PVRSRV_PER_PROCESS_DATA *psPerProc; IMG_INT err = -EFAULT; - LinuxLockMutex(&gPVRSRVLock); + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); #if defined(SUPPORT_DRI_DRM) psBridgePackageKM = (PVRSRV_BRIDGE_PACKAGE *)arg; @@ -474,7 +475,7 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig psPrivateData->hKernelMemInfo = hMemInfo; #if defined(SUPPORT_MEMINFO_IDS) - psPrivateData->ui64Stamp = ++ui64Stamp; + psPrivateData->ui64Stamp = ++g_ui64MemInfoID; psKernelMemInfo->ui64Stamp = psPrivateData->ui64Stamp; if (pvr_put_user(psPrivateData->ui64Stamp, &psExportDeviceMemOUT->ui64Stamp) != 0) @@ -505,7 +506,7 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig { PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY *psDeviceClassMemoryOUT = (PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY *)psBridgePackageKM->pvParamOut; - if (pvr_put_user(++ui64Stamp, &psDeviceClassMemoryOUT->sClientMemInfo.ui64Stamp) != 0) + if (pvr_put_user(++g_ui64MemInfoID, &psDeviceClassMemoryOUT->sClientMemInfo.ui64Stamp) != 0) { err = -EFAULT; goto unlock_and_return; diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_debug.c b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_debug.c index 04e42ad3afb..df3a9b5ef22 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_debug.c +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_debug.c @@ -51,16 +51,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <asm/io.h> #include <asm/uaccess.h> #include <linux/kernel.h> +#include <linux/sched.h> #include <linux/hardirq.h> #include <linux/module.h> #include <linux/spinlock.h> #include <linux/string.h> // strncpy, strlen #include <stdarg.h> +#include <linux/seq_file.h> #include "img_types.h" #include "servicesext.h" #include "pvr_debug.h" #include "srvkm.h" -#include "proc.h" #include "mutex.h" #include "linkage.h" #include "pvr_uaccess.h" @@ -69,6 +70,104 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PVR_DEBUG_ALWAYS_USE_SPINLOCK #endif +#if defined(PVRSRV_NEED_PVR_DPF) + +/******** BUFFERED LOG MESSAGES ********/ + +/* Because we don't want to have to handle CCB wrapping, each buffered + * message is rounded up to PVRSRV_DEBUG_CCB_MESG_MAX bytes. This means + * there is the same fixed number of messages that can be stored, + * regardless of message length. + */ + +#if defined(PVRSRV_DEBUG_CCB_MAX) + +#define PVRSRV_DEBUG_CCB_MESG_MAX PVR_MAX_DEBUG_MESSAGE_LEN + +#include <linux/syscalls.h> +#include <linux/time.h> + +typedef struct +{ + const IMG_CHAR *pszFile; + IMG_INT iLine; + IMG_UINT32 ui32TID; + IMG_CHAR pcMesg[PVRSRV_DEBUG_CCB_MESG_MAX]; + struct timeval sTimeVal; +} +PVRSRV_DEBUG_CCB; + +static PVRSRV_DEBUG_CCB gsDebugCCB[PVRSRV_DEBUG_CCB_MAX] = { { 0 } }; + +static IMG_UINT giOffset = 0; + +static PVRSRV_LINUX_MUTEX gsDebugCCBMutex; + +static void +AddToBufferCCB(const IMG_CHAR *pszFileName, IMG_UINT32 ui32Line, + const IMG_CHAR *szBuffer) +{ + LinuxLockMutex(&gsDebugCCBMutex); + + gsDebugCCB[giOffset].pszFile = pszFileName; + gsDebugCCB[giOffset].iLine = ui32Line; + gsDebugCCB[giOffset].ui32TID = current->tgid; + + do_gettimeofday(&gsDebugCCB[giOffset].sTimeVal); + + strncpy(gsDebugCCB[giOffset].pcMesg, szBuffer, PVRSRV_DEBUG_CCB_MESG_MAX - 1); + gsDebugCCB[giOffset].pcMesg[PVRSRV_DEBUG_CCB_MESG_MAX - 1] = 0; + + giOffset = (giOffset + 1) % PVRSRV_DEBUG_CCB_MAX; + + LinuxUnLockMutex(&gsDebugCCBMutex); +} + +IMG_EXPORT IMG_VOID PVRSRVDebugPrintfDumpCCB(void) +{ + int i; + + LinuxLockMutex(&gsDebugCCBMutex); + + for(i = 0; i < PVRSRV_DEBUG_CCB_MAX; i++) + { + PVRSRV_DEBUG_CCB *psDebugCCBEntry = + &gsDebugCCB[(giOffset + i) % PVRSRV_DEBUG_CCB_MAX]; + + /* Early on, we won't have PVRSRV_DEBUG_CCB_MAX messages */ + if(!psDebugCCBEntry->pszFile) + continue; + + printk("%s:%d:\t[%5ld.%6ld] %s\n", + psDebugCCBEntry->pszFile, + psDebugCCBEntry->iLine, + (long)psDebugCCBEntry->sTimeVal.tv_sec, + (long)psDebugCCBEntry->sTimeVal.tv_usec, + psDebugCCBEntry->pcMesg); + } + + LinuxUnLockMutex(&gsDebugCCBMutex); +} + +#else /* defined(PVRSRV_DEBUG_CCB_MAX) */ +static INLINE void +AddToBufferCCB(const IMG_CHAR *pszFileName, IMG_UINT32 ui32Line, + const IMG_CHAR *szBuffer) +{ + (void)pszFileName; + (void)szBuffer; + (void)ui32Line; +} + +IMG_EXPORT IMG_VOID PVRSRVDebugPrintfDumpCCB(void) +{ + /* Not available */ +} + +#endif /* defined(PVRSRV_DEBUG_CCB_MAX) */ + +#endif /* defined(PVRSRV_NEED_PVR_DPF) */ + static IMG_BOOL VBAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, const IMG_CHAR* pszFormat, va_list VArgs) IMG_FORMAT_PRINTF(3, 0); @@ -76,15 +175,9 @@ static IMG_BOOL VBAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, #if defined(PVRSRV_NEED_PVR_DPF) -#define PVR_MAX_FILEPATH_LEN 256 - -static IMG_BOOL BAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, - const IMG_CHAR *pszFormat, ...) - IMG_FORMAT_PRINTF(3, 4); - /* NOTE: Must NOT be static! Used in module.c.. */ IMG_UINT32 gPVRDebugLevel = - (DBGPRIV_FATAL | DBGPRIV_ERROR | DBGPRIV_WARNING); + (DBGPRIV_FATAL | DBGPRIV_ERROR | DBGPRIV_WARNING | DBGPRIV_BUFFERED); #endif /* defined(PVRSRV_NEED_PVR_DPF) || defined(PVRSRV_NEED_PVR_TRACE) */ @@ -128,7 +221,7 @@ static inline void GetBufferLock(unsigned long *pulLockFlags) #if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) else { - LinuxLockMutex(&gsDebugMutexNonIRQ); + LinuxLockMutexNested(&gsDebugMutexNonIRQ, PVRSRV_LOCK_CLASS_PVR_DEBUG); } #endif } @@ -194,7 +287,10 @@ static IMG_BOOL VBAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, const IMG_CHAR IMG_VOID PVRDPFInit(IMG_VOID) { #if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) - LinuxInitMutex(&gsDebugMutexNonIRQ); + LinuxInitMutex(&gsDebugMutexNonIRQ); +#endif +#if defined(PVRSRV_DEBUG_CCB_MAX) + LinuxInitMutex(&gsDebugCCBMutex); #endif } @@ -231,7 +327,6 @@ IMG_VOID PVRSRVReleasePrintf(const IMG_CHAR *pszFormat, ...) ReleaseBufferLock(ulLockFlags); va_end(vaArgs); - } #if defined(PVRSRV_NEED_PVR_TRACE) @@ -277,25 +372,6 @@ IMG_VOID PVRSRVTrace(const IMG_CHAR* pszFormat, ...) #if defined(PVRSRV_NEED_PVR_DPF) -/* - * Append a string to a buffer using formatted conversion. - * The function takes a variable number of arguments, calling - * VBAppend to do the actual work. - */ -static IMG_BOOL BAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, const IMG_CHAR *pszFormat, ...) -{ - va_list VArgs; - IMG_BOOL bTrunc; - - va_start (VArgs, pszFormat); - - bTrunc = VBAppend(pszBuf, ui32BufSiz, pszFormat, VArgs); - - va_end (VArgs); - - return bTrunc; -} - /*! ****************************************************************************** @Function PVRSRVDebugPrintf @@ -317,8 +393,6 @@ IMG_VOID PVRSRVDebugPrintf ( { IMG_BOOL bTrace; const IMG_CHAR *pszFileName = pszFullFileName; - IMG_CHAR *pszLeafName; - bTrace = (IMG_BOOL)(ui32DebugLevel & DBGPRIV_CALLTRACE) ? IMG_TRUE : IMG_FALSE; @@ -365,9 +439,14 @@ IMG_VOID PVRSRVDebugPrintf ( strncpy (pszBuf, "PVR_K:(Verbose): ", (ui32BufSiz -1)); break; } + case DBGPRIV_BUFFERED: + { + strncpy (pszBuf, "PVR_K: ", (ui32BufSiz -1)); + break; + } default: { - strncpy (pszBuf, "PVR_K:(Unknown message level)", (ui32BufSiz -1)); + strncpy (pszBuf, "PVR_K:(Unknown message level): ", (ui32BufSiz -1)); break; } } @@ -383,82 +462,14 @@ IMG_VOID PVRSRVDebugPrintf ( } else { - /* Traces don't need a location */ - if (bTrace == IMG_FALSE) + if (ui32DebugLevel & DBGPRIV_BUFFERED) { -#ifdef DEBUG_LOG_PATH_TRUNCATE - /* Buffer for rewriting filepath in log messages */ - static IMG_CHAR szFileNameRewrite[PVR_MAX_FILEPATH_LEN]; - - IMG_CHAR* pszTruncIter; - IMG_CHAR* pszTruncBackInter; - - /* Truncate path (DEBUG_LOG_PATH_TRUNCATE shoud be set to EURASIA env var)*/ - if (strlen(pszFullFileName) > strlen(DEBUG_LOG_PATH_TRUNCATE)+1) - pszFileName = pszFullFileName + strlen(DEBUG_LOG_PATH_TRUNCATE)+1; + /* We don't need the full path here */ + const IMG_CHAR *pszShortName = strrchr(pszFileName, '/') + 1; + if(pszShortName) + pszFileName = pszShortName; - /* Try to find '/../' entries and remove it together with - previous entry. Repeat unit all removed */ - strncpy(szFileNameRewrite, pszFileName,PVR_MAX_FILEPATH_LEN); - - if(strlen(szFileNameRewrite) == PVR_MAX_FILEPATH_LEN-1) { - IMG_CHAR szTruncateMassage[] = "FILENAME TRUNCATED"; - strcpy(szFileNameRewrite + (PVR_MAX_FILEPATH_LEN - 1 - strlen(szTruncateMassage)), szTruncateMassage); - } - - pszTruncIter = szFileNameRewrite; - while(*pszTruncIter++ != 0) - { - IMG_CHAR* pszNextStartPoint; - /* Find '/../' pattern */ - if( - !( ( *pszTruncIter == '/' && (pszTruncIter-4 >= szFileNameRewrite) ) && - ( *(pszTruncIter-1) == '.') && - ( *(pszTruncIter-2) == '.') && - ( *(pszTruncIter-3) == '/') ) - ) continue; - - /* Find previous '/' */ - pszTruncBackInter = pszTruncIter - 3; - while(*(--pszTruncBackInter) != '/') - { - if(pszTruncBackInter <= szFileNameRewrite) break; - } - pszNextStartPoint = pszTruncBackInter; - - /* Remove found region */ - while(*pszTruncIter != 0) - { - *pszTruncBackInter++ = *pszTruncIter++; - } - *pszTruncBackInter = 0; - - /* Start again */ - pszTruncIter = pszNextStartPoint; - } - - pszFileName = szFileNameRewrite; - /* Remove first '/' if exist (it's always relative path */ - if(*pszFileName == '/') pszFileName++; -#endif - -#if !defined(__sh__) - pszLeafName = (IMG_CHAR *)strrchr (pszFileName, '\\'); - - if (pszLeafName) - { - pszFileName = pszLeafName; - } -#endif /* __sh__ */ - - if (BAppend(pszBuf, ui32BufSiz, " [%u, %s]", ui32Line, pszFileName)) - { - printk(KERN_INFO "PVR_K:(Message Truncated): %s\n", pszBuf); - } - else - { - printk(KERN_INFO "%s\n", pszBuf); - } + AddToBufferCCB(pszFileName, ui32Line, pszBuf); } else { @@ -481,6 +492,9 @@ IMG_INT PVRDebugProcSetLevel(struct file *file, const IMG_CHAR *buffer, IMG_UINT #define _PROC_SET_BUFFER_SZ 6 IMG_CHAR data_buffer[_PROC_SET_BUFFER_SZ]; + PVR_UNREFERENCED_PARAMETER(file); + PVR_UNREFERENCED_PARAMETER(data); + if (count > _PROC_SET_BUFFER_SZ) { return -EINVAL; @@ -498,8 +512,10 @@ IMG_INT PVRDebugProcSetLevel(struct file *file, const IMG_CHAR *buffer, IMG_UINT return (count); } -void ProcSeqShowDebugLevel(struct seq_file *sfile,void* el) +void ProcSeqShowDebugLevel(struct seq_file *sfile, void* el) { + PVR_UNREFERENCED_PARAMETER(el); + seq_printf(sfile, "%u\n", gPVRDebugLevel); } diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_drm.c b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_drm.c new file mode 100755 index 00000000000..3aae69e232e --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_drm.c @@ -0,0 +1,739 @@ +/*************************************************************************/ /*! +@Title PowerVR drm driver +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@Description linux module setup +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ +#if defined(SUPPORT_DRI_DRM) + +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) +#ifndef AUTOCONF_INCLUDED +#include <linux/config.h> +#endif +#endif + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/fs.h> +#include <linux/proc_fs.h> +#include <linux/sched.h> +#include <asm/ioctl.h> +#include <drm/drmP.h> +#include <drm/drm.h> + +#include "img_defs.h" +#include "services.h" +#include "kerneldisplay.h" +#include "kernelbuffer.h" +#include "syscommon.h" +#include "pvrmmap.h" +#include "mm.h" +#include "mmap.h" +#include "mutex.h" +#include "pvr_debug.h" +#include "srvkm.h" +#include "perproc.h" +#include "handle.h" +#include "pvr_bridge_km.h" +#include "pvr_bridge.h" +#include "pvrmodule.h" +#include "pvrversion.h" +#include "lock.h" +#include "linkage.h" +#include "pvr_drm.h" + +#if defined(PVR_DRI_DRM_NOT_PCI) +#include "pvr_drm_mod.h" +#endif + +#if (defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(PVR_LDM_PLATFORM_PRE_REGISTERED)) || defined(NO_HARDWARE) +#define PVR_DRM_NAME SYS_SGX_DEV_NAME +#else +#define PVR_DRM_NAME PVRSRV_MODNAME +#endif + +#define PVR_DRM_DESC "Imagination Technologies PVR DRM" + +#define PVR_DRM_DATE "20110701" + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRI_DRM_PLUGIN) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) +#define PVR_NEW_STYLE_DRM_PLATFORM_DEV +#else +#define PVR_OLD_STYLE_DRM_PLATFORM_DEV +#endif +#endif + +/* + * Prior to Linux 2.6.36, we couldn't do the release processing in post close + * when workqueues were being used, because drm_release held the big kernel + * lock (BKL) when it called post close. + * If the resman needs to wait for processing being done by a workqueue, + * that processing won't complete whilst the lock is held by another thread, + * as the workqueue won't get scheduled. + */ +#undef PVR_DRI_DRM_USE_POST_CLOSE +#if (defined(SUPPORT_DRI_DRM_EXT) && !defined(PVR_LINUX_USING_WORKQUEUES)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define PVR_DRI_DRM_USE_POST_CLOSE +#endif + +DECLARE_WAIT_QUEUE_HEAD(sWaitForInit); + +#if defined(SUPPORT_DRM_MODESET) +static struct drm_driver sPVRDrmDriver; +#endif + +/* Once bInitComplete and bInitFailed are set, they stay set */ +IMG_BOOL bInitComplete; +IMG_BOOL bInitFailed; + +#if !defined(PVR_DRI_DRM_NOT_PCI) && !defined(SUPPORT_DRI_DRM_PLUGIN) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +struct platform_device *gpsPVRLDMDev; +#else +struct pci_dev *gpsPVRLDMDev; +#endif +#endif + +struct drm_device *gpsPVRDRMDev; + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24)) +#error "Linux kernel version 2.6.25 or later required for PVR DRM support" +#endif + +#define PVR_DRM_FILE struct drm_file * + +#if !defined(SUPPORT_DRI_DRM_EXT) && !defined(SUPPORT_DRI_DRM_PLUGIN) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +static struct platform_device_id asPlatIdList[] = { + {SYS_SGX_DEV_NAME, 0}, + {} +}; +#else /* defined(PVR_DRI_DRM_PLATFORM_DEV) */ +static struct pci_device_id asPciIdList[] = { +#if defined(PVR_DRI_DRM_NOT_PCI) + {1, 1, 1, 1, 0, 0, 0}, +#else /* defined(PVR_DRI_DRM_NOT_PCI) */ + {SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +#if defined(SYS_SGX_DEV1_DEVICE_ID) + {SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV1_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +#endif /* defined(SYS_SGX_DEV1_DEVICE_ID) */ +#endif /* defined(PVR_DRI_DRM_NOT_PCI) */ + {0} +}; +#endif /* defined(PVR_DRI_DRM_PLATFORM_DEV) */ +#endif /* !defined(SUPPORT_DRI_DRM_EXT) */ + +DRI_DRM_STATIC int +PVRSRVDrmLoad(struct drm_device *dev, unsigned long flags) +{ + int iRes = 0; + + PVR_TRACE(("PVRSRVDrmLoad")); + + gpsPVRDRMDev = dev; +#if !defined(PVR_DRI_DRM_NOT_PCI) && !defined(SUPPORT_DRI_DRM_PLUGIN) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) + gpsPVRLDMDev = dev->platformdev; +#else + gpsPVRLDMDev = dev->pdev; +#endif +#endif + +#if defined(PDUMP) + iRes = dbgdrv_init(); + if (iRes != 0) + { + goto exit; + } +#endif + /* Module initialisation */ + iRes = PVRCore_Init(); + if (iRes != 0) + { + goto exit_dbgdrv_cleanup; + } + +#if defined(DISPLAY_CONTROLLER) + iRes = PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Init)(dev); + if (iRes != 0) + { + goto exit_pvrcore_cleanup; + } +#endif + goto exit; + +#if defined(DISPLAY_CONTROLLER) +exit_pvrcore_cleanup: + PVRCore_Cleanup(); +#endif +exit_dbgdrv_cleanup: +#if defined(PDUMP) + dbgdrv_cleanup(); +#endif +exit: + if (iRes != 0) + { + bInitFailed = IMG_TRUE; + } + bInitComplete = IMG_TRUE; + + wake_up_interruptible(&sWaitForInit); + + return iRes; +} + +DRI_DRM_STATIC int +PVRSRVDrmUnload(struct drm_device *dev) +{ + PVR_TRACE(("PVRSRVDrmUnload")); + +#if defined(DISPLAY_CONTROLLER) + PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Cleanup)(dev); +#endif + + PVRCore_Cleanup(); + +#if defined(PDUMP) + dbgdrv_cleanup(); +#endif + + return 0; +} + +DRI_DRM_STATIC int +PVRSRVDrmOpen(struct drm_device *dev, struct drm_file *file) +{ + while (!bInitComplete) + { + DEFINE_WAIT(sWait); + + prepare_to_wait(&sWaitForInit, &sWait, TASK_INTERRUPTIBLE); + + if (!bInitComplete) + { + PVR_TRACE(("%s: Waiting for module initialisation to complete", __FUNCTION__)); + + schedule(); + } + + finish_wait(&sWaitForInit, &sWait); + + if (signal_pending(current)) + { + return -ERESTARTSYS; + } + } + + if (bInitFailed) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Module initialisation failed", __FUNCTION__)); + return -EINVAL; + } + + return PVRSRVOpen(dev, file); +} + +#if defined(PVR_DRI_DRM_USE_POST_CLOSE) || defined(SUPPORT_DRI_DRM_PLUGIN) +#if defined(SUPPORT_DRI_DRM_PLUGIN) +DRI_DRM_STATIC int +PVRSRVDrmRelease(struct drm_device *dev, struct drm_file *file) +#else +DRI_DRM_STATIC void +PVRSRVDrmPostClose(struct drm_device *dev, struct drm_file *file) +#endif +{ + PVRSRVRelease(file->driver_priv); + + file->driver_priv = NULL; + +#if defined(SUPPORT_DRI_DRM_PLUGIN) + return 0; +#endif +} +#else +DRI_DRM_STATIC int +PVRSRVDrmRelease(struct inode *inode, struct file *filp) +{ + struct drm_file *file_priv = filp->private_data; + void *psDriverPriv = file_priv->driver_priv; + int ret; + + ret = drm_release(inode, filp); + + if (ret != 0) + { + /* + * An error means drm_release didn't call drm_lastclose, + * but it will have freed file_priv. + */ + PVR_DPF((PVR_DBG_ERROR, "%s : drm_release failed: %d", + __FUNCTION__, ret)); + } + + PVRSRVRelease(psDriverPriv); + + return 0; +} +#endif + +DRI_DRM_STATIC int +PVRDRMIsMaster(struct drm_device *dev, void *arg, struct drm_file *pFile) +{ + return 0; +} + +#if defined(SUPPORT_DRI_DRM_EXT) +int +PVRDRM_Dummy_ioctl(struct drm_device *dev, void *arg, struct drm_file *pFile) +{ + return 0; +} +#endif + +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 + { + drm_pvr_unpriv_cmd *psArgs = (drm_pvr_unpriv_cmd *)arg; + + switch (psArgs->cmd) + { + case PVR_DRM_UNPRIV_INIT_SUCCESFUL: + psArgs->res = PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL) ? 1 : 0; + break; + + default: + ret = -EFAULT; + } + + } + + LinuxUnLockMutex(&gPVRSRVLock); + + return ret; +} + +#if defined(DISPLAY_CONTROLLER) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +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; +} +#endif + +#if defined(SUPPORT_DRM_MODESET) +static int +PVRSRVPciProbe(struct pci_dev *dev, const struct pci_device_id *id) +{ + PVR_TRACE(("PVRSRVPciProbe")); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) + return drm_get_pci_dev(dev, id, &sPVRDrmDriver); +#else + return drm_get_dev(dev, id, &sPVRDrmDriver); +#endif +} + +static void +PVRSRVPciRemove(struct pci_dev *dev) +{ + struct drm_device *psDrmDev; + + PVR_TRACE(("PVRSRVPciRemove")); + + psDrmDev = pci_get_drvdata(dev); + drm_put_dev(psDrmDev); +} +#endif + +/* + * For Linux 2.6.33 and above, the DRM ioctl entry point is of the unlocked + * variety. The big kernel lock is still taken for ioctls, unless + * the DRM_UNLOCKED flag is set. If you revise one of the driver specific + * ioctls, or add a new one, consider whether the gPVRSRVLock mutex needs + * to be taken. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) +#define PVR_DRM_FOPS_IOCTL .unlocked_ioctl +#define PVR_DRM_UNLOCKED DRM_UNLOCKED +#else +#define PVR_DRM_FOPS_IOCTL .ioctl +#define PVR_DRM_UNLOCKED 0 +#endif + +#if !defined(SUPPORT_DRI_DRM_EXT) + +#if defined(DRM_IOCTL_DEF) +#define PVR_DRM_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(DRM_##ioctl, _func, _flags) +#else +#define PVR_DRM_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) +#endif + +struct drm_ioctl_desc sPVRDrmIoctls[] = { + PVR_DRM_IOCTL_DEF(PVR_SRVKM, PVRSRV_BridgeDispatchKM, PVR_DRM_UNLOCKED), + PVR_DRM_IOCTL_DEF(PVR_IS_MASTER, PVRDRMIsMaster, DRM_MASTER | PVR_DRM_UNLOCKED), + PVR_DRM_IOCTL_DEF(PVR_UNPRIV, PVRDRMUnprivCmd, PVR_DRM_UNLOCKED), +#if defined(PDUMP) + PVR_DRM_IOCTL_DEF(PVR_DBGDRV, dbgdrv_ioctl, PVR_DRM_UNLOCKED), +#endif +#if defined(DISPLAY_CONTROLLER) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) + PVR_DRM_IOCTL_DEF(PVR_DISP, PVRDRM_Display_ioctl, DRM_MASTER | PVR_DRM_UNLOCKED) +#endif +}; + +#if !defined(SUPPORT_DRI_DRM_PLUGIN) +static int pvr_max_ioctl = DRM_ARRAY_SIZE(sPVRDrmIoctls); +#endif + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRI_DRM_EXT) && \ + !defined(SUPPORT_DRI_DRM_PLUGIN) +static int PVRSRVDrmProbe(struct platform_device *pDevice); +static int PVRSRVDrmRemove(struct platform_device *pDevice); +#endif /* defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRI_DRM_EXT) */ + +#if defined(SUPPORT_DRI_DRM_PLUGIN) +static PVRSRV_DRM_PLUGIN sPVRDrmPlugin = +{ + .name = PVR_DRM_NAME, + + .open = PVRSRVDrmOpen, + .load = PVRSRVDrmLoad, + .unload = PVRSRVDrmUnload, + + .release = PVRSRVDrmRelease, + + .mmap = PVRMMap, + + .ioctls = sPVRDrmIoctls, + .num_ioctls = DRM_ARRAY_SIZE(sPVRDrmIoctls), + .ioctl_start = 0 +}; +#else /* defined(SUPPORT_DRI_DRM_PLUGIN) */ + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) +static const struct file_operations sPVRFileOps = +{ + .owner = THIS_MODULE, + .open = drm_open, +#if defined(PVR_DRI_DRM_USE_POST_CLOSE) + .release = drm_release, +#else + .release = PVRSRVDrmRelease, +#endif + PVR_DRM_FOPS_IOCTL = drm_ioctl, + .mmap = PVRMMap, + .poll = drm_poll, + .fasync = drm_fasync, +}; +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) */ + +static struct drm_driver sPVRDrmDriver = +{ +#if defined(PVR_OLD_STYLE_DRM_PLATFORM_DEV) + .driver_features = DRIVER_USE_PLATFORM_DEVICE, +#else + .driver_features = 0, +#endif + .dev_priv_size = 0, + .load = PVRSRVDrmLoad, + .unload = PVRSRVDrmUnload, + .open = PVRSRVDrmOpen, +#if defined(PVR_DRI_DRM_USE_POST_CLOSE) + .postclose = PVRSRVDrmPostClose, +#endif +#if !defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRM_MODESET) + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, +#endif + .ioctls = sPVRDrmIoctls, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) + .fops = &sPVRFileOps, +#else + .fops = + { + .owner = THIS_MODULE, + .open = drm_open, +#if defined(PVR_DRI_DRM_USE_POST_CLOSE) + .release = drm_release, +#else + .release = PVRSRVDrmRelease, +#endif + PVR_DRM_FOPS_IOCTL = drm_ioctl, + .mmap = PVRMMap, + .poll = drm_poll, + .fasync = drm_fasync, + }, +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) +#if defined(PVR_OLD_STYLE_DRM_PLATFORM_DEV) + .platform_driver = + { + .id_table = asPlatIdList, + .driver = + { + .name = PVR_DRM_NAME, + }, + .probe = PVRSRVDrmProbe, + .remove = PVRSRVDrmRemove, + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, + .shutdown = PVRSRVDriverShutdown, + }, +#else + .pci_driver = + { + .name = PVR_DRM_NAME, + .id_table = asPciIdList, +#if defined(SUPPORT_DRM_MODESET) + .probe = PVRSRVPciProbe, + .remove = PVRSRVPciRemove, + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, +#endif + }, +#endif +#endif + .name = PVR_DRM_NAME, + .desc = PVR_DRM_DESC, + .date = PVR_DRM_DATE, + .major = PVRVERSION_MAJ, + .minor = PVRVERSION_MIN, + .patchlevel = PVRVERSION_BUILD, +}; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) && !defined(PVR_DRI_DRM_PLATFORM_DEV) +static struct pci_driver sPVRPCIDriver = +{ + .name = PVR_DRM_NAME, + .id_table = asPciIdList, +#if defined(SUPPORT_DRM_MODESET) + .probe = PVRSRVPciProbe, + .remove = PVRSRVPciRemove, + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, +#endif +}; +#endif + +#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) +#if !defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(NO_HARDWARE) +static void PVRSRVDeviceRelease(struct device unref__ *pDevice) +{ +} + +static struct platform_device sPVRPlatDevice = { + .name = PVR_DRM_NAME, + .id = -1, + .dev = { + .release = PVRSRVDeviceRelease + } +}; +#endif + +static struct platform_driver sPVRPlatDriver = +{ + .id_table = asPlatIdList, + .driver = + { + .name = PVR_DRM_NAME, + }, + .probe = PVRSRVDrmProbe, + .remove = PVRSRVDrmRemove, + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, + .shutdown = PVRSRVDriverShutdown, +}; +#endif + +#endif /* defined(SUPPORT_DRI_DRM_PLUGIN) */ + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRI_DRM_EXT) && \ + !defined(SUPPORT_DRI_DRM_PLUGIN) +static int +PVRSRVDrmProbe(struct platform_device *pDevice) +{ + PVR_TRACE(("PVRSRVDrmProbe")); + +#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) + gpsPVRLDMDev = pDevice; + + return drm_platform_init(&sPVRDrmDriver, gpsPVRLDMDev); +#else + return drm_get_platform_dev(pDevice, &sPVRDrmDriver); +#endif +} + +static int +PVRSRVDrmRemove(struct platform_device *pDevice) +{ + PVR_TRACE(("PVRSRVDrmRemove")); + +#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) + drm_platform_exit(&sPVRDrmDriver, gpsPVRLDMDev); +#else + drm_put_dev(gpsPVRDRMDev); +#endif + return 0; +} +#endif + +static int __init PVRSRVDrmInit(void) +{ + int iRes; +#if !defined(SUPPORT_DRI_DRM_PLUGIN) + sPVRDrmDriver.num_ioctls = pvr_max_ioctl; +#endif + +#if defined(SUPPORT_DRM_MODESET) + sPVRDrmDriver.driver_features |= DRIVER_MODESET; +#endif + + /* Must come before attempting to print anything via Services */ + PVRDPFInit(); + +#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) + iRes = platform_driver_register(&sPVRPlatDriver); +#if !defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(NO_HARDWARE) + if (iRes == 0) + { + iRes = platform_device_register(&sPVRPlatDevice); + if (iRes != 0) + { + platform_driver_unregister(&sPVRPlatDriver); + } + } +#endif +#else /* defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) */ +#if defined(SUPPORT_DRI_DRM_PLUGIN) + iRes = SysDRMRegisterPlugin(&sPVRDrmPlugin); +#else /* defined(SUPPORT_DRI_DRM_PLUGIN) */ +#if defined(PVR_DRI_DRM_NOT_PCI) + iRes = drm_pvr_dev_add(); + if (iRes != 0) + { + return iRes; + } +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) + iRes = drm_platform_init(&sPVRDrmDriver, gpsPVRLDMDev); +#else + iRes = drm_pci_init(&sPVRDrmDriver, &sPVRPCIDriver); +#endif +#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + iRes = drm_init(&sPVRDrmDriver); +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + +#if defined(PVR_DRI_DRM_NOT_PCI) + if (iRes != 0) + { + drm_pvr_dev_remove(); + } +#endif +#endif /* defined(SUPPORT_DRI_DRM_PLUGIN) */ +#endif /* defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) */ + return iRes; +} + +static void __exit PVRSRVDrmExit(void) +{ +#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) +#if !defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(NO_HARDWARE) + platform_device_unregister(&sPVRPlatDevice); +#endif + platform_driver_unregister(&sPVRPlatDriver); +#else /* defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) */ +#if defined(SUPPORT_DRI_DRM_PLUGIN) + SysDRMUnregisterPlugin(&sPVRDrmPlugin); +#else /* defined(SUPPORT_DRI_DRM_PLUGIN) */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) + drm_platform_exit(&sPVRDrmDriver, gpsPVRLDMDev); +#else + drm_pci_exit(&sPVRDrmDriver, &sPVRPCIDriver); +#endif +#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + drm_exit(&sPVRDrmDriver); +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + +#if defined(PVR_DRI_DRM_NOT_PCI) + drm_pvr_dev_remove(); +#endif +#endif /* defined(SUPPORT_DRI_DRM_PLUGIN) */ +#endif /* defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) */ +} + +/* + * These macro calls define the initialisation and removal functions of the + * driver. Although they are prefixed `module_', they apply when compiling + * statically as well; in both cases they define the function the kernel will + * run to start/stop the driver. +*/ +module_init(PVRSRVDrmInit); +module_exit(PVRSRVDrmExit); +#endif /* !defined(SUPPORT_DRI_DRM_EXT) */ +#endif /* defined(SUPPORT_DRI_DRM) */ + + diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_drm.h b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_drm.h new file mode 100755 index 00000000000..c3ed413a720 --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_drm.h @@ -0,0 +1,184 @@ +/*************************************************************************/ /*! +@Title PowerVR drm driver +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@Description drm module +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ +#if !defined(__PVR_DRM_H__) +#define __PVR_DRM_H__ + +#if defined (PDUMP) +#include "linuxsrv.h" +#endif + +#include "pvr_drm_shared.h" + +#if defined(SUPPORT_DRI_DRM) + +#if defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +#include "3rdparty_dc_drm_shared.h" +#endif + +#define PVR_DRM_MAKENAME_HELPER(x, y) x ## y +#define PVR_DRM_MAKENAME(x, y) PVR_DRM_MAKENAME_HELPER(x, y) + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +#define LDM_DEV struct platform_device +#endif + +int PVRCore_Init(void); +void PVRCore_Cleanup(void); +int PVRSRVOpen(struct drm_device *dev, struct drm_file *pFile); +void PVRSRVRelease(void *pvPrivData); + +#if !defined(SUPPORT_DRI_DRM_PLUGIN) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +void PVRSRVDriverShutdown(LDM_DEV *pDevice); +int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state); +int PVRSRVDriverResume(LDM_DEV *pDevice); +#else +#if defined(SUPPORT_DRM_MODESET) +int PVRSRVDriverSuspend(struct pci_dev *pDevice, pm_message_t state); +int PVRSRVDriverResume(struct pci_dev *pDevice); +#else +int PVRSRVDriverSuspend(struct drm_device *pDevice, pm_message_t state); +int PVRSRVDriverResume(struct drm_device *pDevice); +#endif /* defined(SUPPORT_DRM_MODESET) */ +#endif /* defined(PVR_DRI_DRM_PLATFORM_DEV) */ +#endif /* !defined(SUPPORT_DRI_DRM_PLUGIN) */ + +int PVRSRV_BridgeDispatchKM(struct drm_device *dev, void *arg, struct drm_file *pFile); + +#if defined(SUPPORT_DRI_DRM_EXT) +#define DRI_DRM_STATIC +/*Exported functions to common drm layer*/ +int PVRSRVDrmLoad(struct drm_device *dev, unsigned long flags); +int PVRSRVDrmUnload(struct drm_device *dev); +int PVRSRVDrmOpen(struct drm_device *dev, struct drm_file *file); +#if defined(PVR_LINUX_USING_WORKQUEUES) +DRI_DRM_STATIC int PVRSRVDrmRelease(struct inode *inode, struct file *filp); +#else +void PVRSRVDrmPostClose(struct drm_device *dev, struct drm_file *file); +#endif +int PVRDRMIsMaster(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +int PVRDRMUnprivCmd(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +int PVRDRM_Dummy_ioctl(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +#else +#define DRI_DRM_STATIC static +#endif /* defined(SUPPORT_DRI_DRM_EXT) */ + +#if defined(DISPLAY_CONTROLLER) +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Init)(struct drm_device *); +extern void PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Cleanup)(struct drm_device *); +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Suspend)(struct drm_device *); +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Resume)(struct drm_device *); +#if defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device *dev, void *arg, struct drm_file *pFile); +#endif +#endif + +#if defined(PDUMP) +int dbgdrv_init(void); +void dbgdrv_cleanup(void); +IMG_INT dbgdrv_ioctl(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +#endif + +#if !defined(SUPPORT_DRI_DRM_EXT) +/* + * We need the command number names to begin with "DRM_" for newer versions + * of the macro used to fill out the DRM ioctl table. Similarly, the + * ioctl number names must begin with "DRM_IOCTL_". The suffixes for the + * two sets of strings must match (e.g. end with "PVR_SRVKM" in both + * cases). + */ + +#define DRM_PVR_SRVKM PVR_DRM_SRVKM_CMD +#define DRM_PVR_IS_MASTER PVR_DRM_IS_MASTER_CMD +#define DRM_PVR_UNPRIV PVR_DRM_UNPRIV_CMD +#define DRM_PVR_DBGDRV PVR_DRM_DBGDRV_CMD +#define DRM_PVR_DISP PVR_DRM_DISP_CMD + +/* + * Some versions of the kernel will dereference a NULL pointer if data is + * is passed to an ioctl that doesn't expect any, so avoid using the _IO + * macro, and use _IOW instead, specifying a dummy argument. +*/ +typedef struct { + char dummy[4]; +} drm_pvr_dummy_arg; + +/* IOCTL numbers, relative to DRM_COMMAND_BASE */ +#define DRM_IOCTL_PVR_SRVKM _IOWR(0, DRM_PVR_SRVKM, PVRSRV_BRIDGE_PACKAGE) +#define DRM_IOCTL_PVR_IS_MASTER _IOW(0, DRM_PVR_IS_MASTER, drm_pvr_dummy_arg) +#define DRM_IOCTL_PVR_UNPRIV _IOWR(0, DRM_PVR_UNPRIV, drm_pvr_unpriv_cmd) + +#if defined(PDUMP) +#define DRM_IOCTL_PVR_DBGDRV _IOWR(0, DRM_PVR_DBGDRV, IOCTL_PACKAGE) +#endif + +#if defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +#define DRM_IOCTL_PVR_DISP _IOWR(0, DRM_PVR_DISP, drm_pvr_display_cmd) +#endif +#endif /* !defined(SUPPORT_DRI_DRM_EXT) */ + +#if defined(SUPPORT_DRI_DRM_PLUGIN) +typedef struct { + char *name; + + int (*load)(struct drm_device *dev, unsigned long flags); + int (*unload)(struct drm_device *dev); + + int (*open)(struct drm_device *dev, struct drm_file *file); + int (*release)(struct drm_device *dev, struct drm_file *file); + + int (*mmap)(struct file* pFile, struct vm_area_struct* ps_vma); + + struct drm_ioctl_desc *ioctls; + int num_ioctls; + int ioctl_start; +} PVRSRV_DRM_PLUGIN; + +int SysDRMRegisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin); +void SysDRMUnregisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin); +#endif /* defined(SUPPORT_DRI_DRM_PLUGIN) */ + +#endif /* defined(SUPPORT_DRI_DRM) */ + +#endif /* defined(__PVR_DRM_H__) */ + + diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_sync.c b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_sync.c new file mode 100755 index 00000000000..476f0a8cb10 --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_sync.c @@ -0,0 +1,1766 @@ +/*************************************************************************/ /*! +@File pvr_sync.c +@Title Kernel driver for Android's sync mechanism +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#include "pvr_sync.h" + +#include <linux/kernel.h> +#include <linux/file.h> +#include <linux/fs.h> +#include <linux/miscdevice.h> +#include <linux/module.h> +#include <linux/syscalls.h> +#include <linux/uaccess.h> +#include <linux/types.h> +#include <linux/atomic.h> +#include <linux/anon_inodes.h> +#include <linux/seq_file.h> + +#include "services_headers.h" +#include "sgxutils.h" +#include "ttrace.h" +#include "mutex.h" +#include "lock.h" + +//#define DEBUG_PRINT + +#if defined(DEBUG_PRINT) +#define DPF(fmt, ...) PVR_DPF((PVR_DBG_BUFFERED, fmt, __VA_ARGS__)) +#else +#define DPF(fmt, ...) do {} while(0) +#endif + +/* We can't support this code when the MISR runs in atomic context because + * PVRSyncFreeSync() may be called by sync_timeline_signal() which may be + * scheduled by the MISR. PVRSyncFreeSync() needs to protect the handle + * tables against modification and so uses the Linux bridge mutex. + * + * You can't lock a mutex in atomic context. + */ +#if !defined(PVR_LINUX_MISR_USING_WORKQUEUE) && \ + !defined(PVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE) +#error The Android sync driver requires that the SGX MISR runs in wq context +#endif + +/* Local wrapper around PVRSRV_KERNEL_SYNC_INFO to add a list head */ + +struct PVR_SYNC_KERNEL_SYNC_INFO +{ + /* Base services sync info structure */ + PVRSRV_KERNEL_SYNC_INFO *psBase; + + /* Sync points can go away when there are deferred hardware + * operations still outstanding. We must not free the SYNC_INFO + * until the hardware is finished, so we add it to a defer list + * which is processed periodically ("defer-free"). + * + * This is also used for "defer-free" of a timeline -- the process + * may destroy its timeline or terminate abnormally but the HW could + * still be using the sync object hanging off of the timeline. + * + * Note that the defer-free list is global, not per-timeline. + */ + struct list_head sHead; +}; + +/* This is the IMG extension of a sync_timeline */ + +struct PVR_SYNC_TIMELINE +{ + struct sync_timeline obj; + + /* Needed to keep a global list of all timelines for MISR checks. */ + struct list_head sTimelineList; + + /* True if a sync point on the timeline has signaled */ + IMG_BOOL bSyncHasSignaled; + + /* A mutex, as we want to ensure that the comparison (and possible + * reset) of the highest SW fence value is atomic with the takeop, + * so both the SW fence value and the WOP snapshot should both have + * the same order for all SW syncs. + * + * This mutex also protects modifications to the fence stamp counter. + */ + struct mutex sTimelineLock; + + /* Every timeline has a services sync object. This object must not + * be used by the hardware to enforce ordering -- that's what the + * per sync-point objects are for. This object is attached to every + * TQ scheduled on the timeline and is primarily useful for debugging. + */ + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo; +}; + +/* A PVR_SYNC_DATA is the basic guts of a sync point. It's kept separate + * because sync points can be dup'ed, and we don't want to duplicate all + * of the shared metadata. + * + * This is also used to back an allocated sync info, which can be passed to + * the CREATE ioctl to insert the fence and add it to the timeline. This is + * used as an intermediate step as a PVRSRV_KERNEL_SYNC_INFO is needed to + * attach to the transfer task used as a fence in the hardware. + */ + +struct PVR_SYNC_DATA +{ + /* Every sync point has a services sync object. This object is used + * by the hardware to enforce ordering -- it is attached as a source + * dependency to various commands. + */ + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo; + + /* This refcount is incremented at create and dup time, and decremented + * at free time. It ensures the object doesn't start the defer-free + * process until it is no longer referenced. + */ + atomic_t sRefcount; + + /* This is purely a debug feature. Record the WOP snapshot from the + * timeline synchronization object when a new fence is created. + */ + IMG_UINT32 ui32WOPSnapshot; + + /* This is a globally unique ID for the sync point. If a sync point is + * dupped, its stamp is copied over (seems counter-intuitive, but in + * nearly all cases a sync point is merged with another, the original + * is freed). + */ + IMG_UINT64 ui64Stamp; +}; + +/* A PVR_ALLOC_SYNC_DATA is used to back an allocated, but not yet created + * and inserted into a timeline, sync data. This is required as we must + * allocate the syncinfo to be passed down with the transfer task used to + * implement fences in the hardware. + */ +struct PVR_ALLOC_SYNC_DATA +{ + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo; + + /* A link to the timeline is required to add a per-timeline sync + * to the fence transfer task. + */ + struct PVR_SYNC_TIMELINE *psTimeline; + struct file *psFile; +}; + +/* This is the IMG extension of a sync_pt */ + +struct PVR_SYNC +{ + struct sync_pt pt; + struct PVR_SYNC_DATA *psSyncData; +}; + +struct PVR_SYNC_FENCE +{ + /* Base sync_fence structure */ + struct sync_fence *psBase; + + /* To ensure callbacks are always received for fences / sync_pts, even + * after the fence has been 'put' (freed), we must take a reference to + * the fence. We still need to 'put' the fence ourselves, but this might + * happen in irq context, where fput() is not allowed (in kernels <3.6). + * We must add the fence to a list which is processed in WQ context. + */ + struct list_head sHead; +}; + +/* Any sync point from a foreign (non-PVR) timeline needs to have a "shadow" + * syncinfo. This is modelled as a software operation. The foreign driver + * completes the operation by calling a callback we registered with it. + * + * Because we are allocating SYNCINFOs for each sync_pt, rather than each + * fence, we need to extend the waiter struct slightly to include the + * necessary metadata. + */ +struct PVR_SYNC_FENCE_WAITER +{ + /* Base sync driver waiter structure */ + struct sync_fence_waiter sWaiter; + + /* "Shadow" syncinfo backing the foreign driver's sync_pt */ + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo; + + /* Optimizes lookup of fence for defer-put operation */ + struct PVR_SYNC_FENCE *psSyncFence; +}; + +/* Global data relating to PVR services connection */ + +static struct +{ + /* Process that initialized the sync driver. House-keep this so + * the correct per-proc data is used during shutdown. This PID is + * conventionally whatever `pvrsrvctl' was when it was alive. + */ + IMG_UINT32 ui32Pid; + + /* Device cookie for services allocation functions. The device would + * ordinarily be SGX, and the first/only device in the system. + */ + IMG_HANDLE hDevCookie; + + /* Device memory context that all SYNC_INFOs allocated by this driver + * will be created in. Because SYNC_INFOs are placed in a shared heap, + * it does not matter from which process the create ioctl originates. + */ + IMG_HANDLE hDevMemContext; +} +gsSyncServicesConnection; + +/* Multi-purpose workqueue. Various functions in the Google sync driver + * may call down to us in atomic context. However, sometimes we may need + * to lock a mutex. To work around this conflict, use the workqueue to + * defer whatever the operation was. + */ +static struct workqueue_struct *gpsWorkQueue; + +/* Linux work struct for workqueue. */ +static struct work_struct gsWork; + +/* List of timelines, used by MISR callback to find signalled sync points + * and also to kick the hardware if signalling may allow progress to be + * made. + */ +static LIST_HEAD(gTimelineList); +static DEFINE_MUTEX(gTimelineListLock); + +/* The "defer-free" object list. Driver global. */ +static LIST_HEAD(gSyncInfoFreeList); +static DEFINE_SPINLOCK(gSyncInfoFreeListLock); + +/* The "defer-put" object list. Driver global. */ +static LIST_HEAD(gFencePutList); +static DEFINE_SPINLOCK(gFencePutListLock); + +/* Sync point stamp counter -- incremented on creation of a new sync point */ +static IMG_UINT64 gui64SyncPointStamp; + +/* Forward declare due to cyclic dependency on gsSyncFenceAllocFOps */ +static struct PVR_ALLOC_SYNC_DATA *PVRSyncAllocFDGet(int fd); + +/* NOTE: Must only be called with services bridge mutex held */ +static void PVRSyncSWTakeOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + psKernelSyncInfo->psSyncData->ui32WriteOpsPending = 1; +} + +static void PVRSyncSWCompleteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + psKernelSyncInfo->psSyncData->ui32WriteOpsComplete = 1; +} + +static struct PVR_SYNC * +PVRSyncCreateSync(struct PVR_SYNC_TIMELINE *obj, + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo) +{ + struct PVR_SYNC *psPt = NULL; + + psPt = (struct PVR_SYNC *) + sync_pt_create(&obj->obj, sizeof(struct PVR_SYNC)); + if(!psPt) + { + PVR_DPF((PVR_DBG_ERROR, "%s: sync_pt_create failed", __func__)); + goto err_out; + } + + psPt->psSyncData = kmalloc(sizeof(struct PVR_SYNC_DATA), GFP_KERNEL); + if(!psPt->psSyncData) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate PVR_SYNC_DATA", + __func__)); + goto err_free_pt; + } + + atomic_set(&psPt->psSyncData->sRefcount, 1); + + psPt->psSyncData->ui32WOPSnapshot = + obj->psSyncInfo->psBase->psSyncData->ui32WriteOpsPending; + + psPt->psSyncData->psSyncInfo = psSyncInfo; + + /* Stamp the point and update the global counter under lock */ + mutex_lock(&obj->sTimelineLock); + psPt->psSyncData->ui64Stamp = gui64SyncPointStamp++; + mutex_unlock(&obj->sTimelineLock); + +err_out: + return psPt; +err_free_pt: + sync_pt_free((struct sync_pt *)psPt); + psPt = NULL; + goto err_out; +} + +static IMG_BOOL PVRSyncIsSyncInfoInUse(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo) +{ + return !(psSyncInfo->psSyncData->ui32WriteOpsPending == + psSyncInfo->psSyncData->ui32WriteOpsComplete && + psSyncInfo->psSyncData->ui32ReadOpsPending == + psSyncInfo->psSyncData->ui32ReadOpsComplete && + psSyncInfo->psSyncData->ui32ReadOps2Pending == + psSyncInfo->psSyncData->ui32ReadOps2Complete); +} + +/* Releases a sync info by adding it to a deferred list to be freed later. */ +static void +PVRSyncReleaseSyncInfo(struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo) +{ + unsigned long flags; + + spin_lock_irqsave(&gSyncInfoFreeListLock, flags); + list_add_tail(&psSyncInfo->sHead, &gSyncInfoFreeList); + spin_unlock_irqrestore(&gSyncInfoFreeListLock, flags); + + queue_work(gpsWorkQueue, &gsWork); +} + +static void PVRSyncFreeSyncData(struct PVR_SYNC_DATA *psSyncData) +{ + PVR_ASSERT(atomic_read(&psSyncData->sRefcount) == 0); + PVRSyncReleaseSyncInfo(psSyncData->psSyncInfo); + psSyncData->psSyncInfo = NULL; + kfree(psSyncData); +} + +static void PVRSyncFreeSync(struct sync_pt *psPt) +{ + struct PVR_SYNC *psSync = (struct PVR_SYNC *)psPt; +#if defined(DEBUG_PRINT) + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = + psSync->psSyncData->psSyncInfo->psBase; +#endif + + PVR_ASSERT(atomic_read(&psSync->psSyncData->sRefcount) > 0); + + /* Only free on the last reference */ + if (atomic_dec_return(&psSync->psSyncData->sRefcount) != 0) + return; + + DPF("R( ): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X " + "WOP/C=0x%x/0x%x ROP/C=0x%x/0x%x RO2P/C=0x%x/0x%x " + "ID=%llu, S=0x%x, F=%p", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->sReadOps2CompleteDevVAddr.uiAddr, + psSyncInfo->psSyncData->ui32WriteOpsPending, + psSyncInfo->psSyncData->ui32WriteOpsComplete, + psSyncInfo->psSyncData->ui32ReadOpsPending, + psSyncInfo->psSyncData->ui32ReadOpsComplete, + psSyncInfo->psSyncData->ui32ReadOps2Pending, + psSyncInfo->psSyncData->ui32ReadOps2Complete, + psSync->psSyncData->ui64Stamp, + psSync->psSyncData->ui32WOPSnapshot, + psSync->pt.fence); + + PVRSyncFreeSyncData(psSync->psSyncData); + psSync->psSyncData = NULL; +} + +static struct sync_pt *PVRSyncDup(struct sync_pt *sync_pt) +{ + struct PVR_SYNC *psPt, *psParentPt = (struct PVR_SYNC *)sync_pt; + + psPt = (struct PVR_SYNC *) + sync_pt_create(sync_pt->parent, sizeof(struct PVR_SYNC)); + if(!psPt) + { + PVR_DPF((PVR_DBG_ERROR, "%s: sync_pt_create failed", __func__)); + goto err_out; + } + + psPt->psSyncData = psParentPt->psSyncData; + atomic_inc(&psPt->psSyncData->sRefcount); + + PVR_ASSERT(atomic_read(&psPt->psSyncData->sRefcount) > 1); + +err_out: + return (struct sync_pt*)psPt; +} + +static int PVRSyncHasSignaled(struct sync_pt *sync_pt) +{ + struct PVR_SYNC *psPt = (struct PVR_SYNC *)sync_pt; + struct PVR_SYNC_TIMELINE *psTimeline = + (struct PVR_SYNC_TIMELINE *) sync_pt->parent; + PVRSRV_SYNC_DATA *psSyncData = + psPt->psSyncData->psSyncInfo->psBase->psSyncData; + + if (psSyncData->ui32WriteOpsComplete >= psSyncData->ui32WriteOpsPending) + { + psTimeline->bSyncHasSignaled = IMG_TRUE; + return 1; + } + + return 0; +} + +static int PVRSyncCompare(struct sync_pt *a, struct sync_pt *b) +{ + IMG_UINT64 ui64StampA = ((struct PVR_SYNC *)a)->psSyncData->ui64Stamp; + IMG_UINT64 ui64StampB = ((struct PVR_SYNC *)b)->psSyncData->ui64Stamp; + + if (ui64StampA == ui64StampB) + return 0; + else if (ui64StampA > ui64StampB) + return 1; + else + return -1; +} + +static void PVRSyncPrintTimeline(struct seq_file *s, + struct sync_timeline *psObj) +{ + struct PVR_SYNC_TIMELINE *psTimeline = (struct PVR_SYNC_TIMELINE *)psObj; + + seq_printf(s, "WOP/WOC=0x%x/0x%x", + psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsPending, + psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsComplete); +} + +static void PVRSyncPrint(struct seq_file *s, struct sync_pt *psPt) +{ + struct PVR_SYNC *psSync = (struct PVR_SYNC *)psPt; + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = + psSync->psSyncData->psSyncInfo->psBase; + + seq_printf(s, "ID=%llu, refs=%u, WOPSnapshot=0x%x, parent=%p", + psSync->psSyncData->ui64Stamp, + atomic_read(&psSync->psSyncData->sRefcount), + psSync->psSyncData->ui32WOPSnapshot, + psSync->pt.parent); + seq_printf(s, "\n WOP/WOC=0x%x/0x%x, " + "ROP/ROC=0x%x/0x%x, ROP2/ROC2=0x%x/0x%x, " + "WOC DevVA=0x%.8x, ROC DevVA=0x%.8x, " + "ROC2 DevVA=0x%.8x", + psSyncInfo->psSyncData->ui32WriteOpsPending, + psSyncInfo->psSyncData->ui32WriteOpsComplete, + psSyncInfo->psSyncData->ui32ReadOpsPending, + psSyncInfo->psSyncData->ui32ReadOpsComplete, + psSyncInfo->psSyncData->ui32ReadOps2Pending, + psSyncInfo->psSyncData->ui32ReadOps2Complete, + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->sReadOps2CompleteDevVAddr.uiAddr); +} + +static void PVRSyncReleaseTimeline(struct sync_timeline *psObj) +{ + struct PVR_SYNC_TIMELINE *psTimeline = (struct PVR_SYNC_TIMELINE *)psObj; + + mutex_lock(&gTimelineListLock); + list_del(&psTimeline->sTimelineList); + mutex_unlock(&gTimelineListLock); + + DPF("R(t): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X " + "WOP/C=0x%x/0x%x ROP/C=0x%x/0x%x RO2P/C=0x%x/0x%x T=%p", + psTimeline->psSyncInfo->psBase->sWriteOpsCompleteDevVAddr.uiAddr, + psTimeline->psSyncInfo->psBase->sReadOpsCompleteDevVAddr.uiAddr, + psTimeline->psSyncInfo->psBase->sReadOps2CompleteDevVAddr.uiAddr, + psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsPending, + psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsComplete, + psTimeline->psSyncInfo->psBase->psSyncData->ui32ReadOpsPending, + psTimeline->psSyncInfo->psBase->psSyncData->ui32ReadOpsComplete, + psTimeline->psSyncInfo->psBase->psSyncData->ui32ReadOps2Pending, + psTimeline->psSyncInfo->psBase->psSyncData->ui32ReadOps2Complete, + psTimeline); + + PVRSyncReleaseSyncInfo(psTimeline->psSyncInfo); + psTimeline->psSyncInfo = NULL; +} + +static PVRSRV_ERROR PVRSyncInitServices(void) +{ + IMG_BOOL bCreated, bShared[PVRSRV_MAX_CLIENT_HEAPS]; + PVRSRV_HEAP_INFO sHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; + IMG_UINT32 ui32ClientHeapCount = 0; + PVRSRV_PER_PROCESS_DATA *psPerProc; + PVRSRV_ERROR eError; + + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); + + gsSyncServicesConnection.ui32Pid = OSGetCurrentProcessIDKM(); + + eError = PVRSRVProcessConnect(gsSyncServicesConnection.ui32Pid, 0); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: PVRSRVProcessConnect failed", + __func__)); + goto err_unlock; + } + + psPerProc = PVRSRVFindPerProcessData(); + if (!psPerProc) + { + PVR_DPF((PVR_DBG_ERROR, "%s: PVRSRVFindPerProcessData failed", + __func__)); + goto err_disconnect; + } + + eError = PVRSRVAcquireDeviceDataKM(0, PVRSRV_DEVICE_TYPE_SGX, + &gsSyncServicesConnection.hDevCookie); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: PVRSRVAcquireDeviceDataKM failed", + __func__)); + goto err_disconnect; + } + + if (!gsSyncServicesConnection.hDevCookie) + { + PVR_DPF((PVR_DBG_ERROR, "%s: hDevCookie is NULL", __func__)); + goto err_disconnect; + } + + eError = PVRSRVCreateDeviceMemContextKM(gsSyncServicesConnection.hDevCookie, + psPerProc, + &gsSyncServicesConnection.hDevMemContext, + &ui32ClientHeapCount, + &sHeapInfo[0], + &bCreated, + &bShared[0]); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: PVRSRVCreateDeviceMemContextKM failed", + __func__)); + goto err_disconnect; + } + + if (!gsSyncServicesConnection.hDevMemContext) + { + PVR_DPF((PVR_DBG_ERROR, "%s: hDevMemContext is NULL", __func__)); + goto err_disconnect; + } + +err_unlock: + LinuxUnLockMutex(&gPVRSRVLock); + return eError; + +err_disconnect: + PVRSRVProcessDisconnect(gsSyncServicesConnection.ui32Pid); + goto err_unlock; +} + +static void PVRSyncCloseServices(void) +{ + IMG_BOOL bDummy; + + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); + + PVRSRVDestroyDeviceMemContextKM(gsSyncServicesConnection.hDevCookie, + gsSyncServicesConnection.hDevMemContext, + &bDummy); + gsSyncServicesConnection.hDevMemContext = NULL; + gsSyncServicesConnection.hDevCookie = NULL; + + PVRSRVProcessDisconnect(gsSyncServicesConnection.ui32Pid); + gsSyncServicesConnection.ui32Pid = 0; + + LinuxUnLockMutex(&gPVRSRVLock); +} + +static struct sync_timeline_ops gsTimelineOps = +{ + .driver_name = "pvr_sync", + .dup = PVRSyncDup, + .has_signaled = PVRSyncHasSignaled, + .compare = PVRSyncCompare, + .release_obj = PVRSyncReleaseTimeline, + .print_obj = PVRSyncPrintTimeline, + .print_pt = PVRSyncPrint, + .free_pt = PVRSyncFreeSync, +}; + +static struct PVR_SYNC_TIMELINE *PVRSyncCreateTimeline(const IMG_CHAR *pszName) +{ + struct PVR_SYNC_TIMELINE *psTimeline; + PVRSRV_ERROR eError; + + psTimeline = (struct PVR_SYNC_TIMELINE *) + sync_timeline_create(&gsTimelineOps, sizeof(struct PVR_SYNC_TIMELINE), + pszName); + if (!psTimeline) + { + PVR_DPF((PVR_DBG_ERROR, "%s: sync_timeline_create failed", __func__)); + goto err_out; + } + + psTimeline->psSyncInfo = + kmalloc(sizeof(struct PVR_SYNC_KERNEL_SYNC_INFO), GFP_KERNEL); + if(!psTimeline->psSyncInfo) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate " + "PVR_SYNC_KERNEL_SYNC_INFO", __func__)); + goto err_free_timeline; + } + + psTimeline->bSyncHasSignaled = IMG_FALSE; + + mutex_init(&psTimeline->sTimelineLock); + + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); + eError = PVRSRVAllocSyncInfoKM(gsSyncServicesConnection.hDevCookie, + gsSyncServicesConnection.hDevMemContext, + &psTimeline->psSyncInfo->psBase); + LinuxUnLockMutex(&gPVRSRVLock); + + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate timeline syncinfo", + __func__)); + goto err_free_syncinfo; + } + + DPF("A(t): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X T=%p %s", + psTimeline->psSyncInfo->psBase->sWriteOpsCompleteDevVAddr.uiAddr, + psTimeline->psSyncInfo->psBase->sReadOpsCompleteDevVAddr.uiAddr, + psTimeline->psSyncInfo->psBase->sReadOps2CompleteDevVAddr.uiAddr, + psTimeline, pszName); + +err_out: + return psTimeline; +err_free_syncinfo: + kfree(psTimeline->psSyncInfo); +err_free_timeline: + sync_timeline_destroy((struct sync_timeline *)psTimeline); + psTimeline = NULL; + goto err_out; +} + +static int PVRSyncOpen(struct inode *inode, struct file *file) +{ + struct PVR_SYNC_TIMELINE *psTimeline; + IMG_CHAR task_comm[TASK_COMM_LEN+1]; + + get_task_comm(task_comm, current); + + psTimeline = PVRSyncCreateTimeline(task_comm); + if (!psTimeline) + return -ENOMEM; + + mutex_lock(&gTimelineListLock); + list_add_tail(&psTimeline->sTimelineList, &gTimelineList); + mutex_unlock(&gTimelineListLock); + + file->private_data = psTimeline; + return 0; +} + +static int PVRSyncRelease(struct inode *inode, struct file *file) +{ + struct PVR_SYNC_TIMELINE *psTimeline = file->private_data; + sync_timeline_destroy(&psTimeline->obj); + return 0; +} + +static long +PVRSyncIOCTLCreate(struct PVR_SYNC_TIMELINE *psObj, void __user *pvData) +{ + struct PVR_SYNC_KERNEL_SYNC_INFO *psProvidedSyncInfo = NULL; + struct PVR_ALLOC_SYNC_DATA *psAllocSyncData; + struct PVR_SYNC_CREATE_IOCTL_DATA sData; + int err = -EFAULT, iFd = get_unused_fd(); + struct sync_fence *psFence; + struct sync_pt *psPt; + + if (iFd < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to find unused fd (%d)", + __func__, iFd)); + goto err_out; + } + + if (!access_ok(VERIFY_READ, pvData, sizeof(sData))) + goto err_put_fd; + + if (copy_from_user(&sData, pvData, sizeof(sData))) + goto err_put_fd; + + if (sData.allocdSyncInfo < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Requested to create a fence from " + " an invalid alloc'd fd (%d)", __func__, + sData.allocdSyncInfo)); + goto err_put_fd; + } + + psAllocSyncData = PVRSyncAllocFDGet(sData.allocdSyncInfo); + if (!psAllocSyncData) + { + PVR_DPF((PVR_DBG_ERROR, "%s: PVRSyncAllocFDGet returned NULL, " + "possibly fd passed to CREATE is not an " + "ALLOC'd sync?", __func__)); + goto err_put_fd; + } + + /* Move the psSyncInfo to the newly created sync, to avoid attempting + * to create multiple syncs from the same allocation. + */ + psProvidedSyncInfo = psAllocSyncData->psSyncInfo; + psAllocSyncData->psSyncInfo = NULL; + + if (psProvidedSyncInfo == NULL) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Alloc'd sync info is null - " + "possibly already CREATEd?", __func__)); + fput(psAllocSyncData->psFile); + goto err_put_fd; + } + + fput(psAllocSyncData->psFile); + + psPt = (struct sync_pt *)PVRSyncCreateSync(psObj, psProvidedSyncInfo); + if (!psPt) + { + err = -ENOMEM; + goto err_put_fd; + } + + sData.name[sizeof(sData.name) - 1] = '\0'; + psFence = sync_fence_create(sData.name, psPt); + if (!psFence) + { + sync_pt_free(psPt); + err = -ENOMEM; + goto err_put_fd; + } + + sData.fence = iFd; + + if (!access_ok(VERIFY_WRITE, pvData, sizeof(sData))) + { + sync_fence_put(psFence); + goto err_put_fd; + } + + if (copy_to_user(pvData, &sData, sizeof(sData))) + { + sync_fence_put(psFence); + goto err_put_fd; + } + + /* If the fence is a 'real' one, its signal status will be updated by + * the MISR calling PVRSyncUpdateAllSyncs(). However, if we created + * a 'fake' fence (for power optimization reasons) it has already + * completed, and needs to be marked signalled (as the MISR will + * never run for 'fake' fences). + */ + if(psProvidedSyncInfo->psBase->psSyncData->ui32WriteOpsPending == 0) + sync_timeline_signal((struct sync_timeline *)psObj); + + DPF("C( ): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X F=%p %s", + psProvidedSyncInfo->psBase->sWriteOpsCompleteDevVAddr.uiAddr, + psProvidedSyncInfo->psBase->sReadOpsCompleteDevVAddr.uiAddr, + psProvidedSyncInfo->psBase->sReadOps2CompleteDevVAddr.uiAddr, + psFence, sData.name); + + sync_fence_install(psFence, iFd); + err = 0; +err_out: + return err; + +err_put_fd: + put_unused_fd(iFd); + goto err_out; +} + +static long +PVRSyncIOCTLDebug(struct PVR_SYNC_TIMELINE *psObj, void __user *pvData) +{ + struct PVR_SYNC_DEBUG_IOCTL_DATA sData; + struct sync_fence *psFence; + struct list_head *psEntry; + int i = 0, err = -EFAULT; + + if(!access_ok(VERIFY_READ, pvData, sizeof(sData))) + goto err_out; + + if(copy_from_user(&sData, pvData, sizeof(sData))) + goto err_out; + + psFence = sync_fence_fdget(sData.iFenceFD); + if(!psFence) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get fence from fd", __func__)); + goto err_out; + } + + list_for_each(psEntry, &psFence->pt_list_head) + { + PVR_SYNC_DEBUG *psMetaData = &sData.sSync[i].sMetaData; + PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; + struct PVR_SYNC_TIMELINE *psTimeline; + struct PVR_SYNC *psPt; + + if(i == PVR_SYNC_DEBUG_MAX_POINTS) + { + PVR_DPF((PVR_DBG_WARNING, "%s: Fence merged with more than %d " + "points", __func__, + PVR_SYNC_DEBUG_MAX_POINTS)); + break; + } + + psPt = (struct PVR_SYNC *) + container_of(psEntry, struct sync_pt, pt_list); + + /* Don't dump foreign points */ + if(psPt->pt.parent->ops != &gsTimelineOps) + continue; + + psTimeline = (struct PVR_SYNC_TIMELINE *)psPt->pt.parent; + psKernelSyncInfo = psPt->psSyncData->psSyncInfo->psBase; + PVR_ASSERT(psKernelSyncInfo != NULL); + + /* The sync refcount is valid as long as the FenceFD stays open, + * so we can access it directly without worrying about it being + * freed. + */ + sData.sSync[i].sSyncData = *psKernelSyncInfo->psSyncData; + + psMetaData->ui64Stamp = psPt->psSyncData->ui64Stamp; + psMetaData->ui32WriteOpsPendingSnapshot = psPt->psSyncData->ui32WOPSnapshot; + i++; + } + + sync_fence_put(psFence); + + sData.ui32NumPoints = i; + + if(!access_ok(VERIFY_WRITE, pvData, sizeof(sData))) + goto err_out; + + if(copy_to_user(pvData, &sData, sizeof(sData))) + goto err_out; + + err = 0; +err_out: + return err; +} + +static int PVRSyncFenceAllocRelease(struct inode *inode, struct file *file) +{ + struct PVR_ALLOC_SYNC_DATA *psAllocSyncData = file->private_data; + + if(psAllocSyncData->psSyncInfo) + { +#if defined(DEBUG_PRINT) + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = + psAllocSyncData->psSyncInfo->psBase; +#endif + + DPF("R(a): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X", + psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->sReadOps2CompleteDevVAddr.uiAddr); + + PVRSyncReleaseSyncInfo(psAllocSyncData->psSyncInfo); + psAllocSyncData->psSyncInfo = NULL; + } + + kfree(psAllocSyncData); + return 0; +} + +static const struct file_operations gsSyncFenceAllocFOps = +{ + .release = PVRSyncFenceAllocRelease, +}; + +static struct PVR_ALLOC_SYNC_DATA *PVRSyncAllocFDGet(int fd) +{ + struct file *file = fget(fd); + if (!file) + return NULL; + if (file->f_op != &gsSyncFenceAllocFOps) + goto err; + return file->private_data; +err: + fput(file); + return NULL; +} + +static long +PVRSyncIOCTLAlloc(struct PVR_SYNC_TIMELINE *psTimeline, void __user *pvData) +{ + struct PVR_ALLOC_SYNC_DATA *psAllocSyncData; + int err = -EFAULT, iFd = get_unused_fd(); + struct PVR_SYNC_ALLOC_IOCTL_DATA sData; + PVRSRV_SYNC_DATA *psSyncData; + struct file *psFile; + PVRSRV_ERROR eError; + + if (iFd < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to find unused fd (%d)", + __func__, iFd)); + goto err_out; + } + + if (!access_ok(VERIFY_READ, pvData, sizeof(sData))) + goto err_put_fd; + + if (copy_from_user(&sData, pvData, sizeof(sData))) + goto err_put_fd; + + psAllocSyncData = kmalloc(sizeof(struct PVR_ALLOC_SYNC_DATA), GFP_KERNEL); + if (!psAllocSyncData) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate PVR_ALLOC_SYNC_DATA", + __func__)); + err = -ENOMEM; + goto err_put_fd; + } + + psAllocSyncData->psSyncInfo = + kmalloc(sizeof(struct PVR_SYNC_KERNEL_SYNC_INFO), GFP_KERNEL); + if (!psAllocSyncData->psSyncInfo) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate " + "PVR_SYNC_KERNEL_SYNC_INFO", __func__)); + err = -ENOMEM; + goto err_free_alloc_sync_data; + } + + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); + eError = PVRSRVAllocSyncInfoKM(gsSyncServicesConnection.hDevCookie, + gsSyncServicesConnection.hDevMemContext, + &psAllocSyncData->psSyncInfo->psBase); + LinuxUnLockMutex(&gPVRSRVLock); + + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to alloc syncinfo (%d)", + __func__, eError)); + err = -ENOMEM; + goto err_free_sync_info; + } + + psFile = anon_inode_getfile("pvr_sync_alloc", + &gsSyncFenceAllocFOps, psAllocSyncData, 0); + if (!psFile) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to create anon inode", + __func__)); + err = -ENOMEM; + goto err_release_sync_info; + } + + sData.fence = iFd; + + /* Check if this timeline looks idle. If there are still TQs running + * on it, userspace shouldn't attempt any kind of power optimization + * (e.g. it must not dummy-process GPU fences). + * + * Determining idleness here is safe because the ALLOC and CREATE + * pvr_sync ioctls must be called under the gralloc module lock, so + * we can't be creating another new fence op while we are still + * processing this one. + * + * Take the bridge lock anyway so we can be sure that we read the + * timeline sync's pending value coherently. The complete value may + * be modified by the GPU, but worse-case we will decide we can't do + * the power optimization and will still be correct. + */ + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); + + psSyncData = psTimeline->psSyncInfo->psBase->psSyncData; + if(psSyncData->ui32WriteOpsPending == psSyncData->ui32WriteOpsComplete) + sData.bTimelineIdle = IMG_TRUE; + else + sData.bTimelineIdle = IMG_FALSE; + + LinuxUnLockMutex(&gPVRSRVLock); + + if (!access_ok(VERIFY_WRITE, pvData, sizeof(sData))) + goto err_release_file; + + if (copy_to_user(pvData, &sData, sizeof(sData))) + goto err_release_file; + + psAllocSyncData->psTimeline = psTimeline; + psAllocSyncData->psFile = psFile; + + DPF("A( ): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X", + psAllocSyncData->psSyncInfo->psBase->sWriteOpsCompleteDevVAddr.uiAddr, + psAllocSyncData->psSyncInfo->psBase->sReadOpsCompleteDevVAddr.uiAddr, + psAllocSyncData->psSyncInfo->psBase->sReadOps2CompleteDevVAddr.uiAddr); + + fd_install(iFd, psFile); + err = 0; +err_out: + return err; +err_release_sync_info: + PVRSRVReleaseSyncInfoKM(psAllocSyncData->psSyncInfo->psBase); +err_free_sync_info: + kfree(psAllocSyncData->psSyncInfo); +err_free_alloc_sync_data: + kfree(psAllocSyncData); +err_put_fd: + put_unused_fd(iFd); + goto err_out; +err_release_file: + fput(psFile); + put_unused_fd(iFd); + goto err_out; +} + +static long +PVRSyncIOCTL(struct file *file, unsigned int cmd, unsigned long __user arg) +{ + struct PVR_SYNC_TIMELINE *psTimeline = file->private_data; + void __user *pvData = (void __user *)arg; + + switch (cmd) + { + case PVR_SYNC_IOC_CREATE_FENCE: + return PVRSyncIOCTLCreate(psTimeline, pvData); + case PVR_SYNC_IOC_DEBUG_FENCE: + return PVRSyncIOCTLDebug(psTimeline, pvData); + case PVR_SYNC_IOC_ALLOC_FENCE: + return PVRSyncIOCTLAlloc(psTimeline, pvData); + default: + return -ENOTTY; + } +} + +static void PVRSyncWorkQueueFunction(struct work_struct *data) +{ + PVRSRV_DEVICE_NODE *psDevNode = + (PVRSRV_DEVICE_NODE*)gsSyncServicesConnection.hDevCookie; + struct list_head sFreeList, *psEntry, *n; + unsigned long flags; + + /* We lock the bridge mutex here for two reasons. + * + * Firstly, the SGXScheduleProcessQueuesKM and PVRSRVReleaseSyncInfoKM + * functions require that they are called under lock. Multiple threads + * into services are not allowed. + * + * Secondly, we need to ensure that when processing the defer-free list, + * the PVRSyncIsSyncInfoInUse() function is called *after* any freed + * sync was attached as a HW dependency (had ROP/ROP2 taken). This is + * because for 'foreign' sync timelines we allocate a new object and + * mark it for deletion immediately. If the 'foreign' sync_pt signals + * before the kick ioctl has completed, we can block it from being + * prematurely freed by holding the bridge mutex. + * + * NOTE: This code relies on the assumption that we can acquire a + * spinlock while a mutex is held and that other users of the spinlock + * do not need to hold the bridge mutex. + */ + LinuxLockMutexNested(&gPVRSRVLock, PVRSRV_LOCK_CLASS_BRIDGE); + + /* A completed SW operation may un-block the GPU */ + SGXScheduleProcessQueuesKM(psDevNode); + + /* We can't call PVRSRVReleaseSyncInfoKM directly in this loop because + * that will take the mmap mutex. We can't take mutexes while we have + * this list locked with a spinlock. So move all the items we want to + * free to another, local list (no locking required) and process it + * in a second loop. + */ + + INIT_LIST_HEAD(&sFreeList); + spin_lock_irqsave(&gSyncInfoFreeListLock, flags); + list_for_each_safe(psEntry, n, &gSyncInfoFreeList) + { + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo = + container_of(psEntry, struct PVR_SYNC_KERNEL_SYNC_INFO, sHead); + + if(!PVRSyncIsSyncInfoInUse(psSyncInfo->psBase)) + list_move_tail(psEntry, &sFreeList); + + } + spin_unlock_irqrestore(&gSyncInfoFreeListLock, flags); + + list_for_each_safe(psEntry, n, &sFreeList) + { + struct PVR_SYNC_KERNEL_SYNC_INFO *psSyncInfo = + container_of(psEntry, struct PVR_SYNC_KERNEL_SYNC_INFO, sHead); + + list_del(psEntry); + + DPF("F(d): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X", + psSyncInfo->psBase->sWriteOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psBase->sReadOpsCompleteDevVAddr.uiAddr, + psSyncInfo->psBase->sReadOps2CompleteDevVAddr.uiAddr); + + PVRSRVReleaseSyncInfoKM(psSyncInfo->psBase); + psSyncInfo->psBase = NULL; + + kfree(psSyncInfo); + } + + LinuxUnLockMutex(&gPVRSRVLock); + + /* Copying from one list to another (so a spinlock isn't held) used to + * work around the problem that PVRSyncReleaseSyncInfo() would hold the + * services mutex. However, we no longer do this, so this code could + * potentially be simplified. + * + * Note however that sync_fence_put must be called from process/WQ + * context because it uses fput(), which is not allowed to be called + * from interrupt context in kernels <3.6. + */ + INIT_LIST_HEAD(&sFreeList); + spin_lock_irqsave(&gFencePutListLock, flags); + list_for_each_safe(psEntry, n, &gFencePutList) + { + list_move_tail(psEntry, &sFreeList); + } + spin_unlock_irqrestore(&gFencePutListLock, flags); + + list_for_each_safe(psEntry, n, &sFreeList) + { + struct PVR_SYNC_FENCE *psSyncFence = + container_of(psEntry, struct PVR_SYNC_FENCE, sHead); + + list_del(psEntry); + + sync_fence_put(psSyncFence->psBase); + psSyncFence->psBase = NULL; + + kfree(psSyncFence); + } +} + +static const struct file_operations gsPVRSyncFOps = +{ + .owner = THIS_MODULE, + .open = PVRSyncOpen, + .release = PVRSyncRelease, + .unlocked_ioctl = PVRSyncIOCTL, +}; + +static struct miscdevice gsPVRSyncDev = +{ + .minor = MISC_DYNAMIC_MINOR, + .name = "pvr_sync", + .fops = &gsPVRSyncFOps, +}; + +IMG_INTERNAL +int PVRSyncDeviceInit(void) +{ + int err = -1; + + if(PVRSyncInitServices() != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to initialise services", + __func__)); + goto err_out; + } + + gpsWorkQueue = create_freezable_workqueue("pvr_sync_workqueue"); + if(!gpsWorkQueue) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to create pvr_sync workqueue", + __func__)); + goto err_deinit_services; + } + + INIT_WORK(&gsWork, PVRSyncWorkQueueFunction); + + err = misc_register(&gsPVRSyncDev); + if(err) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to register pvr_sync misc " + "device (err=%d)", __func__, err)); + goto err_deinit_services; + } + + err = 0; +err_out: + return err; +err_deinit_services: + PVRSyncCloseServices(); + goto err_out; +} + +IMG_INTERNAL +void PVRSyncDeviceDeInit(void) +{ + misc_deregister(&gsPVRSyncDev); + destroy_workqueue(gpsWorkQueue); + PVRSyncCloseServices(); +} + +IMG_INTERNAL +void PVRSyncUpdateAllSyncs(void) +{ + IMG_BOOL bNeedToProcessQueues = IMG_FALSE; + struct list_head *psEntry; + + /* Check to see if any syncs have signalled. If they have, it may unblock + * the GPU. Decide what is needed and optionally schedule queue + * processing. + */ + mutex_lock(&gTimelineListLock); + list_for_each(psEntry, &gTimelineList) + { + struct PVR_SYNC_TIMELINE *psTimeline = + container_of(psEntry, struct PVR_SYNC_TIMELINE, sTimelineList); + + sync_timeline_signal((struct sync_timeline *)psTimeline); + + if(psTimeline->bSyncHasSignaled) + { + psTimeline->bSyncHasSignaled = IMG_FALSE; + bNeedToProcessQueues = IMG_TRUE; + } + } + mutex_unlock(&gTimelineListLock); + + if(bNeedToProcessQueues) + queue_work(gpsWorkQueue, &gsWork); +} + +static IMG_BOOL +PVRSyncIsDuplicate(PVRSRV_KERNEL_SYNC_INFO *psA, PVRSRV_KERNEL_SYNC_INFO *psB) +{ + return psA->sWriteOpsCompleteDevVAddr.uiAddr == + psB->sWriteOpsCompleteDevVAddr.uiAddr ? IMG_TRUE : IMG_FALSE; +} + +static void ForeignSyncPtSignaled(struct sync_fence *fence, + struct sync_fence_waiter *waiter) +{ + struct PVR_SYNC_FENCE_WAITER *psWaiter = + (struct PVR_SYNC_FENCE_WAITER *)waiter; + unsigned long flags; + + PVRSyncSWCompleteOp(psWaiter->psSyncInfo->psBase); + + DPF("R(f): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X " + "WOP/C=0x%x/0x%x ROP/C=0x%x/0x%x RO2P/C=0x%x/0x%x", + psWaiter->psSyncInfo->psBase->sWriteOpsCompleteDevVAddr.uiAddr, + psWaiter->psSyncInfo->psBase->sReadOpsCompleteDevVAddr.uiAddr, + psWaiter->psSyncInfo->psBase->sReadOps2CompleteDevVAddr.uiAddr, + psWaiter->psSyncInfo->psBase->psSyncData->ui32WriteOpsPending, + psWaiter->psSyncInfo->psBase->psSyncData->ui32WriteOpsComplete, + psWaiter->psSyncInfo->psBase->psSyncData->ui32ReadOpsPending, + psWaiter->psSyncInfo->psBase->psSyncData->ui32ReadOpsComplete, + psWaiter->psSyncInfo->psBase->psSyncData->ui32ReadOps2Pending, + psWaiter->psSyncInfo->psBase->psSyncData->ui32ReadOps2Complete); + + PVRSyncReleaseSyncInfo(psWaiter->psSyncInfo); + psWaiter->psSyncInfo = NULL; + + /* We can 'put' the fence now, but this function might be called in irq + * context so we must defer to WQ. + */ + spin_lock_irqsave(&gFencePutListLock, flags); + list_add_tail(&psWaiter->psSyncFence->sHead, &gFencePutList); + psWaiter->psSyncFence = NULL; + spin_unlock_irqrestore(&gFencePutListLock, flags); + + /* The PVRSyncReleaseSyncInfo() call above already queued work */ + /*queue_work(gpsWorkQueue, &gsWork);*/ + + kfree(psWaiter); +} + +static PVRSRV_KERNEL_SYNC_INFO *ForeignSyncPointToSyncInfo(int iFenceFd) +{ + PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; + struct PVR_SYNC_FENCE_WAITER *psWaiter; + struct PVR_SYNC_FENCE *psSyncFence; + struct sync_fence *psFence; + PVRSRV_ERROR eError; + int err; + + /* FIXME: Could optimize this function by pre-testing sync_wait(.., 0) + * to determine if it has already signalled. We must avoid this + * for now because the sync driver was broken in earlier kernels. + */ + + /* The custom waiter structure is freed in the waiter callback */ + psWaiter = kmalloc(sizeof(struct PVR_SYNC_FENCE_WAITER), GFP_KERNEL); + if(!psWaiter) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate waiter", __func__)); + goto err_out; + } + + psWaiter->psSyncInfo = + kmalloc(sizeof(struct PVR_SYNC_KERNEL_SYNC_INFO), GFP_KERNEL); + if(!psWaiter->psSyncInfo) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate " + "PVR_SYNC_KERNEL_SYNC_INFO", __func__)); + goto err_free_waiter; + } + + /* We take another reference on the parent fence, each time we see a + * 'foreign' sync_pt. This is to ensure the timeline, fence and sync_pts + * from the foreign timeline cannot go away until the sync_pt signals. + * In practice this also means they will not go away until the entire + * fence signals. It means that we will always get a + * sync_fence_wait_async() callback for these points. + */ + psFence = sync_fence_fdget(iFenceFd); + if(!psFence) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to take reference on fence", + __func__)); + goto err_free_syncinfo; + } + + /* Allocate packet we can store this fence on (with a list head) so we + * can add it to the defer-put list without allocating memory in irq + * context. + * + * NOTE: At the moment we allocate one of these per sync_pts, but it + * might be possible to optimize this to one per fence. + */ + psSyncFence = kmalloc(sizeof(struct PVR_SYNC_FENCE), GFP_KERNEL); + if(!psSyncFence) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate " + "PVR_SYNC_FENCE", __func__)); + goto err_sync_fence_put; + } + + psSyncFence->psBase = psFence; + psWaiter->psSyncFence = psSyncFence; + + /* Allocate a "shadow" SYNCINFO for this sync_pt and set it up to be + * completed by the callback. + */ + eError = PVRSRVAllocSyncInfoKM(gsSyncServicesConnection.hDevCookie, + gsSyncServicesConnection.hDevMemContext, + &psKernelSyncInfo); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate syncinfo", __func__)); + goto err_free_sync_fence; + } + + /* Make sure we take the SW operation before adding the waiter, to avoid + * racing with parallel completes. + */ + PVRSyncSWTakeOp(psKernelSyncInfo); + + sync_fence_waiter_init(&psWaiter->sWaiter, ForeignSyncPtSignaled); + psWaiter->psSyncInfo->psBase = psKernelSyncInfo; + + err = sync_fence_wait_async(psFence, &psWaiter->sWaiter); + if(err) + { + if(err < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Fence was in error state", __func__)); + /* Fall-thru */ + } + + /* -1 means the fence was broken, 1 means the fence already + * signalled. In either case, roll back what we've done and + * skip using this sync_pt for synchronization. + */ + goto err_release_sync_info; + } + + DPF("A(f): WOCVA=0x%.8X ROCVA=0x%.8X RO2CVA=0x%.8X F=%p", + psKernelSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psKernelSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psKernelSyncInfo->sReadOps2CompleteDevVAddr.uiAddr, + psFence); + + /* NOTE: Don't use psWaiter after this point as it may asynchronously + * signal before this function completes (and be freed already). + */ + + /* Even if the fence signals while we're hanging on to this, the sync + * can't be freed until the bridge mutex is taken in the callback. The + * bridge mutex won't be released by the caller of this function until + * the GPU operation has been scheduled, which increments ROP, + * preventing the sync from being freed when still in use by the GPU. + */ + return psKernelSyncInfo; + +err_release_sync_info: + PVRSyncSWCompleteOp(psKernelSyncInfo); + PVRSRVReleaseSyncInfoKM(psKernelSyncInfo); +err_free_sync_fence: + kfree(psSyncFence); +err_sync_fence_put: + sync_fence_put(psFence); +err_free_syncinfo: + kfree(psWaiter->psSyncInfo); +err_free_waiter: + kfree(psWaiter); +err_out: + return NULL; +} + +static void +CopyKernelSyncInfoToDeviceSyncObject(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, + PVRSRV_DEVICE_SYNC_OBJECT *psSyncObject) +{ + psSyncObject->sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + psSyncObject->sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; + psSyncObject->sReadOps2CompleteDevVAddr = psSyncInfo->sReadOps2CompleteDevVAddr; + psSyncObject->ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; + psSyncObject->ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; + psSyncObject->ui32ReadOps2PendingVal = psSyncInfo->psSyncData->ui32ReadOps2Pending; +} + +static IMG_BOOL FenceHasForeignPoints(struct sync_fence *psFence) +{ + struct list_head *psEntry; + + list_for_each(psEntry, &psFence->pt_list_head) + { + struct sync_pt *psPt = + container_of(psEntry, struct sync_pt, pt_list); + + if(psPt->parent->ops != &gsTimelineOps) + return IMG_TRUE; + } + + return IMG_FALSE; +} + +static IMG_BOOL +AddSyncInfoToArray(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, + IMG_UINT32 ui32SyncPointLimit, + IMG_UINT32 *pui32NumRealSyncs, + PVRSRV_KERNEL_SYNC_INFO *apsSyncInfo[]) +{ + /* Ran out of syncs. Not much userspace can do about this, since it + * could have been passed multiple merged syncs and doesn't know they + * were merged. Allow this through, but print a warning and stop + * synchronizing. + */ + if(*pui32NumRealSyncs == ui32SyncPointLimit) + { + PVR_DPF((PVR_DBG_WARNING, "%s: Ran out of source syncs %d == %d", + __func__, *pui32NumRealSyncs, + ui32SyncPointLimit)); + return IMG_FALSE; + } + + apsSyncInfo[*pui32NumRealSyncs] = psSyncInfo; + (*pui32NumRealSyncs)++; + return IMG_TRUE; +} + +static IMG_BOOL +ExpandAndDeDuplicateFenceSyncs(IMG_UINT32 ui32NumSyncs, + int aiFenceFds[], + IMG_UINT32 ui32SyncPointLimit, + struct sync_fence *apsFence[], + IMG_UINT32 *pui32NumRealSyncs, + PVRSRV_KERNEL_SYNC_INFO *apsSyncInfo[]) +{ + IMG_UINT32 i, j, ui32FenceIndex = 0; + IMG_BOOL bRet = IMG_TRUE; + + *pui32NumRealSyncs = 0; + + for(i = 0; i < ui32NumSyncs; i++) + { + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; + struct list_head *psEntry; + + /* Skip any invalid fence file descriptors without error */ + if(aiFenceFds[i] < 0) + continue; + + /* By converting a file descriptor to a struct sync_fence, we are + * taking a reference on the fence. We don't want the fence to go + * away until we have submitted the command, even if it signals + * before we dispatch the command, or the timeline(s) are destroyed. + * + * This reference should be released by the caller of this function + * once hardware operations have been scheduled on the GPU sync_pts + * participating in this fence. When our MISR is scheduled, the + * defer-free list will be processed, cleaning up the SYNCINFO. + * + * Note that this reference *isn't* enough for non-GPU sync_pts. + * We'll take another reference on the fence for those operations + * later (the life-cycle requirements there are totally different). + * + * Fence lookup may fail here if the fd became invalid since it was + * patched in userspace. That's really a userspace driver bug, so + * just fail here instead of not synchronizing. + */ + apsFence[ui32FenceIndex] = sync_fence_fdget(aiFenceFds[i]); + if(!apsFence[ui32FenceIndex]) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get fence from fd=%d", + __func__, aiFenceFds[i])); + bRet = IMG_FALSE; + goto err_out; + } + + /* If this fence has any points from foreign timelines, we need to + * allocate a 'shadow' SYNCINFO and update it in software ourselves, + * so the ukernel can test the readiness of the dependency. + * + * It's tempting to just handle all fences like this (since most of + * the time they *will* be merged with sw_sync) but such 'shadow' + * syncs are slower. This is because we need to wait for the MISR to + * schedule to update the GPU part of the fence (normally the ukernel + * would be able to make the update directly). + */ + if(FenceHasForeignPoints(apsFence[ui32FenceIndex])) + { + psSyncInfo = ForeignSyncPointToSyncInfo(aiFenceFds[i]); + if(psSyncInfo) + { + if(!AddSyncInfoToArray(psSyncInfo, ui32SyncPointLimit, + pui32NumRealSyncs, apsSyncInfo)) + { + /* Soft-fail. Stop synchronizing. */ + goto err_out; + } + } + ui32FenceIndex++; + continue; + } + + /* FIXME: The ForeignSyncPointToSyncInfo() path optimizes away already + * signalled fences. Consider optimizing this path too. + */ + list_for_each(psEntry, &apsFence[ui32FenceIndex]->pt_list_head) + { + struct sync_pt *psPt = + container_of(psEntry, struct sync_pt, pt_list); + + psSyncInfo = + ((struct PVR_SYNC *)psPt)->psSyncData->psSyncInfo->psBase; + + /* Walk the current list of points and make sure this isn't a + * duplicate. Duplicates will deadlock. + */ + for(j = 0; j < *pui32NumRealSyncs; j++) + { + /* The point is from a different timeline so we must use it */ + if(!PVRSyncIsDuplicate(apsSyncInfo[j], psSyncInfo)) + continue; + + /* There's no need to bump the real sync count as we either + * ignored the duplicate or replaced an previously counted + * entry. + */ + break; + } + + if(j == *pui32NumRealSyncs) + { + /* It's not a duplicate; moving on.. */ + if(!AddSyncInfoToArray(psSyncInfo, ui32SyncPointLimit, + pui32NumRealSyncs, apsSyncInfo)) + goto err_out; + } + } + + ui32FenceIndex++; + } + +err_out: + return bRet; +} + +IMG_INTERNAL PVRSRV_ERROR +PVRSyncPatchCCBKickSyncInfos(IMG_HANDLE ahSyncs[SGX_MAX_SRC_SYNCS_TA], + PVRSRV_DEVICE_SYNC_OBJECT asDevSyncs[SGX_MAX_SRC_SYNCS_TA], + IMG_UINT32 *pui32NumSrcSyncs) +{ + PVRSRV_KERNEL_SYNC_INFO *apsSyncInfo[SGX_MAX_SRC_SYNCS_TA]; + struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA] = {}; + IMG_UINT32 i, ui32NumRealSrcSyncs; + PVRSRV_ERROR eError = PVRSRV_OK; + + if(!ExpandAndDeDuplicateFenceSyncs(*pui32NumSrcSyncs, + (int *)ahSyncs, + SGX_MAX_SRC_SYNCS_TA, + apsFence, + &ui32NumRealSrcSyncs, + apsSyncInfo)) + { + eError = PVRSRV_ERROR_HANDLE_NOT_FOUND; + goto err_put_fence; + } + + /* There should only be one destination sync for a transfer. + * Ultimately this will be patched to two (the sync_pt SYNCINFO, + * and the timeline's SYNCINFO for debugging). + */ + for(i = 0; i < ui32NumRealSrcSyncs; i++) + { + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = apsSyncInfo[i]; + + /* The following code is mostly the same as the texture dependencies + * handling in SGXDoKickKM, but we have to copy it here because it + * must be run while the fence is 'locked' by sync_fence_fdget. + */ + + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_KICK, KICK_TOKEN_SRC_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + + CopyKernelSyncInfoToDeviceSyncObject(psSyncInfo, &asDevSyncs[i]); + + /* Texture dependencies are read operations */ + psSyncInfo->psSyncData->ui32ReadOpsPending++; + + /* Finally, patch the sync back into the input array. + * NOTE: The syncs are protected here by the defer-free worker. + */ + ahSyncs[i] = psSyncInfo; + } + + /* Updating this allows the PDUMP handling and ROP rollbacks to work + * correctly in SGXDoKickKM. + */ + *pui32NumSrcSyncs = ui32NumRealSrcSyncs; + +err_put_fence: + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); + return eError; +} + +IMG_INTERNAL PVRSRV_ERROR +PVRSyncPatchTransferSyncInfos(IMG_HANDLE ahSyncs[SGX_MAX_SRC_SYNCS_TA], + PVRSRV_DEVICE_SYNC_OBJECT asDevSyncs[SGX_MAX_SRC_SYNCS_TA], + IMG_UINT32 *pui32NumSrcSyncs) +{ + struct PVR_ALLOC_SYNC_DATA *psTransferSyncData; + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; + PVRSRV_ERROR eError = PVRSRV_OK; + + if (*pui32NumSrcSyncs != 1) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Invalid number of syncs (%d), clamping " + "to 1", __func__, *pui32NumSrcSyncs)); + } + + psTransferSyncData = PVRSyncAllocFDGet((int)ahSyncs[0]); + + if (!psTransferSyncData) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get PVR_SYNC_DATA from " + "supplied fd", __func__)); + eError = PVRSRV_ERROR_HANDLE_NOT_FOUND; + goto err_out; + } + + /* There should only be one destination sync for a transfer. + * Ultimately this will be patched to two (the sync_pt SYNCINFO, + * and the timeline's SYNCINFO for debugging). + */ + psSyncInfo = psTransferSyncData->psSyncInfo->psBase; + + /* The following code is mostly the same as the texture dependencies + * handling in SGXDoKickKM, but we have to copy it here because it + * must be run while the fence is 'locked' by sync_fence_fdget. + */ + + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_SRC_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + + CopyKernelSyncInfoToDeviceSyncObject(psSyncInfo, &asDevSyncs[0]); + CopyKernelSyncInfoToDeviceSyncObject(psTransferSyncData->psTimeline->psSyncInfo->psBase, + &asDevSyncs[1]); + + /* Treat fence TQs as write operations */ + psSyncInfo->psSyncData->ui32WriteOpsPending++; + psTransferSyncData->psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsPending++; + + /* Finally, patch the sync back into the input array. + * NOTE: The syncs are protected here by the defer-free worker. + */ + ahSyncs[0] = psSyncInfo; + ahSyncs[1] = psTransferSyncData->psTimeline->psSyncInfo->psBase; + + /* Updating this allows the PDUMP handling and ROP rollbacks to work + * correctly in SGXDoKickKM. + */ + *pui32NumSrcSyncs = 2; + + fput(psTransferSyncData->psFile); +err_out: + return eError; +} + +/* NOTE: This returns an array of sync_fences which need to be 'put' + * or they will leak. + */ + +IMG_INTERNAL PVRSRV_ERROR +PVRSyncFencesToSyncInfos(PVRSRV_KERNEL_SYNC_INFO *apsSyncs[], + IMG_UINT32 *pui32NumSyncs, + struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA]) +{ + PVRSRV_KERNEL_SYNC_INFO *apsSyncInfo[SGX_MAX_SRC_SYNCS_TA]; + IMG_UINT32 i, ui32NumRealSrcSyncs; + PVRSRV_ERROR eError = PVRSRV_OK; + + memset(apsFence, 0, sizeof(struct sync_fence *) * SGX_MAX_SRC_SYNCS_TA); + + if(!ExpandAndDeDuplicateFenceSyncs(*pui32NumSyncs, + (int *)apsSyncs, + *pui32NumSyncs, + apsFence, + &ui32NumRealSrcSyncs, + apsSyncInfo)) + { + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); + return PVRSRV_ERROR_HANDLE_NOT_FOUND; + } + + /* We don't expect to see merged syncs here. Abort if that happens. + * Allow through cases where the same fence was specified more than + * once -- we can handle that without reallocation of memory. + */ + PVR_ASSERT(ui32NumRealSrcSyncs <= *pui32NumSyncs); + + for(i = 0; i < ui32NumRealSrcSyncs; i++) + apsSyncs[i] = apsSyncInfo[i]; + + *pui32NumSyncs = ui32NumRealSrcSyncs; + return eError; +} diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_sync.h b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_sync.h new file mode 100755 index 00000000000..fa05b6093a2 --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_sync.h @@ -0,0 +1,78 @@ +/*************************************************************************/ /*! +@File pvr_sync.c +@Title Kernel sync driver +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@Description Version numbers and strings for PVR Consumer services + components. +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#ifndef _PVR_SYNC_H +#define _PVR_SYNC_H + +#include <linux/seq_file.h> +#include <linux/version.h> + +#if !defined(__KERNEL__) || (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) +#include <linux/sync.h> +#else +#include <../drivers/staging/android/sync.h> +#endif + +#include "pvr_sync_user.h" +#include "servicesint.h" // PVRSRV_DEVICE_SYNC_OBJECT + +/* services4 internal interface */ + +int PVRSyncDeviceInit(void); +void PVRSyncDeviceDeInit(void); +void PVRSyncUpdateAllSyncs(void); +PVRSRV_ERROR +PVRSyncPatchCCBKickSyncInfos(IMG_HANDLE ahSyncs[SGX_MAX_SRC_SYNCS_TA], + PVRSRV_DEVICE_SYNC_OBJECT asDevSyncs[SGX_MAX_SRC_SYNCS_TA], + IMG_UINT32 *pui32NumSrcSyncs); +PVRSRV_ERROR +PVRSyncPatchTransferSyncInfos(IMG_HANDLE ahSyncs[SGX_MAX_SRC_SYNCS_TA], + PVRSRV_DEVICE_SYNC_OBJECT asDevSyncs[SGX_MAX_SRC_SYNCS_TA], + IMG_UINT32 *pui32NumSrcSyncs); +PVRSRV_ERROR +PVRSyncFencesToSyncInfos(PVRSRV_KERNEL_SYNC_INFO *apsSyncs[], + IMG_UINT32 *pui32NumSyncs, + struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA]); + +#endif /* _PVR_SYNC_H */ diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_uaccess.h b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_uaccess.h index 7583d7eb25b..7583d7eb25b 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_uaccess.h +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/pvr_uaccess.h diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/sysfs.c b/drivers/gpu/pvr/services4/srvkm/env/linux/sysfs.c deleted file mode 100644 index 63066ade212..00000000000 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/sysfs.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/kobject.h> -#include <linux/sysfs.h> -#include <linux/stat.h> -#include <asm/page.h> -#include <linux/slab.h> -#include "services_headers.h" -#include "pdump_km.h" -#include "sysfs.h" - -/* sysfs structures */ -struct pvrsrv_attribute { - struct attribute attr; - int sgx_version; - int sgx_revision; -}; - -static struct pvrsrv_attribute PVRSRVAttr = { - .attr.name = "egl.cfg", - .attr.mode = S_IRUGO, - .sgx_version = SGXCORE, - .sgx_revision = SGX_CORE_REV, -}; - -/* sysfs read function */ -static ssize_t PVRSRVEglCfgShow(struct kobject *kobj, struct attribute *attr, - char *buffer) { - struct pvrsrv_attribute *pvrsrv_attr; - - pvrsrv_attr = container_of(attr, struct pvrsrv_attribute, attr); - return snprintf(buffer, PAGE_SIZE, "0 0 android\n0 1 POWERVR_SGX%d_%d", - pvrsrv_attr->sgx_version, pvrsrv_attr->sgx_revision); -} - -/* sysfs write function unsupported*/ -static ssize_t PVRSRVEglCfgStore(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t size) { - PVR_DPF((PVR_DBG_ERROR, "PVRSRVEglCfgStore not implemented")); - return 0; -} - -static struct attribute *pvrsrv_sysfs_attrs[] = { - &PVRSRVAttr.attr, - NULL -}; - -static const struct sysfs_ops pvrsrv_sysfs_ops = { - .show = PVRSRVEglCfgShow, - .store = PVRSRVEglCfgStore, -}; - -static struct kobj_type pvrsrv_ktype = { - .sysfs_ops = &pvrsrv_sysfs_ops, - .default_attrs = pvrsrv_sysfs_attrs, -}; - -/* create sysfs entry /sys/egl/egl.cfg to determine - which gfx libraries to load */ - -int PVRSRVCreateSysfsEntry(void) -{ - struct kobject *egl_cfg_kobject; - int r; - - egl_cfg_kobject = kzalloc(sizeof(*egl_cfg_kobject), GFP_KERNEL); - r = kobject_init_and_add(egl_cfg_kobject, &pvrsrv_ktype, NULL, "egl"); - - if (r) { - PVR_DPF((PVR_DBG_ERROR, - "Failed to create egl.cfg sysfs entry")); - return PVRSRV_ERROR_INIT_FAILURE; - } - - return PVRSRV_OK; -} diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/sysfs.h b/drivers/gpu/pvr/services4/srvkm/env/linux/sysfs.h deleted file mode 100644 index fb8d20f23e2..00000000000 --- a/drivers/gpu/pvr/services4/srvkm/env/linux/sysfs.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __SYSFS_H -#define __SYSFS_H - -int PVRSRVCreateSysfsEntry(void); - -#endif diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/systrace.c b/drivers/gpu/pvr/services4/srvkm/env/linux/systrace.c new file mode 100755 index 00000000000..00f3e4fc319 --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/systrace.c @@ -0,0 +1,282 @@ +/*************************************************************************/ /*! +@Title Systrace related functions +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#include "systrace.h" + +#include <trace/events/gpu.h> + +#include <linux/debugfs.h> +#include <linux/sched.h> +#include <linux/fs.h> + +#include "img_types.h" + +/*Kernel debugfs variables*/ +static unsigned int capture_hwperfdata; +static struct dentry *pvrdir_ret; + +static PVRSRV_SYSTRACE_ERROR CreateJob(PVRSRV_SYSTRACE_DATA *psSystraceData, IMG_UINT32 ui32PID, IMG_UINT32 ui32FrameNum, IMG_UINT32 ui32RTData) +{ + PVRSRV_SYSTRACE_CONTEXT *psContext = NULL; + PVRSRV_SYSTRACE_JOB *psJob = NULL; + IMG_UINT32 i = 0; + + if(psSystraceData == NULL) + return PVRSRV_SYSTRACE_NOT_INITIALISED; + + /*Look for the PID in the context CB*/ + for(i = 0; i < 8; ++i) + { + if(psSystraceData->asSystraceContext[i].ui32PID == ui32PID) + { + psContext = &(psSystraceData->asSystraceContext[i]); + break; + } + } + + /*If we find it lets check its jobs, otherwise we create it*/ + if(psContext == NULL) + { + psSystraceData->ui32Index = (psSystraceData->ui32Index+1)%8; + + psSystraceData->asSystraceContext[psSystraceData->ui32Index].ui32CtxID = psSystraceData->ui32CurrentCtxID; + ++psSystraceData->ui32CurrentCtxID; + psSystraceData->asSystraceContext[psSystraceData->ui32Index].ui32PID = ui32PID; + psSystraceData->asSystraceContext[psSystraceData->ui32Index].ui32Start = 0; + psSystraceData->asSystraceContext[psSystraceData->ui32Index].ui32End = 0; + psSystraceData->asSystraceContext[psSystraceData->ui32Index].ui32CurrentJobID = 0; + + psContext = &(psSystraceData->asSystraceContext[psSystraceData->ui32Index]); + } + + /*This is just done during the first kick so it must not be in the job list*/ + /*JobID not found, we create it*/ + psJob = &(psContext->asJobs[psContext->ui32End]); + psJob->ui32JobID = psContext->ui32CurrentJobID; + ++psContext->ui32CurrentJobID; + + psJob->ui32FrameNum = ui32FrameNum; + psJob->ui32RTData = ui32RTData; + /*Advance the CB*/ + psContext->ui32End = (psContext->ui32End + 1)%16; + if(psContext->ui32End == psContext->ui32Start) + psContext->ui32Start = (psContext->ui32Start + 1)%16; + + return PVRSRV_SYSTRACE_OK; +} + +static PVRSRV_SYSTRACE_ERROR GetCtxAndJobID(PVRSRV_SYSTRACE_DATA *psSystraceData, IMG_UINT32 ui32PID, IMG_UINT32 ui32FrameNum, IMG_UINT32 ui32RTData, + IMG_UINT32 *pui32CtxID, IMG_UINT32 *pui32JobID) +{ + PVRSRV_SYSTRACE_CONTEXT *psContext = NULL; + //PVRSRV_SYSTRACE_JOB *psJob = NULL; + IMG_UINT32 i = 0; + + if(psSystraceData == NULL) + return PVRSRV_SYSTRACE_NOT_INITIALISED; + + /*Look for the PID in the context CB*/ + for(i = 0; i < 8; ++i) + { + if(psSystraceData->asSystraceContext[i].ui32PID == ui32PID) + { + psContext = &(psSystraceData->asSystraceContext[i]); + break; + } + } + /*If we find it lets check its jobs, otherwise we create it*/ + if(psContext == NULL) + { + /*Don't create anything here*/ + return PVRSRV_SYSTRACE_JOB_NOT_FOUND; + } + /*Look for the JobID in the jobs CB otherwise create it and return ID*/ + for(i = 0; i < 16; ++i) + { + if((psContext->asJobs[i].ui32FrameNum == ui32FrameNum) && + (psContext->asJobs[i].ui32RTData == ui32RTData)) + { + *pui32CtxID = psContext->ui32CtxID; + *pui32JobID = psContext->asJobs[i].ui32JobID; + return PVRSRV_SYSTRACE_OK; + } + } + /*Not found*/ + return PVRSRV_SYSTRACE_JOB_NOT_FOUND; +} + +void SystraceCreateFS(void) +{ + struct dentry *capture_sgx_hwperfdata_ret; + + pvrdir_ret = debugfs_create_dir("pvr", NULL); + capture_sgx_hwperfdata_ret = debugfs_create_bool("gpu_tracing_on", S_IFREG | S_IRUGO | S_IWUSR, pvrdir_ret, &capture_hwperfdata); +} + +void SystraceDestroyFS(void) +{ + debugfs_remove_recursive(pvrdir_ret); +} + +IMG_BOOL SystraceIsCapturingHWData(void) +{ + return capture_hwperfdata; +} + +void SystraceTAKick(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_UINT32 ui32FrameNum, IMG_UINT32 ui32RTData, IMG_BOOL bIsFirstKick) +{ + IMG_UINT32 ui32PID = OSGetCurrentProcessIDKM(); + IMG_UINT32 ui32JobID = 0; + IMG_UINT32 ui32CtxID = 0; + PVRSRV_SYSTRACE_ERROR eError = PVRSRV_SYSTRACE_OK; + + if(psDevInfo->bSystraceInitialised) + { + if(bIsFirstKick) + { + eError = CreateJob(psDevInfo->psSystraceData, ui32PID, ui32FrameNum, ui32RTData); + if(eError != PVRSRV_SYSTRACE_OK) + { + PVR_DPF((PVR_DBG_WARNING,"Systrace: Error creating a Job")); + } + } + + eError = GetCtxAndJobID(psDevInfo->psSystraceData, ui32PID, ui32FrameNum, ui32RTData, &ui32CtxID, &ui32JobID); + + if(eError != PVRSRV_SYSTRACE_OK) + { + PVR_DPF((PVR_DBG_WARNING,"Systrace: Job not found")); + } + + trace_gpu_job_enqueue(ui32CtxID, ui32JobID, "TA"); + } +} + +void SystraceHWPerfPackets(PVRSRV_SGXDEV_INFO *psDevInfo, PVRSRV_SGX_HWPERF_CB_ENTRY* psSGXHWPerf, IMG_UINT32 ui32DataCount, IMG_UINT32 ui32SgxClockspeed) +{ + IMG_UINT32 ui32PID, ui32FrameNo, ui32EvtType, ui32RTData, ui32Clocksx16Difference, ui32ClockMultiplier; + + IMG_UINT32 ui32SgxClocksx16 = 0; + IMG_UINT32 i = 0; + IMG_UINT64 ui64HostTimestamp = 0; + IMG_UINT64 ui64TimeDifference = 0; + IMG_UINT64 ui64PacketTimeStamp = 0; + + IMG_UINT32 ui32JobID = 0; + IMG_UINT32 ui32CtxID = 0; + + IMG_UINT64 ui64LastHostTimestamp = 0; + IMG_UINT32 ui32LastSGXClocksx16 = 0; + + ui64LastHostTimestamp = psDevInfo->psSystraceData->ui64LastHostTimestamp; + ui32LastSGXClocksx16 = psDevInfo->psSystraceData->ui32LastSGXClocksx16; + ui64HostTimestamp = sched_clock(); + + /*If this is the first packet read, use it as the initial reference*/ + if (ui64LastHostTimestamp == 0) + { + if (ui32DataCount > 0) + { + ui64LastHostTimestamp = ui64HostTimestamp; + ui32LastSGXClocksx16 = psSGXHWPerf[0].ui32Clocksx16; + } + } + + /* SGX clockspeed reported 307200000 HZ */ + /* Get the ui32ClockMultipliertiplier per 1us*/ + ui32ClockMultiplier = (ui32SgxClockspeed)/(1000*1000); + + for(i = 0; i < ui32DataCount; ++i) + { + ui32SgxClocksx16 = psSGXHWPerf[i].ui32Clocksx16; + ui32EvtType = psSGXHWPerf[i].ui32Type; + ui32FrameNo = psSGXHWPerf[i].ui32FrameNo; + ui32PID = psSGXHWPerf[i].ui32PID; + ui32RTData = psSGXHWPerf[i].ui32RTData; + + if ((ui32EvtType == PVRSRV_SGX_HWPERF_TYPE_TA_START) || + (ui32EvtType == PVRSRV_SGX_HWPERF_TYPE_TA_END) || + (ui32EvtType == PVRSRV_SGX_HWPERF_TYPE_3D_START) || + (ui32EvtType == PVRSRV_SGX_HWPERF_TYPE_3D_END)) + { + /*Get the JobID*/ + GetCtxAndJobID(psDevInfo->psSystraceData, ui32PID, ui32FrameNo, ui32RTData, &ui32CtxID, &ui32JobID); + + /* Calculate the time difference in ns*/ + /* Get the clock difference */ + ui32Clocksx16Difference = (ui32SgxClocksx16 - ui32LastSGXClocksx16); + /* Multipy it by 16 and 1000 to convert from us to ns */ + ui64TimeDifference = (16*ui32Clocksx16Difference*1000)/ui32ClockMultiplier; + + + /* Add the time diff to the last time-stamp, in nanoseconds*/ + ui64PacketTimeStamp = (unsigned long long) ui64LastHostTimestamp + (unsigned long long)ui64TimeDifference; + + switch(ui32EvtType) + { + case PVRSRV_SGX_HWPERF_TYPE_TA_START: + trace_gpu_sched_switch("TA", ui64PacketTimeStamp, ui32CtxID, ui32FrameNo, ui32JobID); + break; + + case PVRSRV_SGX_HWPERF_TYPE_TA_END: + trace_gpu_sched_switch("TA", ui64PacketTimeStamp, 0, ui32FrameNo, ui32JobID); + break; + + case PVRSRV_SGX_HWPERF_TYPE_3D_START: + trace_gpu_sched_switch("3D", ui64PacketTimeStamp, ui32CtxID, ui32FrameNo, ui32JobID); + break; + + case PVRSRV_SGX_HWPERF_TYPE_3D_END: + trace_gpu_sched_switch("3D", ui64PacketTimeStamp, 0, ui32FrameNo, ui32JobID); + break; + + default: + break; + } + } + } + if(ui32DataCount > 0) + { + psDevInfo->psSystraceData->ui32LastSGXClocksx16 = ui32SgxClocksx16; + } + /* Get the last set of packets timestamp and sleep 1ms */ + psDevInfo->psSystraceData->ui64LastHostTimestamp = ui64HostTimestamp; +} diff --git a/drivers/gpu/pvr/services4/srvkm/env/linux/systrace.h b/drivers/gpu/pvr/services4/srvkm/env/linux/systrace.h new file mode 100755 index 00000000000..ad4bcc0ccee --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/env/linux/systrace.h @@ -0,0 +1,68 @@ +/*************************************************************************/ /*! +@Title Systrace related functions +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#ifndef _SYSTRACE_ +#define _SYSTRACE_ + +#include "img_defs.h" +#include "img_types.h" + +#include "services_headers.h" +#include "sgxapi_km.h" +#include "sgxinfo.h" +#include "sgxinfokm.h" + +typedef enum +{ + PVRSRV_SYSTRACE_OK = 0x00, + PVRSRV_SYSTRACE_NOT_INITIALISED, + PVRSRV_SYSTRACE_JOB_NOT_FOUND +} PVRSRV_SYSTRACE_ERROR; + + +void SystraceHWPerfPackets(PVRSRV_SGXDEV_INFO *psDevInfo, PVRSRV_SGX_HWPERF_CB_ENTRY* psSGXHWPerf, IMG_UINT32 ui32DataCount, IMG_UINT32 ui32SgxClockspeed); +void SystraceTAKick(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_UINT32 ui32FrameNum, IMG_UINT32 ui32RTData, IMG_BOOL bIsFirstKick); + +void SystraceCreateFS(void); +void SystraceDestroyFS(void); +IMG_BOOL SystraceIsCapturingHWData(void); + +#endif /* _SYSTRACE_ */ diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/mnemedefs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/mnemedefs.h index 83a65f563fb..83a65f563fb 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/mnemedefs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/mnemedefs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/ocpdefs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/ocpdefs.h index 07a64122935..07a64122935 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/ocpdefs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/ocpdefs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx520defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx520defs.h index 80c33638d85..80c33638d85 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx520defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx520defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx530defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx530defs.h index 3223feb7a65..3223feb7a65 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx530defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx530defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx531defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx531defs.h index 3295d890e89..3295d890e89 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx531defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx531defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx535defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx535defs.h index 8039da4a73e..8039da4a73e 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx535defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx535defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx540defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx540defs.h index 47080c71af4..47080c71af4 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx540defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx540defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543_v1.164defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543_v1.164defs.h index 8c8b3531f2d..8c8b3531f2d 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543_v1.164defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543_v1.164defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543defs.h index 0d3568d045c..0d3568d045c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx543defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx544defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx544defs.h index 79efcbcaf03..79efcbcaf03 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx544defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx544defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx545defs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx545defs.h index c5adee2c0c8..c5adee2c0c8 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx545defs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgx545defs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxdefs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxdefs.h index ed24647e3c4..ed24647e3c4 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxdefs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxdefs.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxerrata.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxerrata.h index 711e356c2d9..52b13bb5766 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxerrata.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxerrata.h @@ -112,11 +112,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_CORE_REV SGX_CORE_REV_HEAD #endif - #if SGX_CORE_REV == 101 - #define FIX_HW_BRN_26620/* Workaround in services (srvkm) */ - #define FIX_HW_BRN_28011/* Workaround in services (srvkm) */ - #define FIX_HW_BRN_34028/* Workaround in services (srvkm) */ - #else #if SGX_CORE_REV == 110 #define FIX_HW_BRN_34028/* Workaround in services (srvkm) */ #else @@ -126,7 +121,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #error "sgxerrata.h: SGX531 Core Revision unspecified" #endif #endif - #endif /* signal that the Core Version has a valid definition */ #define SGX_CORE_DEFINED #endif @@ -167,19 +161,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_CORE_REV SGX_CORE_REV_HEAD #endif - #if SGX_CORE_REV == 101 - #define FIX_HW_BRN_25499/* Workaround in sgx featuredefs */ - #define FIX_HW_BRN_25503/* Workaround in code (services) */ - #define FIX_HW_BRN_26620/* Workaround in services (srvkm) */ - #define FIX_HW_BRN_28011/* Workaround in services (srvkm) */ - #define FIX_HW_BRN_34028/* Workaround in services (srvkm) */ - #else - #if SGX_CORE_REV == 110 - #define FIX_HW_BRN_25503/* Workaround in code (services) */ - #define FIX_HW_BRN_26620/* Workaround in services (srvkm) */ - #define FIX_HW_BRN_28011/* Workaround in services (srvkm) */ - #define FIX_HW_BRN_34028/* Workaround in services (srvkm) */ - #else #if SGX_CORE_REV == 120 #define FIX_HW_BRN_26620/* Workaround in services (srvkm) */ #define FIX_HW_BRN_28011/* Workaround in services (srvkm) */ @@ -200,8 +181,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #endif #endif - #endif - #endif /* signal that the Core Version has a valid definition */ #define SGX_CORE_DEFINED #endif @@ -224,9 +203,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define FIX_HW_BRN_31272/* workaround in services (srvclient) and uKernel */ #define FIX_HW_BRN_31278/* disabled prefetching in MMU */ #define FIX_HW_BRN_31542/* workaround in uKernel and Services */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31620/* workaround in services */ #define FIX_HW_BRN_31780/* workaround in uKernel */ #define FIX_HW_BRN_32044 /* workaround in uKernel, services and client drivers */ @@ -243,9 +219,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define FIX_HW_BRN_31195/* workaround in services */ #define FIX_HW_BRN_31272/* workaround in services (srvclient) and uKernel */ #define FIX_HW_BRN_31278/* disabled prefetching in MMU */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31542/* workaround in uKernel and Services */ #define FIX_HW_BRN_31671/* workaround in uKernel */ #define FIX_HW_BRN_31780/* workaround in uKernel */ @@ -260,9 +233,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #else #if SGX_CORE_REV == 141 #define FIX_HW_BRN_29954/* turns off regbank split feature */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31671 /* workaround in uKernel */ #define FIX_HW_BRN_31780/* workaround in uKernel */ #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) @@ -273,9 +243,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #else #if SGX_CORE_REV == 142 #define FIX_HW_BRN_29954/* turns off regbank split feature */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31671 /* workaround in uKernel */ #define FIX_HW_BRN_31780/* workaround in uKernel */ #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) @@ -284,32 +251,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ /* add BRNs here */ #else - #if SGX_CORE_REV == 2111 - #define FIX_HW_BRN_30982 /* workaround in uKernel and services */ - #define FIX_HW_BRN_31093/* workaround in services */ - #define FIX_HW_BRN_31195/* workaround in services */ - #define FIX_HW_BRN_31272/* workaround in services (srvclient) and uKernel */ - #define FIX_HW_BRN_31278/* disabled prefetching in MMU */ - #define FIX_HW_BRN_31542/* workaround in uKernel and Services */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif - #define FIX_HW_BRN_31620/* workaround in services */ - #define FIX_HW_BRN_31780/* workaround in uKernel */ - #define FIX_HW_BRN_32044 /* workaround in uKernel, services and client drivers */ - #define FIX_HW_BRN_32085 /* workaround in services: prefetch fix applied, investigating PT based fix */ - #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_33657/* workaround in ukernel*/ - #endif - #define FIX_HW_BRN_33920/* workaround in ukernel */ - #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ - /* add BRNs here */ - #else #if SGX_CORE_REV == 213 #define FIX_HW_BRN_31272/* workaround in services (srvclient) and uKernel */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31671 /* workaround in uKernel */ #define FIX_HW_BRN_31780/* workaround in uKernel */ #define FIX_HW_BRN_32085 /* workaround in services: prefetch fix applied, investigating PT based fix */ @@ -326,17 +269,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ #else - #if SGX_CORE_REV == 302 - #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_33657/* workaround in ukernel*/ - #endif - #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ - #else #if SGX_CORE_REV == 303 #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) #define FIX_HW_BRN_33657/* workaround in ukernel*/ #endif - #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ + #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_43863 /* Workaround in ukernel */ + #endif #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) @@ -352,8 +292,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #endif #endif - #endif - #endif /* signal that the Core Version has a valid definition */ #define SGX_CORE_DEFINED #endif @@ -372,9 +310,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define FIX_HW_BRN_31195/* workaround in services */ #define FIX_HW_BRN_31272/* workaround in services (srvclient) and uKernel */ #define FIX_HW_BRN_31278/* disabled prefetching in MMU */ - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31542 /* workaround in uKernel and Services */ #define FIX_HW_BRN_31620/* workaround in services */ #define FIX_HW_BRN_31671 /* workaround in uKernel */ @@ -388,9 +323,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ #else #if SGX_CORE_REV == 105 - #if defined(SGX_FEATURE_MP) - #define FIX_HW_BRN_31559/* workaround in services and uKernel */ - #endif #define FIX_HW_BRN_31780/* workaround in uKernel */ #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) #define FIX_HW_BRN_33657/* workaround in ukernel*/ @@ -421,9 +353,18 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) #define FIX_HW_BRN_33657/* workaround in ukernel */ #endif + #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ + #else + #if SGX_CORE_REV == 117 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657/* workaround in ukernel */ + #endif #define FIX_HW_BRN_33809/* workaround in kernel (enable burst combiner) */ #define FIX_HW_BRN_36513 /* workaround in uKernel and Services */ #else + #if SGX_CORE_REV == 118 + #define FIX_HW_BRN_33920/* workaround in ukernel */ + #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) #define FIX_HW_BRN_33657/* workaround in ukernel*/ @@ -437,6 +378,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #endif #endif + #endif + #endif /* signal that the Core Version has a valid definition */ #define SGX_CORE_DEFINED #endif @@ -449,11 +392,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_CORE_REV SGX_CORE_REV_HEAD #endif - #if SGX_CORE_REV == 109 - #define FIX_HW_BRN_29702/* Workaround in services */ - #define FIX_HW_BRN_29823/* Workaround in services */ - #define FIX_HW_BRN_31939/* workaround in uKernel */ - #else #if SGX_CORE_REV == 10131 #else #if SGX_CORE_REV == 1014 @@ -468,7 +406,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #endif #endif - #endif /* signal that the Core Version has a valid definition */ #define SGX_CORE_DEFINED #endif diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxfeaturedefs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxfeaturedefs.h index 3e3a1169a39..9efce89ff3f 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxfeaturedefs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxfeaturedefs.h @@ -44,6 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_ADDRESS_SPACE_SIZE (28) #define SGX_FEATURE_NUM_USE_PIPES (1) #define SGX_FEATURE_AUTOCLOCKGATING + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1) #else #if defined(SGX530) #define SGX_CORE_FRIENDLY_NAME "SGX530" @@ -51,6 +52,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_ADDRESS_SPACE_SIZE (28) #define SGX_FEATURE_NUM_USE_PIPES (2) #define SGX_FEATURE_AUTOCLOCKGATING + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1) #else #if defined(SGX531) #define SGX_CORE_FRIENDLY_NAME "SGX531" @@ -59,6 +61,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_NUM_USE_PIPES (2) #define SGX_FEATURE_AUTOCLOCKGATING #define SGX_FEATURE_MULTI_EVENT_KICK + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1) #else #if defined(SGX535) #define SGX_CORE_FRIENDLY_NAME "SGX535" @@ -71,6 +74,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_AUTOCLOCKGATING #define SUPPORT_SGX_GENERAL_MAPPING_HEAP #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1) #else #if defined(SGX540) #define SGX_CORE_FRIENDLY_NAME "SGX540" @@ -79,6 +83,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_NUM_USE_PIPES (4) #define SGX_FEATURE_AUTOCLOCKGATING #define SGX_FEATURE_MULTI_EVENT_KICK + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1) #else #if defined(SGX543) #define SGX_CORE_FRIENDLY_NAME "SGX543" @@ -104,8 +109,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH #endif #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH - #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH #endif + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (4) #else #if defined(SGX544) #define SGX_CORE_FRIENDLY_NAME "SGX544" @@ -122,8 +127,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #define SGX_FEATURE_DATA_BREAKPOINTS // #define SGX_FEATURE_PERPIPE_BKPT_REGS // #define SGX_FEATURE_PERPIPE_BKPT_REGS_NUMPIPES (2) -// #define SGX_FEATURE_2D_HARDWARE -// #define SGX_FEATURE_PTLA + #if defined(SGX_FEATURE_MP) + #define SGX_FEATURE_2D_HARDWARE + #define SGX_FEATURE_PTLA + #endif #define SGX_FEATURE_EXTENDED_PERF_COUNTERS #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) @@ -131,8 +138,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH #endif - #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH #endif + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (4) #else #if defined(SGX545) #define SGX_CORE_FRIENDLY_NAME "SGX545" @@ -160,9 +167,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_BIF_WIDE_TILING_AND_4K_ADDRESS #define SGX_FEATURE_MULTI_EVENT_KICK #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE - #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) - #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH - #endif + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (4) #else #if defined(SGX554) #define SGX_CORE_FRIENDLY_NAME "SGX554" @@ -188,8 +193,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH #endif #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH - #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH #endif + #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (4) #endif #endif #endif diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmmu.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmmu.h index a6a907aecb6..a6a907aecb6 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmmu.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmmu.h diff --git a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmpdefs.h b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmpdefs.h index 4b9649f9f88..a4cd81ec819 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmpdefs.h +++ b/drivers/gpu/pvr/services4/srvkm/hwdefs/sgxmpdefs.h @@ -65,6 +65,28 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define EUR_CR_MASTER_BIF_CTRL_MMU_BYPASS_MASTER_DPM_MASK 0x00080000U #define EUR_CR_MASTER_BIF_CTRL_MMU_BYPASS_MASTER_DPM_SHIFT 19 #define EUR_CR_MASTER_BIF_CTRL_MMU_BYPASS_MASTER_DPM_SIGNED 0 +/* Register EUR_CR_MASTER_BIF_INT_STAT */ +#define EUR_CR_MASTER_BIF_INT_STAT 0x4C04 +#define EUR_CR_MASTER_BIF_INT_STAT_FAULT_REQ_MASK 0x00003FFFU +#define EUR_CR_MASTER_BIF_INT_STAT_FAULT_REQ_SHIFT 0 +#define EUR_CR_MASTER_BIF_INT_STAT_FAULT_REQ_SIGNED 0 +#define EUR_CR_MASTER_BIF_INT_STAT_FAULT_TYPE_MASK 0x00070000U +#define EUR_CR_MASTER_BIF_INT_STAT_FAULT_TYPE_SHIFT 16 +#define EUR_CR_MASTER_BIF_INT_STAT_FAULT_TYPE_SIGNED 0 +#define EUR_CR_MASTER_BIF_INT_STAT_FLUSH_COMPLETE_MASK 0x00080000U +#define EUR_CR_MASTER_BIF_INT_STAT_FLUSH_COMPLETE_SHIFT 19 +#define EUR_CR_MASTER_BIF_INT_STAT_FLUSH_COMPLETE_SIGNED 0 +/* Register EUR_CR_MASTER_BIF_FAULT */ +#define EUR_CR_MASTER_BIF_FAULT 0x4C08 +#define EUR_CR_MASTER_BIF_FAULT_CID_MASK 0x0000000FU +#define EUR_CR_MASTER_BIF_FAULT_CID_SHIFT 0 +#define EUR_CR_MASTER_BIF_FAULT_CID_SIGNED 0 +#define EUR_CR_MASTER_BIF_FAULT_SB_MASK 0x000001F0U +#define EUR_CR_MASTER_BIF_FAULT_SB_SHIFT 4 +#define EUR_CR_MASTER_BIF_FAULT_SB_SIGNED 0 +#define EUR_CR_MASTER_BIF_FAULT_ADDR_MASK 0xFFFFF000U +#define EUR_CR_MASTER_BIF_FAULT_ADDR_SHIFT 12 +#define EUR_CR_MASTER_BIF_FAULT_ADDR_SIGNED 0 /* Register EUR_CR_MASTER_BIF_CTRL_INVAL */ #define EUR_CR_MASTER_BIF_CTRL_INVAL 0x4C34 #define EUR_CR_MASTER_BIF_CTRL_INVAL_PTE_MASK 0x00000004U diff --git a/drivers/gpu/pvr/services4/srvkm/include/buffer_manager.h b/drivers/gpu/pvr/services4/srvkm/include/buffer_manager.h index c16efaac005..49d023e4854 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/buffer_manager.h +++ b/drivers/gpu/pvr/services4/srvkm/include/buffer_manager.h @@ -91,17 +91,6 @@ struct _BM_MAPPING_ IMG_UINT32 ui32NumVirtChunks; IMG_UINT32 ui32NumPhysChunks; IMG_BOOL *pabMapChunk; - - /* GPU mapping reference count - * When goes down to 0 GPU mapping - * gets removed */ - IMG_UINT32 ui32MappingCount; - - /* need to track the original required alignment to make sure - * that an unmapped buffer which is later remapped to device - * is remapped with the original alignment restrictions. - */ - IMG_UINT32 ui32DevVAddrAlignment; }; /* @@ -346,8 +335,8 @@ BM_Alloc (IMG_HANDLE hDevMemHeap, */ IMG_BOOL BM_Wrap ( IMG_HANDLE hDevMemHeap, - IMG_SIZE_T ui32Size, - IMG_SIZE_T ui32Offset, + IMG_SIZE_T uSize, + IMG_SIZE_T uOffset, IMG_BOOL bPhysContig, IMG_SYS_PHYADDR *psSysAddr, IMG_VOID *pvCPUVAddr, @@ -423,32 +412,6 @@ IMG_HANDLE BM_HandleToOSMemHandle (BM_HANDLE hBuf); /** - * @Function BM_RemapToDev - * - * @Description - * - * Remaps the device Virtual Mapping. - * - * @Input hBuf - buffer handle. - * @Return ref count on success - */ -IMG_INT32 -BM_RemapToDev(BM_HANDLE hBuf); - -/** - * @Function BM_UnmapFromDev - * - * @Description - * - * Removes the device Virtual Mapping. - * - * @Input hBuf - buffer handle. - * @Return Ref count on success - */ -IMG_INT32 -BM_UnmapFromDev(BM_HANDLE hBuf); - -/** * @Function BM_GetPhysPageAddr * * @Description @@ -631,7 +594,6 @@ IMG_BOOL BM_VirtOffsetToPhysical(IMG_HANDLE hBMHandle, PVRSRV_ERROR BM_XProcWorkaroundSetShareIndex(IMG_UINT32 ui32Index); PVRSRV_ERROR BM_XProcWorkaroundUnsetShareIndex(IMG_UINT32 ui32Index); PVRSRV_ERROR BM_XProcWorkaroundFindNewBufferAndSetShareIndex(IMG_UINT32 *pui32Index); -IMG_INT32 BM_XProcGetShareDataRefCount(IMG_UINT32 ui32Index); #if defined(PVRSRV_REFCOUNT_DEBUG) IMG_VOID _BM_XProcIndexAcquireDebug(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index); @@ -646,26 +608,13 @@ IMG_VOID _BM_XProcIndexReleaseDebug(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_ IMG_VOID _BM_XProcIndexAcquire(IMG_UINT32 ui32Index); IMG_VOID _BM_XProcIndexRelease(IMG_UINT32 ui32Index); + #define BM_XProcIndexAcquire(x) \ _BM_XProcIndexAcquire( x) #define BM_XProcIndexRelease(x) \ _BM_XProcIndexRelease( x) #endif -static INLINE IMG_CHAR * -_BMMappingType (IMG_INT eCpuMemoryOrigin) -{ - switch (eCpuMemoryOrigin) - { - case hm_wrapped: return "hm_wrapped"; - case hm_wrapped_scatter: return "hm_wrapped_scatter"; - case hm_wrapped_virtaddr: return "hm_wrapped_virtaddr"; - case hm_wrapped_scatter_virtaddr: return "hm_wrapped_scatter_virtaddr"; - case hm_env: return "hm_env"; - case hm_contiguous: return "hm_contiguous"; - } - return "junk"; -} #if defined(__cplusplus) } diff --git a/drivers/gpu/pvr/services4/srvkm/include/device.h b/drivers/gpu/pvr/services4/srvkm/include/device.h index 6ddee5da177..6ddee5da177 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/device.h +++ b/drivers/gpu/pvr/services4/srvkm/include/device.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/devicemem.h b/drivers/gpu/pvr/services4/srvkm/include/devicemem.h new file mode 100755 index 00000000000..00f8fe154a0 --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/include/devicemem.h @@ -0,0 +1,52 @@ +/*************************************************************************/ /*! +@Title KM internal device memory functions +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#include "img_defs.h" +#include "img_types.h" +#include "servicesext.h" + +#ifndef __DEVICEMEM_H__ +#define __DEVICEMEM_H__ + +PVRSRV_ERROR IMG_CALLCONV PVRSRVInitDeviceMem(IMG_VOID); +IMG_VOID IMG_CALLCONV PVRSRVDeInitDeviceMem(IMG_VOID); + +#endif /* __DEVICEMEM_H__ */ diff --git a/drivers/gpu/pvr/services4/srvkm/include/handle.h b/drivers/gpu/pvr/services4/srvkm/include/handle.h index 157d2097884..f636073db2b 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/handle.h +++ b/drivers/gpu/pvr/services4/srvkm/include/handle.h @@ -230,30 +230,11 @@ typedef enum struct _PVRSRV_HANDLE_BASE_; typedef struct _PVRSRV_HANDLE_BASE_ PVRSRV_HANDLE_BASE; -#if defined (PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) extern PVRSRV_HANDLE_BASE *gpsKernelHandleBase; #define KERNEL_HANDLE_BASE (gpsKernelHandleBase) -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag); - -PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_SID hParent); - -PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType); - -PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, PVRSRV_HANDLE_TYPE *peType, IMG_SID hHandle); - -PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); - -PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType, IMG_SID hAncestor); - -PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phParent, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); - -PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); - -PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); -#else PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag); PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent); @@ -271,7 +252,6 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType); PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType); -#endif /* #if defined (SUPPORT_SID_INTERFACE) */ PVRSRV_ERROR PVRSRVNewHandleBatch(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32BatchSize); @@ -295,7 +275,7 @@ PVRSRV_ERROR PVRSRVHandleInit(IMG_VOID); PVRSRV_ERROR PVRSRVHandleDeInit(IMG_VOID); -#else /* #if defined (PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE)*/ +#else /* #if defined (PVR_SECURE_HANDLES) */ #define KERNEL_HANDLE_BASE IMG_NULL @@ -543,7 +523,7 @@ PVRSRV_ERROR PVRSRVHandleDeInit(IMG_VOID) return PVRSRV_OK; } -#endif /* #if defined (PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE)*/ +#endif /* #if defined (PVR_SECURE_HANDLES) */ /* * Versions of PVRSRVAllocHandle and PVRSRVAllocSubHandle with no return diff --git a/drivers/gpu/pvr/services4/srvkm/include/hash.h b/drivers/gpu/pvr/services4/srvkm/include/hash.h index 1ed6fd0238c..1ed6fd0238c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/hash.h +++ b/drivers/gpu/pvr/services4/srvkm/include/hash.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/ion_sync.h b/drivers/gpu/pvr/services4/srvkm/include/ion_sync.h new file mode 100755 index 00000000000..8600a19ebb7 --- /dev/null +++ b/drivers/gpu/pvr/services4/srvkm/include/ion_sync.h @@ -0,0 +1,73 @@ +/*************************************************************************/ /*! +@Title Services Ion synchronisation integration +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#include "img_defs.h" +#include "img_types.h" +#include "servicesint.h" + +#ifndef __ION_SYNC_H__ +#define __ION_SYNC_H__ + +typedef struct _PVRSRV_ION_SYNC_INFO_ { + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; + IMG_HANDLE hUnique; + IMG_UINT32 ui32RefCount; + IMG_UINT64 ui64Stamp; +} PVRSRV_ION_SYNC_INFO; + +PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo); + +IMG_VOID PVRSRVIonBufferSyncRelease(PVRSRV_ION_SYNC_INFO *psIonSyncInfo); + +static INLINE PVRSRV_KERNEL_SYNC_INFO *IonBufferSyncGetKernelSyncInfo(PVRSRV_ION_SYNC_INFO *psIonSyncInfo) +{ + return psIonSyncInfo->psSyncInfo; +} + +static INLINE IMG_UINT64 IonBufferSyncGetStamp(PVRSRV_ION_SYNC_INFO *psIonSyncInfo) +{ + return psIonSyncInfo->ui64Stamp; +} + +#endif /* __ION_SYNC_H__ */ diff --git a/drivers/gpu/pvr/services4/srvkm/include/lists.h b/drivers/gpu/pvr/services4/srvkm/include/lists.h index 81205de3bd1..31f54096893 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/lists.h +++ b/drivers/gpu/pvr/services4/srvkm/include/lists.h @@ -332,6 +332,10 @@ DECLARE_LIST_ANY_VA_2(PVRSRV_POWER_DEV, PVRSRV_ERROR, PVRSRV_OK); DECLARE_LIST_INSERT(PVRSRV_POWER_DEV); DECLARE_LIST_REMOVE(PVRSRV_POWER_DEV); +DECLARE_LIST_ANY_2(PVRSRV_KERNEL_SYNC_INFO, PVRSRV_ERROR, PVRSRV_OK); +DECLARE_LIST_INSERT(PVRSRV_KERNEL_SYNC_INFO); +DECLARE_LIST_REMOVE(PVRSRV_KERNEL_SYNC_INFO); + #undef DECLARE_LIST_ANY_2 #undef DECLARE_LIST_ANY_VA #undef DECLARE_LIST_ANY_VA_2 diff --git a/drivers/gpu/pvr/services4/srvkm/include/metrics.h b/drivers/gpu/pvr/services4/srvkm/include/metrics.h index 18079cb9624..18079cb9624 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/metrics.h +++ b/drivers/gpu/pvr/services4/srvkm/include/metrics.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/osfunc.h b/drivers/gpu/pvr/services4/srvkm/include/osfunc.h index dcaa58abda8..9bb772c3bbe 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/osfunc.h +++ b/drivers/gpu/pvr/services4/srvkm/include/osfunc.h @@ -54,7 +54,6 @@ extern "C" { #if defined(__linux__) && defined(__KERNEL__) #include <linux/hardirq.h> #include <linux/string.h> -#include <asm/system.h> #if defined(__arm__) #include <asm/memory.h> #endif @@ -87,7 +86,7 @@ extern "C" { IMG_UINT32 OSClockus(IMG_VOID); -IMG_SIZE_T OSGetPageSize(IMG_VOID); +IMG_UINT32 OSGetPageSize(IMG_VOID); PVRSRV_ERROR OSInstallDeviceLISR(IMG_VOID *pvSysData, IMG_UINT32 ui32Irq, IMG_CHAR *pszISRName, @@ -98,12 +97,12 @@ PVRSRV_ERROR OSUninstallSystemLISR(IMG_VOID *pvSysData); PVRSRV_ERROR OSInstallMISR(IMG_VOID *pvSysData); PVRSRV_ERROR OSUninstallMISR(IMG_VOID *pvSysData); IMG_CPU_PHYADDR OSMapLinToCPUPhys(IMG_HANDLE, IMG_VOID* pvLinAddr); -IMG_VOID OSMemCopy(IMG_VOID *pvDst, IMG_VOID *pvSrc, IMG_SIZE_T ui32Size); -IMG_VOID *OSMapPhysToLin(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandle); -IMG_BOOL OSUnMapPhysToLin(IMG_VOID *pvLinAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); +IMG_VOID OSMemCopy(IMG_VOID *pvDst, IMG_VOID *pvSrc, IMG_SIZE_T uiSize); +IMG_VOID *OSMapPhysToLin(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandle); +IMG_BOOL OSUnMapPhysToLin(IMG_VOID *pvLinAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); -PVRSRV_ERROR OSReservePhys(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hBMHandle, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle); -PVRSRV_ERROR OSUnReservePhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); +PVRSRV_ERROR OSReservePhys(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hBMHandle, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle); +PVRSRV_ERROR OSUnReservePhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); /* Some terminology: * @@ -193,11 +192,11 @@ static INLINE IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, #if defined(__linux__) || defined(__QNXNTO__) PVRSRV_ERROR OSRegisterDiscontigMem(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCpuVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandle); PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); #else /* defined(__linux__) */ @@ -206,7 +205,7 @@ PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, #endif static INLINE PVRSRV_ERROR OSRegisterDiscontigMem(IMG_SYS_PHYADDR *pBasePAddr, IMG_VOID *pvCpuVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandle) { @@ -223,7 +222,7 @@ static INLINE PVRSRV_ERROR OSRegisterDiscontigMem(IMG_SYS_PHYADDR *pBasePAddr, #pragma inline(OSUnRegisterDiscontigMem) #endif static INLINE PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) { @@ -241,11 +240,11 @@ static INLINE PVRSRV_ERROR OSUnRegisterDiscontigMem(IMG_VOID *pvCpuVAddr, #ifdef INLINE_IS_PRAGMA #pragma inline(OSReserveDiscontigPhys) #endif -static INLINE PVRSRV_ERROR OSReserveDiscontigPhys(IMG_SYS_PHYADDR *pBasePAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle) +static INLINE PVRSRV_ERROR OSReserveDiscontigPhys(IMG_SYS_PHYADDR *pBasePAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle) { #if defined(__linux__) || defined(__QNXNTO__) *ppvCpuVAddr = IMG_NULL; - return OSRegisterDiscontigMem(pBasePAddr, *ppvCpuVAddr, ui32Bytes, ui32Flags, phOSMemHandle); + return OSRegisterDiscontigMem(pBasePAddr, *ppvCpuVAddr, uBytes, ui32Flags, phOSMemHandle); #else extern IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr(IMG_SYS_PHYADDR SysPAddr); @@ -258,14 +257,14 @@ static INLINE PVRSRV_ERROR OSReserveDiscontigPhys(IMG_SYS_PHYADDR *pBasePAddr, I * 4. We don't need to unmap */ - return OSReservePhys(SysSysPAddrToCpuPAddr(pBasePAddr[0]), ui32Bytes, ui32Flags, IMG_NULL, ppvCpuVAddr, phOSMemHandle); + return OSReservePhys(SysSysPAddrToCpuPAddr(pBasePAddr[0]), uBytes, ui32Flags, IMG_NULL, ppvCpuVAddr, phOSMemHandle); #endif } -static INLINE PVRSRV_ERROR OSUnReserveDiscontigPhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) +static INLINE PVRSRV_ERROR OSUnReserveDiscontigPhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) { #if defined(__linux__) || defined(__QNXNTO__) - OSUnRegisterDiscontigMem(pvCpuVAddr, ui32Bytes, ui32Flags, hOSMemHandle); + OSUnRegisterDiscontigMem(pvCpuVAddr, uBytes, ui32Flags, hOSMemHandle); #endif /* We don't need to unmap */ return PVRSRV_OK; @@ -276,10 +275,10 @@ static INLINE PVRSRV_ERROR OSUnReserveDiscontigPhys(IMG_VOID *pvCpuVAddr, IMG_SI #ifdef INLINE_IS_PRAGMA #pragma inline(OSReserveDiscontigPhys) #endif -static INLINE PVRSRV_ERROR OSReserveDiscontigPhys(IMG_SYS_PHYADDR *pBasePAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle) +static INLINE PVRSRV_ERROR OSReserveDiscontigPhys(IMG_SYS_PHYADDR *pBasePAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle) { PVR_UNREFERENCED_PARAMETER(pBasePAddr); - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uBytes); PVR_UNREFERENCED_PARAMETER(ui32Flags); PVR_UNREFERENCED_PARAMETER(ppvCpuVAddr); PVR_UNREFERENCED_PARAMETER(phOSMemHandle); @@ -290,10 +289,10 @@ static INLINE PVRSRV_ERROR OSReserveDiscontigPhys(IMG_SYS_PHYADDR *pBasePAddr, I #ifdef INLINE_IS_PRAGMA #pragma inline(OSUnReserveDiscontigPhys) #endif -static INLINE PVRSRV_ERROR OSUnReserveDiscontigPhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) +static INLINE PVRSRV_ERROR OSUnReserveDiscontigPhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle) { PVR_UNREFERENCED_PARAMETER(pvCpuVAddr); - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uBytes); PVR_UNREFERENCED_PARAMETER(ui32Flags); PVR_UNREFERENCED_PARAMETER(hOSMemHandle); @@ -303,11 +302,11 @@ static INLINE PVRSRV_ERROR OSUnReserveDiscontigPhys(IMG_VOID *pvCpuVAddr, IMG_SI PVRSRV_ERROR OSRegisterMem(IMG_CPU_PHYADDR BasePAddr, IMG_VOID *pvCpuVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandle); PVRSRV_ERROR OSUnRegisterMem(IMG_VOID *pvCpuVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); @@ -315,8 +314,8 @@ PVRSRV_ERROR OSUnRegisterMem(IMG_VOID *pvCpuVAddr, #if defined(__linux__) || defined(__QNXNTO__) PVRSRV_ERROR OSGetSubMemHandle(IMG_HANDLE hOSMemHandle, - IMG_UINTPTR_T ui32ByteOffset, - IMG_SIZE_T ui32Bytes, + IMG_UINTPTR_T uByteOffset, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandleRet); PVRSRV_ERROR OSReleaseSubMemHandle(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Flags); @@ -325,13 +324,13 @@ PVRSRV_ERROR OSReleaseSubMemHandle(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Flags #pragma inline(OSGetSubMemHandle) #endif static INLINE PVRSRV_ERROR OSGetSubMemHandle(IMG_HANDLE hOSMemHandle, - IMG_UINTPTR_T ui32ByteOffset, - IMG_SIZE_T ui32Bytes, + IMG_UINTPTR_T uByteOffset, + IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags, IMG_HANDLE *phOSMemHandleRet) { - PVR_UNREFERENCED_PARAMETER(ui32ByteOffset); - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uByteOffset); + PVR_UNREFERENCED_PARAMETER(uBytes); PVR_UNREFERENCED_PARAMETER(ui32Flags); *phOSMemHandleRet = hOSMemHandle; @@ -347,18 +346,15 @@ static INLINE PVRSRV_ERROR OSReleaseSubMemHandle(IMG_HANDLE hOSMemHandle, IMG_UI #endif IMG_UINT32 OSGetCurrentProcessIDKM(IMG_VOID); -int OSGetProcCmdline(IMG_UINT32 ui32PID, char * buffer, int buff_size); -const char* OSGetPathBaseName(char * buffer, int buff_size); +#if defined (MEM_TRACK_INFO_DEBUG) +IMG_UINT32 OSGetCurrentTimeInUSecsKM(IMG_VOID); +#endif IMG_UINTPTR_T OSGetCurrentThreadID( IMG_VOID ); -IMG_VOID OSMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T ui32Size); +IMG_VOID OSMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T uSize); -PVRSRV_ERROR OSAllocPages_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_UINT32 ui32PageSize, +PVRSRV_ERROR OSAllocPages_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uSize, IMG_UINT32 ui32PageSize, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, IMG_HANDLE hBMHandle, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phPageAlloc); -PVRSRV_ERROR OSFreePages(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID pvLinAddr, IMG_HANDLE hPageAlloc); - -IMG_INT32 -OSGetMemMultiPlaneInfo(IMG_HANDLE hOSMemHandle, IMG_UINT32* pui32AddressOffsets, - IMG_UINT32* ui32NumAddrOffsets); +PVRSRV_ERROR OSFreePages(IMG_UINT32 ui32Flags, IMG_SIZE_T uSize, IMG_PVOID pvLinAddr, IMG_HANDLE hPageAlloc); /*--------------------- @@ -440,14 +436,14 @@ else alias to level 1 wrapper, else the wrapper function will be used*/ /*If level 1 wrapper is enabled declare the functions with extra parameters else alias to level 0 and declare the functions without the extra debugging parameters*/ #if (defined(__linux__) || defined(__QNXNTO__)) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line); - PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID pvLinAddr, IMG_HANDLE hBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line); + PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uSize, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line); + PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uSize, IMG_PVOID pvLinAddr, IMG_HANDLE hBlockAlloc, IMG_CHAR *pszFilename, IMG_UINT32 ui32Line); #define OSAllocMem_Debug_Linux_Memory_Allocations OSAllocMem_Impl #define OSFreeMem_Debug_Linux_Memory_Allocations OSFreeMem_Impl #else - PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phBlockAlloc); - PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID pvLinAddr, IMG_HANDLE hBlockAlloc); + PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uSize, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phBlockAlloc); + PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uSize, IMG_PVOID pvLinAddr, IMG_HANDLE hBlockAlloc); #define OSAllocMem_Debug_Linux_Memory_Allocations(flags, size, addr, blockAlloc, file, line) \ OSAllocMem_Impl(flags, size, addr, blockAlloc) @@ -457,16 +453,16 @@ else alias to level 0 and declare the functions without the extra debugging para #if defined(__linux__) || defined(__QNXNTO__) -IMG_CPU_PHYADDR OSMemHandleToCpuPAddr(IMG_VOID *hOSMemHandle, IMG_SIZE_T ui32ByteOffset); +IMG_CPU_PHYADDR OSMemHandleToCpuPAddr(IMG_VOID *hOSMemHandle, IMG_UINTPTR_T uiByteOffset); #else #ifdef INLINE_IS_PRAGMA #pragma inline(OSMemHandleToCpuPAddr) #endif -static INLINE IMG_CPU_PHYADDR OSMemHandleToCpuPAddr(IMG_HANDLE hOSMemHandle, IMG_SIZE_T ui32ByteOffset) +static INLINE IMG_CPU_PHYADDR OSMemHandleToCpuPAddr(IMG_HANDLE hOSMemHandle, IMG_UINTPTR_T uiByteOffset) { IMG_CPU_PHYADDR sCpuPAddr; PVR_UNREFERENCED_PARAMETER(hOSMemHandle); - PVR_UNREFERENCED_PARAMETER(ui32ByteOffset); + PVR_UNREFERENCED_PARAMETER(uiByteOffset); sCpuPAddr.uiAddr = 0; return sCpuPAddr; } @@ -488,20 +484,9 @@ static INLINE IMG_BOOL OSMemHandleIsPhysContig(IMG_HANDLE hOSMemHandle) PVRSRV_ERROR OSInitEnvData(IMG_PVOID *ppvEnvSpecificData); PVRSRV_ERROR OSDeInitEnvData(IMG_PVOID pvEnvSpecificData); IMG_CHAR* OSStringCopy(IMG_CHAR *pszDest, const IMG_CHAR *pszSrc); -IMG_INT32 OSSNPrintf(IMG_CHAR *pStr, IMG_SIZE_T ui32Size, const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(3, 4); +IMG_INT32 OSSNPrintf(IMG_CHAR *pStr, IMG_SIZE_T uSize, const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(3, 4); #define OSStringLength(pszString) strlen(pszString) -#if defined (SUPPORT_SID_INTERFACE) -PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, - PVRSRV_EVENTOBJECT_KM *psEventObject); -PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT_KM *psEventObject); -PVRSRV_ERROR OSEventObjectSignalKM(IMG_HANDLE hOSEventKM); -PVRSRV_ERROR OSEventObjectWaitKM(IMG_HANDLE hOSEventKM); -PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT_KM *psEventObject, - IMG_HANDLE *phOSEvent); -PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT_KM *psEventObject, - IMG_HANDLE hOSEventKM); -#else PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *psEventObject); PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT *psEventObject); @@ -511,17 +496,16 @@ PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT *psEventObject, IMG_HANDLE *phOSEvent); PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT *psEventObject, IMG_HANDLE hOSEventKM); -#endif /* #if defined (SUPPORT_SID_INTERFACE) */ -PVRSRV_ERROR OSBaseAllocContigMemory(IMG_SIZE_T ui32Size, IMG_CPU_VIRTADDR *pLinAddr, IMG_CPU_PHYADDR *pPhysAddr); -PVRSRV_ERROR OSBaseFreeContigMemory(IMG_SIZE_T ui32Size, IMG_CPU_VIRTADDR LinAddr, IMG_CPU_PHYADDR PhysAddr); +PVRSRV_ERROR OSBaseAllocContigMemory(IMG_SIZE_T uSize, IMG_CPU_VIRTADDR *pLinAddr, IMG_CPU_PHYADDR *pPhysAddr); +PVRSRV_ERROR OSBaseFreeContigMemory(IMG_SIZE_T uSize, IMG_CPU_VIRTADDR LinAddr, IMG_CPU_PHYADDR PhysAddr); -IMG_PVOID MapUserFromKernel(IMG_PVOID pvLinAddrKM,IMG_SIZE_T ui32Size,IMG_HANDLE *phMemBlock); +IMG_PVOID MapUserFromKernel(IMG_PVOID pvLinAddrKM,IMG_SIZE_T uSize,IMG_HANDLE *phMemBlock); IMG_PVOID OSMapHWRegsIntoUserSpace(IMG_HANDLE hDevCookie, IMG_SYS_PHYADDR sRegAddr, IMG_UINT32 ulSize, IMG_PVOID *ppvProcess); IMG_VOID OSUnmapHWRegsFromUserSpace(IMG_HANDLE hDevCookie, IMG_PVOID pvUserAddr, IMG_PVOID pvProcess); -IMG_VOID UnmapUserFromKernel(IMG_PVOID pvLinAddrUM, IMG_SIZE_T ui32Size, IMG_HANDLE hMemBlock); +IMG_VOID UnmapUserFromKernel(IMG_PVOID pvLinAddrUM, IMG_SIZE_T uSize, IMG_HANDLE hMemBlock); PVRSRV_ERROR OSMapPhysToUserSpace(IMG_HANDLE hDevCookie, IMG_SYS_PHYADDR sCPUPhysAddr, @@ -627,7 +611,7 @@ PVRSRV_ERROR OSRemoveTimer (IMG_HANDLE hTimer); PVRSRV_ERROR OSEnableTimer (IMG_HANDLE hTimer); PVRSRV_ERROR OSDisableTimer (IMG_HANDLE hTimer); -PVRSRV_ERROR OSGetSysMemSize(IMG_SIZE_T *pui32Bytes); +PVRSRV_ERROR OSGetSysMemSize(IMG_SIZE_T *puBytes); typedef enum _HOST_PCI_INIT_FLAGS_ { @@ -674,14 +658,14 @@ typedef enum _img_verify_test PVR_VERIFY_READ } IMG_VERIFY_TEST; -IMG_BOOL OSAccessOK(IMG_VERIFY_TEST eVerification, IMG_VOID *pvUserPtr, IMG_SIZE_T ui32Bytes); +IMG_BOOL OSAccessOK(IMG_VERIFY_TEST eVerification, IMG_VOID *pvUserPtr, IMG_SIZE_T uBytes); -PVRSRV_ERROR OSCopyToUser(IMG_PVOID pvProcess, IMG_VOID *pvDest, IMG_VOID *pvSrc, IMG_SIZE_T ui32Bytes); -PVRSRV_ERROR OSCopyFromUser(IMG_PVOID pvProcess, IMG_VOID *pvDest, IMG_VOID *pvSrc, IMG_SIZE_T ui32Bytes); +PVRSRV_ERROR OSCopyToUser(IMG_PVOID pvProcess, IMG_VOID *pvDest, IMG_VOID *pvSrc, IMG_SIZE_T uBytes); +PVRSRV_ERROR OSCopyFromUser(IMG_PVOID pvProcess, IMG_VOID *pvDest, IMG_VOID *pvSrc, IMG_SIZE_T uBytes); #if defined(__linux__) || defined(__QNXNTO__) PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID* pvCPUVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_SYS_PHYADDR *psSysPAddr, IMG_HANDLE *phOSWrapMem); PVRSRV_ERROR OSReleasePhysPageAddr(IMG_HANDLE hOSWrapMem); @@ -690,12 +674,12 @@ PVRSRV_ERROR OSReleasePhysPageAddr(IMG_HANDLE hOSWrapMem); #pragma inline(OSAcquirePhysPageAddr) #endif static INLINE PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID* pvCPUVAddr, - IMG_SIZE_T ui32Bytes, + IMG_SIZE_T uBytes, IMG_SYS_PHYADDR *psSysPAddr, IMG_HANDLE *phOSWrapMem) { PVR_UNREFERENCED_PARAMETER(pvCPUVAddr); - PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(uBytes); PVR_UNREFERENCED_PARAMETER(psSysPAddr); PVR_UNREFERENCED_PARAMETER(phOSWrapMem); return PVRSRV_OK; @@ -787,6 +771,12 @@ static INLINE IMG_VOID OSGetCurrentProcessNameKM(IMG_CHAR *pszName, IMG_UINT32 u #endif +#if defined(__linux__) && defined(DEBUG) +#define OSDumpStack dump_stack +#else +#define OSDumpStack() +#endif + #if defined (__cplusplus) } #endif diff --git a/drivers/gpu/pvr/services4/srvkm/include/osperproc.h b/drivers/gpu/pvr/services4/srvkm/include/osperproc.h index 0b962b43830..0b962b43830 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/osperproc.h +++ b/drivers/gpu/pvr/services4/srvkm/include/osperproc.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/pdump_int.h b/drivers/gpu/pvr/services4/srvkm/include/pdump_int.h index a76fed0163b..a76fed0163b 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/pdump_int.h +++ b/drivers/gpu/pvr/services4/srvkm/include/pdump_int.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/pdump_km.h b/drivers/gpu/pvr/services4/srvkm/include/pdump_km.h index e4325ccb360..4d62154fb66 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/pdump_km.h +++ b/drivers/gpu/pvr/services4/srvkm/include/pdump_km.h @@ -77,6 +77,10 @@ extern IMG_UINT32 g_ui32EveryLineCounter; #define MAKEUNIQUETAG(hMemInfo) (0) #endif +IMG_BOOL _PDumpIsProcessActive(IMG_VOID); + +IMG_BOOL PDumpWillCapture(IMG_UINT32 ui32Flags); + #ifdef PDUMP #define MAKEUNIQUETAG(hMemInfo) (((BM_BUF *)(((PVRSRV_KERNEL_MEM_INFO *)(hMemInfo))->sMemBlk.hBuffer))->pMapping) @@ -267,8 +271,8 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32NumBytes, IMG_UINT32 ui32PageSize, - IMG_BOOL bShared, - IMG_HANDLE hUniqueTag); + IMG_HANDLE hUniqueTag, + IMG_UINT32 ui32Flags); PVRSRV_ERROR PDumpMallocPageTable(PVRSRV_DEVICE_IDENTIFIER *psDevId, IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Offset, @@ -282,7 +286,8 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_UINT32 ui32PageSize, IMG_HANDLE hUniqueTag, IMG_BOOL bInterleaved, - IMG_BOOL bSparse); + IMG_BOOL bSparse, + IMG_UINT32 ui32Flags); PVRSRV_ERROR PDumpFreePageTable(PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_HANDLE hOSMemHandle, IMG_CPU_VIRTADDR pvLinAddr, diff --git a/drivers/gpu/pvr/services4/srvkm/include/pdump_osfunc.h b/drivers/gpu/pvr/services4/srvkm/include/pdump_osfunc.h index 0f2e103c23b..9fc1fd82297 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/pdump_osfunc.h +++ b/drivers/gpu/pvr/services4/srvkm/include/pdump_osfunc.h @@ -58,7 +58,10 @@ extern "C" { * supported (e.g. Linux). */ #define MAX_PDUMP_STRING_LENGTH (256) -#if defined(__QNXNTO__) + + +#if defined(__QNXNTO__) + #define PDUMP_GET_SCRIPT_STRING() \ IMG_CHAR pszScript[MAX_PDUMP_STRING_LENGTH]; \ IMG_UINT32 ui32MaxLen = MAX_PDUMP_STRING_LENGTH-1; \ @@ -79,7 +82,12 @@ extern "C" { IMG_UINT32 ui32MaxLenFileName = MAX_PDUMP_STRING_LENGTH-1; \ IMG_HANDLE hScript = (IMG_HANDLE)pszScript; -#else /* WIN32 or QNX */ +#define PDUMP_LOCK(args...) +#define PDUMP_UNLOCK(args...) +#define PDUMP_LOCK_MSG(args...) +#define PDUMP_UNLOCK_MSG(args...) + +#else /* __QNXNTO__ */ /* @@ -117,6 +125,48 @@ extern "C" { eError = PDumpOSGetFilenameString(&pszFileName, &ui32MaxLenFileName);\ if(eError != PVRSRV_OK) return eError; +#define PDUMP_LOCK() \ + PDumpOSLock(__LINE__); + +#define PDUMP_UNLOCK() \ + PDumpOSUnlock(__LINE__); + +#define PDUMP_LOCK_MSG() \ + PDumpOSLockMessageBuffer(); + +#define PDUMP_UNLOCK_MSG() \ + PDumpOSUnlockMessageBuffer(); + + /*! + * @name PDumpOSLock + * @brief Lock the PDump streams + * @return error none + */ + IMG_VOID PDumpOSLock(IMG_UINT32 ui32Line); + + /*! + * @name PDumpOSUnlock + * @brief Lock the PDump streams + * @return error none + */ + IMG_VOID PDumpOSUnlock(IMG_UINT32 ui32Line); + + /*! + * @name PDumpOSLockMessageBuffer + * @brief Lock the PDump message buffer + * @return error none + */ + IMG_VOID PDumpOSLockMessageBuffer(IMG_VOID); + + /*! + * @name PDumpOSUnlockMessageBuffer + * @brief Lock the PDump message buffer + * @return error none + */ + IMG_VOID PDumpOSUnlockMessageBuffer(IMG_VOID); + +#endif /* __QNXNTO__ */ + /*! * @name PDumpOSGetScriptString * @brief Get the "script" buffer @@ -147,8 +197,6 @@ extern "C" { */ PVRSRV_ERROR PDumpOSGetFilenameString(IMG_CHAR **ppszFile, IMG_UINT32 *pui32MaxLen); -#endif /* WIN32 or QNX */ - /* * Define macro for processing variable args list in OS-independent @@ -305,13 +353,13 @@ IMG_VOID PDumpOSCPUVAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, * @param hOSMemHandle mem allocation handle (used if kernel virtual mem space is limited, e.g. linux) * @param ui32Offset offset within mem allocation block * @param pui8LinAddr CPU linear addr - * @param ui32DataPageMask mask for data page (= data page size -1) + * @param uiDataPageMask mask for data page (= data page size -1) * @return pui32PageOffset CPU page offset (same as device page offset if page sizes equal) */ IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Offset, IMG_PUINT8 pui8LinAddr, - IMG_UINT32 ui32DataPageMask, + IMG_UINTPTR_T uiDataPageMask, IMG_UINT32 *pui32PageOffset); /*! diff --git a/drivers/gpu/pvr/services4/srvkm/include/perfkm.h b/drivers/gpu/pvr/services4/srvkm/include/perfkm.h index 458a29b2fab..458a29b2fab 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/perfkm.h +++ b/drivers/gpu/pvr/services4/srvkm/include/perfkm.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/perproc.h b/drivers/gpu/pvr/services4/srvkm/include/perproc.h index d60361320f1..124f2f23342 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/perproc.h +++ b/drivers/gpu/pvr/services4/srvkm/include/perproc.h @@ -56,21 +56,12 @@ typedef struct _PVRSRV_PER_PROCESS_DATA_ IMG_UINT32 ui32PID; IMG_HANDLE hBlockAlloc; PRESMAN_CONTEXT hResManContext; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hPerProcData; -#else IMG_HANDLE hPerProcData; -#endif PVRSRV_HANDLE_BASE *psHandleBase; -#if defined (SUPPORT_SID_INTERFACE) - /* Handles are being allocated in batches */ - IMG_BOOL bHandlesBatched; -#else #if defined (PVR_SECURE_HANDLES) /* Handles are being allocated in batches */ IMG_BOOL bHandlesBatched; #endif /* PVR_SECURE_HANDLES */ -#endif /* SUPPORT_SID_INTERFACE */ IMG_UINT32 ui32RefCount; /* True if the process is the initialisation server. */ diff --git a/drivers/gpu/pvr/services4/srvkm/include/power.h b/drivers/gpu/pvr/services4/srvkm/include/power.h index 0abaf7554e1..0abaf7554e1 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/power.h +++ b/drivers/gpu/pvr/services4/srvkm/include/power.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/queue.h b/drivers/gpu/pvr/services4/srvkm/include/queue.h index 58f80936e8d..6bc82ed5f6e 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/queue.h +++ b/drivers/gpu/pvr/services4/srvkm/include/queue.h @@ -43,6 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef QUEUE_H #define QUEUE_H +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) #if defined(__cplusplus) extern "C" { @@ -51,9 +52,9 @@ extern "C" { /*! * Macro to Read Offset in given command queue */ -#define UPDATE_QUEUE_ROFF(psQueue, ui32Size) \ - (psQueue)->ui32ReadOffset = ((psQueue)->ui32ReadOffset + (ui32Size)) \ - & ((psQueue)->ui32QueueSize - 1); +#define UPDATE_QUEUE_ROFF(psQueue, uSize) \ + (psQueue)->uReadOffset = ((psQueue)->uReadOffset + (uSize)) \ + & ((psQueue)->uQueueSize - 1); /*! generic cmd complete structure. @@ -75,6 +76,11 @@ extern "C" { IMG_UINT32 ui32AllocSize; /*!< allocated size*/ PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete; /*!< Command complete callback */ IMG_HANDLE hCallbackData; /*!< Command complete callback data */ + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + IMG_VOID *pvCleanupFence; /*!< Sync fence to 'put' after timeline inc() */ + IMG_VOID *pvTimeline; /*!< Android sync timeline to inc() */ +#endif }COMMAND_COMPLETE_DATA, *PCOMMAND_COMPLETE_DATA; #if !defined(USE_CODE) @@ -92,7 +98,7 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el); IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, +PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize, PVRSRV_QUEUE_INFO **ppsQueueInfo); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueueInfo); @@ -108,11 +114,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, PVRSRV_KERNEL_SYNC_INFO *apsSrcSync[], IMG_SIZE_T ui32DataByteSize, PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete, - IMG_HANDLE hCallbackData); + IMG_HANDLE hCallbackData, + IMG_HANDLE *phFence); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetQueueSpaceKM(PVRSRV_QUEUE_INFO *psQueue, - IMG_SIZE_T ui32ParamSize, + IMG_SIZE_T uParamSize, IMG_VOID **ppvSpace); IMG_IMPORT @@ -138,6 +145,8 @@ PVRSRV_ERROR PVRSRVRemoveCmdProcListKM(IMG_UINT32 ui32DevIndex, } #endif +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + #endif /* QUEUE_H */ /****************************************************************************** diff --git a/drivers/gpu/pvr/services4/srvkm/include/ra.h b/drivers/gpu/pvr/services4/srvkm/include/ra.h index b84a8e54fbe..aaeb345beb0 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/ra.h +++ b/drivers/gpu/pvr/services4/srvkm/include/ra.h @@ -87,9 +87,6 @@ struct _RA_STATISTICS_ /** total number of spans deallocated by the callback mechanism */ IMG_SIZE_T uExportCount; - - IMG_SIZE_T uFailedAllocCount; - }; typedef struct _RA_STATISTICS_ RA_STATISTICS; diff --git a/drivers/gpu/pvr/services4/srvkm/include/refcount.h b/drivers/gpu/pvr/services4/srvkm/include/refcount.h index 0e3479df119..a2efd6ceb11 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/refcount.h +++ b/drivers/gpu/pvr/services4/srvkm/include/refcount.h @@ -43,6 +43,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define __REFCOUNT_H__ #include "pvr_bridge_km.h" +#if defined(SUPPORT_ION) +#include "ion_sync.h" +#endif /* defined(SUPPORT_ION) */ #if defined(PVRSRV_REFCOUNT_DEBUG) @@ -111,6 +114,23 @@ void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, PKV_OFFSET_STRUCT psOffsetStruct); +#if defined(SUPPORT_ION) +#define PVRSRVIonBufferSyncInfoIncRef(x...) \ + PVRSRVIonBufferSyncInfoIncRef2(__FILE__, __LINE__, x) +#define PVRSRVIonBufferSyncInfoDecRef(x...) \ + PVRSRVIonBufferSyncInfoDecRef2(__FILE__, __LINE__, x) + +PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, + IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo); +void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, + PVRSRV_ION_SYNC_INFO *psIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo); +#endif /* defined (SUPPORT_ION) */ + #endif /* defined(__linux__) */ #else /* defined(PVRSRV_REFCOUNT_DEBUG) */ @@ -196,6 +216,29 @@ static INLINE void PVRSRVOffsetStructDecMapped(PKV_OFFSET_STRUCT psOffsetStruct) psOffsetStruct->ui32Mapped--; } +#if defined(SUPPORT_ION) +static INLINE PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef(IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) +{ + PVR_UNREFERENCED_PARAMETER(psKernelMemInfo); + + return PVRSRVIonBufferSyncAcquire(hUnique, + hDevCookie, + hDevMemContext, + ppsIonSyncInfo); +} + +static INLINE void PVRSRVIonBufferSyncInfoDecRef(PVRSRV_ION_SYNC_INFO *psIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) +{ + PVR_UNREFERENCED_PARAMETER(psKernelMemInfo); + PVRSRVIonBufferSyncRelease(psIonSyncInfo); +} +#endif /* defined (SUPPORT_ION) */ + #endif /* defined(__linux__) */ #endif /* defined(PVRSRV_REFCOUNT_DEBUG) */ diff --git a/drivers/gpu/pvr/services4/srvkm/include/resman.h b/drivers/gpu/pvr/services4/srvkm/include/resman.h index 92659d9843f..92659d9843f 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/resman.h +++ b/drivers/gpu/pvr/services4/srvkm/include/resman.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/services_headers.h b/drivers/gpu/pvr/services4/srvkm/include/services_headers.h index d09b8a882c0..d09b8a882c0 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/services_headers.h +++ b/drivers/gpu/pvr/services4/srvkm/include/services_headers.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/srvkm.h b/drivers/gpu/pvr/services4/srvkm/include/srvkm.h index 5d396f89e50..45ac3b1aad8 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/srvkm.h +++ b/drivers/gpu/pvr/services4/srvkm/include/srvkm.h @@ -42,6 +42,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SRVKM_H #define SRVKM_H +#include "servicesint.h" #if defined(__cplusplus) extern "C" { @@ -63,12 +64,155 @@ extern "C" { IMG_IMPORT IMG_VOID PVRSRVScheduleDevicesKM(IMG_VOID); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) IMG_VOID IMG_CALLCONV PVRSRVSetDCState(IMG_UINT32 ui32State); +#endif PVRSRV_ERROR IMG_CALLCONV PVRSRVSaveRestoreLiveSegments(IMG_HANDLE hArena, IMG_PBYTE pbyBuffer, IMG_SIZE_T *puiBufSize, IMG_BOOL bSave); IMG_VOID PVRSRVScheduleDeviceCallbacks(IMG_VOID); + IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDumpSyncs(IMG_BOOL bActiveOnly); + +#define SYNC_OP_CLASS_MASK 0x0000ffffUL +#define SYNC_OP_CLASS_SHIFT 0 +#define SYNC_OP_CLASS_MODOBJ (1<<0) +#define SYNC_OP_CLASS_QUEUE (1<<1) +#define SYNC_OP_CLASS_KICKTA (1<<2) +#define SYNC_OP_CLASS_TQ_3D (1<<3) +#define SYNC_OP_CLASS_TQ_2D (1<<4) + +#define SYNC_OP_TYPE_MASK 0x00f0000UL +#define SYNC_OP_TYPE_SHIFT 16 +#define SYNC_OP_TYPE_READOP (1<<0) +#define SYNC_OP_TYPE_WRITEOP (1<<1) +#define SYNC_OP_TYPE_READOP2 (1<<2) + +#define SYNC_OP_HAS_DATA 0x80000000UL +#define SYNC_OP_TAKE 0x40000000UL +#define SYNC_OP_ROLLBACK 0x20000000UL + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SyncTakeWriteOp) +#endif +static INLINE +IMG_UINT32 SyncTakeWriteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType) +{ +#if defined(SUPPORT_PER_SYNC_DEBUG) + IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex; + + /* Record a history of all the classes of operation taken on this sync */ + psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + + /* Add this operation to the history buffer */ + psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_WRITEOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_TAKE; + psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending; + psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending; + psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending; + psKernelSync->ui32HistoryIndex++; + psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY; +#endif + PVR_UNREFERENCED_PARAMETER(ui32OpType); + return psKernelSync->psSyncData->ui32WriteOpsPending++; +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SyncTakeReadOp) +#endif +static INLINE +IMG_UINT32 SyncTakeReadOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType) +{ +#if defined(SUPPORT_PER_SYNC_DEBUG) + IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex; + + /* Record a history of all the classes of operation taken on this sync */ + psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + + /* Add this operation to the history buffer */ + psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_READOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_TAKE; + psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending; + psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending; + psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending; + psKernelSync->ui32HistoryIndex++; + psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY; +#endif + PVR_UNREFERENCED_PARAMETER(ui32OpType); + return psKernelSync->psSyncData->ui32ReadOpsPending++; +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SyncTakeReadOp2) +#endif +static INLINE +IMG_UINT32 SyncTakeReadOp2(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType) +{ +#if defined(SUPPORT_PER_SYNC_DEBUG) + IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex; + + /* Record a history of all the classes of operation taken on this sync */ + psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + + /* Add this operation to the history buffer */ + psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_READOP2 << SYNC_OP_TYPE_SHIFT) | SYNC_OP_TAKE; + psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending; + psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending; + psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending; + psKernelSync->ui32HistoryIndex++; + psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY; +#endif + PVR_UNREFERENCED_PARAMETER(ui32OpType); + return psKernelSync->psSyncData->ui32ReadOps2Pending++; +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SyncRollBackWriteOp) +#endif +static INLINE +IMG_UINT32 SyncRollBackWriteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType) +{ +#if defined(SUPPORT_PER_SYNC_DEBUG) + IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex; + + /* Record a history of all the classes of operation taken on this sync */ + psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + + /* Add this operation to the history buffer */ + psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_WRITEOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_ROLLBACK; + psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending; + psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending; + psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending; + psKernelSync->ui32HistoryIndex++; + psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY; +#endif + PVR_UNREFERENCED_PARAMETER(ui32OpType); + return psKernelSync->psSyncData->ui32WriteOpsPending--; +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SyncRollBackReadOp) +#endif +static INLINE +IMG_UINT32 SyncRollBackReadOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType) +{ +#if defined(SUPPORT_PER_SYNC_DEBUG) + IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex; + + /* Record a history of all the classes of operation taken on this sync */ + psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + + /* Add this operation to the history buffer */ + psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_READOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_ROLLBACK; + psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending; + psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending; + psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending; + psKernelSync->ui32HistoryIndex++; + psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY; +#endif + PVR_UNREFERENCED_PARAMETER(ui32OpType); + return psKernelSync->psSyncData->ui32ReadOpsPending--; +} + + #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/services4/srvkm/include/ttrace.h b/drivers/gpu/pvr/services4/srvkm/include/ttrace.h index cb70ff8e2a2..cb70ff8e2a2 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/ttrace.h +++ b/drivers/gpu/pvr/services4/srvkm/include/ttrace.h diff --git a/drivers/gpu/pvr/services4/srvkm/include/ttrace_common.h b/drivers/gpu/pvr/services4/srvkm/include/ttrace_common.h index b14f256fc06..e149c20f0c3 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/ttrace_common.h +++ b/drivers/gpu/pvr/services4/srvkm/include/ttrace_common.h @@ -121,7 +121,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define READ_HEADER(n,m) \ ((m & (PVRSRV_TRACE_##n##_MASK << PVRSRV_TRACE_##n##_SHIFT)) >> PVRSRV_TRACE_##n##_SHIFT) + +#if defined(TTRACE_LARGE_BUFFER) +#define TIME_TRACE_BUFFER_SIZE 8192 +#else #define TIME_TRACE_BUFFER_SIZE 4096 +#endif /* Type defines for trace items */ #define PVRSRV_TRACE_TYPE_UI8 0 diff --git a/drivers/gpu/pvr/services4/srvkm/include/ttrace_tokens.h b/drivers/gpu/pvr/services4/srvkm/include/ttrace_tokens.h index 24bc4843ec2..5f898495cdf 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/include/ttrace_tokens.h +++ b/drivers/gpu/pvr/services4/srvkm/include/ttrace_tokens.h @@ -52,26 +52,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PVRSRV_TRACE_GROUP_QUEUE 2 #define PVRSRV_TRACE_GROUP_POWER 3 #define PVRSRV_TRACE_GROUP_MKSYNC 4 +#define PVRSRV_TRACE_GROUP_MODOBJ 5 #define PVRSRV_TRACE_GROUP_PADDING 255 /* Trace classes */ #define PVRSRV_TRACE_CLASS_FUNCTION_ENTER 0 #define PVRSRV_TRACE_CLASS_FUNCTION_EXIT 1 -#define PVRSRV_TRACE_CLASS_SYNC 2 -#define PVRSRV_TRACE_CLASS_CCB 3 +#define PVRSRV_TRACE_CLASS_SYNC 2 +#define PVRSRV_TRACE_CLASS_CCB 3 #define PVRSRV_TRACE_CLASS_CMD_START 4 -#define PVRSRV_TRACE_CLASS_CMD_END 5 +#define PVRSRV_TRACE_CLASS_CMD_END 5 #define PVRSRV_TRACE_CLASS_CMD_COMP_START 6 #define PVRSRV_TRACE_CLASS_CMD_COMP_END 7 #define PVRSRV_TRACE_CLASS_FLAGS 8 - -#define PVRSRV_TRACE_CLASS_NONE 255 +#define PVRSRV_TRACE_CLASS_DEVVADDR 9 +#define PVRSRV_TRACE_CLASS_FRAMENUM 10 + +#define PVRSRV_TRACE_CLASS_NONE 255 /* Operation about to happen on the sync object */ #define PVRSRV_SYNCOP_SAMPLE 0 #define PVRSRV_SYNCOP_COMPLETE 1 -#define PVRSRV_SYNCOP_DUMP 2 +#define PVRSRV_SYNCOP_DUMP 2 /* * Trace tokens @@ -80,15 +83,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* Kick group tokens */ -#define KICK_TOKEN_DOKICK 0 +#define KICK_TOKEN_DOKICK 0 #define KICK_TOKEN_CCB_OFFSET 1 #define KICK_TOKEN_TA3D_SYNC 2 -#define KICK_TOKEN_TA_SYNC 3 -#define KICK_TOKEN_3D_SYNC 4 -#define KICK_TOKEN_SRC_SYNC 5 -#define KICK_TOKEN_DST_SYNC 6 -#define KICK_TOKEN_FIRST_KICK 7 -#define KICK_TOKEN_LAST_KICK 8 +#define KICK_TOKEN_TA_SYNC 3 +#define KICK_TOKEN_3D_SYNC 4 +#define KICK_TOKEN_SRC_SYNC 5 +#define KICK_TOKEN_DST_SYNC 6 +#define KICK_TOKEN_FIRST_KICK 7 +#define KICK_TOKEN_LAST_KICK 8 +#define KICK_TOKEN_HWRTDATASET 9 +#define KICK_TOKEN_HWRTDATA 10 +#define KICK_TOKEN_FRAMENUM 11 +#define KICK_TOKEN_RENDERCONTEXT 12 /* Transfer Queue group tokens */ #define TRANSFER_TOKEN_SUBMIT 0 @@ -99,21 +106,30 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define TRANSFER_TOKEN_CCB_OFFSET 5 /* Queue group tokens */ -#define QUEUE_TOKEN_GET_SPACE 0 -#define QUEUE_TOKEN_INSERTKM 1 -#define QUEUE_TOKEN_SUBMITKM 2 -#define QUEUE_TOKEN_PROCESS_COMMAND 3 -#define QUEUE_TOKEN_PROCESS_QUEUES 4 +#define QUEUE_TOKEN_GET_SPACE 0 +#define QUEUE_TOKEN_INSERTKM 1 +#define QUEUE_TOKEN_SUBMITKM 2 +#define QUEUE_TOKEN_PROCESS_COMMAND 3 +#define QUEUE_TOKEN_PROCESS_QUEUES 4 #define QUEUE_TOKEN_COMMAND_COMPLETE 5 -#define QUEUE_TOKEN_UPDATE_DST 6 -#define QUEUE_TOKEN_UPDATE_SRC 7 -#define QUEUE_TOKEN_SRC_SYNC 8 -#define QUEUE_TOKEN_DST_SYNC 9 -#define QUEUE_TOKEN_COMMAND_TYPE 10 +#define QUEUE_TOKEN_UPDATE_DST 6 +#define QUEUE_TOKEN_UPDATE_SRC 7 +#define QUEUE_TOKEN_SRC_SYNC 8 +#define QUEUE_TOKEN_DST_SYNC 9 +#define QUEUE_TOKEN_COMMAND_TYPE 10 /* uKernel Sync tokens */ #define MKSYNC_TOKEN_KERNEL_CCB_OFFSET 0 -#define MKSYNC_TOKEN_CORE_CLK 1 -#define MKSYNC_TOKEN_UKERNEL_CLK 2 +#define MKSYNC_TOKEN_CORE_CLK 1 +#define MKSYNC_TOKEN_UKERNEL_CLK 2 + +/* ModObj tokens */ +#define MODOBJ_TOKEN_MODIFY_PENDING 0 +#define MODOBJ_TOKEN_COMPLETE_PENDING 1 +#define MODOBJ_TOKEN_READ_SYNC 2 +#define MODOBJ_TOKEN_WRITE_SYNC 3 +#define MODOBJ_TOKEN_READ_WRITE_SYNC 4 +#define MODOBJ_TOKEN_SYNC_UPDATE 5 +#define MODOBJ_TOKEN_READ2_SYNC 6 #endif /* __TTRACE_TOKENS_H__ */ diff --git a/drivers/gpu/pvr/services4/system/include/syscommon.h b/drivers/gpu/pvr/services4/system/include/syscommon.h index 4fd35126c87..a31794ba57a 100644..100755 --- a/drivers/gpu/pvr/services4/system/include/syscommon.h +++ b/drivers/gpu/pvr/services4/system/include/syscommon.h @@ -116,11 +116,7 @@ typedef struct _SYS_DATA_TAG_ RA_ARENA *apsLocalDevMemArena[SYS_MAX_LOCAL_DEVMEM_ARENAS]; /*!< RA Arenas for local device memory heap management */ IMG_CHAR *pszVersionString; /*!< Human readable string showing relevent system version info */ -#if defined (SUPPORT_SID_INTERFACE) - PVRSRV_EVENTOBJECT_KM *psGlobalEventObject; /*!< OS Global Event Object */ -#else PVRSRV_EVENTOBJECT *psGlobalEventObject; /*!< OS Global Event Object */ -#endif PVRSRV_MISC_INFO_CPUCACHEOP_TYPE ePendingCacheOpType; /*!< Deferred CPU cache op control */ @@ -172,9 +168,6 @@ PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock); IMG_VOID SysPowerLockUnwrap(IMG_VOID); #endif -IMG_VOID SysLockSystemSuspend(IMG_VOID); -IMG_VOID SysUnlockSystemSuspend(IMG_VOID); - PVRSRV_ERROR SysOEMFunction ( IMG_UINT32 ui32ID, IMG_VOID *pvIn, IMG_UINT32 ulInSize, diff --git a/drivers/gpu/pvr/services4/system/omap3630/oemfuncs.h b/drivers/gpu/pvr/services4/system/omap/oemfuncs.h index 090204238b0..090204238b0 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/oemfuncs.h +++ b/drivers/gpu/pvr/services4/system/omap/oemfuncs.h diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq.c b/drivers/gpu/pvr/services4/system/omap/sgxfreq.c index 7e8e8fd6a07..1febc758c2f 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq.c +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq.c @@ -15,7 +15,13 @@ */ #include <linux/opp.h> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) #include <plat/gpu.h> +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +#include <linux/regulator/consumer.h> +#endif + #include "sgxfreq.h" static struct sgxfreq_data { @@ -32,7 +38,16 @@ static struct sgxfreq_data { struct mutex gov_mutex; struct sgxfreq_sgx_data sgx_data; struct device *dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) struct gpu_platform_data *pdata; +#else + struct clk *core_clk; + struct clk *gpu_clk; + struct clk *per_clk; + struct clk *gpu_core_clk; + struct clk *gpu_hyd_clk; + struct regulator *gpu_reg; +#endif } sfd; /* Governor init/deinit functions */ @@ -70,7 +85,7 @@ static unsigned long _idle_prev_time; static unsigned long _active_curr_time; static unsigned long _active_prev_time; -#if defined(CONFIG_THERMAL_FRAMEWORK) +#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK)) int cool_init(void); void cool_deinit(void); #endif @@ -187,19 +202,106 @@ static const struct attribute *sgxfreq_attributes[] = { }; /************************ end sysfs interface ************************/ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +static int set_volt_for_freq(unsigned long freq) +{ + struct opp *opp; + unsigned long volt = 0; + int ret; + + if (sfd.gpu_reg) { + opp = opp_find_freq_exact(sfd.dev, freq, true); + if(IS_ERR(opp)) + { + int r = PTR_ERR(opp); + pr_err("sgxfreq: Couldn't find opp matching freq: %lu. Err: %d", + freq, r); + return -1; + } + + volt = opp_get_voltage(opp); + if (!volt) + { + pr_err("sgxfreq: Could find volt corresponding to freq: %lu\n", + freq); + return -1; + } + + ret = regulator_set_voltage_tol(sfd.gpu_reg, volt , 6000); + if (ret) { + pr_err("sgxfreq: Error(%d) setting volt: %lu for freq:%lu\n", + ret, volt, freq); + return ret; + } + } -static void __set_freq(void) + return 0; + +} +#endif + +static int __set_freq(void) { unsigned long freq; + int ret = 0; freq = min(sfd.freq_request, sfd.freq_limit); if (freq != sfd.freq) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) + if (freq > sfd.freq) { + /* Going up - must scale voltage before clocks */ + if (set_volt_for_freq(freq) != 0) { + pr_err("sgxfreq: Error setting voltage for freq: %lu\n", + freq); + goto err1; + } + } + + ret = clk_set_rate(sfd.gpu_core_clk, freq); + if (ret) { + pr_err("sgxfreq: Error(%d) setting gpu core clock rate: %lu\n", + ret, freq); + goto err2; + } + + ret = clk_set_rate(sfd.gpu_hyd_clk, freq); + if (ret) { + pr_err("sgxfreq: Error(%d) setting gpu hyd clock rate: %lu\n", + ret, freq); + goto err3; + } + + if (freq < sfd.freq) { + /* Going down - must scale voltage after clocks */ + if(set_volt_for_freq(freq) != 0) { + pr_err("sgxfreq: Error setting voltage for freq: %lu\n", + freq); + goto err4; + } + } + +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) sfd.pdata->device_scale(sfd.dev, sfd.dev, freq); #else sfd.pdata->device_scale(sfd.dev, freq); #endif sfd.freq = freq; + + goto noerr; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +err4: + ret |= clk_set_rate(sfd.gpu_hyd_clk, sfd.freq); + +err3: + ret |= clk_set_rate(sfd.gpu_core_clk, sfd.freq); +err2: + if(freq > sfd.freq) + ret |= set_volt_for_freq(sfd.freq); +err1: +#endif +noerr: + return ret; } } @@ -278,17 +380,28 @@ int sgxfreq_init(struct device *dev) sfd.dev = dev; if (!sfd.dev) return -EINVAL; - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) sfd.pdata = (struct gpu_platform_data *)dev->platform_data; if (!sfd.pdata || !sfd.pdata->opp_get_opp_count || !sfd.pdata->opp_find_freq_ceil || !sfd.pdata->device_scale) return -EINVAL; +#endif rcu_read_lock(); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) sfd.freq_cnt = sfd.pdata->opp_get_opp_count(dev); +#else + ret = of_init_opp_table(dev); + if (ret) { + pr_err("sgxfreq: failed to init OPP table: %d\n", ret); + return -EINVAL; + } + + sfd.freq_cnt = opp_get_opp_count(dev); +#endif if (sfd.freq_cnt < 1) { rcu_read_unlock(); return -ENODEV; @@ -302,7 +415,11 @@ int sgxfreq_init(struct device *dev) freq = 0; for (i = 0; i < sfd.freq_cnt; i++) { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) opp = sfd.pdata->opp_find_freq_ceil(dev, &freq); +#else + opp = opp_find_freq_ceil(dev, &freq); +#endif if (IS_ERR_OR_NULL(opp)) { rcu_read_unlock(); kfree(sfd.freq_list); @@ -313,6 +430,63 @@ int sgxfreq_init(struct device *dev) } rcu_read_unlock(); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) + sfd.core_clk = devm_clk_get(dev, "dpll_core_h14x2_ck"); + if (IS_ERR(sfd.core_clk)) { + ret = PTR_ERR(sfd.core_clk); + pr_err("sgxfreq: failed to get core clock: %d\n", ret); + return ret; + } + + sfd.gpu_clk = devm_clk_get(dev, "dpll_gpu_m2_ck"); + if (IS_ERR(sfd.gpu_clk)) { + ret = PTR_ERR(sfd.gpu_clk); + pr_err("sgxfreq: failed to get gpu clock: %d\n", ret); + return ret; + } + + sfd.per_clk = devm_clk_get(dev, "dpll_per_h14x2_ck"); + if (IS_ERR(sfd.per_clk)) { + ret = PTR_ERR(sfd.per_clk); + pr_err("sgxfreq: failed to get per clock: %d\n", ret); + return ret; + } + + sfd.gpu_core_clk = devm_clk_get(dev, "gpu_core_gclk_mux"); + if (IS_ERR(sfd.gpu_core_clk)) { + ret = PTR_ERR(sfd.gpu_core_clk); + pr_err("sgxfreq: failed to get gpu core clock: %d\n", ret); + return ret; + } + + sfd.gpu_hyd_clk = devm_clk_get(dev, "gpu_core_gclk_mux"); + if (IS_ERR(sfd.gpu_hyd_clk)) { + ret = PTR_ERR(sfd.gpu_hyd_clk); + pr_err("sgxfreq: failed to get gpu hyd clock: %d\n", ret); + return ret; + } + + sfd.gpu_reg = devm_regulator_get(dev, "gpu"); + if (IS_ERR(sfd.gpu_reg)) { + if (PTR_ERR(sfd.gpu_reg) == -EPROBE_DEFER) { + dev_err(dev, "gpu regulator not ready, retry\n"); + return -EPROBE_DEFER; + } + pr_err("sgxfreq: failed to get gpu regulator: %ld\n", PTR_ERR(sfd.gpu_reg)); + sfd.gpu_reg = NULL; + } + + ret = clk_set_parent(sfd.gpu_hyd_clk, sfd.core_clk); + if (ret != 0) { + pr_err("sgxfreq: failed to set gpu_hyd_clk parent: %d\n", ret); + } + + ret = clk_set_parent(sfd.gpu_core_clk, sfd.core_clk); + if (ret != 0) { + pr_err("sgxfreq: failed to set gpu_core_clk parent: %d\n", ret); + } +#endif + mutex_init(&sfd.freq_mutex); sfd.freq_limit = sfd.freq_list[sfd.freq_cnt - 1]; sgxfreq_set_freq_request(sfd.freq_list[sfd.freq_cnt - 1]); @@ -329,7 +503,7 @@ int sgxfreq_init(struct device *dev) return ret; } -#if defined(CONFIG_THERMAL_FRAMEWORK) +#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK)) cool_init(); #endif @@ -355,7 +529,7 @@ int sgxfreq_deinit(void) sgxfreq_set_freq_request(sfd.freq_list[0]); -#if defined(CONFIG_THERMAL_FRAMEWORK) +#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK)) cool_deinit(); #endif diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq.h b/drivers/gpu/pvr/services4/system/omap/sgxfreq.h index ff6fc88d4a6..ff6fc88d4a6 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq.h +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq.h diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_activeidle.c b/drivers/gpu/pvr/services4/system/omap/sgxfreq_activeidle.c index 45159d7269b..45159d7269b 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_activeidle.c +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq_activeidle.c diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_cool.c b/drivers/gpu/pvr/services4/system/omap/sgxfreq_cool.c index 9233defd352..a58eb390a53 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_cool.c +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq_cool.c @@ -14,6 +14,92 @@ * this program. If not, see <http://www.gnu.org/licenses/>. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) + +#include <linux/thermal.h> + +static struct cool_data { + int freq_cnt; + unsigned long *freq_list; + unsigned long state; + struct thermal_cooling_device *cdev; +} cd; + +static int sgxfreq_get_max_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + *state = cd.freq_cnt - 1; + return 0; +} + +static int sgxfreq_get_cur_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + *state = cd.state; + return 0; +} + +static int sgxfreq_set_cur_state(struct thermal_cooling_device *cdev, + unsigned long state) +{ + int freq_max_index, freq_limit_index; + + freq_max_index = cd.freq_cnt - 1; + + freq_limit_index = freq_max_index - (unsigned int)state; + + if (freq_limit_index < 0) + freq_limit_index = 0; + + sgxfreq_set_freq_limit(cd.freq_list[freq_limit_index]); + + cd.state = state; + return 0; +} + + +static const struct thermal_cooling_device_ops sgxfreq_cooling_ops = { + .get_max_state = sgxfreq_get_max_state, + .get_cur_state = sgxfreq_get_cur_state, + .set_cur_state = sgxfreq_set_cur_state, +}; + +int cool_init(void) +{ + int ret; + struct thermal_zone_device *tz; + + cd.freq_cnt = sgxfreq_get_freq_list(&cd.freq_list); + if (!cd.freq_cnt || !cd.freq_list) + return -EINVAL; + + cd.cdev = thermal_cooling_device_register("gpu", (void *)NULL, &sgxfreq_cooling_ops); + + if(IS_ERR(cd.cdev)) { + pr_err("sgxfreq: Error while regeistering cooling device: %ld\n", PTR_ERR(cd.cdev)); + return -1; + } + + tz = thermal_zone_get_zone_by_name("gpu"); + if(IS_ERR(tz)) { + pr_err("sgxfreq: Error while trying to obtain zone device: %ld\n", PTR_ERR(tz)); + return -1; + } + + ret = thermal_zone_bind_cooling_device(tz, 0, cd.cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); + if (ret) + { + pr_err("sgxfreq: Error binding cooling device: %d\n", ret); + } + + return 0; +} + +void cool_deinit(void) +{ + thermal_cooling_device_unregister(cd.cdev); +} +#else //if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) #include <linux/thermal_framework.h> static int cool_device(struct thermal_dev *dev, int cooling_level); @@ -102,3 +188,4 @@ static int cool_device(struct thermal_dev *dev, int cooling_level) return 0; } +#endif //if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_on3demand.c b/drivers/gpu/pvr/services4/system/omap/sgxfreq_on3demand.c index c4e4bd911f8..70764b12b23 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_on3demand.c +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq_on3demand.c @@ -22,17 +22,13 @@ static int on3demand_start(struct sgxfreq_sgx_data *data); static void on3demand_stop(void); static void on3demand_predict(void); -static void on3demand_frame_done(void); -static void on3demand_active(void); -static void on3demand_timeout(struct work_struct *work); static struct sgxfreq_governor on3demand_gov = { .name = "on3demand", .gov_start = on3demand_start, .gov_stop = on3demand_stop, - .sgx_frame_done = on3demand_frame_done, - .sgx_active = on3demand_active, + .sgx_frame_done = on3demand_predict }; static struct on3demand_data { @@ -43,19 +39,12 @@ static struct on3demand_data { unsigned long prev_total_idle; unsigned long prev_total_active; unsigned int low_load_cnt; - unsigned int poll_interval; - unsigned long delta_active; - unsigned long delta_idle; - bool polling_enabled; - struct delayed_work work; struct mutex mutex; } odd; #define ON3DEMAND_DEFAULT_UP_THRESHOLD 80 #define ON3DEMAND_DEFAULT_DOWN_THRESHOLD 30 #define ON3DEMAND_DEFAULT_HISTORY_SIZE_THRESHOLD 5 -/* For Live wallpaper frame done at interval of ~64ms */ -#define ON3DEMAND_DEFAULT_POLL_INTERVAL 75 /*FIXME: This should be dynamic and queried from platform */ #define ON3DEMAND_FRAME_DONE_DEADLINE_MS 16 @@ -213,10 +202,6 @@ static int on3demand_start(struct sgxfreq_sgx_data *data) odd.prev_total_active = 0; odd.prev_total_idle = 0; odd.low_load_cnt = 0; - odd.poll_interval = ON3DEMAND_DEFAULT_POLL_INTERVAL; - odd.polling_enabled = false; - - INIT_DELAYED_WORK(&odd.work, on3demand_timeout); ret = sysfs_create_group(sgxfreq_kobj, &on3demand_attr_group); if (ret) @@ -227,14 +212,14 @@ static int on3demand_start(struct sgxfreq_sgx_data *data) static void on3demand_stop(void) { - cancel_delayed_work_sync(&odd.work); sysfs_remove_group(sgxfreq_kobj, &on3demand_attr_group); } static void on3demand_predict(void) { static unsigned short first_sample = 1; - unsigned long total_active, total_idle; + unsigned long total_active, delta_active; + unsigned long total_idle, delta_idle; unsigned long freq; if (first_sample == 1) { @@ -249,21 +234,20 @@ static void on3demand_predict(void) total_idle = sgxfreq_get_total_idle_time(); /* Compute load */ - odd.delta_active = __delta32(total_active, odd.prev_total_active); - odd.delta_idle = __delta32(total_idle, odd.prev_total_idle); + delta_active = __delta32(total_active, odd.prev_total_active); + delta_idle = __delta32(total_idle, odd.prev_total_idle); /* * If SGX was active for longer than frame display time (1/fps), * scale to highest possible frequency. */ - if (odd.delta_active > ON3DEMAND_FRAME_DONE_DEADLINE_MS) { + if (delta_active > ON3DEMAND_FRAME_DONE_DEADLINE_MS) { odd.low_load_cnt = 0; sgxfreq_set_freq_request(sgxfreq_get_freq_max()); } - if ((odd.delta_active + odd.delta_idle)) - odd.load = (100 * odd.delta_active / (odd.delta_active + odd.delta_idle)); - + if ((delta_active + delta_idle)) + odd.load = (100 * delta_active / (delta_active + delta_idle)); odd.prev_total_active = total_active; odd.prev_total_idle = total_idle; @@ -284,41 +268,3 @@ static void on3demand_predict(void) odd.low_load_cnt = 0; } } - - -static void on3demand_active(void) -{ - if (!odd.polling_enabled) { - sgxfreq_set_freq_request(sgxfreq_get_freq_max()); - odd.low_load_cnt = 0; - odd.polling_enabled = true; - schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000); - } - -} - -static void on3demand_frame_done(void) -{ - if (odd.polling_enabled) { - cancel_delayed_work_sync(&odd.work); - schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000); - } - on3demand_predict(); -} - -static void on3demand_timeout(struct work_struct *work) -{ - /* - * If sgx was idle all throughout timer disable polling and - * enable it on next sgx active event - */ - if (!odd.delta_active) { - sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - odd.low_load_cnt = 0; - odd.polling_enabled = false; - } else { - on3demand_predict(); - odd.polling_enabled = true; - schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000); - } -} diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_onoff.c b/drivers/gpu/pvr/services4/system/omap/sgxfreq_onoff.c index 39dd3fc5c42..39dd3fc5c42 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_onoff.c +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq_onoff.c diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_userspace.c b/drivers/gpu/pvr/services4/system/omap/sgxfreq_userspace.c index 5ff0dd07d8a..aff6087411f 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_userspace.c +++ b/drivers/gpu/pvr/services4/system/omap/sgxfreq_userspace.c @@ -20,26 +20,17 @@ static int userspace_start(struct sgxfreq_sgx_data *data); static void userspace_stop(void); -static void userspace_sgx_clk_on(void); -static void userspace_sgx_clk_off(void); -static void userspace_sgx_active(void); -static void userspace_sgx_idle(void); static struct sgxfreq_governor userspace_gov = { .name = "userspace", .gov_start = userspace_start, .gov_stop = userspace_stop, - .sgx_clk_on = userspace_sgx_clk_on, - .sgx_clk_off = userspace_sgx_clk_off, - .sgx_active = userspace_sgx_active, - .sgx_idle = userspace_sgx_idle, }; static struct userspace_data { - unsigned long freq_user; /* in KHz */ - struct mutex mutex; + unsigned long freq_user; /* in Hz */ } usd; @@ -65,15 +56,11 @@ static ssize_t store_frequency_set(struct device *dev, if (ret != 1) return -EINVAL; - mutex_lock(&odd.mutex); - if (freq > sgxfreq_get_freq_max()) freq = sgxfreq_get_freq_max(); usd.freq_user = sgxfreq_set_freq_request(freq); trace_printk("USERSPACE: new freq=%luHz.\n", usd.freq_user); - mutex_unlock(&odd.mutex); - return count; } @@ -100,8 +87,6 @@ int userspace_init(void) { int ret; - mutex_init(&odd.mutex); - ret = sgxfreq_register_governor(&userspace_gov); if (ret) return ret; @@ -133,48 +118,7 @@ static int userspace_start(struct sgxfreq_sgx_data *data) static void userspace_stop(void) { - usd.freq_user = sgxfreq_set_freq_request(sgxfreq_get_freq_min()); sysfs_remove_group(sgxfreq_kobj, &userspace_attr_group); trace_printk("USERSPACE: stopped.\n"); } - - -static void userspace_sgx_clk_on(void) -{ - mutex_lock(&ood.mutex); - - sgxfreq_set_freq_request(usd.freq_user); - - mutex_unlock(&ood.mutex); -} - - -static void userspace_sgx_clk_off(void) -{ - mutex_lock(&ood.mutex); - - sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - - mutex_unlock(&ood.mutex); -} - - -static void userspace_sgx_active(void) -{ - mutex_lock(&aid.mutex); - - sgxfreq_set_freq_request(usd.freq_user); - - mutex_unlock(&aid.mutex); -} - - -static void userspace_sgx_idle(void) -{ - mutex_lock(&aid.mutex); - - sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - - mutex_unlock(&aid.mutex); -} diff --git a/drivers/gpu/pvr/services4/system/omap3630/sysconfig.c b/drivers/gpu/pvr/services4/system/omap/sysconfig.c index 625da765d7c..36384bc1b67 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sysconfig.c +++ b/drivers/gpu/pvr/services4/system/omap/sysconfig.c @@ -50,8 +50,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "ocpdefs.h" -#define OMAP5430_CORE_REV 0x10005 - /* top level system data anchor point*/ SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL; SYS_DATA gsSysData; @@ -165,7 +163,7 @@ static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) */ /* Registers */ - gsSGXDeviceMap.ui32RegsSize = SYS_OMAP3630_SGX_REGS_SIZE; + gsSGXDeviceMap.ui32RegsSize = SYS_OMAP_SGX_REGS_SIZE; eError = OSBaseAllocContigMemory(gsSGXDeviceMap.ui32RegsSize, &gsSGXRegsCPUVAddr, @@ -218,24 +216,21 @@ static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) PVR_TRACE(("SGX register base: 0x%lx", (unsigned long)gsSGXDeviceMap.sRegsCpuPBase.uiAddr)); #if defined(SGX544) && defined(SGX_FEATURE_MP) - /* Workaround: Due to the change in the HWMOD, the driver is only detecting the - size of the first memory section. For the moment, set the size with a macro - until a better solution found */ - gsSGXDeviceMap.ui32RegsSize = SYS_OMAP3630_SGX_REGS_SIZE; + /* FIXME: Workaround due to HWMOD change. Otherwise this region is too small. */ + gsSGXDeviceMap.ui32RegsSize = SYS_OMAP_SGX_REGS_SIZE; #else gsSGXDeviceMap.ui32RegsSize = (unsigned int)(dev_res->end - dev_res->start); #endif - PVR_TRACE(("SGX register size: %d",gsSGXDeviceMap.ui32RegsSize)); gsSGXDeviceMap.ui32IRQ = dev_irq; PVR_TRACE(("SGX IRQ: %d", gsSGXDeviceMap.ui32IRQ)); #else /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */ - gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_OMAP3630_SGX_REGS_SYS_PHYS_BASE; + gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_OMAP_SGX_REGS_SYS_PHYS_BASE; gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase); - gsSGXDeviceMap.ui32RegsSize = SYS_OMAP3630_SGX_REGS_SIZE; + gsSGXDeviceMap.ui32RegsSize = SYS_OMAP_SGX_REGS_SIZE; - gsSGXDeviceMap.ui32IRQ = SYS_OMAP3630_SGX_IRQ; + gsSGXDeviceMap.ui32IRQ = SYS_OMAP_SGX_IRQ; #endif /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */ #if defined(SGX_OCP_REGS_ENABLED) @@ -284,51 +279,19 @@ static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) static IMG_CHAR *SysCreateVersionString(void) { static IMG_CHAR aszVersionString[100]; + IMG_UINT32 ui32MaxStrLen; SYS_DATA *psSysData; IMG_UINT32 ui32SGXRevision; IMG_INT32 i32Count; -#if !defined(NO_HARDWARE) - IMG_VOID *pvRegsLinAddr; - - pvRegsLinAddr = OSMapPhysToLin(gsSGXDeviceMap.sRegsCpuPBase, - gsSGXDeviceMap.ui32RegsSize, - PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY, - IMG_NULL); - if(!pvRegsLinAddr) - { - return IMG_NULL; - } - -#if defined(SGX544) && defined(SGX_FEATURE_MP) - ui32SGXRevision = OMAP5430_CORE_REV; -#else - ui32SGXRevision = OSReadHWReg((IMG_PVOID)((IMG_PBYTE)pvRegsLinAddr), - EUR_CR_CORE_REVISION); -#endif - -#else - ui32SGXRevision = 0; -#endif SysAcquireData(&psSysData); - i32Count = OSSNPrintf(aszVersionString, 100, - "SGX revision = %u.%u.%u", - (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MAJOR_MASK) - >> EUR_CR_CORE_REVISION_MAJOR_SHIFT), - (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MINOR_MASK) - >> EUR_CR_CORE_REVISION_MINOR_SHIFT), - (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MAINTENANCE_MASK) - >> EUR_CR_CORE_REVISION_MAINTENANCE_SHIFT) - ); - -#if !defined(NO_HARDWARE) - OSUnMapPhysToLin(pvRegsLinAddr, - SYS_OMAP3630_SGX_REGS_SIZE, - PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY, - IMG_NULL); -#endif + ui32SGXRevision = SGX_CORE_REV; + ui32MaxStrLen = 99; + i32Count = OSSNPrintf(aszVersionString, ui32MaxStrLen + 1, + "SGX revision = %u", + (IMG_UINT)(ui32SGXRevision)); if(i32Count == -1) { return IMG_NULL; @@ -432,7 +395,7 @@ PVRSRV_ERROR SysInitialise(IMG_VOID) } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV); - eError = SysPMRuntimeRegister(gpsSysSpecificData); + eError = SysPMRuntimeRegister(); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register with OSPM!")); @@ -551,7 +514,7 @@ PVRSRV_ERROR SysInitialise(IMG_VOID) #if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA) TimerRegPhysBase = gsSysSpecificData.sTimerRegPhysBase; #else - TimerRegPhysBase.uiAddr = SYS_OMAP3630_GP11TIMER_REGS_SYS_PHYS_BASE; + TimerRegPhysBase.uiAddr = SYS_OMAP_GP11TIMER_REGS_SYS_PHYS_BASE; #endif gpsSysData->pvSOCTimerRegisterKM = IMG_NULL; gpsSysData->hSOCTimerRegisterOSMemHandle = 0; @@ -618,7 +581,7 @@ PVRSRV_ERROR SysFinalise(IMG_VOID) SysEnableSGXInterrupts(gpsSysData); #endif #endif /* defined(SYS_USING_INTERRUPTS) */ -#if defined(__linux__) +#if defined(__linux__) || defined(__QNXNTO__) /* Create a human readable version string for this system */ gpsSysData->pszVersionString = SysCreateVersionString(); if (!gpsSysData->pszVersionString) @@ -711,7 +674,7 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ /* Deinitialise SGX */ - eError = PVRSRVDeinitialiseDevice (gui32SGXDeviceID); + eError = PVRSRVDeinitialiseDevice(gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init the device")); @@ -719,6 +682,12 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) } } + /* Disable system clocks. Must happen after last access to hardware */ + if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS)) + { + DisableSystemClocks(gpsSysData); + } + if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_DVFS_INIT)) { eError = SysDvfsDeinitialize(gpsSysSpecificData); @@ -732,7 +701,7 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME)) { - eError = SysPMRuntimeUnregister(gpsSysSpecificData); + eError = SysPMRuntimeUnregister(); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: Failed to unregister with OSPM!")); @@ -741,14 +710,6 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) } } - /* - Disable system clocks - must happen after last access to hardware. - */ - if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS)) - { - DisableSystemClocks(gpsSysData); - } - if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA)) { eError = OSDeInitEnvData(gpsSysData->pvEnvSpecificData); @@ -766,7 +727,7 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) { #if defined(NO_HARDWARE) /* Free hardware resources. */ - OSBaseFreeContigMemory(SYS_OMAP3630_SGX_REGS_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase); + OSBaseFreeContigMemory(SYS_OMAP_SGX_REGS_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase); #else #if defined(SGX_OCP_REGS_ENABLED) OSUnMapPhysToLin(gsSGXRegsCPUVAddr, @@ -1277,20 +1238,6 @@ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, return eError; } -IMG_VOID SysLockSystemSuspend(IMG_VOID) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock(&gpsSysSpecificData->wake_lock); -#endif -} - -IMG_VOID SysUnlockSystemSuspend(IMG_VOID) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_unlock(&gpsSysSpecificData->wake_lock); -#endif -} - /***************************************************************************** @Function SysOEMFunction @@ -1314,6 +1261,7 @@ PVRSRV_ERROR SysOEMFunction ( IMG_UINT32 ui32ID, PVR_UNREFERENCED_PARAMETER(pvOut); PVR_UNREFERENCED_PARAMETER(ulOutSize); +#if !defined(__QNXNTO__) if ((ui32ID == OEM_GET_EXT_FUNCS) && (ulOutSize == sizeof(PVRSRV_DC_OEM_JTABLE))) { @@ -1321,6 +1269,7 @@ PVRSRV_ERROR SysOEMFunction ( IMG_UINT32 ui32ID, psOEMJTable->pfnOEMBridgeDispatch = &PVRSRV_BridgeDispatchKM; return PVRSRV_OK; } +#endif return PVRSRV_ERROR_INVALID_PARAMS; } diff --git a/drivers/gpu/pvr/services4/system/omap4/sysconfig.h b/drivers/gpu/pvr/services4/system/omap/sysconfig.h index 64f3187d7bb..faff7dfc950 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/sysconfig.h +++ b/drivers/gpu/pvr/services4/system/omap/sysconfig.h @@ -43,14 +43,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if !defined(__SOCCONFIG_H__) #define __SOCCONFIG_H__ -#define VS_PRODUCT_NAME "OMAP4" - -#if defined(SGX540) && (SGX_CORE_REV == 120) -#define SYS_SGX_CLOCK_SPEED 307200000 +#if defined(VS_PRODUCT_VERSION) && VS_PRODUCT_VERSION == 5 +#define VS_PRODUCT_NAME "OMAP5" #else -#define SYS_SGX_CLOCK_SPEED 304742400 +#define VS_PRODUCT_NAME "OMAP4" #endif + #define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100) // 10ms (100hz) #define SYS_SGX_PDS_TIMER_FREQ (1000) // 1ms (1000hz) @@ -60,30 +59,30 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif -#define SYS_OMAP4430_SGX_REGS_SYS_PHYS_BASE 0x56000000 -#define SYS_OMAP4430_SGX_REGS_SIZE 0xFFFF +#define SYS_OMAP_SGX_REGS_SYS_PHYS_BASE 0x56000000 +#define SYS_OMAP_SGX_REGS_SIZE 0xFFFF -#define SYS_OMAP4430_SGX_IRQ 53 /* OMAP4 IRQ's are offset by 32 */ +#define SYS_OMAP_SGX_IRQ 53 /* OMAP4 IRQ's are offset by 32 */ -#define SYS_OMAP4430_DSS_REGS_SYS_PHYS_BASE 0x58000000 -#define SYS_OMAP4430_DSS_REGS_SIZE 0x7000 +#define SYS_OMAP_DSS_REGS_SYS_PHYS_BASE 0x58000000 +#define SYS_OMAP_DSS_REGS_SIZE 0x7000 -#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_STATUS_REG 0x6028 -#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_ENABLE_REG 0x602c +#define SYS_OMAP_DSS_HDMI_INTERRUPT_STATUS_REG 0x6028 +#define SYS_OMAP_DSS_HDMI_INTERRUPT_ENABLE_REG 0x602c -#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_VSYNC_ENABLE_MASK 0x10000 -#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_VSYNC_STATUS_MASK 0x10000 +#define SYS_OMAP_DSS_HDMI_INTERRUPT_VSYNC_ENABLE_MASK 0x10000 +#define SYS_OMAP_DSS_HDMI_INTERRUPT_VSYNC_STATUS_MASK 0x10000 -#define SYS_OMAP4430_DSS_LCD_INTERRUPT_STATUS_REG 0x1018 -#define SYS_OMAP4430_DSS_LCD_INTERRUPT_ENABLE_REG 0x101c +#define SYS_OMAP_DSS_LCD_INTERRUPT_STATUS_REG 0x1018 +#define SYS_OMAP_DSS_LCD_INTERRUPT_ENABLE_REG 0x101c -#define SYS_OMAP4430_DSS_LCD_INTERRUPT_VSYNC_ENABLE_MASK 0x40002 -#define SYS_OMAP4430_DSS_LCD_INTERRUPT_VSYNC_STATUS_MASK 0x40002 +#define SYS_OMAP_DSS_LCD_INTERRUPT_VSYNC_ENABLE_MASK 0x40002 +#define SYS_OMAP_DSS_LCD_INTERRUPT_VSYNC_STATUS_MASK 0x40002 -#define SYS_OMAP4430_GP11TIMER_ENABLE_SYS_PHYS_BASE 0x48088038 -#define SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE 0x4808803C -#define SYS_OMAP4430_GP11TIMER_TSICR_SYS_PHYS_BASE 0x48088054 +#define SYS_OMAP_GP11TIMER_ENABLE_SYS_PHYS_BASE 0x48088038 +#define SYS_OMAP_GP11TIMER_REGS_SYS_PHYS_BASE 0x4808803C +#define SYS_OMAP_GP11TIMER_TSICR_SYS_PHYS_BASE 0x48088054 /* Interrupt bits */ #define DEVICE_SGX_INTERRUPT (1<<0) diff --git a/drivers/gpu/pvr/services4/system/omap3630/sysinfo.h b/drivers/gpu/pvr/services4/system/omap/sysinfo.h index 70ae1481b70..84febaba803 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sysinfo.h +++ b/drivers/gpu/pvr/services4/system/omap/sysinfo.h @@ -43,6 +43,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if !defined(__SYSINFO_H__) #define __SYSINFO_H__ +#if defined(SGX540) && (SGX_CORE_REV == 120) +#define SYS_SGX_CLOCK_SPEED 307200000 +#else +#define SYS_SGX_CLOCK_SPEED 304742400 +#endif + /*!< System specific poll/timeout details */ #if defined(PVR_LINUX_USING_WORKQUEUES) /* diff --git a/drivers/gpu/pvr/services4/system/omap3630/syslocal.h b/drivers/gpu/pvr/services4/system/omap/syslocal.h index 91aef99ef64..ba312d66b2f 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/syslocal.h +++ b/drivers/gpu/pvr/services4/system/omap/syslocal.h @@ -84,7 +84,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) #include <plat/gpu.h> #endif #if !defined(PVR_NO_OMAP_TIMER) @@ -93,7 +93,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #endif -#if defined(CONFIG_HAS_WAKELOCK) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) #include <linux/wakelock.h> #endif @@ -109,9 +109,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(__linux__) #if defined(SGX_OCP_REGS_ENABLED) +/* FIXME: Temporary workaround for OMAP4470 and active power off in 4430 */ +#if !defined(SGX544) && defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) #define SGX_OCP_NO_INT_BYPASS #endif #endif +#endif #if defined (__cplusplus) extern "C" { @@ -213,12 +216,11 @@ IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData); #if defined(__linux__) -PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData); -PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData); +PVRSRV_ERROR SysPMRuntimeRegister(void); +PVRSRV_ERROR SysPMRuntimeUnregister(void); PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData); PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData); -int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); #else /* defined(__linux__) */ @@ -241,21 +243,21 @@ static INLINE PVRSRV_ERROR SysPMRuntimeUnregister(void) #ifdef INLINE_IS_PRAGMA #pragma inline(SysDvfsInitialize) #endif -static INLINE PVRSRV_ERROR SysDvfsInitialize(void) +static INLINE PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData) { + PVR_UNREFERENCED_PARAMETER(psSysSpecificData); return PVRSRV_OK; } #ifdef INLINE_IS_PRAGMA #pragma inline(SysDvfsDeinitialize) #endif -static INLINE PVRSRV_ERROR SysDvfsDeinitialize(void) +static INLINE PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData) { + PVR_UNREFERENCED_PARAMETER(psSysSpecificData); return PVRSRV_OK; } -#define pvr_access_process_vm(tsk, addr, buf, len, write) -1 - #endif /* defined(__linux__) */ #if defined(__cplusplus) diff --git a/drivers/gpu/pvr/services4/system/omap3630/sysutils.c b/drivers/gpu/pvr/services4/system/omap/sysutils.c index 20baad2a7d5..b1ea0558df9 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sysutils.c +++ b/drivers/gpu/pvr/services4/system/omap/sysutils.c @@ -44,16 +44,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(__linux__) #include "sysutils_linux.c" -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) #include "sgxfreq.c" #include "sgxfreq_onoff.c" #include "sgxfreq_activeidle.c" #include "sgxfreq_on3demand.c" #include "sgxfreq_userspace.c" -#if defined(CONFIG_THERMAL_FRAMEWORK) +#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK)) #include "sgxfreq_cool.c" #endif #endif #endif + +#if defined(__QNXNTO__) +#include "sysutils_nto.c" +#endif diff --git a/drivers/gpu/pvr/services4/system/omap4/sysutils_linux.c b/drivers/gpu/pvr/services4/system/omap/sysutils_linux.c index 1bef2ee8e0b..ad026738aac 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/sysutils_linux.c +++ b/drivers/gpu/pvr/services4/system/omap/sysutils_linux.c @@ -57,7 +57,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/platform_device.h> #include <linux/pm_runtime.h> -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) #include "sgxfreq.h" #endif @@ -70,10 +70,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pvr_drm.h" #endif -#if defined(CONFIG_OMAP4_DPLL_CASCADING) -#include <mach/omap4-common.h> -#endif - #define ONE_MHZ 1000000 #define HZ_TO_MHZ(m) ((m) / ONE_MHZ) @@ -160,7 +156,7 @@ IMG_VOID SysGetSGXTimingInformation(SGX_TIMING_INFORMATION *psTimingInfo) #if !defined(NO_HARDWARE) PVR_ASSERT(atomic_read(&gpsSysSpecificData->sSGXClocksEnabled) != 0); #endif -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) /* * The core SGX driver and ukernel code expects SGX frequency * changes to occur only just prior to SGX initialization. We @@ -170,7 +166,7 @@ IMG_VOID SysGetSGXTimingInformation(SGX_TIMING_INFORMATION *psTimingInfo) * parameters such as APM and HWR timeouts. */ psTimingInfo->ui32CoreClockSpeed = (IMG_UINT32)sgxfreq_get_freq_max(); -#else /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#else /* defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) */ psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; #endif psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; @@ -208,29 +204,20 @@ PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData) #if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) { - int res; - -#if defined(CONFIG_OMAP4_DPLL_CASCADING) - if (omap4_dpll_cascading_blocker_hold(&gpsPVRLDMDev->dev)) - { - PVR_DPF((PVR_DBG_WARNING, "EnableSGXClocks: " - "omap4_dpll_cascading_blocker_hold failed")); - } -#endif /* * pm_runtime_get_sync returns 1 after the module has * been reloaded. */ - res = pm_runtime_get_sync(&gpsPVRLDMDev->dev); + int res = pm_runtime_get_sync(&gpsPVRLDMDev->dev); if (res < 0) { PVR_DPF((PVR_DBG_ERROR, "EnableSGXClocks: pm_runtime_get_sync failed (%d)", -res)); return PVRSRV_ERROR_UNABLE_TO_ENABLE_CLOCK; } } -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) sgxfreq_notif_sgx_clk_on(); -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#endif /* defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) */ #endif /* defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) */ SysEnableSGXInterrupts(psSysData); @@ -277,17 +264,10 @@ IMG_VOID DisableSGXClocks(SYS_DATA *psSysData) { PVR_DPF((PVR_DBG_ERROR, "DisableSGXClocks: pm_runtime_put_sync failed (%d)", -res)); } -#if defined(CONFIG_OMAP4_DPLL_CASCADING) - if (omap4_dpll_cascading_blocker_release(&gpsPVRLDMDev->dev)) - { - PVR_DPF((PVR_DBG_WARNING, "DisableSGXClocks: " - "omap4_dpll_cascading_blocker_release failed")); - } -#endif } -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) sgxfreq_notif_sgx_clk_off(); -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#endif /* defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) */ #endif /* defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) */ /* Indicate that the SGX clocks are disabled */ @@ -316,6 +296,14 @@ static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) PVR_ASSERT(psSysSpecData->psGPTimer == NULL); /* + * This code has problems on module reload for OMAP5 running Linux + * 3.4.10, due to omap2_dm_timer_set_src (called by + * omap_dm_timer_request_specific), being unable to set the parent + * clock to OMAP_TIMER_SRC_32_KHZ. + * Not calling omap_dm_timer_set_source doesn't help. + */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) || !defined(MODULE) + /* * This code could try requesting registers 9, 10, and 11, * stopping at the first succesful request. We'll stick with * 11 for now, as it avoids having to hard code yet more @@ -329,7 +317,6 @@ static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) return PVRSRV_ERROR_CLOCK_REQUEST_FAILED; } - /* Set timer source to system clock */ omap_dm_timer_set_source(psSysSpecData->psGPTimer, OMAP_TIMER_SRC_SYS_CLK); omap_dm_timer_enable(psSysSpecData->psGPTimer); @@ -339,10 +326,13 @@ static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) omap_dm_timer_start(psSysSpecData->psGPTimer); /* - * The DM timer API doesn't have a mechansim for obtaining the + * The DM timer API doesn't have a mechanism for obtaining the * physical address of the counter register. */ - psSysSpecData->sTimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE; + psSysSpecData->sTimerRegPhysBase.uiAddr = SYS_OMAP_GP11TIMER_REGS_SYS_PHYS_BASE; +#else /* (LINUX_VERSION_CODE <= KERNEL_VERSION(3,4,0)) || !defined(MODULE) */ + (void)psSysSpecData; +#endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(3,4,0)) || !defined(MODULE) */ return PVRSRV_OK; } @@ -456,7 +446,7 @@ static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) #endif /* defined(PVR_OMAP4_TIMING_PRCM) */ /* Set the timer to non-posted mode */ - sTimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_TSICR_SYS_PHYS_BASE; + sTimerRegPhysBase.uiAddr = SYS_OMAP_GP11TIMER_TSICR_SYS_PHYS_BASE; pui32TimerEnable = OSMapPhysToLin(sTimerRegPhysBase, 4, PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, @@ -482,7 +472,7 @@ static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) hTimerEnable); /* Enable the timer */ - sTimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_ENABLE_SYS_PHYS_BASE; + sTimerRegPhysBase.uiAddr = SYS_OMAP_GP11TIMER_ENABLE_SYS_PHYS_BASE; pui32TimerEnable = OSMapPhysToLin(sTimerRegPhysBase, 4, PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, @@ -636,35 +626,29 @@ IMG_VOID DisableSystemClocks(SYS_DATA *psSysData) ReleaseGPTimer(psSysSpecData); } -PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData) +PVRSRV_ERROR SysPMRuntimeRegister(void) { #if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) pm_runtime_enable(&gpsPVRLDMDev->dev); #endif -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_init(&psSysSpecificData->wake_lock, WAKE_LOCK_SUSPEND, "pvrsrvkm"); -#endif return PVRSRV_OK; } -PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData) +PVRSRV_ERROR SysPMRuntimeUnregister(void) { #if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) pm_runtime_disable(&gpsPVRLDMDev->dev); #endif -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_destroy(&psSysSpecificData->wake_lock); -#endif return PVRSRV_OK; } PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData) { PVR_UNREFERENCED_PARAMETER(psSysSpecificData); -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) if (sgxfreq_init(&gpsPVRLDMDev->dev)) return PVRSRV_ERROR_NOT_SUPPORTED; -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#endif /* defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) */ return PVRSRV_OK; } @@ -672,10 +656,10 @@ PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData) PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData) { PVR_UNREFERENCED_PARAMETER(psSysSpecificData); -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) if (sgxfreq_deinit()) return PVRSRV_ERROR_NOT_SUPPORTED; -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#endif /* defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) */ return PVRSRV_OK; } @@ -719,25 +703,17 @@ SysDRMUnregisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin) } #endif -int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) -{ - struct gpu_platform_data *pdata; - pdata = (struct gpu_platform_data *)gpsPVRLDMDev->dev.platform_data; - if(!pdata || !pdata->access_process_vm) - return -1; - return pdata->access_process_vm(tsk, addr, buf, len, write); -} - IMG_VOID SysSGXIdleEntered(IMG_VOID) { -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) sgxfreq_notif_sgx_idle(); #endif } IMG_VOID SysSGXCommandPending(IMG_BOOL bSGXIdle) { -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) + if (bSGXIdle) sgxfreq_notif_sgx_active(); #else PVR_UNREFERENCED_PARAMETER(bSGXIdle); diff --git a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_cool.c b/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_cool.c deleted file mode 100644 index 9233defd352..00000000000 --- a/drivers/gpu/pvr/services4/system/omap3630/sgxfreq_cool.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/thermal_framework.h> - -static int cool_device(struct thermal_dev *dev, int cooling_level); - -static struct cool_data { - int freq_cnt; - unsigned long *freq_list; -} cd; - -static struct thermal_dev_ops cool_dev_ops = { - .cool_device = cool_device, -}; - -static struct thermal_dev cool_dev = { - .name = "gpu_cooling.0", - .domain_name = "gpu", - .dev_ops = &cool_dev_ops, -}; - -static struct thermal_dev case_cool_dev = { - .name = "gpu_cooling.1", - .domain_name = "case", - .dev_ops = &cool_dev_ops, -}; - -static unsigned int gpu_cooling_level; -#if defined(CONFIG_CASE_TEMP_GOVERNOR) -static unsigned int case_cooling_level; -#endif - -int cool_init(void) -{ - int ret; - cd.freq_cnt = sgxfreq_get_freq_list(&cd.freq_list); - if (!cd.freq_cnt || !cd.freq_list) - return -EINVAL; - - ret = thermal_cooling_dev_register(&cool_dev); - if (ret) - return ret; - - return thermal_cooling_dev_register(&case_cool_dev); -} - -void cool_deinit(void) -{ - thermal_cooling_dev_unregister(&cool_dev); - thermal_cooling_dev_unregister(&case_cool_dev); -} - -static int cool_device(struct thermal_dev *dev, int cooling_level) -{ - int freq_max_index, freq_limit_index; - -#if defined(CONFIG_CASE_TEMP_GOVERNOR) - if (!strcmp(dev->domain_name, "case")) - { - int tmp = 0; - tmp = cooling_level - case_subzone_number; - if (tmp < 0) - tmp = 0; - case_cooling_level = tmp; - } - else -#endif - { - gpu_cooling_level = cooling_level; - } - - freq_max_index = cd.freq_cnt - 1; -#if defined(CONFIG_CASE_TEMP_GOVERNOR) - if (case_cooling_level > gpu_cooling_level) - { - freq_limit_index = freq_max_index - case_cooling_level; - } - else -#endif - { - freq_limit_index = freq_max_index - gpu_cooling_level; - } - - if (freq_limit_index < 0) - freq_limit_index = 0; - - sgxfreq_set_freq_limit(cd.freq_list[freq_limit_index]); - - return 0; -} diff --git a/drivers/gpu/pvr/services4/system/omap3630/sysutils_linux.c b/drivers/gpu/pvr/services4/system/omap3630/sysutils_linux.c deleted file mode 100644 index 14719223388..00000000000 --- a/drivers/gpu/pvr/services4/system/omap3630/sysutils_linux.c +++ /dev/null @@ -1,747 +0,0 @@ -/*************************************************************************/ /*! -@Title System dependent utilities -@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved -@Description Provides system-specific functions -@License Dual MIT/GPLv2 - -The contents of this file are subject to the MIT license as set out below. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -Alternatively, the contents of this file may be used under the terms of -the GNU General Public License Version 2 ("GPL") in which case the provisions -of GPL are applicable instead of those above. - -If you wish to allow use of your version of this file only under the terms of -GPL, and not to allow others to use your version of this file under the terms -of the MIT license, indicate your decision by deleting the provisions above -and replace them with the notice and other provisions required by GPL as set -out in the file called "GPL-COPYING" included in this distribution. If you do -not delete the provisions above, a recipient may use your version of this file -under the terms of either the MIT license or GPL. - -This License is also included in this distribution in the file called -"MIT-COPYING". - -EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS -PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ /**************************************************************************/ -#include <linux/version.h> -#include <linux/clk.h> -#include <linux/err.h> -#include <linux/hardirq.h> -#include <linux/mutex.h> -#include <linux/slab.h> - -#include "sgxdefs.h" -#include "services_headers.h" -#include "sysinfo.h" -#include "sgxapi_km.h" -#include "sysconfig.h" -#include "sgxinfokm.h" -#include "syslocal.h" - -#include <linux/platform_device.h> -#include <linux/pm_runtime.h> - -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) -#include "sgxfreq.h" -#endif - -#if defined(SUPPORT_DRI_DRM_PLUGIN) -#include <drm/drmP.h> -#include <drm/drm.h> - -#include <linux/omap_gpu.h> - -#include "pvr_drm.h" -#endif - -#if defined(CONFIG_OMAP4_DPLL_CASCADING) -#include <mach/omap4-common.h> -#endif - -#define ONE_MHZ 1000000 -#define HZ_TO_MHZ(m) ((m) / ONE_MHZ) - -#if defined(SUPPORT_OMAP3430_SGXFCLK_96M) -#define SGX_PARENT_CLOCK "cm_96m_fck" -#else -#define SGX_PARENT_CLOCK "core_ck" -#endif - -#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) -extern struct platform_device *gpsPVRLDMDev; -#endif - -static PVRSRV_ERROR PowerLockWrap(SYS_SPECIFIC_DATA *psSysSpecData, IMG_BOOL bTryLock) -{ - if (!in_interrupt()) - { - if (bTryLock) - { - int locked = mutex_trylock(&psSysSpecData->sPowerLock); - if (locked == 0) - { - return PVRSRV_ERROR_RETRY; - } - } - else - { - mutex_lock(&psSysSpecData->sPowerLock); - } - } - - return PVRSRV_OK; -} - -static IMG_VOID PowerLockUnwrap(SYS_SPECIFIC_DATA *psSysSpecData) -{ - if (!in_interrupt()) - { - mutex_unlock(&psSysSpecData->sPowerLock); - } -} - -PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock) -{ - SYS_DATA *psSysData; - - SysAcquireData(&psSysData); - - return PowerLockWrap(psSysData->pvSysSpecificData, bTryLock); -} - -IMG_VOID SysPowerLockUnwrap(IMG_VOID) -{ - SYS_DATA *psSysData; - - SysAcquireData(&psSysData); - - PowerLockUnwrap(psSysData->pvSysSpecificData); -} - -/* - * This function should be called to unwrap the Services power lock, prior - * to calling any function that might sleep. - * This function shouldn't be called prior to calling EnableSystemClocks - * or DisableSystemClocks, as those functions perform their own power lock - * unwrapping. - * If the function returns IMG_TRUE, UnwrapSystemPowerChange must be - * called to rewrap the power lock, prior to returning to Services. - */ -IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData) -{ - return IMG_TRUE; -} - -IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData) -{ -} - -/* - * Return SGX timining information to caller. - */ -IMG_VOID SysGetSGXTimingInformation(SGX_TIMING_INFORMATION *psTimingInfo) -{ -#if !defined(NO_HARDWARE) - PVR_ASSERT(atomic_read(&gpsSysSpecificData->sSGXClocksEnabled) != 0); -#endif -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - /* - * The core SGX driver and ukernel code expects SGX frequency - * changes to occur only just prior to SGX initialization. We - * don't wish to constrain the DVFS implementation as such. So - * we let these components believe that frequency setting is - * always at maximum. This produces safe values for derived - * parameters such as APM and HWR timeouts. - */ - psTimingInfo->ui32CoreClockSpeed = (IMG_UINT32)sgxfreq_get_freq_max(); -#else /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ - psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; -#endif - psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; - psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ; -#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) - psTimingInfo->bEnableActivePM = IMG_TRUE; -#else - psTimingInfo->bEnableActivePM = IMG_FALSE; -#endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ - psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; -} - -/*! -****************************************************************************** - - @Function EnableSGXClocks - - @Description Enable SGX clocks - - @Return PVRSRV_ERROR - -******************************************************************************/ -PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData) -{ -#if !defined(NO_HARDWARE) - SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; - - /* SGX clocks already enabled? */ - if (atomic_read(&psSysSpecData->sSGXClocksEnabled) != 0) - { - return PVRSRV_OK; - } - - PVR_DPF((PVR_DBG_MESSAGE, "EnableSGXClocks: Enabling SGX Clocks")); - -#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) - { - int res; - -#if defined(CONFIG_OMAP4_DPLL_CASCADING) - if (omap4_dpll_cascading_blocker_hold(&gpsPVRLDMDev->dev)) - { - PVR_DPF((PVR_DBG_WARNING, "EnableSGXClocks: " - "omap4_dpll_cascading_blocker_hold failed")); - } -#endif - /* - * pm_runtime_get_sync returns 1 after the module has - * been reloaded. - */ - res = pm_runtime_get_sync(&gpsPVRLDMDev->dev); - if (res < 0) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSGXClocks: pm_runtime_get_sync failed (%d)", -res)); - return PVRSRV_ERROR_UNABLE_TO_ENABLE_CLOCK; - } - } -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - sgxfreq_notif_sgx_clk_on(); -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ -#endif /* defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) */ - - SysEnableSGXInterrupts(psSysData); - - /* Indicate that the SGX clocks are enabled */ - atomic_set(&psSysSpecData->sSGXClocksEnabled, 1); - -#else /* !defined(NO_HARDWARE) */ - PVR_UNREFERENCED_PARAMETER(psSysData); -#endif /* !defined(NO_HARDWARE) */ - return PVRSRV_OK; -} - - -/*! -****************************************************************************** - - @Function DisableSGXClocks - - @Description Disable SGX clocks. - - @Return none - -******************************************************************************/ -IMG_VOID DisableSGXClocks(SYS_DATA *psSysData) -{ -#if !defined(NO_HARDWARE) - SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; - - /* SGX clocks already disabled? */ - if (atomic_read(&psSysSpecData->sSGXClocksEnabled) == 0) - { - return; - } - - PVR_DPF((PVR_DBG_MESSAGE, "DisableSGXClocks: Disabling SGX Clocks")); - - SysDisableSGXInterrupts(psSysData); - -#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) - { - int res = pm_runtime_put_sync(&gpsPVRLDMDev->dev); - if (res < 0) - { - PVR_DPF((PVR_DBG_ERROR, "DisableSGXClocks: pm_runtime_put_sync failed (%d)", -res)); - } -#if defined(CONFIG_OMAP4_DPLL_CASCADING) - if (omap4_dpll_cascading_blocker_release(&gpsPVRLDMDev->dev)) - { - PVR_DPF((PVR_DBG_WARNING, "DisableSGXClocks: " - "omap4_dpll_cascading_blocker_release failed")); - } -#endif - } -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - sgxfreq_notif_sgx_clk_off(); -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ -#endif /* defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) */ - - /* Indicate that the SGX clocks are disabled */ - atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); - -#else /* !defined(NO_HARDWARE) */ - PVR_UNREFERENCED_PARAMETER(psSysData); -#endif /* !defined(NO_HARDWARE) */ -} - -#if (defined(DEBUG) || defined(TIMING)) && !defined(PVR_NO_OMAP_TIMER) -#if defined(PVR_OMAP_USE_DM_TIMER_API) -#define GPTIMER_TO_USE 11 -/*! -****************************************************************************** - - @Function AcquireGPTimer - - @Description Acquire a GP timer - - @Return PVRSRV_ERROR - -******************************************************************************/ -static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) -{ - PVR_ASSERT(psSysSpecData->psGPTimer == NULL); - - /* - * This code could try requesting registers 9, 10, and 11, - * stopping at the first succesful request. We'll stick with - * 11 for now, as it avoids having to hard code yet more - * physical addresses into the code. - */ - psSysSpecData->psGPTimer = omap_dm_timer_request_specific(GPTIMER_TO_USE); - if (psSysSpecData->psGPTimer == NULL) - { - - PVR_DPF((PVR_DBG_WARNING, "%s: omap_dm_timer_request_specific failed", __FUNCTION__)); - return PVRSRV_ERROR_CLOCK_REQUEST_FAILED; - } - - /* Set timer source to system clock */ - omap_dm_timer_set_source(psSysSpecData->psGPTimer, OMAP_TIMER_SRC_SYS_CLK); - omap_dm_timer_enable(psSysSpecData->psGPTimer); - - /* Set autoreload, and start value of 0 */ - omap_dm_timer_set_load_start(psSysSpecData->psGPTimer, 1, 0); - - omap_dm_timer_start(psSysSpecData->psGPTimer); - - /* - * The DM timer API doesn't have a mechansim for obtaining the - * physical address of the counter register. - */ - psSysSpecData->sTimerRegPhysBase.uiAddr = SYS_OMAP3630_GP11TIMER_REGS_SYS_PHYS_BASE; - - return PVRSRV_OK; -} - -/*! -****************************************************************************** - - @Function ReleaseGPTimer - - @Description Release a GP timer - - @Return PVRSRV_ERROR - -******************************************************************************/ -static void ReleaseGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) -{ - if (psSysSpecData->psGPTimer != NULL) - { - /* Always returns 0 */ - (void) omap_dm_timer_stop(psSysSpecData->psGPTimer); - - omap_dm_timer_disable(psSysSpecData->psGPTimer); - - omap_dm_timer_free(psSysSpecData->psGPTimer); - - psSysSpecData->sTimerRegPhysBase.uiAddr = 0; - - psSysSpecData->psGPTimer = NULL; - } - -} -#else /* PVR_OMAP_USE_DM_TIMER_API */ -/*! -****************************************************************************** - - @Function AcquireGPTimer - - @Description Acquire a GP timer - - @Return PVRSRV_ERROR - -******************************************************************************/ -static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) -{ -#if defined(PVR_OMAP4_TIMING_PRCM) - struct clk *psCLK; - IMG_INT res; - struct clk *sys_ck; - IMG_INT rate; -#endif - PVRSRV_ERROR eError; - - IMG_CPU_PHYADDR sTimerRegPhysBase; - IMG_HANDLE hTimerEnable; - IMG_UINT32 *pui32TimerEnable; - - PVR_ASSERT(psSysSpecData->sTimerRegPhysBase.uiAddr == 0); - -#if defined(PVR_OMAP4_TIMING_PRCM) - /* assert our dependence on the GPTIMER11 module */ - psCLK = clk_get(NULL, "gpt11_fck"); - if (IS_ERR(psCLK)) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get GPTIMER11 functional clock")); - goto ExitError; - } - psSysSpecData->psGPT11_FCK = psCLK; - - psCLK = clk_get(NULL, "gpt11_ick"); - if (IS_ERR(psCLK)) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get GPTIMER11 interface clock")); - goto ExitError; - } - psSysSpecData->psGPT11_ICK = psCLK; - - sys_ck = clk_get(NULL, "sys_clkin_ck"); - if (IS_ERR(sys_ck)) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get System clock")); - goto ExitError; - } - - if(clk_get_parent(psSysSpecData->psGPT11_FCK) != sys_ck) - { - PVR_TRACE(("Setting GPTIMER11 parent to System Clock")); - res = clk_set_parent(psSysSpecData->psGPT11_FCK, sys_ck); - if (res < 0) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't set GPTIMER11 parent clock (%d)", res)); - goto ExitError; - } - } - - rate = clk_get_rate(psSysSpecData->psGPT11_FCK); - PVR_TRACE(("GPTIMER11 clock is %dMHz", HZ_TO_MHZ(rate))); - - res = clk_enable(psSysSpecData->psGPT11_FCK); - if (res < 0) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't enable GPTIMER11 functional clock (%d)", res)); - goto ExitError; - } - - res = clk_enable(psSysSpecData->psGPT11_ICK); - if (res < 0) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't enable GPTIMER11 interface clock (%d)", res)); - goto ExitDisableGPT11FCK; - } -#endif /* defined(PVR_OMAP4_TIMING_PRCM) */ - - /* Set the timer to non-posted mode */ - sTimerRegPhysBase.uiAddr = SYS_OMAP3630_GP11TIMER_TSICR_SYS_PHYS_BASE; - pui32TimerEnable = OSMapPhysToLin(sTimerRegPhysBase, - 4, - PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, - &hTimerEnable); - - if (pui32TimerEnable == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: OSMapPhysToLin failed")); - goto ExitDisableGPT11ICK; - } - - if(!(*pui32TimerEnable & 4)) - { - PVR_TRACE(("Setting GPTIMER11 mode to posted (currently is non-posted)")); - - /* Set posted mode */ - *pui32TimerEnable |= 4; - } - - OSUnMapPhysToLin(pui32TimerEnable, - 4, - PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, - hTimerEnable); - - /* Enable the timer */ - sTimerRegPhysBase.uiAddr = SYS_OMAP3630_GP11TIMER_ENABLE_SYS_PHYS_BASE; - pui32TimerEnable = OSMapPhysToLin(sTimerRegPhysBase, - 4, - PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, - &hTimerEnable); - - if (pui32TimerEnable == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: OSMapPhysToLin failed")); - goto ExitDisableGPT11ICK; - } - - /* Enable and set autoreload on overflow */ - *pui32TimerEnable = 3; - - OSUnMapPhysToLin(pui32TimerEnable, - 4, - PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, - hTimerEnable); - - psSysSpecData->sTimerRegPhysBase = sTimerRegPhysBase; - - eError = PVRSRV_OK; - - goto Exit; - -ExitDisableGPT11ICK: -#if defined(PVR_OMAP4_TIMING_PRCM) - clk_disable(psSysSpecData->psGPT11_ICK); -ExitDisableGPT11FCK: - clk_disable(psSysSpecData->psGPT11_FCK); -ExitError: -#endif /* defined(PVR_OMAP4_TIMING_PRCM) */ - eError = PVRSRV_ERROR_CLOCK_REQUEST_FAILED; -Exit: - return eError; -} - -/*! -****************************************************************************** - - @Function ReleaseGPTimer - - @Description Release a GP timer - - @Return PVRSRV_ERROR - -******************************************************************************/ -static void ReleaseGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) -{ - IMG_HANDLE hTimerDisable; - IMG_UINT32 *pui32TimerDisable; - - if (psSysSpecData->sTimerRegPhysBase.uiAddr == 0) - { - return; - } - - /* Disable the timer */ - pui32TimerDisable = OSMapPhysToLin(psSysSpecData->sTimerRegPhysBase, - 4, - PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, - &hTimerDisable); - - if (pui32TimerDisable == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "DisableSystemClocks: OSMapPhysToLin failed")); - } - else - { - *pui32TimerDisable = 0; - - OSUnMapPhysToLin(pui32TimerDisable, - 4, - PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, - hTimerDisable); - } - - psSysSpecData->sTimerRegPhysBase.uiAddr = 0; - -#if defined(PVR_OMAP4_TIMING_PRCM) - clk_disable(psSysSpecData->psGPT11_ICK); - - clk_disable(psSysSpecData->psGPT11_FCK); -#endif /* defined(PVR_OMAP4_TIMING_PRCM) */ -} -#endif /* PVR_OMAP_USE_DM_TIMER_API */ -#else /* (DEBUG || TIMING) && !PVR_NO_OMAP_TIMER */ -static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) -{ - PVR_UNREFERENCED_PARAMETER(psSysSpecData); - - return PVRSRV_OK; -} -static void ReleaseGPTimer(SYS_SPECIFIC_DATA *psSysSpecData) -{ - PVR_UNREFERENCED_PARAMETER(psSysSpecData); -} -#endif /* (DEBUG || TIMING) && !PVR_NO_OMAP_TIMER */ - -/*! -****************************************************************************** - - @Function EnableSystemClocks - - @Description Setup up the clocks for the graphics device to work. - - @Return PVRSRV_ERROR - -******************************************************************************/ -PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData) -{ - SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; - - PVR_TRACE(("EnableSystemClocks: Enabling System Clocks")); - - if (!psSysSpecData->bSysClocksOneTimeInit) - { - mutex_init(&psSysSpecData->sPowerLock); - - atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); - - psSysSpecData->bSysClocksOneTimeInit = IMG_TRUE; - } - - return AcquireGPTimer(psSysSpecData); -} - -/*! -****************************************************************************** - - @Function DisableSystemClocks - - @Description Disable the graphics clocks. - - @Return none - -******************************************************************************/ -IMG_VOID DisableSystemClocks(SYS_DATA *psSysData) -{ - SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; - - PVR_TRACE(("DisableSystemClocks: Disabling System Clocks")); - - /* - * Always disable the SGX clocks when the system clocks are disabled. - * This saves having to make an explicit call to DisableSGXClocks if - * active power management is enabled. - */ - DisableSGXClocks(psSysData); - - ReleaseGPTimer(psSysSpecData); -} - -PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData) -{ -#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) - pm_runtime_enable(&gpsPVRLDMDev->dev); -#endif -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_init(&psSysSpecificData->wake_lock, WAKE_LOCK_SUSPEND, "pvrsrvkm"); -#endif - return PVRSRV_OK; -} - -PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData) -{ -#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) - pm_runtime_disable(&gpsPVRLDMDev->dev); -#endif -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_destroy(&psSysSpecificData->wake_lock); -#endif - return PVRSRV_OK; -} - -PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData) -{ - PVR_UNREFERENCED_PARAMETER(psSysSpecificData); -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - if (sgxfreq_init(&gpsPVRLDMDev->dev)) - return PVRSRV_ERROR_NOT_SUPPORTED; -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ - - return PVRSRV_OK; -} - -PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData) -{ - PVR_UNREFERENCED_PARAMETER(psSysSpecificData); -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - if (sgxfreq_deinit()) - return PVRSRV_ERROR_NOT_SUPPORTED; -#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ - - return PVRSRV_OK; -} - -#if defined(SUPPORT_DRI_DRM_PLUGIN) -static struct omap_gpu_plugin sOMAPGPUPlugin; - -#define SYS_DRM_SET_PLUGIN_FIELD(d, s, f) (d)->f = (s)->f -int -SysDRMRegisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin) -{ - int iRes; - - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, name); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, open); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, load); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, unload); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, release); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, mmap); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, ioctls); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, num_ioctls); - SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, ioctl_start); - - iRes = omap_gpu_register_plugin(&sOMAPGPUPlugin); - if (iRes != 0) - { - PVR_DPF((PVR_DBG_ERROR, "%s: omap_gpu_register_plugin failed (%d)", __FUNCTION__, iRes)); - } - - return iRes; -} - -void -SysDRMUnregisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin) -{ - int iRes = omap_gpu_unregister_plugin(&sOMAPGPUPlugin); - if (iRes != 0) - { - PVR_DPF((PVR_DBG_ERROR, "%s: omap_gpu_unregister_plugin failed (%d)", __FUNCTION__, iRes)); - } -} -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) -int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) -{ - struct gpu_platform_data *pdata; - pdata = (struct gpu_platform_data *)gpsPVRLDMDev->dev.platform_data; - if(!pdata || !pdata->access_process_vm) - return -1; - return pdata->access_process_vm(tsk, addr, buf, len, write); -} -#endif - -IMG_VOID SysSGXIdleEntered(IMG_VOID) -{ -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - sgxfreq_notif_sgx_idle(); -#endif -} - -IMG_VOID SysSGXCommandPending(IMG_BOOL bSGXIdle) -{ -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) - sgxfreq_notif_sgx_active(); -#else - PVR_UNREFERENCED_PARAMETER(bSGXIdle); -#endif -} diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq.c b/drivers/gpu/pvr/services4/system/omap4/sgxfreq.c deleted file mode 100644 index 7e8e8fd6a07..00000000000 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/opp.h> -#include <plat/gpu.h> -#include "sgxfreq.h" - -static struct sgxfreq_data { - int freq_cnt; - unsigned long *freq_list; - unsigned long freq; - unsigned long freq_request; - unsigned long freq_limit; - unsigned long total_idle_time; - unsigned long total_active_time; - struct mutex freq_mutex; - struct list_head gov_list; - struct sgxfreq_governor *gov; - struct mutex gov_mutex; - struct sgxfreq_sgx_data sgx_data; - struct device *dev; - struct gpu_platform_data *pdata; -} sfd; - -/* Governor init/deinit functions */ -int onoff_init(void); -int onoff_deinit(void); -int activeidle_init(void); -int activeidle_deinit(void); -int on3demand_init(void); -int on3demand_deinit(void); -int userspace_init(void); -int userspace_deinit(void); - - -typedef int sgxfreq_gov_init_t(void); -sgxfreq_gov_init_t *sgxfreq_gov_init[] = { - onoff_init, - activeidle_init, - on3demand_init, - userspace_init, - NULL, -}; - -typedef int sgxfreq_gov_deinit_t(void); -sgxfreq_gov_deinit_t *sgxfreq_gov_deinit[] = { - onoff_deinit, - activeidle_deinit, - on3demand_deinit, - userspace_deinit, - NULL, -}; - -#define SGXFREQ_DEFAULT_GOV_NAME "on3demand" -static unsigned long _idle_curr_time; -static unsigned long _idle_prev_time; -static unsigned long _active_curr_time; -static unsigned long _active_prev_time; - -#if defined(CONFIG_THERMAL_FRAMEWORK) -int cool_init(void); -void cool_deinit(void); -#endif - -/*********************** begin sysfs interface ***********************/ - -struct kobject *sgxfreq_kobj; - -static ssize_t show_frequency_list(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int i; - ssize_t count = 0; - - for (i = 0; i < sfd.freq_cnt; i++) - count += sprintf(&buf[count], "%lu ", sfd.freq_list[i]); - count += sprintf(&buf[count], "\n"); - - return count; -} - -static ssize_t show_frequency_request(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", sfd.freq_request); -} - -static ssize_t show_frequency_limit(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", sfd.freq_limit); -} - -static ssize_t show_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", sfd.freq); -} - -static ssize_t show_stat(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "gpu %lu %lu\n", - sfd.total_active_time, sfd.total_idle_time); -} - -static ssize_t show_governor_list(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - ssize_t i = 0; - struct sgxfreq_governor *t; - - list_for_each_entry(t, &sfd.gov_list, governor_list) { - if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) - - (SGXFREQ_NAME_LEN + 2))) - goto out; - i += scnprintf(&buf[i], SGXFREQ_NAME_LEN, "%s ", t->name); - } -out: - i += sprintf(&buf[i], "\n"); - return i; -} - -static ssize_t show_governor(struct device *dev, - struct device_attribute *attr, char *buf) -{ - if (sfd.gov) - return scnprintf(buf, SGXFREQ_NAME_LEN, "%s\n", sfd.gov->name); - - return sprintf(buf, "\n"); -} - -static ssize_t store_governor(struct device *dev, - struct device_attribute *attr, const char *buf, - size_t count) -{ - int ret; - char name[16]; - - ret = sscanf(buf, "%15s", name); - if (ret != 1) - return -EINVAL; - - ret = sgxfreq_set_governor(name); - if (ret) - return ret; - else - return count; -} - -static DEVICE_ATTR(frequency_list, 0444, show_frequency_list, NULL); -static DEVICE_ATTR(frequency_request, 0444, show_frequency_request, NULL); -static DEVICE_ATTR(frequency_limit, 0444, show_frequency_limit, NULL); -static DEVICE_ATTR(frequency, 0444, show_frequency, NULL); -static DEVICE_ATTR(governor_list, 0444, show_governor_list, NULL); -static DEVICE_ATTR(governor, 0644, show_governor, store_governor); -static DEVICE_ATTR(stat, 0444, show_stat, NULL); - -static const struct attribute *sgxfreq_attributes[] = { - &dev_attr_frequency_list.attr, - &dev_attr_frequency_request.attr, - &dev_attr_frequency_limit.attr, - &dev_attr_frequency.attr, - &dev_attr_governor_list.attr, - &dev_attr_governor.attr, - &dev_attr_stat.attr, - NULL -}; - -/************************ end sysfs interface ************************/ - -static void __set_freq(void) -{ - unsigned long freq; - - freq = min(sfd.freq_request, sfd.freq_limit); - if (freq != sfd.freq) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) - sfd.pdata->device_scale(sfd.dev, sfd.dev, freq); -#else - sfd.pdata->device_scale(sfd.dev, freq); -#endif - sfd.freq = freq; - } -} - -static struct sgxfreq_governor *__find_governor(const char *name) -{ - struct sgxfreq_governor *t; - - list_for_each_entry(t, &sfd.gov_list, governor_list) - if (!strnicmp(name, t->name, SGXFREQ_NAME_LEN)) - return t; - - return NULL; -} - -static void __update_timing_info(bool active) -{ - struct timeval tv; - do_gettimeofday(&tv); - if(active) - { - if(sfd.sgx_data.active == true) { - _active_curr_time = __tv2msec(tv); - sfd.total_active_time += __delta32( - _active_curr_time, _active_prev_time); - SGXFREQ_TRACE("A->A TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n", - sfd.total_active_time, - __delta32(_active_curr_time, _active_prev_time), - sfd.total_active_time, - (unsigned long)0); - _active_prev_time = _active_curr_time; - } else { - _idle_curr_time = __tv2msec(tv); - _active_prev_time = _idle_curr_time; - sfd.total_idle_time += - __delta32(_idle_curr_time, _idle_prev_time); - SGXFREQ_TRACE("I->A TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n", - sfd.total_active_time, - (unsigned long)0, - sfd.total_idle_time, - __delta32(_idle_curr_time, _idle_prev_time)); - } - } else { - if(sfd.sgx_data.active == true) - { - _idle_prev_time = _active_curr_time = __tv2msec(tv); - sfd.total_active_time += - __delta32(_active_curr_time, _active_prev_time); - SGXFREQ_TRACE("A->I TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n", - sfd.total_active_time, - __delta32(_active_curr_time, _active_prev_time), - sfd.total_active_time, - (unsigned long)0); - } - else - { - _idle_curr_time = __tv2msec(tv); - sfd.total_idle_time += __delta32( - _idle_curr_time, _idle_prev_time); - SGXFREQ_TRACE("I->I TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n", - sfd.total_active_time, - (unsigned long)0, - sfd.total_idle_time, - __delta32(_idle_curr_time, _idle_prev_time)); - _idle_prev_time = _idle_curr_time; - } - } -} - -int sgxfreq_init(struct device *dev) -{ - int i, ret; - unsigned long freq; - struct opp *opp; - struct timeval tv; - - sfd.dev = dev; - if (!sfd.dev) - return -EINVAL; - - sfd.pdata = (struct gpu_platform_data *)dev->platform_data; - if (!sfd.pdata || - !sfd.pdata->opp_get_opp_count || - !sfd.pdata->opp_find_freq_ceil || - !sfd.pdata->device_scale) - return -EINVAL; - - rcu_read_lock(); - - sfd.freq_cnt = sfd.pdata->opp_get_opp_count(dev); - if (sfd.freq_cnt < 1) { - rcu_read_unlock(); - return -ENODEV; - } - - sfd.freq_list = kmalloc(sfd.freq_cnt * sizeof(unsigned long), GFP_ATOMIC); - if (!sfd.freq_list) { - rcu_read_unlock(); - return -ENOMEM; - } - - freq = 0; - for (i = 0; i < sfd.freq_cnt; i++) { - opp = sfd.pdata->opp_find_freq_ceil(dev, &freq); - if (IS_ERR_OR_NULL(opp)) { - rcu_read_unlock(); - kfree(sfd.freq_list); - return -ENODEV; - } - sfd.freq_list[i] = freq; - freq++; - } - rcu_read_unlock(); - - mutex_init(&sfd.freq_mutex); - sfd.freq_limit = sfd.freq_list[sfd.freq_cnt - 1]; - sgxfreq_set_freq_request(sfd.freq_list[sfd.freq_cnt - 1]); - sfd.sgx_data.clk_on = false; - sfd.sgx_data.active = false; - - mutex_init(&sfd.gov_mutex); - INIT_LIST_HEAD(&sfd.gov_list); - - sgxfreq_kobj = kobject_create_and_add("sgxfreq", &sfd.dev->kobj); - ret = sysfs_create_files(sgxfreq_kobj, sgxfreq_attributes); - if (ret) { - kfree(sfd.freq_list); - return ret; - } - -#if defined(CONFIG_THERMAL_FRAMEWORK) - cool_init(); -#endif - - for (i = 0; sgxfreq_gov_init[i] != NULL; i++) - sgxfreq_gov_init[i](); - - if (sgxfreq_set_governor(SGXFREQ_DEFAULT_GOV_NAME)) { - kfree(sfd.freq_list); - return -ENODEV; - } - do_gettimeofday(&tv); - _idle_prev_time = _active_curr_time = _idle_curr_time = - _active_prev_time = __tv2msec(tv); - - return 0; -} - -int sgxfreq_deinit(void) -{ - int i; - - sgxfreq_set_governor(NULL); - - sgxfreq_set_freq_request(sfd.freq_list[0]); - -#if defined(CONFIG_THERMAL_FRAMEWORK) - cool_deinit(); -#endif - - for (i = 0; sgxfreq_gov_deinit[i] != NULL; i++) - sgxfreq_gov_deinit[i](); - - sysfs_remove_files(sgxfreq_kobj, sgxfreq_attributes); - kobject_put(sgxfreq_kobj); - - kfree(sfd.freq_list); - - return 0; -} - -int sgxfreq_register_governor(struct sgxfreq_governor *governor) -{ - if (!governor) - return -EINVAL; - - list_add(&governor->governor_list, &sfd.gov_list); - - return 0; -} - -void sgxfreq_unregister_governor(struct sgxfreq_governor *governor) -{ - if (!governor) - return; - - list_del(&governor->governor_list); -} - -int sgxfreq_set_governor(const char *name) -{ - int ret = 0; - struct sgxfreq_governor *new_gov = 0; - - if (name) { - new_gov = __find_governor(name); - if (!new_gov) - return -EINVAL; - } - - mutex_lock(&sfd.gov_mutex); - - if (sfd.gov && sfd.gov->gov_stop) - sfd.gov->gov_stop(); - - if (new_gov && new_gov->gov_start) - ret = new_gov->gov_start(&sfd.sgx_data); - - if (ret) { - if (sfd.gov && sfd.gov->gov_start) - sfd.gov->gov_start(&sfd.sgx_data); - return -ENODEV; - } - sfd.gov = new_gov; - - mutex_unlock(&sfd.gov_mutex); - - return 0; -} - -int sgxfreq_get_freq_list(unsigned long **pfreq_list) -{ - *pfreq_list = sfd.freq_list; - - return sfd.freq_cnt; -} - -unsigned long sgxfreq_get_freq_min(void) -{ - return sfd.freq_list[0]; -} - -unsigned long sgxfreq_get_freq_max(void) -{ - return sfd.freq_list[sfd.freq_cnt - 1]; -} - -unsigned long sgxfreq_get_freq_floor(unsigned long freq) -{ - int i; - unsigned long f = 0; - - for (i = sfd.freq_cnt - 1; i >= 0; i--) { - f = sfd.freq_list[i]; - if (f <= freq) - return f; - } - - return f; -} - -unsigned long sgxfreq_get_freq_ceil(unsigned long freq) -{ - int i; - unsigned long f = 0; - - for (i = 0; i < sfd.freq_cnt; i++) { - f = sfd.freq_list[i]; - if (f >= freq) - return f; - } - - return f; -} - -unsigned long sgxfreq_get_freq(void) -{ - return sfd.freq; -} - -unsigned long sgxfreq_get_freq_request(void) -{ - return sfd.freq_request; -} - -unsigned long sgxfreq_get_freq_limit(void) -{ - return sfd.freq_limit; -} - -unsigned long sgxfreq_set_freq_request(unsigned long freq_request) -{ - freq_request = sgxfreq_get_freq_ceil(freq_request); - - mutex_lock(&sfd.freq_mutex); - - sfd.freq_request = freq_request; - __set_freq(); - - mutex_unlock(&sfd.freq_mutex); - - return freq_request; -} - -unsigned long sgxfreq_set_freq_limit(unsigned long freq_limit) -{ - freq_limit = sgxfreq_get_freq_ceil(freq_limit); - - mutex_lock(&sfd.freq_mutex); - - sfd.freq_limit = freq_limit; - __set_freq(); - - mutex_unlock(&sfd.freq_mutex); - - return freq_limit; -} - -unsigned long sgxfreq_get_total_active_time(void) -{ - __update_timing_info(sfd.sgx_data.active); - return sfd.total_active_time; -} - -unsigned long sgxfreq_get_total_idle_time(void) -{ - __update_timing_info(sfd.sgx_data.active); - return sfd.total_idle_time; -} - -/* - * sgx_clk_on, sgx_clk_off, sgx_active, and sgx_idle notifications are - * serialized by power lock. governor notif calls need sync with governor - * setting. - */ -void sgxfreq_notif_sgx_clk_on(void) -{ - sfd.sgx_data.clk_on = true; - - mutex_lock(&sfd.gov_mutex); - - if (sfd.gov && sfd.gov->sgx_clk_on) - sfd.gov->sgx_clk_on(); - - mutex_unlock(&sfd.gov_mutex); -} - -void sgxfreq_notif_sgx_clk_off(void) -{ - sfd.sgx_data.clk_on = false; - - mutex_lock(&sfd.gov_mutex); - - if (sfd.gov && sfd.gov->sgx_clk_off) - sfd.gov->sgx_clk_off(); - - mutex_unlock(&sfd.gov_mutex); -} - - -void sgxfreq_notif_sgx_active(void) -{ - __update_timing_info(true); - - sfd.sgx_data.active = true; - - mutex_lock(&sfd.gov_mutex); - - if (sfd.gov && sfd.gov->sgx_active) - sfd.gov->sgx_active(); - - mutex_unlock(&sfd.gov_mutex); - -} - -void sgxfreq_notif_sgx_idle(void) -{ - - __update_timing_info(false); - - sfd.sgx_data.active = false; - - mutex_lock(&sfd.gov_mutex); - - if (sfd.gov && sfd.gov->sgx_idle) - sfd.gov->sgx_idle(); - - mutex_unlock(&sfd.gov_mutex); -} - -void sgxfreq_notif_sgx_frame_done(void) -{ - mutex_lock(&sfd.gov_mutex); - - if (sfd.gov && sfd.gov->sgx_frame_done) - sfd.gov->sgx_frame_done(); - - mutex_unlock(&sfd.gov_mutex); -} diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq.h b/drivers/gpu/pvr/services4/system/omap4/sgxfreq.h deleted file mode 100644 index ff6fc88d4a6..00000000000 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SGXFREQ_H -#define SGXFREQ_H - -#include <linux/device.h> -#include <linux/time.h> - -#define SGXFREQ_NAME_LEN 16 - -//#define SGXFREQ_DEBUG_FTRACE -#if defined(SGXFREQ_DEBUG_FTRACE) -#define SGXFREQ_TRACE(...) trace_printk(__VA_ARGS__) -#else -#define SGXFREQ_TRACE(...) -#endif - -struct sgxfreq_sgx_data { - bool clk_on; - bool active; -}; - -struct sgxfreq_governor { - char name[SGXFREQ_NAME_LEN]; - int (*gov_start) (struct sgxfreq_sgx_data *data); - void (*gov_stop) (void); - void (*sgx_clk_on) (void); - void (*sgx_clk_off) (void); - void (*sgx_active) (void); - void (*sgx_idle) (void); - void (*sgx_frame_done) (void); - struct list_head governor_list; -}; - -/* sgxfreq_init must be called before any other api */ -int sgxfreq_init(struct device *dev); -int sgxfreq_deinit(void); - -int sgxfreq_register_governor(struct sgxfreq_governor *governor); -void sgxfreq_unregister_governor(struct sgxfreq_governor *governor); - -int sgxfreq_set_governor(const char *name); - -int sgxfreq_get_freq_list(unsigned long **pfreq_list); - -unsigned long sgxfreq_get_freq_min(void); -unsigned long sgxfreq_get_freq_max(void); - -unsigned long sgxfreq_get_freq_floor(unsigned long freq); -unsigned long sgxfreq_get_freq_ceil(unsigned long freq); - -unsigned long sgxfreq_get_freq(void); -unsigned long sgxfreq_get_freq_request(void); -unsigned long sgxfreq_get_freq_limit(void); - -unsigned long sgxfreq_set_freq_request(unsigned long freq_request); -unsigned long sgxfreq_set_freq_limit(unsigned long freq_limit); - -unsigned long sgxfreq_get_total_active_time(void); -unsigned long sgxfreq_get_total_idle_time(void); - -/* Helper functions */ -static inline unsigned long __tv2msec(struct timeval tv) -{ - return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); -} - -static inline unsigned long __delta32(unsigned long a, unsigned long b) -{ - if (a >= b) - return a - b; - else - return 1 + (0xFFFFFFFF - b) + a; -} - -/* External notifications to sgxfreq */ -void sgxfreq_notif_sgx_clk_on(void); -void sgxfreq_notif_sgx_clk_off(void); -void sgxfreq_notif_sgx_active(void); -void sgxfreq_notif_sgx_idle(void); -void sgxfreq_notif_sgx_frame_done(void); - -#endif diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_activeidle.c b/drivers/gpu/pvr/services4/system/omap4/sgxfreq_activeidle.c deleted file mode 100644 index 45159d7269b..00000000000 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_activeidle.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/sysfs.h> -#include "sgxfreq.h" - -static int activeidle_start(struct sgxfreq_sgx_data *data); -static void activeidle_stop(void); -static void activeidle_sgx_active(void); -static void activeidle_sgx_idle(void); - -static struct activeidle_data { - unsigned long freq_active; - unsigned long freq_idle; - struct mutex mutex; - bool sgx_active; -} aid; - -static struct sgxfreq_governor activeidle_gov = { - .name = "activeidle", - .gov_start = activeidle_start, - .gov_stop = activeidle_stop, - .sgx_active = activeidle_sgx_active, - .sgx_idle = activeidle_sgx_idle, -}; - -/*********************** begin sysfs interface ***********************/ - -extern struct kobject *sgxfreq_kobj; - -static ssize_t show_freq_active(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", aid.freq_active); -} - -static ssize_t store_freq_active(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - int ret; - unsigned long freq; - - ret = sscanf(buf, "%lu", &freq); - if (ret != 1) - return -EINVAL; - - freq = sgxfreq_get_freq_ceil(freq); - - mutex_lock(&aid.mutex); - - aid.freq_active = freq; - if (aid.sgx_active) - sgxfreq_set_freq_request(aid.freq_active); - - mutex_unlock(&aid.mutex); - - return count; -} - -static ssize_t show_freq_idle(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", aid.freq_idle); -} - -static ssize_t store_freq_idle(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int ret; - unsigned long freq; - - ret = sscanf(buf, "%lu", &freq); - if (ret != 1) - return -EINVAL; - - freq = sgxfreq_get_freq_floor(freq); - - mutex_lock(&aid.mutex); - - aid.freq_idle = freq; - if (!aid.sgx_active) - sgxfreq_set_freq_request(aid.freq_idle); - - mutex_unlock(&aid.mutex); - - return count; -} -static DEVICE_ATTR(freq_active, 0644, show_freq_active, store_freq_active); -static DEVICE_ATTR(freq_idle, 0644, show_freq_idle, store_freq_idle); - -static struct attribute *activeidle_attributes[] = { - &dev_attr_freq_active.attr, - &dev_attr_freq_idle.attr, - NULL -}; - -static struct attribute_group activeidle_attr_group = { - .attrs = activeidle_attributes, - .name = "activeidle", -}; - -/************************ end sysfs interface ************************/ - -int activeidle_init(void) -{ - int ret; - - mutex_init(&aid.mutex); - - ret = sgxfreq_register_governor(&activeidle_gov); - if (ret) - return ret; - - aid.freq_idle = sgxfreq_get_freq_min(); - aid.freq_active = sgxfreq_get_freq_max(); - - return 0; -} - -int activeidle_deinit(void) -{ - return 0; -} - -static int activeidle_start(struct sgxfreq_sgx_data *data) -{ - int ret; - - aid.sgx_active = data->active; - - ret = sysfs_create_group(sgxfreq_kobj, &activeidle_attr_group); - if (ret) - return ret; - - if (aid.sgx_active) - sgxfreq_set_freq_request(aid.freq_active); - else - sgxfreq_set_freq_request(aid.freq_idle); - - return 0; -} - -static void activeidle_stop(void) -{ - sysfs_remove_group(sgxfreq_kobj, &activeidle_attr_group); -} - -static void activeidle_sgx_active(void) -{ - mutex_lock(&aid.mutex); - - aid.sgx_active = true; - sgxfreq_set_freq_request(aid.freq_active); - - mutex_unlock(&aid.mutex); -} - -static void activeidle_sgx_idle(void) -{ - mutex_lock(&aid.mutex); - - aid.sgx_active = false; - sgxfreq_set_freq_request(aid.freq_idle); - - mutex_unlock(&aid.mutex); -} diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_on3demand.c b/drivers/gpu/pvr/services4/system/omap4/sgxfreq_on3demand.c deleted file mode 100644 index c4e4bd911f8..00000000000 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_on3demand.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/sysfs.h> -#include <linux/vmalloc.h> -#include <asm/io.h> -#include "sgxfreq.h" - -static int on3demand_start(struct sgxfreq_sgx_data *data); -static void on3demand_stop(void); -static void on3demand_predict(void); -static void on3demand_frame_done(void); -static void on3demand_active(void); -static void on3demand_timeout(struct work_struct *work); - - -static struct sgxfreq_governor on3demand_gov = { - .name = "on3demand", - .gov_start = on3demand_start, - .gov_stop = on3demand_stop, - .sgx_frame_done = on3demand_frame_done, - .sgx_active = on3demand_active, -}; - -static struct on3demand_data { - unsigned int load; - unsigned int up_threshold; - unsigned int down_threshold; - unsigned int history_size; - unsigned long prev_total_idle; - unsigned long prev_total_active; - unsigned int low_load_cnt; - unsigned int poll_interval; - unsigned long delta_active; - unsigned long delta_idle; - bool polling_enabled; - struct delayed_work work; - struct mutex mutex; -} odd; - -#define ON3DEMAND_DEFAULT_UP_THRESHOLD 80 -#define ON3DEMAND_DEFAULT_DOWN_THRESHOLD 30 -#define ON3DEMAND_DEFAULT_HISTORY_SIZE_THRESHOLD 5 -/* For Live wallpaper frame done at interval of ~64ms */ -#define ON3DEMAND_DEFAULT_POLL_INTERVAL 75 - -/*FIXME: This should be dynamic and queried from platform */ -#define ON3DEMAND_FRAME_DONE_DEADLINE_MS 16 - - -/*********************** begin sysfs interface ***********************/ - -extern struct kobject *sgxfreq_kobj; - -static ssize_t show_down_threshold(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", odd.down_threshold); -} - -static ssize_t store_down_threshold(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int ret; - unsigned int thres; - - ret = sscanf(buf, "%u", &thres); - if (ret != 1) - return -EINVAL; - - mutex_lock(&odd.mutex); - - if (thres <= 100) { - odd.down_threshold = thres; - odd.low_load_cnt = 0; - } else { - return -EINVAL; - } - - mutex_unlock(&odd.mutex); - - return count; -} - -static ssize_t show_up_threshold(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", odd.up_threshold); -} - -static ssize_t store_up_threshold(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int ret; - unsigned int thres; - - ret = sscanf(buf, "%u", &thres); - if (ret != 1) - return -EINVAL; - - mutex_lock(&odd.mutex); - - if (thres <= 100) { - odd.up_threshold = thres; - odd.low_load_cnt = 0; - } else { - return -EINVAL; - } - - mutex_unlock(&odd.mutex); - - return count; -} - -static ssize_t show_history_size(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", odd.history_size); -} - -static ssize_t store_history_size(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int ret; - unsigned int size; - - ret = sscanf(buf, "%u", &size); - if (ret != 1) - return -EINVAL; - - mutex_lock(&odd.mutex); - - if (size >= 1) { - odd.history_size = size; - odd.low_load_cnt = 0; - } else { - return -EINVAL; - } - - mutex_unlock(&odd.mutex); - - return count; -} - -static ssize_t show_load(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", odd.load); -} - -static DEVICE_ATTR(down_threshold, 0644, - show_down_threshold, store_down_threshold); -static DEVICE_ATTR(up_threshold, 0644, - show_up_threshold, store_up_threshold); -static DEVICE_ATTR(history_size, 0644, - show_history_size, store_history_size); -static DEVICE_ATTR(load, 0444, - show_load, NULL); - -static struct attribute *on3demand_attributes[] = { - &dev_attr_down_threshold.attr, - &dev_attr_up_threshold.attr, - &dev_attr_history_size.attr, - &dev_attr_load.attr, - NULL -}; - -static struct attribute_group on3demand_attr_group = { - .attrs = on3demand_attributes, - .name = "on3demand", -}; -/************************ end sysfs interface ************************/ - -int on3demand_init(void) -{ - int ret; - - mutex_init(&odd.mutex); - - ret = sgxfreq_register_governor(&on3demand_gov); - if (ret) - return ret; - - return 0; -} - -int on3demand_deinit(void) -{ - return 0; -} - -static int on3demand_start(struct sgxfreq_sgx_data *data) -{ - int ret; - - odd.load = 0; - odd.up_threshold = ON3DEMAND_DEFAULT_UP_THRESHOLD; - odd.down_threshold = ON3DEMAND_DEFAULT_DOWN_THRESHOLD; - odd.history_size = ON3DEMAND_DEFAULT_HISTORY_SIZE_THRESHOLD; - odd.prev_total_active = 0; - odd.prev_total_idle = 0; - odd.low_load_cnt = 0; - odd.poll_interval = ON3DEMAND_DEFAULT_POLL_INTERVAL; - odd.polling_enabled = false; - - INIT_DELAYED_WORK(&odd.work, on3demand_timeout); - - ret = sysfs_create_group(sgxfreq_kobj, &on3demand_attr_group); - if (ret) - return ret; - - return 0; -} - -static void on3demand_stop(void) -{ - cancel_delayed_work_sync(&odd.work); - sysfs_remove_group(sgxfreq_kobj, &on3demand_attr_group); -} - -static void on3demand_predict(void) -{ - static unsigned short first_sample = 1; - unsigned long total_active, total_idle; - unsigned long freq; - - if (first_sample == 1) { - first_sample = 0; - odd.prev_total_active = sgxfreq_get_total_active_time(); - odd.prev_total_idle = sgxfreq_get_total_idle_time(); - return; - } - - /* Sample new active and idle times */ - total_active = sgxfreq_get_total_active_time(); - total_idle = sgxfreq_get_total_idle_time(); - - /* Compute load */ - odd.delta_active = __delta32(total_active, odd.prev_total_active); - odd.delta_idle = __delta32(total_idle, odd.prev_total_idle); - - /* - * If SGX was active for longer than frame display time (1/fps), - * scale to highest possible frequency. - */ - if (odd.delta_active > ON3DEMAND_FRAME_DONE_DEADLINE_MS) { - odd.low_load_cnt = 0; - sgxfreq_set_freq_request(sgxfreq_get_freq_max()); - } - - if ((odd.delta_active + odd.delta_idle)) - odd.load = (100 * odd.delta_active / (odd.delta_active + odd.delta_idle)); - - odd.prev_total_active = total_active; - odd.prev_total_idle = total_idle; - - /* Scale GPU frequency on purpose */ - if (odd.load >= odd.up_threshold) { - odd.low_load_cnt = 0; - sgxfreq_set_freq_request(sgxfreq_get_freq_max()); - } else if (odd.load <= odd.down_threshold) { - if (odd.low_load_cnt == odd.history_size) { - /* Convert load to frequency */ - freq = (sgxfreq_get_freq() * odd.load) / 100; - sgxfreq_set_freq_request(freq); - odd.low_load_cnt = 0; - } else { - odd.low_load_cnt++; - } - } else { - odd.low_load_cnt = 0; - } -} - - -static void on3demand_active(void) -{ - if (!odd.polling_enabled) { - sgxfreq_set_freq_request(sgxfreq_get_freq_max()); - odd.low_load_cnt = 0; - odd.polling_enabled = true; - schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000); - } - -} - -static void on3demand_frame_done(void) -{ - if (odd.polling_enabled) { - cancel_delayed_work_sync(&odd.work); - schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000); - } - on3demand_predict(); -} - -static void on3demand_timeout(struct work_struct *work) -{ - /* - * If sgx was idle all throughout timer disable polling and - * enable it on next sgx active event - */ - if (!odd.delta_active) { - sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - odd.low_load_cnt = 0; - odd.polling_enabled = false; - } else { - on3demand_predict(); - odd.polling_enabled = true; - schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000); - } -} diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_onoff.c b/drivers/gpu/pvr/services4/system/omap4/sgxfreq_onoff.c deleted file mode 100644 index 39dd3fc5c42..00000000000 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_onoff.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/sysfs.h> -#include "sgxfreq.h" - -static int onoff_start(struct sgxfreq_sgx_data *data); -static void onoff_stop(void); -static void onoff_sgx_clk_on(void); -static void onoff_sgx_clk_off(void); - -static struct onoff_data { - unsigned long freq_off; - unsigned long freq_on; - struct mutex mutex; - bool sgx_clk_on; -} ood; - -static struct sgxfreq_governor onoff_gov = { - .name = "onoff", - .gov_start = onoff_start, - .gov_stop = onoff_stop, - .sgx_clk_on = onoff_sgx_clk_on, - .sgx_clk_off = onoff_sgx_clk_off, -}; - -/*********************** begin sysfs interface ***********************/ - -extern struct kobject *sgxfreq_kobj; - -static ssize_t show_freq_on(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", ood.freq_on); -} - -static ssize_t store_freq_on(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int ret; - unsigned long freq; - - ret = sscanf(buf, "%lu", &freq); - if (ret != 1) - return -EINVAL; - - freq = sgxfreq_get_freq_ceil(freq); - - mutex_lock(&ood.mutex); - - ood.freq_on = freq; - if (ood.sgx_clk_on) - sgxfreq_set_freq_request(ood.freq_on); - - mutex_unlock(&ood.mutex); - - return count; -} - -static ssize_t show_freq_off(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", ood.freq_off); -} - -static ssize_t store_freq_off(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int ret; - unsigned long freq; - - ret = sscanf(buf, "%lu", &freq); - if (ret != 1) - return -EINVAL; - - freq = sgxfreq_get_freq_floor(freq); - - mutex_lock(&ood.mutex); - - ood.freq_off = freq; - if (!ood.sgx_clk_on) - sgxfreq_set_freq_request(ood.freq_off); - - mutex_unlock(&ood.mutex); - - return count; -} -static DEVICE_ATTR(freq_on, 0644, show_freq_on, store_freq_on); -static DEVICE_ATTR(freq_off, 0644, show_freq_off, store_freq_off); - -static struct attribute *onoff_attributes[] = { - &dev_attr_freq_on.attr, - &dev_attr_freq_off.attr, - NULL -}; - -static struct attribute_group onoff_attr_group = { - .attrs = onoff_attributes, - .name = "onoff", -}; - -/************************ end sysfs interface ************************/ - -int onoff_init(void) -{ - int ret; - - mutex_init(&ood.mutex); - - ret = sgxfreq_register_governor(&onoff_gov); - if (ret) - return ret; - - ood.freq_off = sgxfreq_get_freq_min(); - ood.freq_on = sgxfreq_get_freq_max(); - - return 0; -} - -int onoff_deinit(void) -{ - return 0; -} - -static int onoff_start(struct sgxfreq_sgx_data *data) -{ - int ret; - - ood.sgx_clk_on = data->clk_on; - - ret = sysfs_create_group(sgxfreq_kobj, &onoff_attr_group); - if (ret) - return ret; - - if (ood.sgx_clk_on) - sgxfreq_set_freq_request(ood.freq_on); - else - sgxfreq_set_freq_request(ood.freq_off); - - return 0; -} - -static void onoff_stop(void) -{ - sysfs_remove_group(sgxfreq_kobj, &onoff_attr_group); -} - -static void onoff_sgx_clk_on(void) -{ - mutex_lock(&ood.mutex); - - ood.sgx_clk_on = true; - sgxfreq_set_freq_request(ood.freq_on); - - mutex_unlock(&ood.mutex); -} - -static void onoff_sgx_clk_off(void) -{ - mutex_lock(&ood.mutex); - - ood.sgx_clk_on = false; - sgxfreq_set_freq_request(ood.freq_off); - - mutex_unlock(&ood.mutex); -} - diff --git a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_userspace.c b/drivers/gpu/pvr/services4/system/omap4/sgxfreq_userspace.c deleted file mode 100644 index 5ff0dd07d8a..00000000000 --- a/drivers/gpu/pvr/services4/system/omap4/sgxfreq_userspace.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <linux/sysfs.h> -#include "sgxfreq.h" - - -static int userspace_start(struct sgxfreq_sgx_data *data); -static void userspace_stop(void); -static void userspace_sgx_clk_on(void); -static void userspace_sgx_clk_off(void); -static void userspace_sgx_active(void); -static void userspace_sgx_idle(void); - - -static struct sgxfreq_governor userspace_gov = { - .name = "userspace", - .gov_start = userspace_start, - .gov_stop = userspace_stop, - .sgx_clk_on = userspace_sgx_clk_on, - .sgx_clk_off = userspace_sgx_clk_off, - .sgx_active = userspace_sgx_active, - .sgx_idle = userspace_sgx_idle, -}; - - -static struct userspace_data { - unsigned long freq_user; /* in KHz */ - struct mutex mutex; -} usd; - - -/*********************** begin sysfs interface ***********************/ - -extern struct kobject *sgxfreq_kobj; - - -static ssize_t show_frequency_set(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", usd.freq_user); -} - - -static ssize_t store_frequency_set(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int ret; - unsigned long freq; - - ret = sscanf(buf, "%lu", &freq); - if (ret != 1) - return -EINVAL; - - mutex_lock(&odd.mutex); - - if (freq > sgxfreq_get_freq_max()) - freq = sgxfreq_get_freq_max(); - usd.freq_user = sgxfreq_set_freq_request(freq); - trace_printk("USERSPACE: new freq=%luHz.\n", usd.freq_user); - - mutex_unlock(&odd.mutex); - - return count; -} - - -static DEVICE_ATTR(frequency_set, 0644, - show_frequency_set, store_frequency_set); - - -static struct attribute *userspace_attributes[] = { - &dev_attr_frequency_set.attr, - NULL -}; - - -static struct attribute_group userspace_attr_group = { - .attrs = userspace_attributes, - .name = "userspace", -}; - -/************************ end sysfs interface ************************/ - - -int userspace_init(void) -{ - int ret; - - mutex_init(&odd.mutex); - - ret = sgxfreq_register_governor(&userspace_gov); - if (ret) - return ret; - return 0; -} - - -int userspace_deinit(void) -{ - return 0; -} - - -static int userspace_start(struct sgxfreq_sgx_data *data) -{ - int ret; - - usd.freq_user = sgxfreq_get_freq(); - - ret = sysfs_create_group(sgxfreq_kobj, &userspace_attr_group); - if (ret) - return ret; - - trace_printk("USERSPACE: started.\n"); - - return 0; -} - - -static void userspace_stop(void) -{ - usd.freq_user = sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - sysfs_remove_group(sgxfreq_kobj, &userspace_attr_group); - - trace_printk("USERSPACE: stopped.\n"); -} - - -static void userspace_sgx_clk_on(void) -{ - mutex_lock(&ood.mutex); - - sgxfreq_set_freq_request(usd.freq_user); - - mutex_unlock(&ood.mutex); -} - - -static void userspace_sgx_clk_off(void) -{ - mutex_lock(&ood.mutex); - - sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - - mutex_unlock(&ood.mutex); -} - - -static void userspace_sgx_active(void) -{ - mutex_lock(&aid.mutex); - - sgxfreq_set_freq_request(usd.freq_user); - - mutex_unlock(&aid.mutex); -} - - -static void userspace_sgx_idle(void) -{ - mutex_lock(&aid.mutex); - - sgxfreq_set_freq_request(sgxfreq_get_freq_min()); - - mutex_unlock(&aid.mutex); -} diff --git a/drivers/gpu/pvr/services4/system/omap4/oemfuncs.h b/drivers/gpu/pvr/services4/system/sunxi/oemfuncs.h index 090204238b0..eab3174d6ff 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/oemfuncs.h +++ b/drivers/gpu/pvr/services4/system/sunxi/oemfuncs.h @@ -1,5 +1,4 @@ /*************************************************************************/ /*! -@Title SGX kernel/client driver interface structures and prototypes @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved @License Dual MIT/GPLv2 diff --git a/drivers/gpu/pvr/services4/system/omap4/sysconfig.c b/drivers/gpu/pvr/services4/system/sunxi/sysconfig.c index e9fd0694e3c..e6c774ebf4e 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/sysconfig.c +++ b/drivers/gpu/pvr/services4/system/sunxi/sysconfig.c @@ -1,7 +1,5 @@ /*************************************************************************/ /*! -@Title System Configuration @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved -@Description System Configuration functions @License Dual MIT/GPLv2 The contents of this file are subject to the MIT license as set out below. @@ -48,14 +46,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sgxinfokm.h" #include "syslocal.h" -#include "ocpdefs.h" - -#define OMAP5430_CORE_REV 0x10005 - /* top level system data anchor point*/ SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL; SYS_DATA gsSysData; - static SYS_SPECIFIC_DATA gsSysSpecificData; SYS_SPECIFIC_DATA *gpsSysSpecificData; @@ -64,8 +57,7 @@ static IMG_UINT32 gui32SGXDeviceID; static SGX_DEVICE_MAP gsSGXDeviceMap; static PVRSRV_DEVICE_NODE *gpsSGXDevNode; - -#if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED) +#if defined(NO_HARDWARE) static IMG_CPU_VIRTADDR gsSGXRegsCPUVAddr; #endif @@ -80,33 +72,11 @@ IMG_UINT32 PVRSRV_BridgeDispatchKM(IMG_UINT32 Ioctl, IMG_UINT32 OutBufLen, IMG_UINT32 *pdwBytesTransferred); -#if defined(SGX_OCP_REGS_ENABLED) - -static IMG_CPU_VIRTADDR gpvOCPRegsLinAddr; - -static PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData) -{ - PVRSRV_ERROR eError = EnableSGXClocks(psSysData); - -#if !defined(SGX_OCP_NO_INT_BYPASS) - if(eError == PVRSRV_OK) - { - OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_SYSCONFIG, 0x14); - OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_DEBUG_CONFIG, EUR_CR_OCP_DEBUG_CONFIG_THALIA_INT_BYPASS_MASK); - } -#endif - return eError; -} - -#else /* defined(SGX_OCP_REGS_ENABLED) */ - static INLINE PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData) { - return EnableSGXClocks(psSysData); + return EnableSGXClocks(psSysData, IMG_FALSE); } -#endif /* defined(SGX_OCP_REGS_ENABLED) */ - static INLINE PVRSRV_ERROR EnableSystemClocksWrap(SYS_DATA *psSysData) { PVRSRV_ERROR eError = EnableSystemClocks(psSysData); @@ -165,7 +135,7 @@ static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) */ /* Registers */ - gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE; + gsSGXDeviceMap.ui32RegsSize = SYS_SUNXI_SGX_REGS_SIZE; eError = OSBaseAllocContigMemory(gsSGXDeviceMap.ui32RegsSize, &gsSGXRegsCPUVAddr, @@ -197,63 +167,24 @@ static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) #else /* defined(NO_HARDWARE) */ #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) - /* get the resource and IRQ through platform resource API */ - dev_res = platform_get_resource(gpsPVRLDMDev, IORESOURCE_MEM, 0); - if (dev_res == NULL) - { - PVR_DPF((PVR_DBG_ERROR, "%s: platform_get_resource failed", __FUNCTION__)); - return PVRSRV_ERROR_INVALID_DEVICE; - } - - dev_irq = platform_get_irq(gpsPVRLDMDev, 0); - if (dev_irq < 0) - { - PVR_DPF((PVR_DBG_ERROR, "%s: platform_get_irq failed (%d)", __FUNCTION__, -dev_irq)); - return PVRSRV_ERROR_INVALID_DEVICE; - } - - gsSGXDeviceMap.sRegsSysPBase.uiAddr = dev_res->start; + gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_SUNXI_SGX_REGS_SYS_PHYS_BASE; gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase); PVR_TRACE(("SGX register base: 0x%lx", (unsigned long)gsSGXDeviceMap.sRegsCpuPBase.uiAddr)); -#if defined(SGX544) && defined(SGX_FEATURE_MP) - /* Workaround: Due to the change in the HWMOD, the driver is only detecting the - size of the first memory section. For the moment, set the size with a macro - until a better solution found */ - gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE; -#else - gsSGXDeviceMap.ui32RegsSize = (unsigned int)(dev_res->end - dev_res->start); -#endif - + gsSGXDeviceMap.ui32RegsSize = SYS_SUNXI_SGX_REGS_SIZE; PVR_TRACE(("SGX register size: %d",gsSGXDeviceMap.ui32RegsSize)); - gsSGXDeviceMap.ui32IRQ = dev_irq; + gsSGXDeviceMap.ui32IRQ = SYS_SUNXI_SGX_IRQ; PVR_TRACE(("SGX IRQ: %d", gsSGXDeviceMap.ui32IRQ)); #else /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */ - gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_OMAP4430_SGX_REGS_SYS_PHYS_BASE; + gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_SUNXI_SGX_REGS_SYS_PHYS_BASE; gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase); - gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE; + gsSGXDeviceMap.ui32RegsSize = SYS_SUNXI_SGX_REGS_SIZE; - gsSGXDeviceMap.ui32IRQ = SYS_OMAP4430_SGX_IRQ; + gsSGXDeviceMap.ui32IRQ = SYS_SUNXI_SGX_IRQ; #endif /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */ -#if defined(SGX_OCP_REGS_ENABLED) - gsSGXRegsCPUVAddr = OSMapPhysToLin(gsSGXDeviceMap.sRegsCpuPBase, - gsSGXDeviceMap.ui32RegsSize, - PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY, - IMG_NULL); - - if (gsSGXRegsCPUVAddr == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR,"SysLocateDevices: Failed to map SGX registers")); - return PVRSRV_ERROR_BAD_MAPPING; - } - - /* Indicate the registers are already mapped */ - gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr; - gpvOCPRegsLinAddr = gsSGXRegsCPUVAddr; -#endif #endif /* defined(NO_HARDWARE) */ #if defined(PDUMP) @@ -299,13 +230,9 @@ static IMG_CHAR *SysCreateVersionString(void) return IMG_NULL; } -#if defined(SGX544) && defined(SGX_FEATURE_MP) - ui32SGXRevision = OMAP5430_CORE_REV; -#else - ui32SGXRevision = OSReadHWReg((IMG_PVOID)((IMG_PBYTE)pvRegsLinAddr), - EUR_CR_CORE_REVISION); -#endif - + //ui32SGXRevision = OSReadHWReg((IMG_PVOID)((IMG_PBYTE)pvRegsLinAddr), + // EUR_CR_CORE_REVISION); + ui32SGXRevision = 0x10105; #else ui32SGXRevision = 0; #endif @@ -324,7 +251,7 @@ static IMG_CHAR *SysCreateVersionString(void) #if !defined(NO_HARDWARE) OSUnMapPhysToLin(pvRegsLinAddr, - SYS_OMAP4430_SGX_REGS_SIZE, + SYS_SUNXI_SGX_REGS_SIZE, PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY, IMG_NULL); #endif @@ -353,12 +280,10 @@ PVRSRV_ERROR SysInitialise(IMG_VOID) IMG_UINT32 i; PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; -#if !defined(PVR_NO_OMAP_TIMER) - IMG_CPU_PHYADDR TimerRegPhysBase; -#endif #if !defined(SGX_DYNAMIC_TIMING_INFO) SGX_TIMING_INFORMATION* psTimingInfo; #endif + gpsSysData = &gsSysData; OSMemSet(gpsSysData, 0, sizeof(SYS_DATA)); @@ -432,7 +357,7 @@ PVRSRV_ERROR SysInitialise(IMG_VOID) } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV); - eError = SysPMRuntimeRegister(gpsSysSpecificData); + eError = SysPMRuntimeRegister(); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register with OSPM!")); @@ -547,32 +472,9 @@ PVRSRV_ERROR SysInitialise(IMG_VOID) DisableSGXClocks(gpsSysData); #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ -#if !defined(PVR_NO_OMAP_TIMER) -#if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA) - TimerRegPhysBase = gsSysSpecificData.sTimerRegPhysBase; -#else - TimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE; -#endif - gpsSysData->pvSOCTimerRegisterKM = IMG_NULL; - gpsSysData->hSOCTimerRegisterOSMemHandle = 0; - if (TimerRegPhysBase.uiAddr != 0) - { - OSReservePhys(TimerRegPhysBase, - 4, - PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED, - IMG_NULL, - (IMG_VOID **)&gpsSysData->pvSOCTimerRegisterKM, - &gpsSysData->hSOCTimerRegisterOSMemHandle); - } -#endif /* !defined(PVR_NO_OMAP_TIMER) */ - - return PVRSRV_OK; } -#if defined(CONFIG_OMAPLFB) -int OMAPLFBRegisterPVRDriver(void * pfnFuncTable); -#endif /*! ****************************************************************************** @@ -636,14 +538,6 @@ PVRSRV_ERROR SysFinalise(IMG_VOID) DisableSGXClocks(gpsSysData); #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ -#if defined(CONFIG_OMAPLFB) - if (OMAPLFBRegisterPVRDriver((void *)&PVRGetDisplayClassJTable) != 0) - { - PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to register PVR driver with omaplfb")); - return PVRSRV_ERROR_INIT_FAILURE; - } -#endif - gpsSysSpecificData->bSGXInitComplete = IMG_TRUE; return eError; @@ -701,8 +595,8 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) { #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) PVR_ASSERT(SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS)); - /* Reenable SGX clocks whilst SGX is being deinitialised. */ - eError = EnableSGXClocksWrap(gpsSysData); + /* Re-enable SGX clocks whilst SGX is being de-initialised */ + eError = EnableSGXClocks(gpsSysData, IMG_TRUE); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: EnableSGXClocks failed")); @@ -710,7 +604,7 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) } #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ - /* Deinitialise SGX */ + /* De-initialise SGX */ eError = PVRSRVDeinitialiseDevice (gui32SGXDeviceID); if (eError != PVRSRV_OK) { @@ -732,7 +626,7 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME)) { - eError = SysPMRuntimeUnregister(gpsSysSpecificData); + eError = SysPMRuntimeUnregister(); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: Failed to unregister with OSPM!")); @@ -741,9 +635,7 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) } } - /* - Disable system clocks - must happen after last access to hardware. - */ + /* Disable system clocks - must happen after last access to hardware */ if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS)) { DisableSystemClocks(gpsSysData); @@ -761,26 +653,15 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) SysDeinitialiseCommon(gpsSysData); -#if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED) +#if defined(NO_HARDWARE) if(gsSGXRegsCPUVAddr != IMG_NULL) { -#if defined(NO_HARDWARE) /* Free hardware resources. */ - OSBaseFreeContigMemory(SYS_OMAP4430_SGX_REGS_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase); -#else -#if defined(SGX_OCP_REGS_ENABLED) - OSUnMapPhysToLin(gsSGXRegsCPUVAddr, - gsSGXDeviceMap.ui32RegsSize, - PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY, - IMG_NULL); - - gpvOCPRegsLinAddr = IMG_NULL; -#endif -#endif /* defined(NO_HARDWARE) */ + OSBaseFreeContigMemory(SYS_SUNXI_SGX_REGS_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase); gsSGXRegsCPUVAddr = IMG_NULL; gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr; } -#endif /* defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED) */ +#endif /* defined(NO_HARDWARE) */ gpsSysSpecificData->ui32SysSpecificData = 0; @@ -849,7 +730,7 @@ IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, PVR_UNREFERENCED_PARAMETER(eDeviceType); /* Note: for UMA system we assume DevP == CpuP */ - DevPAddr.uiAddr = CpuPAddr.uiAddr; + DevPAddr.uiAddr = CpuPAddr.uiAddr - 0x40000000; return DevPAddr; } @@ -872,6 +753,7 @@ IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR sys_paddr) /* This would only be an inequality if the CPU's MMU did not point to sys address 0, ie. multi CPU system */ cpu_paddr.uiAddr = sys_paddr.uiAddr; + return cpu_paddr; } @@ -893,6 +775,7 @@ IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr) /* This would only be an inequality if the CPU's MMU did not point to sys address 0, ie. multi CPU system */ sys_paddr.uiAddr = cpu_paddr.uiAddr; + return sys_paddr; } @@ -915,12 +798,12 @@ IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr) IMG_DEV_PHYADDR SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr) { IMG_DEV_PHYADDR DevPAddr; - + PVR_UNREFERENCED_PARAMETER(eDeviceType); - + /* Note: for UMA system we assume DevP == CpuP */ - DevPAddr.uiAddr = SysPAddr.uiAddr; - + DevPAddr.uiAddr = SysPAddr.uiAddr - 0x40000000; + return DevPAddr; } @@ -947,8 +830,8 @@ IMG_SYS_PHYADDR SysDevPAddrToSysPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PH PVR_UNREFERENCED_PARAMETER(eDeviceType); /* Note: for UMA system we assume DevP == SysP */ - SysPAddr.uiAddr = DevPAddr.uiAddr; - + SysPAddr.uiAddr = DevPAddr.uiAddr + 0x40000000; + return SysPAddr; } @@ -1027,59 +910,11 @@ IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits) PVR_UNREFERENCED_PARAMETER(ui32ClearBits); PVR_UNREFERENCED_PARAMETER(psSysData); #if !defined(NO_HARDWARE) -#if defined(SGX_OCP_NO_INT_BYPASS) - OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQSTATUS_2, 0x1); -#endif /* Flush posted writes */ OSReadHWReg(((PVRSRV_SGXDEV_INFO *)gpsSGXDevNode->pvDevice)->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR); #endif /* defined(NO_HARDWARE) */ } -#if defined(SGX_OCP_NO_INT_BYPASS) -/*! -****************************************************************************** - @Function SysEnableSGXInterrupts - - @Description Enables SGX interrupts - - @Input psSysData - - @Return IMG_VOID - -******************************************************************************/ -IMG_VOID SysEnableSGXInterrupts(SYS_DATA *psSysData) -{ - SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData; - if (SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_ENABLE_LISR) && !SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED)) - { - OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQSTATUS_2, 0x1); - OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQENABLE_SET_2, 0x1); - SYS_SPECIFIC_DATA_SET(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED); - } -} - -/*! -****************************************************************************** - @Function SysDisableSGXInterrupts - - @Description Disables SGX interrupts - - @Input psSysData - - @Return IMG_VOID - -******************************************************************************/ -IMG_VOID SysDisableSGXInterrupts(SYS_DATA *psSysData) -{ - SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData; - - if (SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED)) - { - OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQENABLE_CLR_2, 0x1); - SYS_SPECIFIC_DATA_CLEAR(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED); - } -} -#endif /* defined(SGX_OCP_NO_INT_BYPASS) */ /*! ****************************************************************************** @@ -1152,7 +987,6 @@ PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState) PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState) { PVRSRV_ERROR eError = PVRSRV_OK; - if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D0) { PVR_TRACE(("SysSystemPostPowerState: Entering state D0")); @@ -1217,7 +1051,6 @@ PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, PVRSRV_DEV_POWER_STATE eCurrentPowerState) { PVR_UNREFERENCED_PARAMETER(eCurrentPowerState); - if (ui32DeviceIndex != gui32SGXDeviceID) { return PVRSRV_OK; @@ -1258,7 +1091,6 @@ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, PVRSRV_ERROR eError = PVRSRV_OK; PVR_UNREFERENCED_PARAMETER(eNewPowerState); - if (ui32DeviceIndex != gui32SGXDeviceID) { return eError; @@ -1277,20 +1109,15 @@ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, return eError; } -IMG_VOID SysLockSystemSuspend(IMG_VOID) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock(&gpsSysSpecificData->wake_lock); -#endif -} +#if defined(SYS_SUPPORTS_SGX_IDLE_CALLBACK) -IMG_VOID SysUnlockSystemSuspend(IMG_VOID) +IMG_VOID SysSGXIdleTransition(IMG_BOOL bSGXIdle) { -#if defined(CONFIG_HAS_WAKELOCK) - wake_unlock(&gpsSysSpecificData->wake_lock); -#endif + PVR_DPF((PVR_DBG_MESSAGE, "SysSGXIdleTransition switch to %u", bSGXIdle)); } +#endif /* defined(SYS_SUPPORTS_SGX_IDLE_CALLBACK) */ + /***************************************************************************** @Function SysOEMFunction diff --git a/drivers/gpu/pvr/services4/system/omap3630/sysconfig.h b/drivers/gpu/pvr/services4/system/sunxi/sysconfig.h index 16b40ad24ec..14413119db6 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap3630/sysconfig.h +++ b/drivers/gpu/pvr/services4/system/sunxi/sysconfig.h @@ -1,7 +1,5 @@ /*************************************************************************/ /*! -@Title System Description Header @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved -@Description This header provides system-specific declarations and macros @License Dual MIT/GPLv2 The contents of this file are subject to the MIT license as set out below. @@ -42,14 +40,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if !defined(__SOCCONFIG_H__) #define __SOCCONFIG_H__ +#include <mach/irqs-sun6i.h> +#define VS_PRODUCT_NAME "sunxi" -#define VS_PRODUCT_NAME "OMAP3630" - -#if defined(SGX540) && (SGX_CORE_REV == 120) -#define SYS_SGX_CLOCK_SPEED 307200000 -#else -#define SYS_SGX_CLOCK_SPEED 200000000 -#endif +#define SYS_SGX_CLOCK_SPEED 300000000 +#define SYS_SGX_CORE_CLOCK_SPEED 300000000 +#define SYS_SGX_HYD_CLOCK_SPEED 330000000 #define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100) // 10ms (100hz) #define SYS_SGX_PDS_TIMER_FREQ (1000) // 1ms (1000hz) @@ -60,30 +56,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif -#define SYS_OMAP3630_SGX_REGS_SYS_PHYS_BASE 0x50000000 -#define SYS_OMAP3630_SGX_REGS_SIZE 0x10000 - -#define SYS_OMAP3630_SGX_IRQ 21 - -#define SYS_OMAP3630_DSS_REGS_SYS_PHYS_BASE 0x58000000 -#define SYS_OMAP3630_DSS_REGS_SIZE 0x7000 - -#define SYS_OMAP3630_DSS_HDMI_INTERRUPT_STATUS_REG 0x6028 -#define SYS_OMAP3630_DSS_HDMI_INTERRUPT_ENABLE_REG 0x602c +#define SYS_SUNXI_SGX_REGS_SYS_PHYS_BASE 0x01C40000 +#define SYS_SUNXI_SGX_REGS_SIZE 0xFFFF -#define SYS_OMAP3630_DSS_HDMI_INTERRUPT_VSYNC_ENABLE_MASK 0x10000 -#define SYS_OMAP3630_DSS_HDMI_INTERRUPT_VSYNC_STATUS_MASK 0x10000 - -#define SYS_OMAP3630_DSS_LCD_INTERRUPT_STATUS_REG 0x1018 -#define SYS_OMAP3630_DSS_LCD_INTERRUPT_ENABLE_REG 0x101c - -#define SYS_OMAP3630_DSS_LCD_INTERRUPT_VSYNC_ENABLE_MASK 0x40002 -#define SYS_OMAP3630_DSS_LCD_INTERRUPT_VSYNC_STATUS_MASK 0x40002 - - -#define SYS_OMAP3630_GP11TIMER_ENABLE_SYS_PHYS_BASE 0x48088024 -#define SYS_OMAP3630_GP11TIMER_REGS_SYS_PHYS_BASE 0x48088028 -#define SYS_OMAP3630_GP11TIMER_TSICR_SYS_PHYS_BASE 0x48088040 +#define SYS_SUNXI_SGX_IRQ AW_IRQ_GPU /* IC 129, FPGA 58 SUNXI IRQ's aren't offset by 32 */ /* Interrupt bits */ #define DEVICE_SGX_INTERRUPT (1<<0) @@ -91,15 +67,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DEVICE_DISP_INTERRUPT (1<<2) #if defined(__linux__) -/* - * Recent OMAP4 kernels register SGX as platform device "omap_gpu". - * This device must be used with the Linux power management calls - * in sysutils_linux.c, in order for SGX to be powered on. - */ + #if defined(PVR_LDM_PLATFORM_PRE_REGISTERED_DEV) #define SYS_SGX_DEV_NAME PVR_LDM_PLATFORM_PRE_REGISTERED_DEV #else -#define SYS_SGX_DEV_NAME "omap_gpu" +#define SYS_SGX_DEV_NAME "sunxi_gpu" #endif /* defined(PVR_LDM_PLATFORM_PRE_REGISTERED_DEV) */ #endif /* defined(__linux__) */ diff --git a/drivers/gpu/pvr/services4/system/omap4/sysinfo.h b/drivers/gpu/pvr/services4/system/sunxi/sysinfo.h index 70ae1481b70..d193fde5f96 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/sysinfo.h +++ b/drivers/gpu/pvr/services4/system/sunxi/sysinfo.h @@ -1,7 +1,5 @@ /*************************************************************************/ /*! -@Title System Description Header @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved -@Description This header provides system-specific declarations and macros @License Dual MIT/GPLv2 The contents of this file are subject to the MIT license as set out below. @@ -44,7 +42,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define __SYSINFO_H__ /*!< System specific poll/timeout details */ -#if defined(PVR_LINUX_USING_WORKQUEUES) /* * The workqueue based 3rd party display driver may be blocked for up * to 500ms waiting for a vsync when the screen goes blank, so we @@ -53,10 +50,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define MAX_HW_TIME_US (1000000) #define WAIT_TRY_COUNT (20000) -#else -#define MAX_HW_TIME_US (500000) -#define WAIT_TRY_COUNT (10000) -#endif #define SYS_DEVICE_COUNT 15 /* SGX, DISPLAYCLASS (external), BUFFERCLASS (external) */ diff --git a/drivers/gpu/pvr/services4/system/omap4/syslocal.h b/drivers/gpu/pvr/services4/system/sunxi/syslocal.h index 5fd36b3cf2d..06cc5232e79 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/syslocal.h +++ b/drivers/gpu/pvr/services4/system/sunxi/syslocal.h @@ -1,7 +1,5 @@ /*************************************************************************/ /*! -@Title Local system definitions @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved -@Description This header provides local system declarations and macros @License Dual MIT/GPLv2 The contents of this file are subject to the MIT license as set out below. @@ -47,70 +45,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <linux/version.h> #include <linux/clk.h> -#if defined(PVR_LINUX_USING_WORKQUEUES) #include <linux/mutex.h> -#else -#include <linux/spinlock.h> -#endif #include <asm/atomic.h> -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) #include <linux/semaphore.h> #include <linux/resource.h> -#else /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */ -#include <asm/semaphore.h> -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)) -#include <asm/arch/resource.h> -#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)) */ -#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */ - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) -#if !defined(LDM_PLATFORM) -#error "LDM_PLATFORM must be set" -#endif -#define PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO +#if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) #include <linux/platform_device.h> #endif -#if ((defined(DEBUG) || defined(TIMING)) && \ - (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,34))) && \ - !defined(PVR_NO_OMAP_TIMER) -/* - * We need to explicitly enable the GPTIMER11 clocks, or we'll get an - * abort when we try to access the timer registers. - */ -#define PVR_OMAP4_TIMING_PRCM -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) -#include <plat/gpu.h> -#if !defined(PVR_NO_OMAP_TIMER) -#define PVR_OMAP_USE_DM_TIMER_API -#include <plat/dmtimer.h> -#endif +#if !defined(LDM_PLATFORM) +#error "LDM_PLATFORM must be set" #endif - -#if defined(CONFIG_HAS_WAKELOCK) -#include <linux/wakelock.h> +#if !defined(PVR_LINUX_USING_WORKQUEUES) +#error "PVR_LINUX_USING_WORKQUEUES must be set" #endif -#if !defined(PVR_NO_OMAP_TIMER) -#define PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA -#endif #endif /* defined(__linux__) */ -#if !defined(NO_HARDWARE) && \ - defined(SYS_USING_INTERRUPTS) -#define SGX_OCP_REGS_ENABLED -#endif - -#if defined(__linux__) -#if defined(SGX_OCP_REGS_ENABLED) -#define SGX_OCP_NO_INT_BYPASS -#endif -#endif - #if defined (__cplusplus) extern "C" { #endif @@ -127,7 +80,7 @@ IMG_VOID DisableSystemClocks(SYS_DATA *psSysData); PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData); IMG_VOID DisableSGXClocks(SYS_DATA *psSysData); -PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData); +PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData, IMG_BOOL bNoDev); /* * Various flags to indicate what has been initialised, and what @@ -161,9 +114,6 @@ typedef struct _SYS_SPECIFIC_DATA_TAG_ IMG_UINT32 ui32SysSpecificData; PVRSRV_DEVICE_NODE *psSGXDevNode; IMG_BOOL bSGXInitComplete; -#if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA) - IMG_CPU_PHYADDR sTimerRegPhysBase; -#endif #if !defined(__linux__) IMG_BOOL bSGXClocksEnabled; #endif @@ -171,38 +121,15 @@ typedef struct _SYS_SPECIFIC_DATA_TAG_ #if defined(__linux__) IMG_BOOL bSysClocksOneTimeInit; atomic_t sSGXClocksEnabled; -#if defined(PVR_LINUX_USING_WORKQUEUES) struct mutex sPowerLock; -#else - IMG_BOOL bConstraintNotificationsEnabled; - spinlock_t sPowerLock; - atomic_t sPowerLockCPU; - spinlock_t sNotifyLock; - atomic_t sNotifyLockCPU; - IMG_BOOL bCallVDD2PostFunc; -#endif -#if defined(DEBUG) || defined(TIMING) - struct clk *psGPT11_FCK; - struct clk *psGPT11_ICK; -#endif -#if defined(PVR_OMAP_USE_DM_TIMER_API) - struct omap_dm_timer *psGPTimer; -#endif -#if defined(CONFIG_HAS_WAKELOCK) - struct wake_lock wake_lock; -#endif /* CONFIG_HAS_WAKELOCK */ + IMG_BOOL bPMRuntimeGetSync; #endif /* defined(__linux__) */ } SYS_SPECIFIC_DATA; extern SYS_SPECIFIC_DATA *gpsSysSpecificData; -#if defined(SGX_OCP_REGS_ENABLED) && defined(SGX_OCP_NO_INT_BYPASS) -IMG_VOID SysEnableSGXInterrupts(SYS_DATA* psSysData); -IMG_VOID SysDisableSGXInterrupts(SYS_DATA* psSysData); -#else #define SysEnableSGXInterrupts(psSysData) #define SysDisableSGXInterrupts(psSysData) -#endif #if defined(SYS_CUSTOM_POWERLOCK_WRAP) IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData); @@ -211,12 +138,11 @@ IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData); #if defined(__linux__) -PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData); -PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData); +PVRSRV_ERROR SysPMRuntimeRegister(void); +PVRSRV_ERROR SysPMRuntimeUnregister(void); PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData); PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData); -int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); #else /* defined(__linux__) */ @@ -252,8 +178,6 @@ static INLINE PVRSRV_ERROR SysDvfsDeinitialize(void) return PVRSRV_OK; } -#define pvr_access_process_vm(tsk, addr, buf, len, write) -1 - #endif /* defined(__linux__) */ #if defined(__cplusplus) diff --git a/drivers/gpu/pvr/services4/system/omap4/sysutils.c b/drivers/gpu/pvr/services4/system/sunxi/sysutils.c index 20baad2a7d5..b4c87a76196 100644..100755 --- a/drivers/gpu/pvr/services4/system/omap4/sysutils.c +++ b/drivers/gpu/pvr/services4/system/sunxi/sysutils.c @@ -1,7 +1,5 @@ /*************************************************************************/ /*! -@Title Shared (User/kernel) and System dependent utilities @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved -@Description Provides system-specific functions @License Dual MIT/GPLv2 The contents of this file are subject to the MIT license as set out below. @@ -44,16 +42,4 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(__linux__) #include "sysutils_linux.c" -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) -#include "sgxfreq.c" -#include "sgxfreq_onoff.c" -#include "sgxfreq_activeidle.c" -#include "sgxfreq_on3demand.c" -#include "sgxfreq_userspace.c" -#if defined(CONFIG_THERMAL_FRAMEWORK) -#include "sgxfreq_cool.c" #endif -#endif -#endif - - diff --git a/drivers/gpu/pvr/services4/system/sunxi/sysutils_linux.c b/drivers/gpu/pvr/services4/system/sunxi/sysutils_linux.c new file mode 100755 index 00000000000..f58a7fc4316 --- /dev/null +++ b/drivers/gpu/pvr/services4/system/sunxi/sysutils_linux.c @@ -0,0 +1,509 @@ +/*************************************************************************/ /*! +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /**************************************************************************/ + +#include <linux/version.h> +#include <linux/clk.h> +#include <linux/err.h> +#include <linux/hardirq.h> +#include <linux/mutex.h> +#include <linux/slab.h> + +#include "sgxdefs.h" +#include "services_headers.h" +#include "sysinfo.h" +#include "sgxapi_km.h" +#include "sysconfig.h" +#include "sgxinfokm.h" +#include "syslocal.h" + +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> +#include <mach/hardware.h> +#include <mach/platform.h> +#include <mach/clock.h> + +static struct clk *h_ahb_gpu, *h_gpu_coreclk, *h_gpu_hydclk, *h_gpu_memclk, *h_gpu_hydpll, *h_gpu_corepll; +static struct regulator *gpu_power; + +extern struct platform_device *gpsPVRLDMDev; + +static PVRSRV_ERROR PowerLockWrap(SYS_SPECIFIC_DATA *psSysSpecData, IMG_BOOL bTryLock) +{ + if (!in_interrupt()) + { + if (bTryLock) + { + int locked = mutex_trylock(&psSysSpecData->sPowerLock); + if (locked == 0) + { + return PVRSRV_ERROR_RETRY; + } + } + else + { + mutex_lock(&psSysSpecData->sPowerLock); + } + } + + return PVRSRV_OK; +} + +static IMG_VOID PowerLockUnwrap(SYS_SPECIFIC_DATA *psSysSpecData) +{ + if (!in_interrupt()) + { + mutex_unlock(&psSysSpecData->sPowerLock); + } +} + +PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock) +{ + SYS_DATA *psSysData; + + SysAcquireData(&psSysData); + + return PowerLockWrap(psSysData->pvSysSpecificData, bTryLock); +} + +IMG_VOID SysPowerLockUnwrap(IMG_VOID) +{ + SYS_DATA *psSysData; + + SysAcquireData(&psSysData); + + PowerLockUnwrap(psSysData->pvSysSpecificData); +} + +/* + * This function should be called to unwrap the Services power lock, prior + * to calling any function that might sleep. + * This function shouldn't be called prior to calling EnableSystemClocks + * or DisableSystemClocks, as those functions perform their own power lock + * unwrapping. + * If the function returns IMG_TRUE, UnwrapSystemPowerChange must be + * called to rewrap the power lock, prior to returning to Services. + */ +IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData) +{ + + return IMG_TRUE; +} + +IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData) +{ + +} + +/* + * Return SGX timining information to caller. + */ +IMG_VOID SysGetSGXTimingInformation(SGX_TIMING_INFORMATION *psTimingInfo) +{ +#if !defined(NO_HARDWARE) + PVR_ASSERT(atomic_read(&gpsSysSpecificData->sSGXClocksEnabled) != 0); +#endif + psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; + psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; + psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ; +#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) + psTimingInfo->bEnableActivePM = IMG_TRUE; +#else + psTimingInfo->bEnableActivePM = IMG_FALSE; +#endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ + psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; +} + +/*! +****************************************************************************** + + @Function EnableSGXClocks + + @Description Enable SGX clocks + + @Return PVRSRV_ERROR + +******************************************************************************/ +PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData, IMG_BOOL bNoDev) +{ +#if !defined(NO_HARDWARE) + SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; + + /* SGX clocks already enabled? */ + if (atomic_read(&psSysSpecData->sSGXClocksEnabled) != 0) + { + return PVRSRV_OK; + } + + PVR_DPF((PVR_DBG_MESSAGE, "EnableSGXClocks: Enabling SGX Clocks")); + + /*open clock*/ + if (clk_enable(h_gpu_hydclk)) + { + printk(KERN_ALERT "GPU hyd clk enable failed\n"); + } + if (clk_enable(h_gpu_coreclk)) + { + printk(KERN_ALERT "GPU core clk enable failed\n"); + } + if (clk_enable(h_ahb_gpu)) + { + printk(KERN_ALERT "GPU ahb clk enable failed\n"); + } + if (clk_enable(h_gpu_memclk)) + { + printk(KERN_ALERT "GPU mem clk enable failed\n"); + } + + /* + * pm_runtime_get_sync will fail if called as part of device + * unregistration. + */ + if (!bNoDev) + { + /* + * pm_runtime_get_sync returns 1 after the module has + * been reloaded. + */ + int res = pm_runtime_get_sync(&gpsPVRLDMDev->dev); + if (res < 0) + { + PVR_DPF((PVR_DBG_ERROR, "EnableSGXClocks: pm_runtime_get_sync failed (%d)", -res)); + return PVRSRV_ERROR_UNABLE_TO_ENABLE_CLOCK; + } + psSysSpecData->bPMRuntimeGetSync = IMG_TRUE; + } + + SysEnableSGXInterrupts(psSysData); + + /* Indicate that the SGX clocks are enabled */ + atomic_set(&psSysSpecData->sSGXClocksEnabled, 1); + +#else /* !defined(NO_HARDWARE) */ + PVR_UNREFERENCED_PARAMETER(psSysData); +#endif /* !defined(NO_HARDWARE) */ + return PVRSRV_OK; +} + + +/*! +****************************************************************************** + + @Function DisableSGXClocks + + @Description Disable SGX clocks. + + @Return none + +******************************************************************************/ +IMG_VOID DisableSGXClocks(SYS_DATA *psSysData) +{ +#if !defined(NO_HARDWARE) + SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; + + /* SGX clocks already disabled? */ + if (atomic_read(&psSysSpecData->sSGXClocksEnabled) == 0) + { + return; + } + + PVR_DPF((PVR_DBG_MESSAGE, "DisableSGXClocks: Disabling SGX Clocks")); + + SysDisableSGXInterrupts(psSysData); + + /*close clock*/ + if (NULL == h_gpu_memclk || IS_ERR(h_gpu_memclk)) + { + printk(KERN_CRIT "GPU mem clk handle is invalid\n"); + } + else + { + clk_disable(h_gpu_memclk); + } + if (NULL == h_ahb_gpu || IS_ERR(h_ahb_gpu)) + { + printk(KERN_CRIT "GPU ahb clk handle is invalid\n"); + } + else + { + clk_disable(h_ahb_gpu); + } + if (NULL == h_gpu_coreclk || IS_ERR(h_gpu_coreclk)) + { + printk(KERN_CRIT "GPU core clk handle is invalid\n"); + } + else + { + clk_disable(h_gpu_coreclk); + } + if (NULL == h_gpu_hydclk || IS_ERR(h_gpu_hydclk)) + { + printk(KERN_CRIT "GPU hyd clk handle is invalid\n"); + } + else + { + clk_disable(h_gpu_hydclk); + } + + if (psSysSpecData->bPMRuntimeGetSync) + { + int res = pm_runtime_put_sync(&gpsPVRLDMDev->dev); + if (res < 0) + { + PVR_DPF((PVR_DBG_ERROR, "DisableSGXClocks: pm_runtime_put_sync failed (%d)", -res)); + } + psSysSpecData->bPMRuntimeGetSync = IMG_FALSE; + } + + /* Indicate that the SGX clocks are disabled */ + atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); + +#else /* !defined(NO_HARDWARE) */ + PVR_UNREFERENCED_PARAMETER(psSysData); +#endif /* !defined(NO_HARDWARE) */ +} + +/*! +****************************************************************************** + + @Function EnableSystemClocks + + @Description Setup up the clocks for the graphics device to work. + + @Return PVRSRV_ERROR + +******************************************************************************/ +PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData) +{ + SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; + int pwr_reg; + + PVR_TRACE(("EnableSystemClocks: Enabling System Clocks")); + if (!psSysSpecData->bSysClocksOneTimeInit) + { + /* GPU power setup */ + gpu_power = regulator_get(NULL,"axp22_dcdc2"); + if (IS_ERR(gpu_power)) + { + printk(KERN_ALERT "GPU power setup failed\n"); + } + + /* Set up PLL and clock parents */ + h_gpu_hydpll = clk_get(NULL,CLK_SYS_PLL8); + if (!h_gpu_hydpll || IS_ERR(h_gpu_hydpll)) + { + printk(KERN_ALERT "clk_get of sys_pll8 failed\n"); + } + h_gpu_corepll = clk_get(NULL,CLK_SYS_PLL9); + if (!h_gpu_corepll || IS_ERR(h_gpu_corepll)) + { + printk(KERN_ALERT "clk_get of sys_pll9 failed\n"); + } + h_ahb_gpu = clk_get(NULL, CLK_AHB_GPU); + if (!h_ahb_gpu || IS_ERR(h_ahb_gpu)) + { + printk(KERN_ALERT "clk_get of adb_gpu failed\n"); + } + h_gpu_coreclk = clk_get(NULL, CLK_MOD_GPUCORE); + if (!h_gpu_coreclk || IS_ERR(h_gpu_coreclk)) + { + printk(KERN_ALERT "clk_get of mod_gpucore failed\n"); + } + h_gpu_memclk = clk_get(NULL, CLK_MOD_GPUMEM); + if (!h_gpu_memclk || IS_ERR(h_gpu_memclk)) + { + printk(KERN_ALERT "clk_get of mod_gpumem failed\n"); + } + h_gpu_hydclk = clk_get(NULL, CLK_MOD_GPUHYD); + if (!h_gpu_hydclk || IS_ERR(h_gpu_hydclk)) + { + printk(KERN_ALERT "clk_get of mod_gouhyd failed\n"); + } + + /* Set PLL frequency*/ + if (clk_set_rate(h_gpu_hydpll, SYS_SGX_HYD_CLOCK_SPEED)) + { + printk(KERN_ALERT "clk_set of gpu_hydpll rate %d failed\n", SYS_SGX_HYD_CLOCK_SPEED); + } + if (clk_set_rate(h_gpu_corepll, SYS_SGX_CORE_CLOCK_SPEED)) + { + printk(KERN_ALERT "clk_set of gpu_corepll rate %d failed\n", SYS_SGX_CORE_CLOCK_SPEED); + } + + /* Set clock parents */ + if (clk_set_parent(h_gpu_hydclk, h_gpu_hydpll)) + { + printk(KERN_ALERT "clk_set of gpu_hydclk parent to gpu_hydpll failed\n"); + } + if (clk_set_parent(h_gpu_memclk, h_gpu_hydpll)) + { + printk(KERN_ALERT "clk_set of gpu_memclk parent to gpu_hydpll failed\n"); + } + if (clk_set_parent(h_gpu_coreclk, h_gpu_corepll)) + { + printk(KERN_ALERT "clk_set of gpu_coreclk parent to gpu_corepll failed\n"); + } + + mutex_init(&psSysSpecData->sPowerLock); + + atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); + + psSysSpecData->bSysClocksOneTimeInit = IMG_TRUE; + } + + /* Enable GPU power */ + printk(KERN_DEBUG "GPU power on\n"); + if (regulator_enable(gpu_power)) + { + printk(KERN_ALERT "GPU power on failed\n"); + } + /* GPU power off gating as invalid */ + pwr_reg = readl(IO_ADDRESS(AW_R_PRCM_BASE) + 0x118); + pwr_reg &= (~(0x1)); + writel(pwr_reg, IO_ADDRESS(AW_R_PRCM_BASE) + 0x118); + + OSSleepms(2); + + if (clk_reset(h_gpu_coreclk,AW_CCU_CLK_NRESET)) + { + printk(KERN_ALERT "NRESET of gpu_clk failed\n"); + } + /* Enable PLL, in EnableSystemClocks temporarily */ + if (clk_enable(h_gpu_hydpll)) + { + printk(KERN_ALERT "enable of gpu_hydpll output failed\n"); + } + if (clk_enable(h_gpu_corepll)) + { + printk(KERN_ALERT "enable of gpu_corepll output failed\n"); + } + + return PVRSRV_OK; +} + +/*! +****************************************************************************** + + @Function DisableSystemClocks + + @Description Disable the graphics clocks. + + @Return none + +******************************************************************************/ +IMG_VOID DisableSystemClocks(SYS_DATA *psSysData) +{ + int pwr_reg; + + PVR_TRACE(("DisableSystemClocks: Disabling System Clocks")); + /* + * Always disable the SGX clocks when the system clocks are disabled. + * This saves having to make an explicit call to DisableSGXClocks if + * active power management is enabled. + */ + DisableSGXClocks(psSysData); + + if (clk_reset(h_gpu_coreclk,AW_CCU_CLK_RESET)) + { + printk(KERN_CRIT "RESET of gpu_coreclk failed\n"); + } + + /* Disable PLL, in DisableSystemClocks temporarily */ + if (NULL == h_gpu_hydpll || IS_ERR(h_gpu_hydpll)) + { + printk(KERN_ALERT "gpu_hydpll handle is invalid\n"); + } + else + { + clk_disable(h_gpu_hydpll); + } + if (NULL == h_gpu_corepll || IS_ERR(h_gpu_corepll)) + { + printk(KERN_ALERT "gpu_corepll is invalid\n"); + } + else + { + clk_disable(h_gpu_corepll); + } + + /* GPU power off gating valid */ + pwr_reg = readl(IO_ADDRESS(AW_R_PRCM_BASE) + 0x118); + pwr_reg |= 0x1; + writel(pwr_reg, IO_ADDRESS(AW_R_PRCM_BASE) + 0x118); + + /* GPU power off */ + printk(KERN_DEBUG "GPU power off\n"); + if (regulator_is_enabled(gpu_power)) + { + if (regulator_disable(gpu_power)) + { + printk(KERN_ALERT "GPU power off failed\n"); + } + } +} + +PVRSRV_ERROR SysPMRuntimeRegister(void) +{ + pm_runtime_enable(&gpsPVRLDMDev->dev); + + return PVRSRV_OK; +} + +PVRSRV_ERROR SysPMRuntimeUnregister(void) +{ + pm_runtime_disable(&gpsPVRLDMDev->dev); + + return PVRSRV_OK; +} + +PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData) +{ + PVR_UNREFERENCED_PARAMETER(psSysSpecificData); + + return PVRSRV_OK; +} + +PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData) +{ + PVR_UNREFERENCED_PARAMETER(psSysSpecificData); + + return PVRSRV_OK; +} + diff --git a/drivers/gpu/pvr/tools/intern/debug/client/linuxsrv.h b/drivers/gpu/pvr/tools/intern/debug/client/linuxsrv.h index d9fd825326e..d9fd825326e 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/client/linuxsrv.h +++ b/drivers/gpu/pvr/tools/intern/debug/client/linuxsrv.h diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Kbuild.mk b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Kbuild.mk index e1e8868f8c0..e1e8868f8c0 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Kbuild.mk +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Kbuild.mk diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Linux.mk b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Linux.mk index e0508796b02..e0508796b02 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Linux.mk +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/Linux.mk diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.c b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.c index 0b8d445ca00..848367ad6d0 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.c +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.c @@ -934,7 +934,7 @@ static IMG_UINT32 WriteExpandingBuffer(PDBG_STREAM psStream,IMG_UINT8 * pui8InBu */ if ((psStream->psCtrl->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) == 0) { - PVR_DPF((PVR_DBG_ERROR, "WriteExpandingBuffer: buffer %x is disabled", (IMG_UINTPTR_T) psStream)); + PVR_DPF((PVR_DBG_ERROR, "WriteExpandingBuffer: buffer %p is disabled", psStream)); return(0); } @@ -949,7 +949,7 @@ static IMG_UINT32 WriteExpandingBuffer(PDBG_STREAM psStream,IMG_UINT8 * pui8InBu */ if (ui32Space < 32) { - PVR_DPF((PVR_DBG_ERROR, "WriteExpandingBuffer: buffer %x is full and isn't expandable", (IMG_UINTPTR_T) psStream)); + PVR_DPF((PVR_DBG_ERROR, "WriteExpandingBuffer: buffer %p is full and isn't expandable", psStream)); return(0); } } @@ -986,7 +986,7 @@ static IMG_UINT32 WriteExpandingBuffer(PDBG_STREAM psStream,IMG_UINT8 * pui8InBu else { /* out of memory */ - PVR_DPF((PVR_DBG_ERROR, "WriteExpandingBuffer: Unable to expand %x. Out of memory.", (IMG_UINTPTR_T) psStream)); + PVR_DPF((PVR_DBG_ERROR, "WriteExpandingBuffer: Unable to expand %p. Out of memory.", psStream)); InvalidateAllStreams(); return (0xFFFFFFFFUL); } @@ -1815,13 +1815,13 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWrite(PDBG_STREAM psMainStream,IMG_UINT8 * pui8In */ if ((psStream->psCtrl->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) == 0) { - PVR_DPF((PVR_DBG_ERROR, "DBGDrivWrite: buffer %x is disabled", (IMG_UINTPTR_T) psStream)); + PVR_DPF((PVR_DBG_ERROR, "DBGDrivWrite: buffer %p is disabled", psStream)); return(0); } if (ui32Space < 8) { - PVR_DPF((PVR_DBG_ERROR, "DBGDrivWrite: buffer %x is full", (IMG_UINTPTR_T) psStream)); + PVR_DPF((PVR_DBG_ERROR, "DBGDrivWrite: buffer %p is full", psStream)); return(0); } @@ -2002,7 +2002,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivRead(PDBG_STREAM psMainStream, IMG_BOOL bReadInit */ if (!StreamValidForRead(psMainStream)) { - PVR_DPF((PVR_DBG_ERROR, "DBGDrivRead: buffer %x is invalid", (IMG_UINTPTR_T) psMainStream)); + PVR_DPF((PVR_DBG_ERROR, "DBGDrivRead: buffer %p is invalid", psMainStream)); return(0); } diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.h b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.h index d58c62d0c6a..e56d88112b0 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.h +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv.h @@ -51,7 +51,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define MAX_PROCESSES 2 #define BLOCK_USED 0x01 #define BLOCK_LOCKED 0x02 -#define DBGDRIV_MONOBASE 0x000B0000 +#define DBGDRIV_MONOBASE 0x000B0000UL extern IMG_VOID * g_pvAPIMutex; diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv_ioctl.h b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv_ioctl.h index 0909e6de6f3..0909e6de6f3 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv_ioctl.h +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/dbgdriv_ioctl.h diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/handle.c b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/handle.c index a9d37a6cf0f..a9d37a6cf0f 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/handle.c +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/handle.c diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hostfunc.h b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hostfunc.h index e92ad9a1f01..e92ad9a1f01 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hostfunc.h +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hostfunc.h diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.c b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.c index 6bf20a6c307..6bf20a6c307 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.c +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.c diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.h b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.h index 7aa29525753..7aa29525753 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.h +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/hotkey.h diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/ioctl.c b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/ioctl.c index 1767a9b2a19..1767a9b2a19 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/ioctl.c +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/common/ioctl.c diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/hostfunc.c b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/hostfunc.c index 5d5e9ef1a48..5d5e9ef1a48 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/hostfunc.c +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/hostfunc.c diff --git a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/main.c b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/main.c index c1ca85b6333..b35cac40217 100644..100755 --- a/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/main.c +++ b/drivers/gpu/pvr/tools/intern/debug/dbgdriv/linux/main.c @@ -61,7 +61,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(SUPPORT_DRI_DRM) #include "drmP.h" -#include "drm.h" #endif #include "img_types.h" |