summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGowtham Tammana2016-06-20 18:08:36 -0500
committerGowtham Tammana2016-06-21 10:08:34 -0500
commit34ed80f505fea5d81a895c554312f9918de82ec9 (patch)
tree373271c66a211e336bad3546ddd4042553bd3689 /jacinto6
parenta963c5d6bd49269a81d83ce1122a507f3768beaf (diff)
downloaddevice-ti-proprietary-open-34ed80f505fea5d81a895c554312f9918de82ec9.tar.gz
device-ti-proprietary-open-34ed80f505fea5d81a895c554312f9918de82ec9.tar.xz
device-ti-proprietary-open-34ed80f505fea5d81a895c554312f9918de82ec9.zip
jacinto6: sgx-bin: bins and src update for ddk1.14
Updating SGX binaries and KM source update for DDK1.14 on k4.4 Change-Id: Ie51645aa42e31c620f2e50cdb1efd570a1ef7227 Signed-off-by: Gowtham Tammana <g-tammana@ti.com>
Diffstat (limited to 'jacinto6')
-rw-r--r--jacinto6/README.SGX10
-rw-r--r--jacinto6/sgx.tgzbin2922163 -> 3120633 bytes
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/buildvars.mk3
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/commands.mk24
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/arch_common.mk29
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/extra_config.mk19
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/features.mk143
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/paths.mk2
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/platform_version.mk134
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/apis/xorg.mk14
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/dridrm.mk17
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg.mk8
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg_test.mk25
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/config/core.mk61
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/defs.mk5
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/moduledefs.mk6
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/modules.mk1
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_android/Makefile39
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_linux/Makefile113
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/sunxi_android/Makefile4
-rw-r--r--jacinto6/sgx_src/eurasia_km/include4/img_defs.h4
-rw-r--r--jacinto6/sgx_src/eurasia_km/include4/pvr_debug.h71
-rw-r--r--jacinto6/sgx_src/eurasia_km/include4/pvrversion.h16
-rw-r--r--jacinto6/sgx_src/eurasia_km/include4/services.h72
-rw-r--r--jacinto6/sgx_src/eurasia_km/include4/servicesext.h16
-rw-r--r--jacinto6/sgx_src/eurasia_km/include4/sgxapi_km.h15
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c23
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c9
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c20
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/ion_sys_private.h50
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/kerneldisplay.h12
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge.h97
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge_km.h28
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/servicesint.h13
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/sgx_mkif_km.h16
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/sgx_ukernel_status_codes.h5
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/include/sgxinfo.h14
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.c301
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c64
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/buffer_manager.c144
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/deviceclass.c94
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/devicemem.c637
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/handle.c4
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/hash.c3
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pdump_common.c57
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pvrsrv.c68
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/queue.c140
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/ra.c15
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c97
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/common/resman.c6
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/mmu.c108
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxconfig.h188
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinfokm.h15
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinit.c45
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxkick.c225
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxpower.c52
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxreset.c6
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxtransfer.c57
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxutils.c23
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/Kbuild.mk13
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.c460
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.h27
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.c135
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.h4
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/linkage.h2
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/lma_heap_ion.h45
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.c153
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.h14
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mmap.c12
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/module.c73
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c13
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.h12
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osfunc.c146
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osperproc.c6
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_debug.c11
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.c111
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.h12
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.c1371
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.h71
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_sync.c105
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxdefs.h4
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxerrata.h24
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxfeaturedefs.h11
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/buffer_manager.h45
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/dmabuf_sync.h69
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/ion_sync.h (renamed from jacinto6/sgx_src/eurasia_km/services4/srvkm/include/external_sync.h)24
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/osfunc.h15
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/refcount.h83
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/resman.h2
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/include/srvkm.h2
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap/sgxfreq.c24
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap/sysconfig.h4
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap/syslocal.h9
-rw-r--r--jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.c52
-rw-r--r--jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.h2
-rw-r--r--jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/linux/main.c1
96 files changed, 4837 insertions, 1817 deletions
diff --git a/jacinto6/README.SGX b/jacinto6/README.SGX
index 5ec452a..639da2c 100644
--- a/jacinto6/README.SGX
+++ b/jacinto6/README.SGX
@@ -1,7 +1,7 @@
1/* 1/*
2 * TECHNOLOGY AND SOFTWARE PUBLICLY AVAILABLE 2 * TECHNOLOGY AND SOFTWARE PUBLICLY AVAILABLE
3 * 3 *
4 * Copyright (c) 2011, Texas Instruments Incorporated. 4 * Copyright (c) 2016, Texas Instruments Incorporated.
5 * 5 *
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -14,11 +14,11 @@
14sgx.tgz a set of binaries built for SGX544. 14sgx.tgz a set of binaries built for SGX544.
15 15
16[DDK Version] 16[DDK Version]
17 1.12/2917986 17 1.14/4001660
18[DDK commit ID] 18[DDK commit ID]
19 ab0b57a tmp: Disable DVFS and SYNC for kernel 4.4 19 036d7d2 (HACK) SGX-UM: Copy pvrsrvctl as pvrsrvinit
20[Branch] 20[Branch]
21 android/1.12/2917986_k4.4 21 android/1.14/4001660_k4.4_M
22[Kernel modules built against] 22[Kernel modules built against]
23 Kernel Version: 4.4.y with CONFIG_MODVERSIONS=y 23 Kernel Version: 4.4.y with CONFIG_MODVERSIONS=y
24[Build type] 24[Build type]
@@ -35,7 +35,7 @@ Make sure kernel is built before building modules
35# export KERNELDIR=path_to_kernel 35# export KERNELDIR=path_to_kernel
36# export PATH=<path to kernel toolchain>:$PATH 36# export PATH=<path to kernel toolchain>:$PATH
37 37
38To build for OMAP5 (SGX 544 multi core): 38To build for Jacinto6 (SGX 544 multi core):
39# make ARCH=arm KERNEL_CROSS_COMPILE=arm-eabi- CROSS_COMPILE=arm-eabi- TARGET_PRODUCT="jacinto6evm" BUILD=release 39# make ARCH=arm KERNEL_CROSS_COMPILE=arm-eabi- CROSS_COMPILE=arm-eabi- TARGET_PRODUCT="jacinto6evm" BUILD=release
40 40
41Once the .ko is built, install it onto device (/system/lib/modules) 41Once the .ko is built, install it onto device (/system/lib/modules)
diff --git a/jacinto6/sgx.tgz b/jacinto6/sgx.tgz
index e25233e..5f9cd9f 100644
--- a/jacinto6/sgx.tgz
+++ b/jacinto6/sgx.tgz
Binary files differ
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/buildvars.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/buildvars.mk
index ce0608c..b93243b 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/buildvars.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/buildvars.mk
@@ -76,7 +76,7 @@ COMMON_USER_FLAGS += -fno-strict-aliasing
76# We always enable debugging. Either the release binaries are stripped 76# We always enable debugging. Either the release binaries are stripped
77# and the symbols put in the symbolpackage, or we're building debug. 77# and the symbols put in the symbolpackage, or we're building debug.
78# 78#
79COMMON_USER_FLAGS += -g 79COMMON_USER_FLAGS += -g $(ANDROID_FPGA_FORCE_32BIT)
80 80
81# User C and User C++ warning flags 81# User C and User C++ warning flags
82# 82#
@@ -167,6 +167,7 @@ TESTED_KBUILD_FLAGS := \
167 $(call kernel-cc-option,-Wno-pointer-arith) \ 167 $(call kernel-cc-option,-Wno-pointer-arith) \
168 $(call kernel-cc-option,-Wno-aggregate-return) \ 168 $(call kernel-cc-option,-Wno-aggregate-return) \
169 $(call kernel-cc-option,-Wno-unused-but-set-variable) \ 169 $(call kernel-cc-option,-Wno-unused-but-set-variable) \
170 $(call kernel-cc-option,-Wno-old-style-declaration) \
170 $(call kernel-cc-optional-warning,-Wbad-function-cast) \ 171 $(call kernel-cc-optional-warning,-Wbad-function-cast) \
171 $(call kernel-cc-optional-warning,-Wcast-qual) \ 172 $(call kernel-cc-optional-warning,-Wcast-qual) \
172 $(call kernel-cc-optional-warning,-Wcast-align) \ 173 $(call kernel-cc-optional-warning,-Wcast-align) \
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/commands.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/commands.mk
index 093bb1c..ab7a0e9 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/commands.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/commands.mk
@@ -88,7 +88,7 @@ endef
88define target-executable-from-o 88define target-executable-from-o
89$(if $(V),,@echo " LD " $(call relative-to-top,$@)) 89$(if $(V),,@echo " LD " $(call relative-to-top,$@))
90$(CC) \ 90$(CC) \
91 $(SYS_EXE_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \ 91 $(SYS_EXE_LDFLAGS) $(SYS_COMMON_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \
92 $(SYS_EXE_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_EXE_CRTEND) \ 92 $(SYS_EXE_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_EXE_CRTEND) \
93 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC) 93 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC)
94endef 94endef
@@ -96,7 +96,7 @@ endef
96define target-executable-cxx-from-o 96define target-executable-cxx-from-o
97$(if $(V),,@echo " LD " $(call relative-to-top,$@)) 97$(if $(V),,@echo " LD " $(call relative-to-top,$@))
98$(CXX) \ 98$(CXX) \
99 $(SYS_EXE_LDFLAGS_CXX) $(SYS_EXE_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \ 99 $(SYS_EXE_LDFLAGS_CXX) $(SYS_EXE_LDFLAGS) $(SYS_COMMON_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \
100 $(SYS_EXE_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_EXE_CRTEND) \ 100 $(SYS_EXE_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_EXE_CRTEND) \
101 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC) 101 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC)
102endef 102endef
@@ -104,7 +104,7 @@ endef
104define target-shared-library-from-o 104define target-shared-library-from-o
105$(if $(V),,@echo " LD " $(call relative-to-top,$@)) 105$(if $(V),,@echo " LD " $(call relative-to-top,$@))
106$(CC) -shared -Wl,-Bsymbolic \ 106$(CC) -shared -Wl,-Bsymbolic \
107 $(SYS_LIB_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \ 107 $(SYS_LIB_LDFLAGS) $(SYS_COMMON_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \
108 $(SYS_LIB_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_LIB_CRTEND) \ 108 $(SYS_LIB_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_LIB_CRTEND) \
109 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC) 109 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC)
110endef 110endef
@@ -114,7 +114,7 @@ endef
114define target-shared-library-cxx-from-o 114define target-shared-library-cxx-from-o
115$(if $(V),,@echo " LD " $(call relative-to-top,$@)) 115$(if $(V),,@echo " LD " $(call relative-to-top,$@))
116$(CXX) -shared -Wl,-Bsymbolic \ 116$(CXX) -shared -Wl,-Bsymbolic \
117 $(SYS_LIB_LDFLAGS_CXX) $(SYS_LIB_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \ 117 $(SYS_LIB_LDFLAGS_CXX) $(SYS_LIB_LDFLAGS) $(SYS_COMMON_LDFLAGS) $(MODULE_LDFLAGS) -o $@ \
118 $(SYS_LIB_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_LIB_CRTEND) \ 118 $(SYS_LIB_CRTBEGIN) $(sort $(MODULE_ALL_OBJECTS)) $(SYS_LIB_CRTEND) \
119 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC) 119 $(MODULE_LIBRARY_DIR_FLAGS) $(MODULE_LIBRARY_FLAGS) $(LIBGCC)
120endef 120endef
@@ -183,7 +183,11 @@ define make-directory
183$(MKDIR) -p $@ 183$(MKDIR) -p $@
184endef 184endef
185 185
186define check-exports-from-file
187endef
188
186define check-exports 189define check-exports
190$(call check-exports-from-file,$(if $1,$1,$(notdir $@).txt))
187endef 191endef
188 192
189# Programs used in recipes 193# Programs used in recipes
@@ -197,6 +201,7 @@ JAR ?= jar
197JAVA ?= java 201JAVA ?= java
198JAVAC ?= javac 202JAVAC ?= javac
199ZIP ?= zip 203ZIP ?= zip
204PKG_CONFIG ?= pkg-config
200 205
201ifeq ($(USE_CCACHE),1) 206ifeq ($(USE_CCACHE),1)
202CCACHE ?= ccache 207CCACHE ?= ccache
@@ -228,10 +233,10 @@ override CC := $(if $(V),,@)$(CCACHE) $(CC)
228override CXX := $(if $(V),,@)$(CCACHE) $(CXX) 233override CXX := $(if $(V),,@)$(CCACHE) $(CXX)
229endif 234endif
230 235
231override AR := $(if $(V),,@)$(CROSS_COMPILE)ar 236override AR := $(if $(V),,@)$(CROSS_COMPILE)ar
232override BISON := $(if $(V),,@)$(BISON) 237override BISON := $(if $(V),,@)$(BISON)
233override BZIP2 := $(if $(V),,@)bzip2 -9 238override BZIP2 := $(if $(V),,@)bzip2 -9
234override CP := $(if $(V),,@)cp 239override CP := $(if $(V),,@)cp
235override ECHO := $(if $(V),,@)echo 240override ECHO := $(if $(V),,@)echo
236override FLEX := $(if $(V),,@)flex 241override FLEX := $(if $(V),,@)flex
237override GAWK := $(if $(V),,@)gawk 242override GAWK := $(if $(V),,@)gawk
@@ -244,13 +249,14 @@ override INSTALL := $(if $(V),,@)install
244override JAR := $(if $(V),,@)$(JAR) 249override JAR := $(if $(V),,@)$(JAR)
245override JAVA := $(if $(V),,@)$(JAVA) 250override JAVA := $(if $(V),,@)$(JAVA)
246override JAVAC := $(if $(V),,@)$(JAVAC) 251override JAVAC := $(if $(V),,@)$(JAVAC)
247override M4 := $(if $(V),,@)m4 252override LN := $(if $(V),,@)ln -f
253override M4 := $(if $(V),,@)m4
248override MKDIR := $(if $(V),,@)mkdir 254override MKDIR := $(if $(V),,@)mkdir
249override MV := $(if $(V),,@)mv 255override MV := $(if $(V),,@)mv
250override OBJCOPY := $(if $(V),,@)$(CROSS_COMPILE)objcopy 256override OBJCOPY := $(if $(V),,@)$(CROSS_COMPILE)objcopy
251override PDSASM := $(if $(V),,@)$(HOST_OUT)/pdsasm 257override PDSASM := $(if $(V),,@)$(HOST_OUT)/pdsasm
252override RANLIB := $(if $(V),,@)$(CROSS_COMPILE)ranlib 258override RANLIB := $(if $(V),,@)$(CROSS_COMPILE)ranlib
253override RM := $(if $(V),,@)rm -f 259override RM := $(if $(V),,@)rm -f
254override SED := $(if $(V),,@)sed 260override SED := $(if $(V),,@)sed
255override STRIP := $(if $(V),,@)$(CROSS_COMPILE)strip 261override STRIP := $(if $(V),,@)$(CROSS_COMPILE)strip
256override TAR := $(if $(V),,@)tar 262override TAR := $(if $(V),,@)tar
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/arch_common.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/arch_common.mk
index d658679..bf3fe11 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/arch_common.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/arch_common.mk
@@ -56,23 +56,40 @@ SYS_CFLAGS := \
56SYS_INCLUDES := \ 56SYS_INCLUDES := \
57 -isystem $(ANDROID_ROOT)/bionic/libc/arch-$(ANDROID_ARCH)/include \ 57 -isystem $(ANDROID_ROOT)/bionic/libc/arch-$(ANDROID_ARCH)/include \
58 -isystem $(ANDROID_ROOT)/bionic/libc/include \ 58 -isystem $(ANDROID_ROOT)/bionic/libc/include \
59 -isystem $(ANDROID_ROOT)/bionic/libc/kernel/common \ 59 -isystem $(ANDROID_ROOT)/bionic/libc/kernel/uapi \
60 -isystem $(ANDROID_ROOT)/bionic/libc/kernel/arch-$(ANDROID_ARCH) \ 60 -isystem $(ANDROID_ROOT)/bionic/libc/kernel/uapi/asm-$(ANDROID_ARCH) \
61 -isystem $(ANDROID_ROOT)/bionic/libm/include \ 61 -isystem $(ANDROID_ROOT)/bionic/libm/include \
62 -isystem $(ANDROID_ROOT)/bionic/libm/include/$(ANDROID_ARCH) \ 62 -isystem $(ANDROID_ROOT)/bionic/libm/include/$(ANDROID_ARCH) \
63 -isystem $(ANDROID_ROOT)/bionic/libthread_db/include \ 63 -isystem $(ANDROID_ROOT)/bionic/libthread_db/include \
64 -isystem $(ANDROID_ROOT)/external/libunwind/include \
64 -isystem $(ANDROID_ROOT)/frameworks/base/include \ 65 -isystem $(ANDROID_ROOT)/frameworks/base/include \
65 -isystem $(ANDROID_ROOT)/system/core/include \
66 -isystem $(ANDROID_ROOT)/hardware/libhardware/include \ 66 -isystem $(ANDROID_ROOT)/hardware/libhardware/include \
67 -isystem $(ANDROID_ROOT)/external/openssl/include \ 67 -isystem $(ANDROID_ROOT)/hardware/libhardware_legacy/include \
68 -isystem $(ANDROID_ROOT)/system/core/include \
69 -isystem $(ANDROID_ROOT)/system/core/libsync/include \
68 -isystem $(ANDROID_ROOT)/system/media/camera/include \ 70 -isystem $(ANDROID_ROOT)/system/media/camera/include \
69 -isystem $(ANDROID_ROOT)/hardware/libhardware_legacy/include 71 -isystem $(ANDROID_ROOT)/external/libdrm \
72 -isystem $(ANDROID_ROOT)/external/libdrm/include/drm
73
74ifneq ($(wildcard $(ANDROID_ROOT)/external/boringssl/src/include),)
75SYS_INCLUDES += \
76 -isystem $(ANDROID_ROOT)/external/boringssl/src/include
77else
78SYS_INCLUDES += \
79 -isystem $(ANDROID_ROOT)/external/openssl/include
80endif
81
82# Obsolete libc includes
83SYS_INCLUDES += \
84 -isystem $(ANDROID_ROOT)/bionic/libc/kernel/common \
85 -isystem $(ANDROID_ROOT)/bionic/libc/kernel/arch-$(ANDROID_ARCH)
70 86
71# This is comparing PVR_BUILD_DIR to see if it is omap and adding 87# This is comparing PVR_BUILD_DIR to see if it is omap and adding
72# includes required for it's HWC 88# includes required for it's HWC
73ifeq ($(notdir $(abspath .)),omap_android) 89ifeq ($(notdir $(abspath .)),omap_android)
74SYS_INCLUDES += \ 90SYS_INCLUDES += \
75 -isystem $(ANDROID_ROOT)/hardware/ti/omap4xxx/kernel-headers 91 -isystem $(ANDROID_ROOT)/hardware/ti/omap4xxx/kernel-headers \
92 -isystem $(ANDROID_ROOT)/hardware/ti/omap4xxx/ion
76endif 93endif
77 94
78ifeq ($(_CLANG),true) 95ifeq ($(_CLANG),true)
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/extra_config.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/extra_config.mk
index bb47c8d..b8b97e2 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/extra_config.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/extra_config.mk
@@ -39,8 +39,14 @@
39### ########################################################################### 39### ###########################################################################
40 40
41 41
42$(eval $(call BothConfigC,ANDROID,)) 42# On versions of Android prior to L, remap the use of libc++ to a combination
43# of stlport and libstdc++. Not every module written in C++ in the DDK needs
44# the STL, but linking it should be harmless (and most modules do need it).
45ifneq ($(is_at_least_lollipop),1)
46endif
47
43 48
49$(eval $(call BothConfigC,ANDROID,))
44 50
45 51
46 52
@@ -51,4 +57,15 @@ $(eval $(call TunableBothConfigMake,SUPPORT_PVRSRV_ANDROID_SYSTRACE,))
51$(eval $(call TunableBothConfigMake,PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC,)) 57$(eval $(call TunableBothConfigMake,PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC,))
52$(eval $(call TunableBothConfigC,PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC,)) 58$(eval $(call TunableBothConfigC,PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC,))
53 59
60ifeq ($(NO_HARDWARE),1)
61 override PVR_ANDROID_COMPOSERHAL := null
62endif
63
64ifneq ($(PVR_ANDROID_COMPOSERHAL),drm)
65 ifneq ($(SUPPORT_PVRSRV_DEVICE_CLASS),1)
66 override PVR_ANDROID_COMPOSERHAL := null
67 endif
68endif
69
70
54include ../common/ion.mk 71include ../common/ion.mk
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/features.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/features.mk
index 7697f13..68e8132 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/features.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/features.mk
@@ -44,6 +44,7 @@ include ../common/android/platform_version.mk
44# 44#
45SUPPORT_ANDROID_PLATFORM := 1 45SUPPORT_ANDROID_PLATFORM := 1
46SUPPORT_OPENGLES1_V1_ONLY := 1 46SUPPORT_OPENGLES1_V1_ONLY := 1
47DONT_USE_SONAMES := 1
47 48
48# Meminfo IDs are required for buffer stamps 49# Meminfo IDs are required for buffer stamps
49# 50#
@@ -51,8 +52,8 @@ SUPPORT_MEMINFO_IDS := 1
51 52
52# Enable services ion support by default 53# Enable services ion support by default
53# 54#
54SUPPORT_ION := 0 55SUPPORT_ION ?= 0
55SUPPORT_DRM_GEM := 1 56SUPPORT_DMABUF := 1
56 57
57# Need multi-process support in PDUMP 58# Need multi-process support in PDUMP
58# 59#
@@ -101,6 +102,14 @@ SUPPORT_LARGE_GENERAL_HEAP := 1
101# 102#
102PVR_LINUX_MEM_AREA_POOL_MAX_PAGES ?= 5400 103PVR_LINUX_MEM_AREA_POOL_MAX_PAGES ?= 5400
103 104
105# Unless overridden by the user, assume the RenderScript Compute API level
106# matches that of the SDK API_LEVEL.
107#
108RSC_API_LEVEL ?= $(API_LEVEL)
109ifneq ($(findstring $(RSC_API_LEVEL),21 22),)
110RSC_API_LEVEL := 20
111endif
112
104############################################################################## 113##############################################################################
105# Framebuffer target extension is used to find configs compatible with 114# Framebuffer target extension is used to find configs compatible with
106# the framebuffer (added in JB MR1). 115# the framebuffer (added in JB MR1).
@@ -112,18 +121,10 @@ EGL_EXTENSION_ANDROID_FRAMEBUFFER_TARGET := 1
112# 121#
113UNITTEST_INCLUDES := \ 122UNITTEST_INCLUDES := \
114 eurasiacon/android \ 123 eurasiacon/android \
115 $(ANDROID_ROOT)/frameworks/base/native/include 124 $(ANDROID_ROOT)/frameworks/base/native/include \
116
117ifeq ($(is_at_least_jellybean),1)
118UNITTEST_INCLUDES += \
119 $(ANDROID_ROOT)/frameworks/native/include \ 125 $(ANDROID_ROOT)/frameworks/native/include \
120 $(ANDROID_ROOT)/frameworks/native/opengl/include \ 126 $(ANDROID_ROOT)/frameworks/native/opengl/include \
121 $(ANDROID_ROOT)/libnativehelper/include/nativehelper 127 $(ANDROID_ROOT)/libnativehelper/include/nativehelper
122else
123UNITTEST_INCLUDES += \
124 $(ANDROID_ROOT)/frameworks/base/opengl/include \
125 $(ANDROID_ROOT)/dalvik/libnativehelper/include/nativehelper
126endif
127 128
128# But it doesn't have OpenVG headers 129# But it doesn't have OpenVG headers
129# 130#
@@ -140,12 +141,21 @@ DEMO_DESTDIR := /system/vendor/bin
140EGL_DESTDIR := $(SHLIB_DESTDIR)/egl 141EGL_DESTDIR := $(SHLIB_DESTDIR)/egl
141 142
142############################################################################## 143##############################################################################
143# We can support OpenCL in the build since Froyo (stlport was added in 2.2) 144# In K and older, augment the libstdc++ includes with stlport includes. Any
145# part of the C++ library not implemented by stlport will be handled by
146# linking in libstdc++ too (see extra_config.mk).
147#
148# On L and newer, don't use stlport OR libstdc++ at all; just use libc++.
144# 149#
145SYS_CXXFLAGS := -fuse-cxa-atexit $(SYS_CFLAGS) 150SYS_CXXFLAGS := -fuse-cxa-atexit $(SYS_CFLAGS)
151ifeq ($(is_at_least_lollipop),1)
152SYS_INCLUDES += \
153 -isystem $(ANDROID_ROOT)/external/libcxx/include
154else
146SYS_INCLUDES += \ 155SYS_INCLUDES += \
147 -isystem $(ANDROID_ROOT)/bionic \ 156 -isystem $(ANDROID_ROOT)/bionic \
148 -isystem $(ANDROID_ROOT)/external/stlport/stlport 157 -isystem $(ANDROID_ROOT)/external/stlport/stlport
158endif
149 159
150############################################################################## 160##############################################################################
151# Support the OES_EGL_image_external extensions in the client drivers. 161# Support the OES_EGL_image_external extensions in the client drivers.
@@ -167,122 +177,79 @@ EGL_EXTENSION_ANDROID_RECORDABLE := 1
167EGL_EXTENSION_ANDROID_BLOB_CACHE := 1 177EGL_EXTENSION_ANDROID_BLOB_CACHE := 1
168 178
169############################################################################## 179##############################################################################
170# ICS and earlier should rate-limit composition by waiting for 3D renders
171# to complete in the compositor's eglSwapBuffers().
172#
173ifeq ($(is_at_least_jellybean),0)
174PVR_ANDROID_COMPOSITOR_WAIT_FOR_RENDER := 1
175endif
176
177##############################################################################
178# JB added a new corkscrew API for userland backtracing. 180# JB added a new corkscrew API for userland backtracing.
179# 181#
180ifeq ($(is_at_least_jellybean),1) 182ifeq ($(is_at_least_lollipop),0)
181PVR_ANDROID_HAS_CORKSCREW_API := 1 183PVR_ANDROID_HAS_CORKSCREW_API := 1
182endif 184endif
183 185
184############################################################################## 186##############################################################################
185# JB MR1 makes the framebuffer HAL obsolete.
186#
187# We also need to support IMPLEMENTATION_DEFINED so gralloc allocates
188# framebuffers and GPU buffers in a 'preferred' format.
189#
190ifeq ($(is_at_least_jellybean_mr1),0)
191SUPPORT_ANDROID_FRAMEBUFFER_HAL := 1
192else
193PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED := 1
194endif
195
196##############################################################################
197# JB MR1 introduces cross-process syncs associated with a fd. 187# JB MR1 introduces cross-process syncs associated with a fd.
198# This requires a new enough kernel version to have the base/sync driver. 188# This requires a new enough kernel version to have the base/sync driver.
199# 189#
200ifeq ($(is_at_least_jellybean_mr1),1) 190EGL_EXTENSION_ANDROID_NATIVE_FENCE_SYNC ?= 1
201EGL_EXTENSION_ANDROID_NATIVE_FENCE_SYNC := 0 191PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC ?= 1
202PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC := 0
203endif
204 192
205############################################################################## 193##############################################################################
206# JB MR1 introduces new usage bits for the camera HAL and some new formats. 194# Versions of Android between Cupcake and KitKat MR1 required Java 6.
207# 195#
208ifeq ($(is_at_least_jellybean_mr1),1) 196ifeq ($(is_at_least_lollipop),0)
209PVR_ANDROID_HAS_GRALLOC_USAGE_HW_CAMERA := 1 197LEGACY_USE_JAVA6 ?= 1
210PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_RAW_SENSOR := 1
211PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_BLOB := 1
212endif 198endif
213 199
214############################################################################## 200##############################################################################
215# JB MR2 adds a new graphics HAL (gralloc) API function, lock_ycbcr(), and 201# Versions of Android between ICS and KitKat MR1 used ion .heap_mask instead
216# a so-called "flexible" YUV format enum. 202# of .heap_id_mask.
217# 203#
218ifeq ($(is_at_least_jellybean_mr2),1) 204ifeq ($(is_at_least_lollipop),0)
219PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_YCbCr_420_888 := 1 205PVR_ANDROID_HAS_ION_FIELD_HEAP_MASK := 1
220PVR_ANDROID_GRALLOC_HAS_0_2_FEATURES := 1
221endif 206endif
222 207
223############################################################################## 208##############################################################################
224# In JB MR2 we can use a native helper library for the unittest wrapper. 209# Lollipop supports 64-bit. Configure BCC to emit both 32-bit and 64-bit LLVM
225# In earlier versions, we must use a less ideal approach. 210# bitcode in the renderscript driver.
226#
227ifeq ($(is_at_least_jellybean_mr2),0)
228PVR_ANDROID_SURFACE_FIELD_NAME := \"mNativeSurface\"
229endif
230
231##############################################################################
232# JB MR2 introduces two new camera HAL formats (Y8, Y16)
233#
234ifeq ($(is_at_least_jellybean_mr2),1)
235PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_Y8 := 1
236PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_Y16 := 1
237endif
238
239##############################################################################
240# KK's EGL wrapper remaps EGLConfigs in the BGRA and BGRX formats to RGBA and
241# RGBX respectively, for CpuConsumer compatibility. It does this because the
242# usage bits for the gralloc allocation are not available to EGL.
243#
244# In this newer platform version, gralloc has been redefined to allow the
245# 'format' parameter to gralloc->alloc() to be ignored for non-USAGE_SW
246# allocations, so long as the bits per channel and sRGB-ness are preserved.
247# 211#
248ifeq ($(is_at_least_kitkat),1) 212ifeq ($(is_at_least_lollipop),1)
249PVR_ANDROID_REMAP_HW_ONLY_PIXEL_FORMATS := 1 213PVR_ANDROID_BCC_MULTIARCH_SUPPORT := 1
250endif 214endif
251 215
252############################################################################## 216##############################################################################
253# Support newer HWC features in KK 217# Lollipop annotates the cursor allocation with USAGE_CURSOR to enable it to
218# be accelerated with special cursor hardware (rather than wasting an
219# overlay). This flag stops the DDK from blocking the allocation.
254# 220#
255ifeq ($(is_at_least_kitkat),1) 221ifeq ($(is_at_least_lollipop),1)
256PVR_ANDROID_HWC_HAS_1_3_FEATURES := 1 222PVR_ANDROID_HAS_GRALLOC_USAGE_CURSOR := 1
257endif 223endif
258 224
259############################################################################## 225##############################################################################
260# KK eliminated egl.cfg. Only create for older versions. 226# Lollipop changed the camera HAL metadata specification to require that
227# CONTROL_MAX_REGIONS specifies 3 integers (instead of 1).
261# 228#
262ifeq ($(is_at_least_kitkat),0) 229ifeq ($(is_at_least_lollipop),1)
263PVR_ANDROID_HAS_EGL_CFG := 1 230PVR_ANDROID_CAMERA_CONTROL_MAX_REGIONS_HAS_THREE := 1
264endif 231endif
265 232
266############################################################################## 233##############################################################################
267# KK has a bug in its browser that we need to work around. 234# Marshmallow needs --soname turned on
268# 235#
269ifeq ($(is_at_least_kitkat),1) 236ifeq ($(is_at_least_marshmallow),1)
270PVR_ANDROID_RELAX_GRALLOC_MODULE_MAP_CHECKS := 1 237PVR_ANDROID_NEEDS_SONAME ?= 1
271endif 238endif
272 239
273############################################################################## 240##############################################################################
274# KK's Camera HAL requires that ACTIVE_ARRAY_SIZE specify xmin/ymin first 241# Marshmallow replaces RAW_SENSOR with RAW10, RAW12 and RAW16
275# 242#
276ifeq ($(is_at_least_kitkat),1) 243ifeq ($(is_at_least_marshmallow),1)
277PVR_ANDROID_CAMERA_ACTIVE_ARRAY_SIZE_HAS_XMIN_YMIN := 1 244PVR_ANDROID_HAS_HAL_PIXEL_FORMAT_RAWxx := 1
278endif 245endif
279 246
280############################################################################## 247##############################################################################
281# KitKat added a new memory tracking HAL. This enables gralloc support for 248# Marshmallow onwards DDK stopped render script accleration using GPU.
282# the GRAPHICS/GL memtrack types. 249# This flag stops device alloction.
283# 250#
284ifeq ($(is_at_least_kitkat),1) 251ifeq ($(is_at_least_marshmallow),1)
285SUPPORT_ANDROID_MEMTRACK_HAL := 1 252PVR_ANDROID_HAS_GRALLOC_USAGE_RENDERSCRIPT := 1
286endif 253endif
287 254
288# Placeholder for future version handling 255# Placeholder for future version handling
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/paths.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/paths.mk
index 9717ca9..4309c72 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/paths.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/paths.mk
@@ -54,4 +54,4 @@ endif
54TOOLCHAIN ?= $(TARGET_ROOT)/product/$(TARGET_DEVICE)/obj 54TOOLCHAIN ?= $(TARGET_ROOT)/product/$(TARGET_DEVICE)/obj
55TOOLCHAIN2 ?= $(TARGET_ROOT)/product/$(TARGET_DEVICE)/system 55TOOLCHAIN2 ?= $(TARGET_ROOT)/product/$(TARGET_DEVICE)/system
56 56
57LIBGCC := $(shell $(CROSS_COMPILE)gcc -print-libgcc-file-name) 57LIBGCC := $(shell $(CROSS_COMPILE)gcc -m32 -print-libgcc-file-name 2>/dev/null)
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/platform_version.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/platform_version.mk
index bf43dda..f2a5600 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/platform_version.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/platform_version.mk
@@ -38,95 +38,117 @@
38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39### ########################################################################### 39### ###########################################################################
40 40
41# Figure out the version of Android we're building against. 41# If there's no build.prop file in the expected location, bail out. Tell the
42# user which file we were trying to read in case TARGET_DEVICE was not set.
42# 43#
43PLATFORM_VERSION := $(shell \ 44BUILD_PROP := $(TARGET_ROOT)/product/$(TARGET_DEVICE)/system/build.prop
44 if [ -f $(TARGET_ROOT)/product/$(TARGET_DEVICE)/system/build.prop ]; then \ 45ifeq ($(wildcard $(BUILD_PROP)),)
45 cat $(TARGET_ROOT)/product/$(TARGET_DEVICE)/system/build.prop | \ 46$(warning *** Could not determine Android version. Did you set ANDROID_ROOT,\
46 grep ^ro.build.version.release | cut -f2 -d'=' | cut -f1 -d'-'; \ 47OUT_DIR and TARGET_DEVICE in your environment correctly?)
47 else \ 48$(error Error reading $(BUILD_PROP))
48 echo 5.0; \ 49endif
49 fi) 50
51# Extract version.release and version.codename from the build.prop file.
52# If either of the values aren't in the build.prop, the Make variables won't
53# be defined, and fallback handling will take place.
54#
55define newline
56
57
58endef
59$(eval $(subst #,$(newline),$(shell cat $(BUILD_PROP) | \
60 grep '^ro.build.version.release=\|^ro.build.version.codename=' | \
61 sed -e 's,ro.build.version.release=,PLATFORM_RELEASE=,' \
62 -e 's,ro.build.version.codename=,PLATFORM_CODENAME=,' | tr '\n' '#')))
50 63
51define version-starts-with 64define release-starts-with
52$(shell echo $(PLATFORM_VERSION) | grep -q ^$(1); \ 65$(shell echo $(PLATFORM_RELEASE) | grep -q ^$(1); \
53 [ "$$?" = "0" ] && echo 1 || echo 0) 66 [ "$$?" = "0" ] && echo 1 || echo 0)
54endef 67endef
55 68
56# ro.build.version.release contains the version number for release builds, or 69# ro.build.version.release contains the version number for release builds, or
57# the version codename otherwise. In this case we need to assume that the 70# the version codename otherwise. In this case we need to assume that the
58# version of Android we're building against has the features that are in the 71# version of Android we're building against has the features that are in the
59# final release of that version, so we set PLATFORM_VERSION to the 72# final release of that version, so we set PLATFORM_RELEASE to the
60# corresponding release number. 73# corresponding release number.
61# 74#
62# NOTE: It's the _string_ ordering that matters here, not the version number 75# NOTE: It's the _string_ ordering that matters here, not the version number
63# ordering. You need to make sure that strings that are sub-strings of other 76# ordering. You need to make sure that strings that are sub-strings of other
64# checked strings appear _later_ in this list. 77# checked strings appear _later_ in this list.
65# 78#
66# e.g. 'JellyBeanMR' starts with 'JellyBean', but it is not JellyBean. 79# e.g. 'KitKatMR' starts with 'KitKat', but it is not KitKat.
80#
81# NOTE: The version codenames for Android stopped after KitKat, don't read
82# too much into the below names. They are mostly placeholders/reminders.
83#
84ifeq ($(call release-starts-with,KitKatMR),1)
85PLATFORM_RELEASE := 4.4.1
86else ifeq ($(call release-starts-with,KitKat),1)
87PLATFORM_RELEASE := 4.4
88else ifeq ($(call release-starts-with,LollipopMR1),1)
89PLATFORM_RELEASE := 5.1
90else ifeq ($(call release-starts-with,Lollipop),1)
91PLATFORM_RELEASE := 5.0
92else ifeq ($(call release-starts-with,Marshmallow),1)
93PLATFORM_RELEASE := 6.0
94else ifeq ($(PLATFORM_CODENAME),AOSP)
95# AOSP (master) will normally have PLATFORM_CODENAME set to AOSP
96PLATFORM_RELEASE := 6.0.60
97else ifeq ($(shell echo $(PLATFORM_RELEASE) | grep -qE "[A-Za-z]+"; echo $$?),0)
98PLATFORM_RELEASE := 6.1
99endif
100
101# Workaround for master. Sometimes there is an AOSP version ahead of
102# the current master version number, but master still has more features.
67# 103#
68ifeq ($(call version-starts-with,JellyBeanMR1),1) 104ifeq ($(PLATFORM_RELEASE),6.0.60)
69PLATFORM_VERSION := 4.2 105PLATFORM_RELEASE := 6.1
70else ifeq ($(call version-starts-with,JellyBeanMR),1) 106is_aosp_master := 1
71PLATFORM_VERSION := 4.3
72else ifeq ($(call version-starts-with,JellyBean),1)
73PLATFORM_VERSION := 4.1
74else ifeq ($(call version-starts-with,KeyLimePie),1)
75PLATFORM_VERSION := 4.4
76else ifeq ($(call version-starts-with,KitKat),1)
77PLATFORM_VERSION := 4.4
78else ifeq ($(shell echo $(PLATFORM_VERSION) | grep -qE "[A-Za-z]+"; echo $$?),0)
79PLATFORM_VERSION := 5.0
80endif 107endif
81 108
82PLATFORM_VERSION_MAJ := $(shell echo $(PLATFORM_VERSION) | cut -f1 -d'.') 109PLATFORM_RELEASE_MAJ := $(shell echo $(PLATFORM_RELEASE) | cut -f1 -d'.')
83PLATFORM_VERSION_MIN := $(shell echo $(PLATFORM_VERSION) | cut -f2 -d'.') 110PLATFORM_RELEASE_MIN := $(shell echo $(PLATFORM_RELEASE) | cut -f2 -d'.')
84PLATFORM_VERSION_PATCH := $(shell echo $(PLATFORM_VERSION) | cut -f3 -d'.') 111PLATFORM_RELEASE_PATCH := $(shell echo $(PLATFORM_RELEASE) | cut -f3 -d'.')
85 112
86# Not all versions have a patchlevel; fix that up here 113# Not all versions have a patchlevel; fix that up here
87# 114#
88ifeq ($(PLATFORM_VERSION_PATCH),) 115ifeq ($(PLATFORM_RELEASE_PATCH),)
89PLATFORM_VERSION_PATCH := 0 116PLATFORM_RELEASE_PATCH := 0
90endif 117endif
91 118
92# Macros to help categorize support for features and API_LEVEL for tests. 119# Macros to help categorize support for features and API_LEVEL for tests.
93# 120#
94is_at_least_jellybean := \ 121is_at_least_lollipop := \
95 $(shell ( test $(PLATFORM_VERSION_MAJ) -gt 4 || \ 122 $(shell ( test $(PLATFORM_RELEASE_MAJ) -ge 5 ) && echo 1 || echo 0)
96 ( test $(PLATFORM_VERSION_MAJ) -eq 4 && \ 123is_at_least_lollipop_mr1 := \
97 test $(PLATFORM_VERSION_MIN) -ge 1 ) ) && echo 1 || echo 0) 124 $(shell ( test $(PLATFORM_RELEASE_MAJ) -gt 5 || \
98is_at_least_jellybean_mr1 := \ 125 ( test $(PLATFORM_RELEASE_MAJ) -eq 5 && \
99 $(shell ( test $(PLATFORM_VERSION_MAJ) -gt 4 || \ 126 test $(PLATFORM_RELEASE_MIN) -gt 0 ) ) && echo 1 || echo 0)
100 ( test $(PLATFORM_VERSION_MAJ) -eq 4 && \ 127is_at_least_marshmallow := \
101 test $(PLATFORM_VERSION_MIN) -ge 2 ) ) && echo 1 || echo 0) 128 $(shell ( test $(PLATFORM_RELEASE_MAJ) -ge 6 ) && echo 1 || echo 0)
102is_at_least_jellybean_mr2 := \
103 $(shell ( test $(PLATFORM_VERSION_MAJ) -gt 4 || \
104 ( test $(PLATFORM_VERSION_MAJ) -eq 4 && \
105 test $(PLATFORM_VERSION_MIN) -ge 3 ) ) && echo 1 || echo 0)
106is_at_least_kitkat := \
107 $(shell ( test $(PLATFORM_VERSION_MAJ) -gt 4 || \
108 ( test $(PLATFORM_VERSION_MAJ) -eq 4 && \
109 test $(PLATFORM_VERSION_MIN) -ge 4 ) ) && echo 1 || echo 0)
110 129
111# FIXME: Assume "future versions" are >=5.0, but we don't really know 130# Assume "future versions" are >6.0, but we don't really know
112is_future_version := \ 131is_future_version := \
113 $(shell ( test $(PLATFORM_VERSION_MAJ) -ge 5 ) && echo 1 || echo 0) 132 $(shell ( test $(PLATFORM_RELEASE_MAJ) -gt 6 || \
133 ( test $(PLATFORM_RELEASE_MAJ) -eq 6 && \
134 test $(PLATFORM_RELEASE_MIN) -gt 0 ) ) && echo 1 || echo 0)
114 135
115# Picking an exact match of API_LEVEL for the platform we're building 136# Picking an exact match of API_LEVEL for the platform we're building
116# against can avoid compatibility theming and affords better integration. 137# against can avoid compatibility theming and affords better integration.
117# 138#
118ifeq ($(is_future_version),1) 139ifeq ($(is_future_version),1)
119API_LEVEL := 20 140API_LEVEL := 23
141else ifeq ($(is_at_least_marshmallow),1)
142API_LEVEL := 23
143else ifeq ($(is_at_least_lollipop_mr1),1)
144API_LEVEL := 22
145else ifeq ($(is_at_least_lollipop),1)
146API_LEVEL := 21
147#API_LEVEL := 20 was l-preview
120else ifeq ($(is_at_least_kitkat),1) 148else ifeq ($(is_at_least_kitkat),1)
121API_LEVEL := 19 149API_LEVEL := 19
122else ifeq ($(is_at_least_jellybean_mr2),1)
123API_LEVEL := 18
124else ifeq ($(is_at_least_jellybean_mr1),1)
125API_LEVEL := 17
126else ifeq ($(is_at_least_jellybean),1)
127API_LEVEL := 16
128else 150else
129$(error Must build against Android >= 4.1) 151$(error Must build against Android >= 4.4)
130endif 152endif
131 153
132# Each DDK is tested against only a single version of the platform. 154# Each DDK is tested against only a single version of the platform.
@@ -134,6 +156,6 @@ endif
134# 156#
135ifeq ($(is_future_version),1) 157ifeq ($(is_future_version),1)
136$(info WARNING: Android version is newer than this DDK supports) 158$(info WARNING: Android version is newer than this DDK supports)
137else ifneq ($(is_at_least_jellybean_mr2),1) 159else ifneq ($(is_at_least_lollipop_mr1),1)
138$(info WARNING: Android version is older than this DDK supports) 160$(info WARNING: Android version is older than this DDK supports)
139endif 161endif
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/apis/xorg.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/apis/xorg.mk
index c779e9d..cdcabd9 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/apis/xorg.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/apis/xorg.mk
@@ -39,9 +39,17 @@
39# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 39# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40### ########################################################################### 40### ###########################################################################
41 41
42ifeq ($(filter xorg,$(EXCLUDED_APIS)),) 42ifeq ($(WINDOW_SYSTEM),xorg)
43 COMPONENTS += xorg pvr_conf pvr_video wsegl_dri2_linux 43 SUPPORT_BUILD_LWS := 1
44 -include ../common/apis/xorg_opengl.mk 44 COMPONENTS += libudev_stubs
45 ifeq ($(PVR_LWS_NODC),1)
46 COMPONENTS += xorg pvr_conf pvr_video lws_pkgconfig pvr_dri
47 else
48 COMPONENTS += xorg pvr_conf pvr_video wsegl_dri2_linux
49 ifeq ($(filter opengl,$(EXCLUDED_APIS)),)
50 COMPONENTS += pvr_dri
51 endif
52 endif
45ifeq ($(SUPPORT_PVR_REMOTE),1) 53ifeq ($(SUPPORT_PVR_REMOTE),1)
46 COMPONENTS += pvr_input 54 COMPONENTS += pvr_input
47endif 55endif
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/dridrm.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/dridrm.mk
index 4097e7a..b6f945f 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/dridrm.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/dridrm.mk
@@ -59,3 +59,20 @@ $(eval $(call TunableBothConfigMake,PVR_DRI_DRM_NOT_PCI))
59 59
60$(eval $(call TunableKernelConfigC,PVR_DRI_DRM_PLATFORM_DEV,)) 60$(eval $(call TunableKernelConfigC,PVR_DRI_DRM_PLATFORM_DEV,))
61 61
62
63
64ifeq ($(SUPPORT_DRI_DRM_PLUGIN),1)
65PVR_DRI_CLIENT_DRIVER := pvrsrvkm
66else
67# The X and Wayland window systems derive the client driver name from a
68# display driver DRM device node. The Surfaceless window system derives it
69# from a render node.
70ifeq ($(WINDOW_SYSTEM),surfaceless)
71PVR_DRI_CLIENT_DRIVER := pvr
72else
73PVR_DRI_CLIENT_DRIVER := $(if $(PVR_DRM_MODESET_DRIVER_NAME),$(PVR_DRM_MODESET_DRIVER_NAME),pvr)
74endif
75endif
76
77PVR_DRI_GET_EXTENSIONS_ENTRY_POINT := __driDriverGetExtensions_$(PVR_DRI_CLIENT_DRIVER)
78
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg.mk
index 27c77a3..6867263 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg.mk
@@ -38,11 +38,17 @@
38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39### ########################################################################### 39### ###########################################################################
40 40
41PVR_SECURE_DRM_AUTH_EXPORT := 1 41ifeq ($(PVR_DRM_MODESET_DRIVER_NAME),)
42 PVR_SECURE_DRM_AUTH_EXPORT := 1
43endif
42 44
43$(eval $(call TunableKernelConfigC,XPROC_WORKAROUND_NUM_SHAREABLES,4095)) 45$(eval $(call TunableKernelConfigC,XPROC_WORKAROUND_NUM_SHAREABLES,4095))
44 46
45ifeq ($(SUPPORT_PVR_REMOTE),1) 47ifeq ($(SUPPORT_PVR_REMOTE),1)
46else 48else
49 ifeq ($(PVR_LWS_NODC),1)
50 else
51 endif
47endif 52endif
48 53
54
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg_test.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg_test.mk
index fe10742..ea112e7 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg_test.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/xorg_test.mk
@@ -38,14 +38,21 @@
38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39### ########################################################################### 39### ###########################################################################
40 40
41# FIXME: Will go away when SUPPORT_DRI_DRM is untangled from 41ifeq ($(WINDOW_SYSTEM),)
42# the old meaning of SUPPORT_XORG=1. 42 ifeq ($(filter xorg,$(EXCLUDED_APIS)),)
43 43 ifneq ($(wildcard ../common/apis/xorg.mk),)
44ifeq ($(filter xorg,$(EXCLUDED_APIS)),) 44 WINDOW_SYSTEM := xorg
45ifneq ($(wildcard ../common/apis/xorg.mk),) 45 WINDOW_SYSTEM_SET_INTERNALLY := 1
46SUPPORT_BUILD_XORG := 1 46 endif
47ifeq ($(PDUMP),1) 47 endif
48SUPPORT_PDUMP_MULTI_PROCESS := 1
49endif
50endif 48endif
49
50ifeq ($(WINDOW_SYSTEM),xorg)
51 # Set for the benefit of those platform Makefiles that test for it,
52 # but no longer used by the build system.
53 SUPPORT_BUILD_XORG := 1
54
55 ifeq ($(PDUMP),1)
56 SUPPORT_PDUMP_MULTI_PROCESS := 1
57 endif
51endif 58endif
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/config/core.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/config/core.mk
index 1bfce01..5cd7a47 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/config/core.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/config/core.mk
@@ -178,7 +178,11 @@ $(call directory-must-exist,$(TOP)/eurasiacon/build/linux2/$(PVR_BUILD_DIR))
178# final programs/libraries, and install/rc scripts. 178# final programs/libraries, and install/rc scripts.
179# 179#
180BUILD ?= release 180BUILD ?= release
181OUT ?= $(TOP)/eurasiacon/binary2_$(PVR_BUILD_DIR)_$(BUILD) 181ifneq ($(WINDOW_SYSTEM),)
182OUT ?= $(TOP)/eurasiacon/binary_$(PVR_BUILD_DIR)_$(WINDOW_SYSTEM)_$(BUILD)
183else
184OUT ?= $(TOP)/eurasiacon/binary2_$(PVR_BUILD_DIR)_$(BUILD)
185endif
182override OUT := $(if $(filter /%,$(OUT)),$(OUT),$(TOP)/$(OUT)) 186override OUT := $(if $(filter /%,$(OUT)),$(OUT),$(TOP)/$(OUT))
183 187
184CONFIG_MK := $(OUT)/config.mk 188CONFIG_MK := $(OUT)/config.mk
@@ -269,7 +273,9 @@ ifeq ($(SUPPORT_LINUX_USING_WORKQUEUES),1)
269override PVR_LINUX_USING_WORKQUEUES := 1 273override PVR_LINUX_USING_WORKQUEUES := 1
270override PVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE := 1 274override PVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE := 1
271override PVR_LINUX_TIMERS_USING_WORKQUEUES := 1 275override PVR_LINUX_TIMERS_USING_WORKQUEUES := 1
276ifneq ($(SUPPORT_ANDROID_FPGA),1)
272override SYS_CUSTOM_POWERLOCK_WRAP := 1 277override SYS_CUSTOM_POWERLOCK_WRAP := 1
278endif
273else ifeq ($(SUPPORT_LINUX_USING_SHARED_WORKQUEUES),1) 279else ifeq ($(SUPPORT_LINUX_USING_SHARED_WORKQUEUES),1)
274override PVR_LINUX_USING_WORKQUEUES := 1 280override PVR_LINUX_USING_WORKQUEUES := 1
275override PVR_LINUX_MISR_USING_WORKQUEUE := 1 281override PVR_LINUX_MISR_USING_WORKQUEUE := 1
@@ -360,7 +366,7 @@ $$(warning *** Setting $(1) via $$(origin $(1)) is deprecated)
360$$(error If you are trying to disable a component, use e.g. EXCLUDED_APIS="opengles1 opengl") 366$$(error If you are trying to disable a component, use e.g. EXCLUDED_APIS="opengles1 opengl")
361endif 367endif
362endef 368endef
363$(foreach _o,SYS_CFLAGS SYS_CXXFLAGS SYS_INCLUDES SYS_EXE_LDFLAGS SYS_LIB_LDFLAGS SYS_EXE_LDFLAGS_CXX SYS_LIB_LDFLAGS_CXX SUPPORT_EWS SUPPORT_OPENGLES1 SUPPORT_OPENGLES2 SUPPORT_OPENCL SUPPORT_RSCOMPUTE SUPPORT_OPENGL SUPPORT_UNITTESTS SUPPORT_XORG,$(eval $(call sanity-check-support-option-origin,$(_o)))) 369$(foreach _o,SYS_CFLAGS SYS_CXXFLAGS SYS_INCLUDES SYS_COMMON_LDFLAGS SYS_EXE_LDFLAGS SYS_LIB_LDFLAGS SYS_EXE_LDFLAGS_CXX SYS_LIB_LDFLAGS_CXX SUPPORT_EWS SUPPORT_OPENGLES1 SUPPORT_OPENGLES2 SUPPORT_OPENCL SUPPORT_RSCOMPUTE SUPPORT_OPENGL SUPPORT_UNITTESTS SUPPORT_XORG,$(eval $(call sanity-check-support-option-origin,$(_o))))
364 370
365# Check for words in EXCLUDED_APIS that aren't understood by the 371# Check for words in EXCLUDED_APIS that aren't understood by the
366# common/apis/*.mk files. This should be kept in sync with all the tests on 372# common/apis/*.mk files. This should be kept in sync with all the tests on
@@ -401,6 +407,31 @@ COMPONENTS += pvrvncsrv
401COMPONENTS += pvrvncinput 407COMPONENTS += pvrvncinput
402endif 408endif
403 409
410ifeq ($(HAVE_WINDOW_SYSTEM_MAKEFILE),)
411 ifeq ($(WINDOW_SYSTEM_SET_INTERNALLY),)
412 ifneq ($(WINDOW_SYSTEM),)
413 $(error "The WINDOW_SYSTEM build variable is not supported on this platform")
414 endif
415 endif
416 ifneq ($(MESA_EGL),)
417 $(error "The MESA_EGL build variable is not supported on this platform")
418 endif
419 PVR_LWS_NODC :=
420 PVR_LWS_NOBC :=
421endif
422
423ifneq ($(WINDOW_SYSTEM),)
424endif
425ifeq ($(MESA_EGL),1)
426 SUPPORT_OPENGLES1_V1_ONLY := 1
427 GLES1_EXTENSION_EGL_IMAGE_EXTERNAL := 1
428 GLES2_EXTENSION_EGL_IMAGE_EXTERNAL := 1
429else
430 ifeq ($(SUPPORT_BUILD_LWS),1)
431 else
432 endif
433endif
434
404$(if $(filter config,$(D)),$(info Build configuration:)) 435$(if $(filter config,$(D)),$(info Build configuration:))
405 436
406################################# CONFIG #################################### 437################################# CONFIG ####################################
@@ -426,7 +457,7 @@ $(eval $(call TunableBothConfigMake,KERNEL_CROSS_COMPILE,))
426endif 457endif
427 458
428# Check the KERNELDIR has a kernel built. 459# Check the KERNELDIR has a kernel built.
429VMLINUX := $(strip $(wildcard $(KERNELDIR)/vmlinux)) 460VMLINUX :=
430LINUXCFG := $(strip $(wildcard $(KERNELDIR)/.config)) 461LINUXCFG := $(strip $(wildcard $(KERNELDIR)/.config))
431 462
432ifneq ($(VMLINUX),) 463ifneq ($(VMLINUX),)
@@ -437,8 +468,10 @@ VMLINUX_IS_64BIT := $(shell file $(VMLINUX) | grep 64-bit >/dev/null || echo fal
437VMLINUX_HAS_PAE36 := $(shell cat $(LINUXCFG) | grep CONFIG_X86_PAE=y >/dev/null || echo false) 468VMLINUX_HAS_PAE36 := $(shell cat $(LINUXCFG) | grep CONFIG_X86_PAE=y >/dev/null || echo false)
438VMLINUX_HAS_PAE40 := $(shell cat $(LINUXCFG) | grep CONFIG_ARM_LPAE=y >/dev/null || echo false) 469VMLINUX_HAS_PAE40 := $(shell cat $(LINUXCFG) | grep CONFIG_ARM_LPAE=y >/dev/null || echo false)
439VMLINUX_HAS_DMA32 := $(shell cat $(LINUXCFG) | grep CONFIG_ZONE_DMA32=y >/dev/null || echo false) 470VMLINUX_HAS_DMA32 := $(shell cat $(LINUXCFG) | grep CONFIG_ZONE_DMA32=y >/dev/null || echo false)
471VMLINUX_HAS_DMA := $(shell cat $(LINUXCFG) | grep CONFIG_ZONE_DMA=y >/dev/null || echo false)
440 472
441# $(error 64BIT=$(VMLINUX_IS_64BIT) PAE36=$(VMLINUX_HAS_PAE36) PAE40=$(VMLINUX_HAS_PAE40) DMA32=$(VMLINUX_HAS_DMA32) MMU36=$(SGX_FEATURE_36BIT_MMU)) 473
474# $(error 64BIT=$(VMLINUX_IS_64BIT) PAE36=$(VMLINUX_HAS_PAE36) PAE40=$(VMLINUX_HAS_PAE40) DMA=$(VMLINUX_HAS_DMA) DMA32=$(VMLINUX_HAS_DMA32) MMU36=$(SGX_FEATURE_36BIT_MMU))
442 475
443ifneq ($(VMLINUX_IS_64BIT),false) 476ifneq ($(VMLINUX_IS_64BIT),false)
444$(warning $$(KERNELDIR)/vmlinux: Note: vmlinux is 64-bit, which is supported but currently experimental.) 477$(warning $$(KERNELDIR)/vmlinux: Note: vmlinux is 64-bit, which is supported but currently experimental.)
@@ -449,8 +482,8 @@ endif
449endif 482endif
450 483
451ifneq ($(VMLINUX_HAS_PAE40),false) 484ifneq ($(VMLINUX_HAS_PAE40),false)
452ifeq ($(VMLINUX_HAS_DMA32),false) 485ifeq ($(VMLINUX_HAS_DMA),false)
453$(warning SGX MMUs are currently supported up to only 36 bits max. Your Kernel is built with 40-bit PAE but does not have CONFIG_ZONE_DMA32.) 486$(warning SGX MMUs are currently supported up to only 36 bits max. Your Kernel is built with 40-bit PAE but does not have CONFIG_ZONE_DMA.)
454$(warning This means you must ensure the runtime system has <= 4GB of RAM, or there will be BIG problems...) 487$(warning This means you must ensure the runtime system has <= 4GB of RAM, or there will be BIG problems...)
455endif 488endif
456endif 489endif
@@ -465,8 +498,8 @@ endif
465else 498else
466 # Kernel is 32-bit 499 # Kernel is 32-bit
467ifneq ($(VMLINUX_HAS_PAE36),false) 500ifneq ($(VMLINUX_HAS_PAE36),false)
468ifeq ($(VMLINUX_HAS_DMA32),false) 501ifeq ($(VMLINUX_HAS_DMA),false)
469$(warning SGX is configured with 32-bit MMU. Your Kernel is 32-bit PAE, but does not have CONFIG_ZONE_DMA32. ) 502$(warning SGX is configured with 32-bit MMU. Your Kernel is 32-bit PAE, but does not have CONFIG_ZONE_DMA. )
470$(warning This means you must ensure the runtime system has <= 4GB of RAM, or there will be BIG problems...) 503$(warning This means you must ensure the runtime system has <= 4GB of RAM, or there will be BIG problems...)
471endif 504endif
472endif 505endif
@@ -506,13 +539,16 @@ ifneq ($(DISPLAY_CONTROLLER),)
506$(eval $(call BothConfigC,DISPLAY_CONTROLLER,$(DISPLAY_CONTROLLER))) 539$(eval $(call BothConfigC,DISPLAY_CONTROLLER,$(DISPLAY_CONTROLLER)))
507endif 540endif
508 541
542ifneq ($(DRM_DISPLAY_CONTROLLER),)
543endif
544
509ifneq ($(strip $(KERNELDIR)),) 545ifneq ($(strip $(KERNELDIR)),)
510PVR_LINUX_MEM_AREA_POOL_MAX_PAGES ?= 0 546PVR_LINUX_MEM_AREA_POOL_MAX_PAGES ?= 0
511ifneq ($(PVR_LINUX_MEM_AREA_POOL_MAX_PAGES),0) 547ifneq ($(PVR_LINUX_MEM_AREA_POOL_MAX_PAGES),0)
512PVR_LINUX_MEM_AREA_USE_VMAP ?= 1 548PVR_LINUX_MEM_AREA_USE_VMAP ?= 1
513include ../kernel_version.mk 549include ../kernel_version.mk
514ifeq ($(call kernel-version-at-least,3,0),true) 550ifeq ($(call kernel-version-at-least,3,0),true)
515PVR_LINUX_MEM_AREA_POOL_ALLOW_SHRINK ?= 0 551PVR_LINUX_MEM_AREA_POOL_ALLOW_SHRINK ?= 1
516endif 552endif
517endif 553endif
518$(eval $(call KernelConfigC,PVR_LINUX_MEM_AREA_POOL_MAX_PAGES,$(PVR_LINUX_MEM_AREA_POOL_MAX_PAGES))) 554$(eval $(call KernelConfigC,PVR_LINUX_MEM_AREA_POOL_MAX_PAGES,$(PVR_LINUX_MEM_AREA_POOL_MAX_PAGES)))
@@ -537,6 +573,7 @@ $(eval $(call KernelConfigC,DEBUG_BRIDGE_KM,))
537else ifeq ($(BUILD),release) 573else ifeq ($(BUILD),release)
538$(eval $(call BothConfigC,RELEASE,)) 574$(eval $(call BothConfigC,RELEASE,))
539$(eval $(call TunableBothConfigMake,DEBUGLINK,1)) 575$(eval $(call TunableBothConfigMake,DEBUGLINK,1))
576$(eval $(call TunableBothConfigC,PVR_DBGPRIV_LEVEL,))
540else ifeq ($(BUILD),timing) 577else ifeq ($(BUILD),timing)
541$(eval $(call BothConfigC,TIMING,)) 578$(eval $(call BothConfigC,TIMING,))
542$(eval $(call TunableBothConfigMake,DEBUGLINK,1)) 579$(eval $(call TunableBothConfigMake,DEBUGLINK,1))
@@ -566,6 +603,7 @@ $(eval $(call TunableBothConfigC,SGX_FEATURE_MP_PLUS,))
566$(eval $(call TunableBothConfigC,FPGA,)) 603$(eval $(call TunableBothConfigC,FPGA,))
567$(eval $(call TunableBothConfigC,PDUMP,)) 604$(eval $(call TunableBothConfigC,PDUMP,))
568$(eval $(call TunableBothConfigC,MEM_TRACK_INFO_DEBUG,)) 605$(eval $(call TunableBothConfigC,MEM_TRACK_INFO_DEBUG,))
606$(eval $(call TunableBothConfigC,PVRSRV_DEVMEM_TIME_STATS,))
569$(eval $(call TunableBothConfigC,NO_HARDWARE,)) 607$(eval $(call TunableBothConfigC,NO_HARDWARE,))
570$(eval $(call TunableBothConfigC,PDUMP_DEBUG_OUTFILES,)) 608$(eval $(call TunableBothConfigC,PDUMP_DEBUG_OUTFILES,))
571$(eval $(call TunableBothConfigC,PVRSRV_USSE_EDM_STATUS_DEBUG,)) 609$(eval $(call TunableBothConfigC,PVRSRV_USSE_EDM_STATUS_DEBUG,))
@@ -578,7 +616,7 @@ $(eval $(call TunableBothConfigC,PVRSRV_NEED_PVR_ASSERT,))
578$(eval $(call TunableBothConfigC,PVRSRV_NEED_PVR_TRACE,)) 616$(eval $(call TunableBothConfigC,PVRSRV_NEED_PVR_TRACE,))
579$(eval $(call TunableBothConfigC,SUPPORT_SECURE_33657_FIX,)) 617$(eval $(call TunableBothConfigC,SUPPORT_SECURE_33657_FIX,))
580$(eval $(call TunableBothConfigC,SUPPORT_ION,)) 618$(eval $(call TunableBothConfigC,SUPPORT_ION,))
581$(eval $(call TunableBothConfigC,SUPPORT_DRM_GEM,)) 619$(eval $(call TunableBothConfigC,SUPPORT_DMABUF,))
582$(eval $(call TunableBothConfigC,SUPPORT_HWRECOVERY_TRACE_LIMIT,)) 620$(eval $(call TunableBothConfigC,SUPPORT_HWRECOVERY_TRACE_LIMIT,))
583$(eval $(call TunableBothConfigC,SUPPORT_PVRSRV_DEVICE_CLASS,)) 621$(eval $(call TunableBothConfigC,SUPPORT_PVRSRV_DEVICE_CLASS,))
584$(eval $(call TunableBothConfigC,SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER,1)) 622$(eval $(call TunableBothConfigC,SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER,1))
@@ -599,6 +637,7 @@ $(eval $(call TunableKernelConfigC,PVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE,))
599$(eval $(call TunableKernelConfigC,PVR_LINUX_TIMERS_USING_WORKQUEUES,)) 637$(eval $(call TunableKernelConfigC,PVR_LINUX_TIMERS_USING_WORKQUEUES,))
600$(eval $(call TunableKernelConfigC,PVR_LINUX_TIMERS_USING_SHARED_WORKQUEUE,)) 638$(eval $(call TunableKernelConfigC,PVR_LINUX_TIMERS_USING_SHARED_WORKQUEUE,))
601$(eval $(call TunableKernelConfigC,LDM_PLATFORM,)) 639$(eval $(call TunableKernelConfigC,LDM_PLATFORM,))
640$(eval $(call TunableKernelConfigC,PVR_LDM_DEVICE_TREE,))
602$(eval $(call TunableKernelConfigC,PVR_LDM_PLATFORM_PRE_REGISTERED,)) 641$(eval $(call TunableKernelConfigC,PVR_LDM_PLATFORM_PRE_REGISTERED,))
603$(eval $(call TunableKernelConfigC,PVR_LDM_PLATFORM_PRE_REGISTERED_DEV,)) 642$(eval $(call TunableKernelConfigC,PVR_LDM_PLATFORM_PRE_REGISTERED_DEV,))
604$(eval $(call TunableKernelConfigC,PVR_LDM_DRIVER_REGISTRATION_NAME,"\"$(PVRSRV_MODNAME)\"")) 643$(eval $(call TunableKernelConfigC,PVR_LDM_DRIVER_REGISTRATION_NAME,"\"$(PVRSRV_MODNAME)\""))
@@ -620,7 +659,7 @@ $(eval $(call TunableKernelConfigC,SUPPORT_FORCE_SYNC_DUMP,))
620 659
621$(eval $(call TunableBothConfigMake,OPTIM,)) 660$(eval $(call TunableBothConfigMake,OPTIM,))
622$(eval $(call TunableBothConfigMake,SUPPORT_ION,)) 661$(eval $(call TunableBothConfigMake,SUPPORT_ION,))
623$(eval $(call TunableBothConfigMake,SUPPORT_DRM_GEM,)) 662$(eval $(call TunableBothConfigMake,SUPPORT_DMABUF,))
624$(eval $(call TunableBothConfigMake,SUPPORT_PVRSRV_DEVICE_CLASS,)) 663$(eval $(call TunableBothConfigMake,SUPPORT_PVRSRV_DEVICE_CLASS,))
625 664
626 665
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/defs.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/defs.mk
index dee740f..311bbb0 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/defs.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/defs.mk
@@ -146,3 +146,8 @@ endef
146define module-info-line 146define module-info-line
147$(if $(filter modules,$(D)),$(info $(1)),) 147$(if $(filter modules,$(D)),$(info $(1)),)
148endef 148endef
149
150# $(call if-exists,A,B) => A if A is a file which exists, otherwise B
151define if-exists
152$(if $(wildcard $(1)),$(1),$(2))
153endef
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/moduledefs.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/moduledefs.mk
index ef4596c..155d3bb 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/moduledefs.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/moduledefs.mk
@@ -61,12 +61,12 @@ endif
61 61
62# Only allow cflags that do not affect code generation. This is to ensure 62# Only allow cflags that do not affect code generation. This is to ensure
63# proper binary compatibility when LTO (Link-Time Optimization) is enabled. 63# proper binary compatibility when LTO (Link-Time Optimization) is enabled.
64# We make exceptions for -fPIC, -fPIE and -m32 which will all fail linkage 64# We make exceptions for the below flags which will all fail linkage in
65# in non-LTO mode if incorrectly specified. 65# non-LTO mode if incorrectly specified.
66# 66#
67# NOTE: Only used by static_library and objects right now. Other module 67# NOTE: Only used by static_library and objects right now. Other module
68# types should not be affected by complex code generation flags w/ LTO. 68# types should not be affected by complex code generation flags w/ LTO.
69MODULE_ALLOWED_CFLAGS := -W% -D% -std=% -fPIC -fPIE -m32 69MODULE_ALLOWED_CFLAGS := -W% -D% -std=% -fPIC -fPIE -pie -m32
70 70
71# -L flags for library search dirs: these are relative to $(TOP), unless 71# -L flags for library search dirs: these are relative to $(TOP), unless
72# they're absolute paths 72# they're absolute paths
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/modules.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/modules.mk
index 1576590..971f21a 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/modules.mk
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/modules.mk
@@ -42,7 +42,6 @@
42# Bits for processing $(modules) after reading in each Linux.mk 42# Bits for processing $(modules) after reading in each Linux.mk
43 43
44#$(info ---- $(modules) ----) 44#$(info ---- $(modules) ----)
45$(call must-be-nonempty,modules)
46 45
47$(foreach _m,$(modules),$(if $(filter $(_m),$(ALL_MODULES)),$(error In makefile $(THIS_MAKEFILE): Duplicate module $(_m) (first seen in $(INTERNAL_MAKEFILE_FOR_MODULE_$(_m))) listed in $$(modules)),$(eval $(call register-module,$(_m))))) 46$(foreach _m,$(modules),$(if $(filter $(_m),$(ALL_MODULES)),$(error In makefile $(THIS_MAKEFILE): Duplicate module $(_m) (first seen in $(INTERNAL_MAKEFILE_FOR_MODULE_$(_m))) listed in $$(modules)),$(eval $(call register-module,$(_m)))))
48 47
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_android/Makefile b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_android/Makefile
index 109e405..03efcdb 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_android/Makefile
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_android/Makefile
@@ -63,7 +63,21 @@ SGXCORE := 544
63SGX_CORE_REV := 112 63SGX_CORE_REV := 112
64HAL_VARIANT := omap4 64HAL_VARIANT := omap4
65endif 65endif
66ifneq ($(filter jacinto6evm omap5sevm panda5,$(TARGET_DEVICE)),) 66ifneq ($(filter omap5sevm panda5,$(TARGET_DEVICE)),)
67SGXCORE := 544
68SGX_CORE_REV := 105
69SGX_FEATURE_MP := 1
70SGX_FEATURE_SYSTEM_CACHE := 1
71SGX_FEATURE_MP_CORE_COUNT := 2
72HAL_VARIANT := omap5
73
74# OMAP Product Version
75VS_PRODUCT_VERSION := 5
76
77# FIXME: Re-enable this ASAP
78SUPPORT_ACTIVE_POWER_MANAGEMENT := 0
79endif
80ifneq ($(filter jacinto6evm,$(TARGET_DEVICE)),)
67SGXCORE := 544 81SGXCORE := 544
68SGX_CORE_REV := 116 82SGX_CORE_REV := 116
69SGX_FEATURE_MP := 1 83SGX_FEATURE_MP := 1
@@ -72,10 +86,12 @@ SGX_FEATURE_MP_CORE_COUNT := 2
72HAL_VARIANT := jacinto6 86HAL_VARIANT := jacinto6
73 87
74# OMAP Product Version 88# OMAP Product Version
89# FIXME: Get rid of this
75VS_PRODUCT_VERSION := 5 90VS_PRODUCT_VERSION := 5
76 91
77# FIXME: Re-enable this ASAP 92# FIXME: Re-enable this ASAP
78SUPPORT_ACTIVE_POWER_MANAGEMENT := 0 93SUPPORT_ACTIVE_POWER_MANAGEMENT := 0
94
79endif 95endif
80 96
81# Handle any TARGET_DEVICE remapping. Not all DDK TARGET_DEVICEs 97# Handle any TARGET_DEVICE remapping. Not all DDK TARGET_DEVICEs
@@ -92,15 +108,19 @@ SGX_DYNAMIC_TIMING_INFO := 1
92 108
93SUPPORT_LINUX_USING_WORKQUEUES := 1 109SUPPORT_LINUX_USING_WORKQUEUES := 1
94 110
95SUPPORT_PVRSRV_ANDROID_SYSTRACE := 0 111SUPPORT_PVRSRV_ANDROID_SYSTRACE := 1
96 112
97ifneq ($(SUPPORT_PVRSRV_DEVICE_CLASS),0) 113SUPPORT_DMABUF := 1
114
115# TODO: Set SUPPORT_PVRSVR_DEVICE_CLASS to 0
116#DISPLAY_CONTROLLER should not be used for DRM based display controller
117#ifneq ($(SUPPORT_PVRSRV_DEVICE_CLASS),0)
98#DISPLAY_CONTROLLER := omaplfb 118#DISPLAY_CONTROLLER := omaplfb
99endif 119#endif
100 120
101PVR_SYSTEM := omap 121PVR_SYSTEM := omap
102 122
103KERNEL_CROSS_COMPILE ?= arm-none-linux-gnueabi- 123KERNEL_CROSS_COMPILE ?= arm-eabi-
104 124
105# We have more memory on OMAP platforms, so we can spare to make the 125# We have more memory on OMAP platforms, so we can spare to make the
106# pool larger, and have higher resolutions which benefit from it. 126# pool larger, and have higher resolutions which benefit from it.
@@ -126,6 +146,9 @@ ifneq ($(strip $(KERNELDIR)),)
126 SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED := 1 146 SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED := 1
127 SYS_OMAP_HAS_DVFS_FRAMEWORK := 0 147 SYS_OMAP_HAS_DVFS_FRAMEWORK := 0
128 endif 148 endif
149 ifeq ($(call kernel-version-at-least,3,8,13),true)
150 PVR_LDM_DEVICE_TREE := 1
151 endif
129else 152else
130 $(warning "KERNELDIR is not set, so can't feature check DVFS or dsscomp.") 153 $(warning "KERNELDIR is not set, so can't feature check DVFS or dsscomp.")
131 $(warning "Assuming we want DVFS and dsscomp support.") 154 $(warning "Assuming we want DVFS and dsscomp support.")
@@ -143,6 +166,7 @@ DISPLAY_CONTROLLER_COMPONENT := linux_framebuffer
143OMAP_NON_FLIP_DISPLAY := 1 166OMAP_NON_FLIP_DISPLAY := 1
144endif 167endif
145else # LDM_PLATFORM != 1 168else # LDM_PLATFORM != 1
169# TODO: we should set DEVICE_CLASS to zero
146ifneq ($(SUPPORT_PVRSRV_DEVICE_CLASS),0) 170ifneq ($(SUPPORT_PVRSRV_DEVICE_CLASS),0)
147#DISPLAY_CONTROLLER_COMPONENT := dc_omapfb3_linux 171#DISPLAY_CONTROLLER_COMPONENT := dc_omapfb3_linux
148endif 172endif
@@ -176,7 +200,7 @@ SUPPORT_ANDROID_OMAP_NV12 := 1
176 200
177PVR_ANDROID_USE_WINDOW_TRANSFORM_HINT := 1 201PVR_ANDROID_USE_WINDOW_TRANSFORM_HINT := 1
178 202
179PVR_ANDROID_PLATFORM_HAS_LINUX_FBDEV := 0 203PVR_ANDROID_PLATFORM_HAS_LINUX_FBDEV := 1
180 204
181# Handle Google's OMAP-based products 205# Handle Google's OMAP-based products
182# 206#
@@ -200,6 +224,9 @@ endif
200endif # SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED == 1 224endif # SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED == 1
201endif # NO_HARDWARE == 1 225endif # NO_HARDWARE == 1
202 226
227# we are not using PVR composerhal
228#PVR_ANDROID_COMPOSERHAL ?= omap
229
203include ../config/core.mk 230include ../config/core.mk
204include ../common/android/extra_config.mk 231include ../common/android/extra_config.mk
205include ../common/dridrm.mk 232include ../common/dridrm.mk
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_linux/Makefile b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_linux/Makefile
index 8a65e7d..6c9b932 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_linux/Makefile
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap_linux/Makefile
@@ -39,56 +39,69 @@
39# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 39# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40### ########################################################################### 40### ###########################################################################
41 41
42# If a product wasn't specified, we're an OMAP4430 blaze. 42include ../kernel_version.mk
43ifeq ($(call kernel-version-at-least,3,8,13),true)
44 SUPPORT_LWS_WITH_DC ?= 0
45endif
46include ../config/window_system.mk
47
48# If a product wasn't specified, we're a J6 EVM.
43# 49#
44TARGET_PRODUCT ?= jacinto6evm 50TARGET_PRODUCT ?= jacinto6evm
45 51
52PVRSRV_NEED_PVR_DPF := 1
53PVRSRV_NEW_PVR_DPF := 1
54
46# Customize this build as per the TARGET_PRODUCT setting 55# Customize this build as per the TARGET_PRODUCT setting
47# 56#
48ifneq ($(filter blaze blaze_tablet panda,$(TARGET_PRODUCT)),) 57ifneq ($(filter blaze blaze_tablet panda,$(TARGET_PRODUCT)),)
49SGXCORE := 540 58 SGXCORE := 540
50SGX_CORE_REV := 120 59 SGX_CORE_REV := 120
51endif 60endif
52ifneq ($(filter blaze.4470 blaze_tablet.4470,$(TARGET_PRODUCT)),) 61ifneq ($(filter blaze.4470 blaze_tablet.4470,$(TARGET_PRODUCT)),)
53SGXCORE := 544 62 SGXCORE := 544
54SGX_CORE_REV := 112 63 SGX_CORE_REV := 112
55endif 64endif
56ifneq ($(filter omap5sevm panda5,$(TARGET_PRODUCT)),) 65ifneq ($(filter omap5sevm panda5,$(TARGET_PRODUCT)),)
57SGXCORE := 544 66 SGXCORE := 544
58SGX_CORE_REV := 105 67 SGX_CORE_REV := 105
59SGX_FEATURE_MP := 1 68 SGX_FEATURE_MP := 1
60SGX_FEATURE_SYSTEM_CACHE := 1 69 SGX_FEATURE_SYSTEM_CACHE := 1
61SGX_FEATURE_MP_CORE_COUNT := 2 70 SGX_FEATURE_MP_CORE_COUNT := 2
62PVR_OMAPLFB_DRM_FB := 0 71 PVR_OMAPLFB_DRM_FB := 0
63SYS_OMAP_HAS_DVFS_FRAMEWORK := 1 72 SYS_OMAP_HAS_DVFS_FRAMEWORK := 1
64 73
65# OMAP Product Version 74 # OMAP Product Version
66VS_PRODUCT_VERSION := 5 75 VS_PRODUCT_VERSION := 5
67 76
68# FIXME: Re-enable this ASAP 77 # FIXME: Re-enable this ASAP
69SUPPORT_ACTIVE_POWER_MANAGEMENT := 0 78 SUPPORT_ACTIVE_POWER_MANAGEMENT := 0
70endif 79endif
71ifneq ($(filter jacinto6evm omap5uevm,$(TARGET_PRODUCT)),) 80ifneq ($(filter jacinto6evm omap5uevm,$(TARGET_PRODUCT)),)
72SGXCORE := 544 81 SGXCORE := 544
73SGX_CORE_REV := 116 82 SGX_CORE_REV := 116
74SGX_FEATURE_MP := 1 83 SGX_FEATURE_MP := 1
75SGX_FEATURE_SYSTEM_CACHE := 1 84 SGX_FEATURE_SYSTEM_CACHE := 1
76SGX_FEATURE_MP_CORE_COUNT := 2 85 SGX_FEATURE_MP_CORE_COUNT := 2
86 SYS_OMAP_HAS_DVFS_FRAMEWORK := 1
77 87
78SYS_OMAP5_UEVM := 1 88 SYS_OMAP5_UEVM := 1
79 89
80# OMAP Product Version 90 # OMAP Product Version
81VS_PRODUCT_VERSION := 5 91 VS_PRODUCT_VERSION := 5
82endif 92endif
83 93
94PVR_NO_OMAP_TIMER := 1
95
84PVR_SYSTEM := omap 96PVR_SYSTEM := omap
85 97
86KERNEL_COMPONENTS := srvkm bufferclass_example 98KERNEL_COMPONENTS := srvkm
99ifeq ($(PVR_LWS_NOBC),)
100KERNEL_COMPONENTS += bufferclass_example
101endif
87 102
88SUPPORT_OLD_ION_API := 1 103SUPPORT_OLD_ION_API := 1
89 104
90include ../kernel_version.mk
91
92# Only enable active power management if passive power management is 105# Only enable active power management if passive power management is
93# enabled, as indicated by LDM_PLATFORM being set to 1. On OMAP, 106# enabled, as indicated by LDM_PLATFORM being set to 1. On OMAP,
94# the system can suspend in the case where active power management is 107# the system can suspend in the case where active power management is
@@ -99,8 +112,9 @@ LDM_PLATFORM ?= 1
99 112
100ifeq ($(LDM_PLATFORM),1) 113ifeq ($(LDM_PLATFORM),1)
101SUPPORT_LINUX_USING_WORKQUEUES := 1 114SUPPORT_LINUX_USING_WORKQUEUES := 1
102DISPLAY_CONTROLLER_COMPONENT += dc_omapfb3_linux 115#With DRM EGL and display, omaplfb is not needed
103DISPLAY_CONTROLLER := omaplfb 116#DISPLAY_CONTROLLER_COMPONENT += dc_omapfb3_linux
117#DISPLAY_CONTROLLER := omaplfb
104else 118else
105SUPPORT_LINUX_USING_SHARED_WORKQUEUES := 1 119SUPPORT_LINUX_USING_SHARED_WORKQUEUES := 1
106OMAP_NON_FLIP_DISPLAY := 1 120OMAP_NON_FLIP_DISPLAY := 1
@@ -142,16 +156,25 @@ SYS_CUSTOM_POWERLOCK_WRAP := 1
142 156
143ifeq ($(OMAP_NON_FLIP_DISPLAY),1) 157ifeq ($(OMAP_NON_FLIP_DISPLAY),1)
144OPK_DEFAULT := libpvrPVR2D_BLITWSEGL.so 158OPK_DEFAULT := libpvrPVR2D_BLITWSEGL.so
145else
146OPK_DEFAULT := libpvrPVR2D_FLIPWSEGL.so
147endif 159endif
148 160
149ifeq ($(SYS_OMAP5_UEVM),1) 161ifeq ($(SYS_OMAP5_UEVM),1)
162XORG_EXPLICIT_PVR_SERVICES_LOAD := 1
163ifeq ($(call kernel-version-at-least,3,8,13),true)
164LDM_PLATFORM := 1
165PVR_LDM_DEVICE_TREE := 1
166else
150PVR_LDM_PLATFORM_PRE_REGISTERED := 1 167PVR_LDM_PLATFORM_PRE_REGISTERED := 1
151PVR_LDM_PLATFORM_PRE_REGISTERED_DEV := "\"omapdrm_pvr\"" 168PVR_LDM_PLATFORM_PRE_REGISTERED_DEV := "\"omapdrm_pvr\""
152XORG_EXPLICIT_PVR_SERVICES_LOAD := 1 169endif
170ifeq ($(PVR_LWS_NODC),1)
171# No display class driver.
172DISPLAY_CONTROLLER_COMPONENT :=
173DISPLAY_CONTROLLER :=
174else
153PVR_OMAPLFB_DRM_FB := 0 175PVR_OMAPLFB_DRM_FB := 0
154PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY := 1 176PVR_OMAPLFB_DONT_USE_FB_PAN_DISPLAY := 1
177endif
155else 178else
156ifeq ($(call kernel-version-at-least,2,6,35),true) 179ifeq ($(call kernel-version-at-least,2,6,35),true)
157# Work around flipping problems seen with the Taal LCDs on Blaze. 180# Work around flipping problems seen with the Taal LCDs on Blaze.
@@ -182,16 +205,17 @@ endif
182endif 205endif
183endif 206endif
184 207
185include ../common/xorg_test.mk
186ifeq ($(SUPPORT_BUILD_XORG),1)
187SUPPORT_DRI_DRM := 1
188endif
189
190ifeq ($(SUPPORT_DRI_DRM),1) 208ifeq ($(SUPPORT_DRI_DRM),1)
191ifeq ($(SYS_OMAP5_UEVM),1) 209ifeq ($(SYS_OMAP5_UEVM),1)
192PVR_DRI_DRM_PLATFORM_DEV := 1 210PVR_DRI_DRM_PLATFORM_DEV := 1
211ifneq ($(call kernel-version-at-least,3,8,13),true)
193PVR_DRI_DRM_STATIC_BUS_ID := 1 212PVR_DRI_DRM_STATIC_BUS_ID := 1
194PVR_DRI_DRM_DEV_BUS_ID := "\"platform:omapdrm_pvr:00"\" 213PVR_DRI_DRM_DEV_BUS_ID := "\"platform:omapdrm_pvr:00"\"
214endif
215ifeq ($(PVR_LWS_NODC),1)
216PVR_DRM_MODESET_DRIVER_NAME := omapdrm
217PVR_DRM_MODESET_MODULE_NAME := dumb
218endif
195else 219else
196ifeq ($(call kernel-version-at-least,2,6,35),true) 220ifeq ($(call kernel-version-at-least,2,6,35),true)
197PVR_DRI_DRM_PLATFORM_DEV := 1 221PVR_DRI_DRM_PLATFORM_DEV := 1
@@ -212,6 +236,9 @@ endif # kernel-version-at-least,2,6,35
212endif # ($(SYS_OMAP5_UEVM),1) 236endif # ($(SYS_OMAP5_UEVM),1)
213endif # SUPPORT_DRI_DRM 237endif # SUPPORT_DRI_DRM
214 238
239include ../common/xorg_test.mk
240
241ifeq ($(PVR_LWS_NODC),)
215ifeq ($(SUPPORT_BUILD_XORG),1) 242ifeq ($(SUPPORT_BUILD_XORG),1)
216ifeq ($(call kernel-version-at-least,2,6,35,7),true) 243ifeq ($(call kernel-version-at-least,2,6,35,7),true)
217# A client DRI authorisation failure, whilst switched away from the X Server 244# A client DRI authorisation failure, whilst switched away from the X Server
@@ -222,16 +249,9 @@ PVR_XORG_DONT_DROP_MASTER_IN_LEAVE_VT := 1
222endif 249endif
223XORG_PVR_VIDEO ?= omap4 250XORG_PVR_VIDEO ?= omap4
224 251
225OPK_FALLBACK := libpvrPVR2D_DRIWSEGL.so
226
227ifneq ($(OMAP_NON_FLIP_DISPLAY),1) 252ifneq ($(OMAP_NON_FLIP_DISPLAY),1)
228PVR_DISPLAY_CONTROLLER_DRM_IOCTL := 1 253PVR_DISPLAY_CONTROLLER_DRM_IOCTL := 1
229endif 254endif
230
231else # xorg isn't excluded
232
233OPK_FALLBACK := libpvrPVR2D_BLITWSEGL.so
234
235endif # xorg isn't excluded 255endif # xorg isn't excluded
236 256
237ifeq ($(SUPPORT_DRI_DRM),1) 257ifeq ($(SUPPORT_DRI_DRM),1)
@@ -243,6 +263,7 @@ EXTRA_PVRSRVKM_COMPONENTS += $(DISPLAY_CONTROLLER_COMPONENT)
243else 263else
244KERNEL_COMPONENTS += $(DISPLAY_CONTROLLER_COMPONENT) 264KERNEL_COMPONENTS += $(DISPLAY_CONTROLLER_COMPONENT)
245endif 265endif
266endif
246 267
247include ../config/core.mk 268include ../config/core.mk
248include ../common/xorg.mk 269include ../common/xorg.mk
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/sunxi_android/Makefile b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/sunxi_android/Makefile
index 4473d62..9313a1b 100644
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/sunxi_android/Makefile
+++ b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/sunxi_android/Makefile
@@ -76,7 +76,7 @@ PVRSRV_DUMP_MK_TRACE ?= 1
76 76
77SUPPORT_ANDROID_SUNXI ?= 1 77SUPPORT_ANDROID_SUNXI ?= 1
78 78
79ION_DEFAULT_HEAP_MASK := ION_HEAP_CARVEOUT_MASK 79ION_DEFAULT_HEAP_ID_MASK := ION_HEAP_CARVEOUT_MASK
80 80
81# We have more memory on the sun6i platform, so we can spare to make 81# We have more memory on the sun6i platform, so we can spare to make
82# the pool larger, and have higher resolutions which benefit from it. 82# the pool larger, and have higher resolutions which benefit from it.
@@ -108,6 +108,8 @@ KERNEL_COMPONENTS += dc_nohw
108endif 108endif
109endif 109endif
110 110
111PVR_ANDROID_COMPOSERHAL ?= sunxi
112
111include ../config/core.mk 113include ../config/core.mk
112include ../common/android/extra_config.mk 114include ../common/android/extra_config.mk
113include ../common/opencl.mk 115include ../common/opencl.mk
diff --git a/jacinto6/sgx_src/eurasia_km/include4/img_defs.h b/jacinto6/sgx_src/eurasia_km/include4/img_defs.h
index bf0c360..b7447d7 100644
--- a/jacinto6/sgx_src/eurasia_km/include4/img_defs.h
+++ b/jacinto6/sgx_src/eurasia_km/include4/img_defs.h
@@ -211,6 +211,10 @@ typedef char TCHAR, *PTCHAR, *PTSTR;
211 #define IMG_UINT64_FMT "ll" /* May need to be updated as required, for other OSs */ 211 #define IMG_UINT64_FMT "ll" /* May need to be updated as required, for other OSs */
212#endif 212#endif
213 213
214/*
215 Some versions of MSVC don't have snprintf, vsnprintf in their CRTs.
216 Remap to the deprecated unix compatibility versions.
217*/
214 218
215#endif /* #if !defined (__IMG_DEFS_H__) */ 219#endif /* #if !defined (__IMG_DEFS_H__) */
216/***************************************************************************** 220/*****************************************************************************
diff --git a/jacinto6/sgx_src/eurasia_km/include4/pvr_debug.h b/jacinto6/sgx_src/eurasia_km/include4/pvr_debug.h
index fcc0275..be78c77 100644
--- a/jacinto6/sgx_src/eurasia_km/include4/pvr_debug.h
+++ b/jacinto6/sgx_src/eurasia_km/include4/pvr_debug.h
@@ -55,12 +55,12 @@ extern "C" {
55/* These are privately used by pvr_debug, use the PVR_DBG_ defines instead */ 55/* These are privately used by pvr_debug, use the PVR_DBG_ defines instead */
56#define DBGPRIV_FATAL 0x001UL 56#define DBGPRIV_FATAL 0x001UL
57#define DBGPRIV_ERROR 0x002UL 57#define DBGPRIV_ERROR 0x002UL
58#define DBGPRIV_WARNING 0x004UL 58#define DBGPRIV_BUFFERED 0x004UL
59#define DBGPRIV_MESSAGE 0x008UL 59#define DBGPRIV_WARNING 0x008UL
60#define DBGPRIV_VERBOSE 0x010UL 60#define DBGPRIV_MESSAGE 0x010UL
61#define DBGPRIV_CALLTRACE 0x020UL 61#define DBGPRIV_VERBOSE 0x020UL
62#define DBGPRIV_ALLOC 0x040UL 62#define DBGPRIV_CALLTRACE 0x040UL
63#define DBGPRIV_BUFFERED 0x080UL 63#define DBGPRIV_ALLOC 0x080UL
64#define DBGPRIV_DBGDRV_MESSAGE 0x100UL 64#define DBGPRIV_DBGDRV_MESSAGE 0x100UL
65 65
66#define DBGPRIV_DBGLEVEL_COUNT 9 66#define DBGPRIV_DBGLEVEL_COUNT 9
@@ -139,33 +139,72 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugAssertFail(const IMG_CHAR *pszFile,
139 /* New logging mechanism */ 139 /* New logging mechanism */
140 #define PVR_DBG_FATAL DBGPRIV_FATAL 140 #define PVR_DBG_FATAL DBGPRIV_FATAL
141 #define PVR_DBG_ERROR DBGPRIV_ERROR 141 #define PVR_DBG_ERROR DBGPRIV_ERROR
142 #define PVR_DBG_BUFFERED DBGPRIV_BUFFERED
142 #define PVR_DBG_WARNING DBGPRIV_WARNING 143 #define PVR_DBG_WARNING DBGPRIV_WARNING
143 #define PVR_DBG_MESSAGE DBGPRIV_MESSAGE 144 #define PVR_DBG_MESSAGE DBGPRIV_MESSAGE
144 #define PVR_DBG_VERBOSE DBGPRIV_VERBOSE 145 #define PVR_DBG_VERBOSE DBGPRIV_VERBOSE
145 #define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE 146 #define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE
146 #define PVR_DBG_ALLOC DBGPRIV_ALLOC 147 #define PVR_DBG_ALLOC DBGPRIV_ALLOC
147 #define PVR_DBG_BUFFERED DBGPRIV_BUFFERED
148 #define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE 148 #define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE
149 149
150 /* These levels are always on with PVRSRV_NEED_PVR_DPF */ 150 /* These levels are always on with PVRSRV_NEED_PVR_DPF */
151 #define __PVR_DPF_0x001UL(x...) PVRSRVDebugPrintf(DBGPRIV_FATAL, x) 151 #define __PVR_DPF_0x001UL(x...) PVRSRVDebugPrintf(DBGPRIV_FATAL, x)
152 #define __PVR_DPF_0x002UL(x...) PVRSRVDebugPrintf(DBGPRIV_ERROR, x) 152 #define __PVR_DPF_0x002UL(x...) PVRSRVDebugPrintf(DBGPRIV_ERROR, x)
153 #define __PVR_DPF_0x080UL(x...) PVRSRVDebugPrintf(DBGPRIV_BUFFERED, x) 153 #define __PVR_DPF_0x004UL(x...) PVRSRVDebugPrintf(DBGPRIV_BUFFERED, x)
154 154
155 /* Some are compiled out completely in release builds */ 155 /* Some are compiled out completely in release builds */
156#if defined(DEBUG) 156#if defined(DEBUG)
157 #define __PVR_DPF_0x004UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x) 157 #define __PVR_DPF_0x008UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x)
158 #define __PVR_DPF_0x008UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x) 158 #define __PVR_DPF_0x010UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x)
159 #define __PVR_DPF_0x010UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x) 159 #define __PVR_DPF_0x020UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x)
160 #define __PVR_DPF_0x020UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x) 160 #define __PVR_DPF_0x040UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x)
161 #define __PVR_DPF_0x040UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x) 161 #define __PVR_DPF_0x080UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x)
162 #define __PVR_DPF_0x100UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x)
163
164#elif defined(PVR_DBGPRIV_LEVEL)
165
166#if (PVR_DBGPRIV_LEVEL >= DBGPRIV_WARNING)
167 #define __PVR_DPF_0x008UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x)
168#else
169 #define __PVR_DPF_0x008UL(x...)
170#endif
171
172#if (PVR_DBGPRIV_LEVEL >= DBGPRIV_MESSAGE)
173 #define __PVR_DPF_0x010UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x)
174#else
175 #define __PVR_DPF_0x010UL(x...)
176#endif
177
178#if (PVR_DBGPRIV_LEVEL >= DBGPRIV_VERBOSE)
179 #define __PVR_DPF_0x020UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x)
180#else
181 #define __PVR_DPF_0x020UL(x...)
182#endif
183
184#if (PVR_DBGPRIV_LEVEL >= DBGPRIV_CALLTRACE)
185 #define __PVR_DPF_0x040UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x)
186#else
187 #define __PVR_DPF_0x040UL(x...)
188#endif
189
190#if (PVR_DBGPRIV_LEVEL >= DBGPRIV_ALLOC)
191 #define __PVR_DPF_0x080UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x)
192#else
193 #define __PVR_DPF_0x080UL(x...)
194#endif
195
196#if (PVR_DBGPRIV_LEVEL >= DBGPRIV_DBGDRV_MESSAGE)
162 #define __PVR_DPF_0x100UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x) 197 #define __PVR_DPF_0x100UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x)
163#else 198#else
164 #define __PVR_DPF_0x004UL(x...) 199 #define __PVR_DPF_0x100UL(x...)
200#endif
201
202#else
165 #define __PVR_DPF_0x008UL(x...) 203 #define __PVR_DPF_0x008UL(x...)
166 #define __PVR_DPF_0x010UL(x...) 204 #define __PVR_DPF_0x010UL(x...)
167 #define __PVR_DPF_0x020UL(x...) 205 #define __PVR_DPF_0x020UL(x...)
168 #define __PVR_DPF_0x040UL(x...) 206 #define __PVR_DPF_0x040UL(x...)
207 #define __PVR_DPF_0x080UL(x...)
169 #define __PVR_DPF_0x100UL(x...) 208 #define __PVR_DPF_0x100UL(x...)
170#endif 209#endif
171 210
@@ -204,6 +243,10 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel,
204 const IMG_CHAR *pszFormat, 243 const IMG_CHAR *pszFormat,
205 ...) IMG_FORMAT_PRINTF(4, 5); 244 ...) IMG_FORMAT_PRINTF(4, 5);
206 245
246#if defined(PVR_DBGPRIV_LEVEL) && defined(SUPPORT_ANDROID_PLATFORM)
247IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintfSetLevel(IMG_UINT32 ui32DebugLevel);
248#endif
249
207IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintfDumpCCB(void); 250IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintfDumpCCB(void);
208 251
209#else /* defined(PVRSRV_NEED_PVR_DPF) */ 252#else /* defined(PVRSRV_NEED_PVR_DPF) */
diff --git a/jacinto6/sgx_src/eurasia_km/include4/pvrversion.h b/jacinto6/sgx_src/eurasia_km/include4/pvrversion.h
index a8dbd13..d48838f 100644
--- a/jacinto6/sgx_src/eurasia_km/include4/pvrversion.h
+++ b/jacinto6/sgx_src/eurasia_km/include4/pvrversion.h
@@ -49,20 +49,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49#define PVR_STR2(X) PVR_STR(X) 49#define PVR_STR2(X) PVR_STR(X)
50 50
51#define PVRVERSION_MAJ 1 51#define PVRVERSION_MAJ 1
52#define PVRVERSION_MIN 12 52#define PVRVERSION_MIN 14
53 53
54#define PVRVERSION_FAMILY "sgxddk" 54#define PVRVERSION_FAMILY "sgxddk"
55#define PVRVERSION_BRANCHNAME "1.12" 55#define PVRVERSION_BRANCHNAME "1.14"
56#define PVRVERSION_BUILD 2917986 56#define PVRVERSION_BUILD 4001660
57#define PVRVERSION_BSCONTROL "SGX_DDK" 57#define PVRVERSION_BSCONTROL "SGX_DDK_Linux_XOrg"
58 58
59#define PVRVERSION_STRING "SGX_DDK sgxddk 1.12@" PVR_STR2(PVRVERSION_BUILD) 59#define PVRVERSION_STRING "SGX_DDK_Linux_XOrg sgxddk 1.14@" PVR_STR2(PVRVERSION_BUILD)
60#define PVRVERSION_STRING_SHORT "1.12@" PVR_STR2(PVRVERSION_BUILD) "" 60#define PVRVERSION_STRING_SHORT "1.14@" PVR_STR2(PVRVERSION_BUILD) ""
61 61
62#define COPYRIGHT_TXT "Copyright (c) Imagination Technologies Ltd. All Rights Reserved." 62#define COPYRIGHT_TXT "Copyright (c) Imagination Technologies Ltd. All Rights Reserved."
63 63
64#define PVRVERSION_BUILD_HI 291 64#define PVRVERSION_BUILD_HI 400
65#define PVRVERSION_BUILD_LO 7986 65#define PVRVERSION_BUILD_LO 1660
66#define PVRVERSION_STRING_NUMERIC PVR_STR2(PVRVERSION_MAJ) "." PVR_STR2(PVRVERSION_MIN) "." PVR_STR2(PVRVERSION_BUILD_HI) "." PVR_STR2(PVRVERSION_BUILD_LO) 66#define PVRVERSION_STRING_NUMERIC PVR_STR2(PVRVERSION_MAJ) "." PVR_STR2(PVRVERSION_MIN) "." PVR_STR2(PVRVERSION_BUILD_HI) "." PVR_STR2(PVRVERSION_BUILD_LO)
67 67
68#endif /* _PVRVERSION_H_ */ 68#endif /* _PVRVERSION_H_ */
diff --git a/jacinto6/sgx_src/eurasia_km/include4/services.h b/jacinto6/sgx_src/eurasia_km/include4/services.h
index cca0f7d..a5767cb 100644
--- a/jacinto6/sgx_src/eurasia_km/include4/services.h
+++ b/jacinto6/sgx_src/eurasia_km/include4/services.h
@@ -92,7 +92,6 @@ extern "C" {
92#define PVRSRV_MEM_NO_RESMAN (1U<<10) 92#define PVRSRV_MEM_NO_RESMAN (1U<<10)
93#define PVRSRV_MEM_EXPORTED (1U<<11) 93#define PVRSRV_MEM_EXPORTED (1U<<11)
94 94
95
96/* 95/*
97 Heap Attribute flags 96 Heap Attribute flags
98 (bits 12-23) 97 (bits 12-23)
@@ -169,8 +168,6 @@ extern "C" {
169#define PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT (1U<<7) 168#define PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT (1U<<7)
170#define PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT (1U<<8) 169#define PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT (1U<<8)
171#define PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT (1U<<9) 170#define PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT (1U<<9)
172#define PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT (1U<<10)
173#define PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT (1U<<11)
174 171
175#define PVRSRV_MISC_INFO_RESET_PRESENT (1U<<31) 172#define PVRSRV_MISC_INFO_RESET_PRESENT (1U<<31)
176 173
@@ -402,6 +399,26 @@ typedef struct _PVRSRV_MEMBLK_
402 ****************************************************************************** 399 ******************************************************************************
403 * Memory Management (externel interface) 400 * Memory Management (externel interface)
404 *****************************************************************************/ 401 *****************************************************************************/
402#if defined (PVRSRV_DEVMEM_TIME_STATS)
403typedef struct _DEVMEM_UNMAPPING_TIME_STATS_
404{
405 IMG_UINT32 ui32TimeToCPUUnmap;
406 IMG_UINT32 ui32TimeToDevUnmap;
407} DEVMEM_UNMAPPING_TIME_STATS;
408
409typedef struct _PVRSRV_DEVMEM_TIMING_STATS_
410{
411 /* This struct holds time taken to map/unmap device memory into CPU/GPU in microsec granularity */
412 struct
413 {
414 IMG_UINT32 ui32TimeToCPUMap;
415 IMG_UINT32 ui32TimeToDevMap;
416 } sDevMemMapTimes;
417
418 DEVMEM_UNMAPPING_TIME_STATS *psDevMemUnmapTimes; /* User supplied space for "unmap" timings */
419} PVRSRV_DEVMEM_TIMING_STATS;
420#endif
421
405typedef struct _PVRSRV_KERNEL_MEM_INFO_ *PPVRSRV_KERNEL_MEM_INFO; 422typedef struct _PVRSRV_KERNEL_MEM_INFO_ *PPVRSRV_KERNEL_MEM_INFO;
406 423
407typedef struct _PVRSRV_CLIENT_MEM_INFO_ 424typedef struct _PVRSRV_CLIENT_MEM_INFO_
@@ -446,12 +463,16 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_
446 IMG_UINT32 dummy2; 463 IMG_UINT32 dummy2;
447 #endif /* !defined(USE_CODE) */ 464 #endif /* !defined(USE_CODE) */
448#endif /* defined(SUPPORT_MEMINFO_IDS) */ 465#endif /* defined(SUPPORT_MEMINFO_IDS) */
449#if defined(SUPPORT_DRM_GEM)
450 IMG_SIZE_T uiDmabufBufferSize;
451#endif /* defined(SUPPORT_DRM_GEM) */
452#if defined(SUPPORT_ION) 466#if defined(SUPPORT_ION)
453 IMG_SIZE_T uiIonBufferSize; 467 IMG_SIZE_T uiIonBufferSize;
454#endif /* defined(SUPPORT_ION) */ 468#endif /* defined(SUPPORT_ION) */
469#if defined(SUPPORT_DMABUF)
470 IMG_SIZE_T uiDmaBufSize;
471#endif /* defined(SUPPORT_ION) */
472
473#if defined (PVRSRV_DEVMEM_TIME_STATS)
474 PVRSRV_DEVMEM_TIMING_STATS sDevMemTimingStats;
475#endif
455 476
456 /* 477 /*
457 ptr to next mem info 478 ptr to next mem info
@@ -582,7 +603,6 @@ typedef struct _PVRSRV_MISC_INFO_
582 } sGetRefCountCtl; 603 } sGetRefCountCtl;
583 604
584 IMG_UINT32 ui32PageSize; 605 IMG_UINT32 ui32PageSize;
585 IMG_INT32 iDrmFd;
586} PVRSRV_MISC_INFO; 606} PVRSRV_MISC_INFO;
587 607
588/*! 608/*!
@@ -784,21 +804,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory2(IMG_CONST PVRSRV_DEV_DATA *psDe
784 PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo); 804 PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo);
785#endif /* defined(LINUX) */ 805#endif /* defined(LINUX) */
786 806
787#if defined(SUPPORT_DRM_GEM)
788PVRSRV_ERROR PVRSRVMapDmabuf(const PVRSRV_DEV_DATA *psDevData,
789 IMG_HANDLE hDevMemHeap,
790 IMG_UINT32 ui32NumFDs,
791 IMG_INT *paiBufferFDs,
792 IMG_UINT32 ui32ChunkCount,
793 IMG_SIZE_T *pauiOffset,
794 IMG_SIZE_T *pauiSize,
795 IMG_UINT32 ui32Attribs,
796 PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
797
798PVRSRV_ERROR PVRSRVUnmapDmabuf(const PVRSRV_DEV_DATA *psDevData,
799 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
800#endif /* defined (SUPPORT_DRM_GEM) */
801
802#if defined(SUPPORT_ION) 807#if defined(SUPPORT_ION)
803PVRSRV_ERROR PVRSRVMapIonHandle(const PVRSRV_DEV_DATA *psDevData, 808PVRSRV_ERROR PVRSRVMapIonHandle(const PVRSRV_DEV_DATA *psDevData,
804 IMG_HANDLE hDevMemHeap, 809 IMG_HANDLE hDevMemHeap,
@@ -814,6 +819,29 @@ PVRSRV_ERROR PVRSRVUnmapIonHandle(const PVRSRV_DEV_DATA *psDevData,
814 PVRSRV_CLIENT_MEM_INFO *psMemInfo); 819 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
815#endif /* defined (SUPPORT_ION) */ 820#endif /* defined (SUPPORT_ION) */
816 821
822#if defined(SUPPORT_DMABUF)
823IMG_IMPORT
824PVRSRV_ERROR PVRSRVMapDmaBufs(const PVRSRV_DEV_DATA *psDevData,
825 const IMG_HANDLE hDevMemHeap,
826 const IMG_UINT32 ui32Attribs,
827 const IMG_UINT32 ui32NumFDs,
828 const IMG_INT *piDmaBufFD,
829 const IMG_SIZE_T *puiDmaBufOffset,
830 const IMG_SIZE_T *puiDmaBufSize,
831 PVRSRV_CLIENT_MEM_INFO **ppsMemInfo,
832 IMG_SIZE_T *puiMemInfoOffset);
833
834IMG_IMPORT
835PVRSRV_ERROR PVRSRVMapDmaBuf(const PVRSRV_DEV_DATA *psDevData,
836 const IMG_HANDLE hDevMemHeap,
837 const IMG_INT iDmaBufFD,
838 const IMG_UINT32 ui32Attribs,
839 PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
840
841IMG_IMPORT
842PVRSRV_ERROR PVRSRVUnmapDmaBuf(const PVRSRV_DEV_DATA *psDevData,
843 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
844#endif /* SUPPORT_DMABUF */
817 845
818IMG_IMPORT 846IMG_IMPORT
819PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMemSparse(const PVRSRV_DEV_DATA *psDevData, 847PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMemSparse(const PVRSRV_DEV_DATA *psDevData,
diff --git a/jacinto6/sgx_src/eurasia_km/include4/servicesext.h b/jacinto6/sgx_src/eurasia_km/include4/servicesext.h
index a0aff8c..ffb89b9 100644
--- a/jacinto6/sgx_src/eurasia_km/include4/servicesext.h
+++ b/jacinto6/sgx_src/eurasia_km/include4/servicesext.h
@@ -762,6 +762,9 @@ typedef struct PVRSRV_RESOURCE_TAG
762{ 762{
763 volatile IMG_UINT32 ui32Lock; 763 volatile IMG_UINT32 ui32Lock;
764 IMG_UINT32 ui32ID; 764 IMG_UINT32 ui32ID;
765#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
766 IMG_VOID *pOSSyncPrimitive;
767#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
765}PVRSRV_RESOURCE; 768}PVRSRV_RESOURCE;
766typedef PVRSRV_RESOURCE PVRSRV_RES_HANDLE; 769typedef PVRSRV_RESOURCE PVRSRV_RES_HANDLE;
767 770
@@ -925,12 +928,17 @@ typedef struct _PVRSRV_REGISTRY_INFO_
925PVRSRV_ERROR IMG_CALLCONV PVRSRVReadRegistryString (PPVRSRV_REGISTRY_INFO psRegInfo); 928PVRSRV_ERROR IMG_CALLCONV PVRSRVReadRegistryString (PPVRSRV_REGISTRY_INFO psRegInfo);
926PVRSRV_ERROR IMG_CALLCONV PVRSRVWriteRegistryString (PPVRSRV_REGISTRY_INFO psRegInfo); 929PVRSRV_ERROR IMG_CALLCONV PVRSRVWriteRegistryString (PPVRSRV_REGISTRY_INFO psRegInfo);
927 930
931#define PVRSRV_BC_FLAGS_YUVCSC_RANGE_MASK (0x01)
932#define PVRSRV_BC_FLAGS_YUVCSC_RANGE_SHIFT (0x00)
933#define PVRSRV_BC_FLAGS_YUVCSC_CONFORMANT_RANGE (0 << PVRSRV_BC_FLAGS_YUVCSC_RANGE_SHIFT)
934#define PVRSRV_BC_FLAGS_YUVCSC_FULL_RANGE (1 << PVRSRV_BC_FLAGS_YUVCSC_RANGE_SHIFT)
928 935
929#define PVRSRV_BC_FLAGS_YUVCSC_CONFORMANT_RANGE (0 << 0) 936#define PVRSRV_BC_FLAGS_YUVCSC_CS_MASK (0x02)
930#define PVRSRV_BC_FLAGS_YUVCSC_FULL_RANGE (1 << 0) 937#define PVRSRV_BC_FLAGS_YUVCSC_CS_SHIFT (0x01)
938#define PVRSRV_BC_FLAGS_YUVCSC_BT601 (0 << PVRSRV_BC_FLAGS_YUVCSC_CS_SHIFT)
939#define PVRSRV_BC_FLAGS_YUVCSC_BT709 (1 << PVRSRV_BC_FLAGS_YUVCSC_CS_SHIFT)
931 940
932#define PVRSRV_BC_FLAGS_YUVCSC_BT601 (0 << 1) 941#define PVRSRV_BC_FLAGS_YUVCSC_MASK (PVRSRV_BC_FLAGS_YUVCSC_RANGE_MASK | PVRSRV_BC_FLAGS_YUVCSC_CS_MASK)
933#define PVRSRV_BC_FLAGS_YUVCSC_BT709 (1 << 1)
934 942
935#define MAX_BUFFER_DEVICE_NAME_SIZE (50) /* arbitrary choice! */ 943#define MAX_BUFFER_DEVICE_NAME_SIZE (50) /* arbitrary choice! */
936 944
diff --git a/jacinto6/sgx_src/eurasia_km/include4/sgxapi_km.h b/jacinto6/sgx_src/eurasia_km/include4/sgxapi_km.h
index d001e6f..6453db6 100644
--- a/jacinto6/sgx_src/eurasia_km/include4/sgxapi_km.h
+++ b/jacinto6/sgx_src/eurasia_km/include4/sgxapi_km.h
@@ -84,7 +84,12 @@ extern "C" {
84#define SGX_VPB_TILED_HEAP_ID 14 84#define SGX_VPB_TILED_HEAP_ID 14
85#endif 85#endif
86 86
87#define SGX_MAX_HEAP_ID 15 87#if defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION)
88 #define SGX_TEXTURE_HEAP_ID 15
89 #define SGX_MAX_HEAP_ID 16
90#else
91 #define SGX_MAX_HEAP_ID 15
92#endif
88 93
89/* 94/*
90 * Keep SGX_3DPARAMETERS_HEAP_ID as TQ full custom 95 * Keep SGX_3DPARAMETERS_HEAP_ID as TQ full custom
@@ -106,20 +111,12 @@ extern "C" {
106#define SGX_MAX_TA_STATUS_VALS 32 111#define SGX_MAX_TA_STATUS_VALS 32
107#define SGX_MAX_3D_STATUS_VALS 4 112#define SGX_MAX_3D_STATUS_VALS 4
108 113
109#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
110/* sync info structure array size */
111#define SGX_MAX_TA_DST_SYNCS 1
112#define SGX_MAX_TA_SRC_SYNCS 1
113#define SGX_MAX_3D_SRC_SYNCS 4
114/* note: there is implicitly 1 3D Dst Sync */
115#else
116/* sync info structure array size */ 114/* sync info structure array size */
117#define SGX_MAX_SRC_SYNCS_TA 32 115#define SGX_MAX_SRC_SYNCS_TA 32
118#define SGX_MAX_DST_SYNCS_TA 1 116#define SGX_MAX_DST_SYNCS_TA 1
119/* note: only one dst sync is supported by the 2D paths */ 117/* note: only one dst sync is supported by the 2D paths */
120#define SGX_MAX_SRC_SYNCS_TQ 6 118#define SGX_MAX_SRC_SYNCS_TQ 6
121#define SGX_MAX_DST_SYNCS_TQ 2 119#define SGX_MAX_DST_SYNCS_TQ 2
122#endif
123 120
124 121
125#if defined(SGX_FEATURE_EXTENDED_PERF_COUNTERS) 122#if defined(SGX_FEATURE_EXTENDED_PERF_COUNTERS)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c b/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c
index 5a6f99f..9000e96 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c
@@ -353,6 +353,7 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice,
353 DC_NOHW_SWAPCHAIN *psSwapChain; 353 DC_NOHW_SWAPCHAIN *psSwapChain;
354 DC_NOHW_BUFFER *psBuffer; 354 DC_NOHW_BUFFER *psBuffer;
355 IMG_UINT32 i; 355 IMG_UINT32 i;
356 PVRSRV_ERROR eError;
356 357
357 UNREFERENCED_PARAMETER(ui32OEMFlags); 358 UNREFERENCED_PARAMETER(ui32OEMFlags);
358 UNREFERENCED_PARAMETER(pui32SwapChainID); 359 UNREFERENCED_PARAMETER(pui32SwapChainID);
@@ -386,11 +387,11 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice,
386 387
387 if (ui32BufferCount) 388 if (ui32BufferCount)
388 { 389 {
389
390 /* check the buffer count */ 390 /* check the buffer count */
391 if(ui32BufferCount > DC_NOHW_MAX_BACKBUFFERS) 391 if(ui32BufferCount > DC_NOHW_MAX_BACKBUFFERS)
392 { 392 {
393 return (PVRSRV_ERROR_TOOMANYBUFFERS); 393 eError = PVRSRV_ERROR_TOOMANYBUFFERS;
394 goto ExitError;
394 } 395 }
395 396
396 /* 397 /*
@@ -403,7 +404,8 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice,
403 || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sSysDims.ui32Height) 404 || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sSysDims.ui32Height)
404 { 405 {
405 /* DST doesn't match the current mode */ 406 /* DST doesn't match the current mode */
406 return (PVRSRV_ERROR_INVALID_PARAMS); 407 eError = PVRSRV_ERROR_INVALID_PARAMS;
408 goto ExitError;
407 } 409 }
408 410
409 if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat 411 if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat
@@ -412,19 +414,18 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice,
412 || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) 414 || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height)
413 { 415 {
414 /* DST doesn't match the SRC */ 416 /* DST doesn't match the SRC */
415 return (PVRSRV_ERROR_INVALID_PARAMS); 417 eError = PVRSRV_ERROR_INVALID_PARAMS;
418 goto ExitError;
416 } 419 }
417 420
418 /* INTEGRATION_POINT: check the flags */ 421 /* INTEGRATION_POINT: check the flags */
419 UNREFERENCED_PARAMETER(ui32Flags); 422 UNREFERENCED_PARAMETER(ui32Flags);
420 423
421
422
423 psBuffer = (DC_NOHW_BUFFER*)AllocKernelMem(sizeof(DC_NOHW_BUFFER) * ui32BufferCount); 424 psBuffer = (DC_NOHW_BUFFER*)AllocKernelMem(sizeof(DC_NOHW_BUFFER) * ui32BufferCount);
424 if(!psBuffer) 425 if(!psBuffer)
425 { 426 {
426 FreeKernelMem(psSwapChain); 427 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
427 return (PVRSRV_ERROR_OUT_OF_MEMORY); 428 goto ExitError;
428 } 429 }
429 430
430 /* initialise allocations */ 431 /* initialise allocations */
@@ -469,6 +470,10 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice,
469 /* INTEGRATION_POINT: enable Vsync ISR */ 470 /* INTEGRATION_POINT: enable Vsync ISR */
470 471
471 return (PVRSRV_OK); 472 return (PVRSRV_OK);
473
474ExitError:
475 FreeKernelMem(psSwapChain);
476 return eError;
472} 477}
473 478
474 479
@@ -644,7 +649,7 @@ static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie,
644 /* validate data packet */ 649 /* validate data packet */
645 psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND*)pvData; 650 psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND*)pvData;
646 /* Under android, this may be a DISPLAYCLASS_FLIP_COMMAND2, but the structs 651 /* Under android, this may be a DISPLAYCLASS_FLIP_COMMAND2, but the structs
647 * are compatable for everything used by dc_nohw so it makes no difference */ 652 * are compatible for everything used by dc_nohw so it makes no difference */
648 if (psFlipCmd == IMG_NULL) 653 if (psFlipCmd == IMG_NULL)
649 { 654 {
650 return (IMG_FALSE); 655 return (IMG_FALSE);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c b/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c
index 7af5703..be168c3 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c
@@ -93,11 +93,7 @@ extern struct ion_device *omap_ion_device;
93#error CONFIG_DSSCOMP support requires CONFIG_ION_OMAP 93#error CONFIG_DSSCOMP support requires CONFIG_ION_OMAP
94#endif /* defined(CONFIG_ION_OMAP) */ 94#endif /* defined(CONFIG_ION_OMAP) */
95#if defined(CONFIG_DRM_OMAP_DMM_TILER) 95#if defined(CONFIG_DRM_OMAP_DMM_TILER)
96#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
97#include <../drivers/gpu/drm/omapdrm/omap_dmm_tiler.h>
98#else
99#include <../drivers/staging/omapdrm/omap_dmm_tiler.h> 96#include <../drivers/staging/omapdrm/omap_dmm_tiler.h>
100#endif
101#include <../drivers/video/omap2/dsscomp/tiler-utils.h> 97#include <../drivers/video/omap2/dsscomp/tiler-utils.h>
102#elif defined(CONFIG_TI_TILER) 98#elif defined(CONFIG_TI_TILER)
103#include <mach/tiler.h> 99#include <mach/tiler.h>
@@ -972,10 +968,7 @@ void OMAPLFBSwapHandler(OMAPLFB_BUFFER *psBuffer)
972 if (bPreviouslyNotVSynced || psSwapChain->iBlankEvents != iBlankEvents) 968 if (bPreviouslyNotVSynced || psSwapChain->iBlankEvents != iBlankEvents)
973 { 969 {
974 psSwapChain->iBlankEvents = iBlankEvents; 970 psSwapChain->iBlankEvents = iBlankEvents;
975 if (eMode == OMAPLFB_UPDATE_MODE_AUTO) 971 psSwapChain->bNotVSynced = !WaitForVSyncSettle(psDevInfo);
976 {
977 psSwapChain->bNotVSynced = !WaitForVSyncSettle(psDevInfo);
978 }
979 } else if (psBuffer->ulSwapInterval != 0) 972 } else if (psBuffer->ulSwapInterval != 0)
980 { 973 {
981 psSwapChain->bNotVSynced = !OMAPLFBWaitForVSync(psDevInfo); 974 psSwapChain->bNotVSynced = !OMAPLFBWaitForVSync(psDevInfo);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c b/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c
index 2374784..c8072f5 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c
@@ -106,11 +106,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
106 * OmapZoom.org OMAP4 2.6.34 kernel tree - Needs plat/vrfb.h 106 * OmapZoom.org OMAP4 2.6.34 kernel tree - Needs plat/vrfb.h
107 * Sholes 2.6.32 kernel tree - Needs plat/vrfb.h 107 * Sholes 2.6.32 kernel tree - Needs plat/vrfb.h
108 */ 108 */
109#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) 109#if defined(SYS_OMAP5_UEVM)
110#define PVR_OMAPFB3_OMAP5_UEVM
111#endif
112
113#if defined(PVR_OMAPFB3_OMAP5_UEVM)
110#define PVR_OMAPFB3_NEEDS_VIDEO_OMAPVRFB_H 114#define PVR_OMAPFB3_NEEDS_VIDEO_OMAPVRFB_H
111#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) 115#else
116#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
112#define PVR_OMAPFB3_NEEDS_PLAT_VRFB_H 117#define PVR_OMAPFB3_NEEDS_PLAT_VRFB_H
113#endif 118#endif
119#endif
114 120
115#if defined(PVR_OMAPFB3_NEEDS_VIDEO_OMAPVRFB_H) 121#if defined(PVR_OMAPFB3_NEEDS_VIDEO_OMAPVRFB_H)
116#include <video/omapvrfb.h> 122#include <video/omapvrfb.h>
@@ -141,11 +147,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
141 147
142#if defined(CONFIG_DSSCOMP) 148#if defined(CONFIG_DSSCOMP)
143#if defined(CONFIG_DRM_OMAP_DMM_TILER) 149#if defined(CONFIG_DRM_OMAP_DMM_TILER)
144#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
145#include <../drivers/gpu/drm/omapdrm/omap_dmm_tiler.h>
146#else
147#include <../drivers/staging/omapdrm/omap_dmm_tiler.h> 150#include <../drivers/staging/omapdrm/omap_dmm_tiler.h>
148#endif
149#include <../drivers/video/omap2/dsscomp/tiler-utils.h> 151#include <../drivers/video/omap2/dsscomp/tiler-utils.h>
150#elif defined(CONFIG_TI_TILER) 152#elif defined(CONFIG_TI_TILER)
151#include <mach/tiler.h> 153#include <mach/tiler.h>
@@ -179,11 +181,6 @@ MODULE_SUPPORTED_DEVICE(DEVNAME);
179#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev)->output->manager 181#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev)->output->manager
180#define WAIT_FOR_VSYNC(man) ((man)->wait_for_vsync) 182#define WAIT_FOR_VSYNC(man) ((man)->wait_for_vsync)
181#else /* defined(PVR_OMAPFB3_OMAP5_UEVM) */ 183#else /* defined(PVR_OMAPFB3_OMAP5_UEVM) */
182#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
183#define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_driver *drv = (dev)->driver
184#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev)->output->manager
185#define WAIT_FOR_VSYNC(man) ((man)->wait_for_vsync)
186#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) 184#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
188#define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_driver *drv = (dev) != NULL ? (dev)->driver : NULL 185#define OMAP_DSS_DRIVER(drv, dev) struct omap_dss_driver *drv = (dev) != NULL ? (dev)->driver : NULL
189#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev) != NULL ? (dev)->manager : NULL 186#define OMAP_DSS_MANAGER(man, dev) struct omap_overlay_manager *man = (dev) != NULL ? (dev)->manager : NULL
@@ -193,7 +190,6 @@ MODULE_SUPPORTED_DEVICE(DEVNAME);
193#define OMAP_DSS_MANAGER(man, dev) struct omap_dss_device *man = (dev) 190#define OMAP_DSS_MANAGER(man, dev) struct omap_dss_device *man = (dev)
194#define WAIT_FOR_VSYNC(man) ((man)->wait_vsync) 191#define WAIT_FOR_VSYNC(man) ((man)->wait_vsync)
195#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */ 192#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */
196#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
197#endif /* defined(PVR_OMAPFB3_OMAP5_UEVM) */ 193#endif /* defined(PVR_OMAPFB3_OMAP5_UEVM) */
198#endif /* !defined(PVR_OMAPLFB_DRM_FB) */ 194#endif /* !defined(PVR_OMAPLFB_DRM_FB) */
199 195
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/ion_sys_private.h b/jacinto6/sgx_src/eurasia_km/services4/include/ion_sys_private.h
new file mode 100644
index 0000000..8b2c467
--- /dev/null
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/ion_sys_private.h
@@ -0,0 +1,50 @@
1/*************************************************************************/ /*!
2@File ion_sys_private.h
3@Title System-specific private data for ion support code
4@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
43#include SUPPORT_ION_HEADER
44
45typedef struct
46{
47 ion_phys_addr_t uiHeapBase;
48 size_t uiHeapSize;
49 IMG_CPU_PHYADDR sPCIAddrRangeStart;
50} ION_TC_PRIVATE_DATA;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/kerneldisplay.h b/jacinto6/sgx_src/eurasia_km/services4/include/kerneldisplay.h
index 048cb43..fe6ec15 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/kerneldisplay.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/kerneldisplay.h
@@ -166,6 +166,9 @@ typedef struct DISPLAYCLASS_FLIP_COMMAND_TAG
166 /* Ext SwapChain Handle */ 166 /* Ext SwapChain Handle */
167 IMG_HANDLE hExtSwapChain; 167 IMG_HANDLE hExtSwapChain;
168 168
169 /* number of vsync intervals between successive flips */
170 IMG_UINT32 ui32SwapInterval;
171
169 /* Ext Buffer Handle (Buffer to Flip to) */ 172 /* Ext Buffer Handle (Buffer to Flip to) */
170 IMG_HANDLE hExtBuffer; 173 IMG_HANDLE hExtBuffer;
171 174
@@ -178,9 +181,6 @@ typedef struct DISPLAYCLASS_FLIP_COMMAND_TAG
178 /* clip rects */ 181 /* clip rects */
179 IMG_RECT *psClipRect; 182 IMG_RECT *psClipRect;
180 183
181 /* number of vsync intervals between successive flips */
182 IMG_UINT32 ui32SwapInterval;
183
184} DISPLAYCLASS_FLIP_COMMAND; 184} DISPLAYCLASS_FLIP_COMMAND;
185 185
186 186
@@ -192,12 +192,12 @@ typedef struct DISPLAYCLASS_FLIP_COMMAND2_TAG
192 /* Ext SwapChain Handle */ 192 /* Ext SwapChain Handle */
193 IMG_HANDLE hExtSwapChain; 193 IMG_HANDLE hExtSwapChain;
194 194
195 /* Unused field, padding for compatibility with above structure */
196 IMG_HANDLE hUnused;
197
198 /* number of vsync intervals between successive flips */ 195 /* number of vsync intervals between successive flips */
199 IMG_UINT32 ui32SwapInterval; 196 IMG_UINT32 ui32SwapInterval;
200 197
198 /* Unused field, padding for compatibility with above structure */
199 IMG_HANDLE hUnused;
200
201 /* private data from userspace */ 201 /* private data from userspace */
202 IMG_PVOID pvPrivData; 202 IMG_PVOID pvPrivData;
203 203
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge.h b/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge.h
index f8e1439..8b37e39 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge.h
@@ -121,11 +121,22 @@ extern "C" {
121#define PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+26) 121#define PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+26)
122#define PVRSRV_BRIDGE_MAP_DEV_MEMORY_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+27) 122#define PVRSRV_BRIDGE_MAP_DEV_MEMORY_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+27)
123#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+28) 123#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+28)
124#define PVRSRV_BRIDGE_MAP_DMABUF PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29) 124#if defined (SUPPORT_ION)
125#define PVRSRV_BRIDGE_UNMAP_DMABUF PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30) 125#define PVRSRV_BRIDGE_MAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29)
126#define PVRSRV_BRIDGE_MAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+31) 126#define PVRSRV_BRIDGE_UNMAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30)
127#define PVRSRV_BRIDGE_UNMAP_ION_HANDLE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+32) 127#define PVRSRV_BRIDGE_ION_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+30)
128#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+32) 128#else
129#define PVRSRV_BRIDGE_ION_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+28)
130#endif
131#if defined (SUPPORT_DMABUF)
132#define PVRSRV_BRIDGE_DMABUF_CMD_FIRST (PVRSRV_BRIDGE_ION_CMD_LAST+1)
133#define PVRSRV_BRIDGE_MAP_DMABUF PVRSRV_IOWR(PVRSRV_BRIDGE_DMABUF_CMD_FIRST+0)
134#define PVRSRV_BRIDGE_UNMAP_DMABUF PVRSRV_IOWR(PVRSRV_BRIDGE_DMABUF_CMD_FIRST+1)
135#define PVRSRV_BRIDGE_DMABUF_CMD_LAST (PVRSRV_BRIDGE_DMABUF_CMD_FIRST+1)
136#else
137#define PVRSRV_BRIDGE_DMABUF_CMD_LAST PVRSRV_BRIDGE_ION_CMD_LAST
138#endif
139#define PVRSRV_BRIDGE_CORE_CMD_LAST PVRSRV_BRIDGE_DMABUF_CMD_LAST
129/* SIM */ 140/* SIM */
130#define PVRSRV_BRIDGE_SIM_CMD_FIRST (PVRSRV_BRIDGE_CORE_CMD_LAST+1) 141#define PVRSRV_BRIDGE_SIM_CMD_FIRST (PVRSRV_BRIDGE_CORE_CMD_LAST+1)
131#define PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT PVRSRV_IOWR(PVRSRV_BRIDGE_SIM_CMD_FIRST+0) /*!< RTSIM pseudo ISR */ 142#define PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT PVRSRV_IOWR(PVRSRV_BRIDGE_SIM_CMD_FIRST+0) /*!< RTSIM pseudo ISR */
@@ -531,58 +542,56 @@ typedef struct PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM_TAG
531}PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM; 542}PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM;
532 543
533/****************************************************************************** 544/******************************************************************************
534 * 'bridge in' map dmabuf 545 * 'bridge in' map ion handle
535 *****************************************************************************/ 546 *****************************************************************************/
536#define DMABUF_IMPORT_MAX_FDS 3 547#define ION_IMPORT_MAX_FDS 3
537#define DMABUF_IMPORT_MAX_CHUNK_COUNT 3 548#define ION_IMPORT_MAX_CHUNK_COUNT 3
538typedef struct _PVRSRV_BRIDGE_IN_MAP_DMABUF_ 549typedef struct _PVRSRV_BRIDGE_IN_MAP_ION_HANDLE_
539{ 550{
540 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ 551 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */
541 IMG_UINT32 ui32NumFDs; 552 IMG_UINT32 ui32NumFDs;
542 IMG_INT32 ai32BufferFDs[DMABUF_IMPORT_MAX_FDS]; 553 IMG_INT32 ai32BufferFDs[ION_IMPORT_MAX_FDS];
543 IMG_UINT32 ui32Attribs; 554 IMG_UINT32 ui32Attribs;
544 IMG_UINT32 ui32ChunkCount; 555 IMG_UINT32 ui32ChunkCount;
545 IMG_SIZE_T auiOffset[DMABUF_IMPORT_MAX_CHUNK_COUNT]; 556 IMG_SIZE_T auiOffset[ION_IMPORT_MAX_CHUNK_COUNT];
546 IMG_SIZE_T auiSize[DMABUF_IMPORT_MAX_CHUNK_COUNT]; 557 IMG_SIZE_T auiSize[ION_IMPORT_MAX_CHUNK_COUNT];
547 IMG_HANDLE hDevCookie; 558 IMG_HANDLE hDevCookie;
548 IMG_HANDLE hDevMemHeap; 559 IMG_HANDLE hDevMemHeap;
549} PVRSRV_BRIDGE_IN_MAP_DMABUF; 560} PVRSRV_BRIDGE_IN_MAP_ION_HANDLE;
550 561
551/****************************************************************************** 562/******************************************************************************
552 * 'bridge in' unmap dmabuf 563 * 'bridge in' unmap ion handle
553 *****************************************************************************/ 564 *****************************************************************************/
554typedef struct PVRSRV_BRIDGE_IN_UNMAP_DMABUF_TAG 565typedef struct PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE_TAG
555{ 566{
556 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ 567 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */
557 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; 568 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
558}PVRSRV_BRIDGE_IN_UNMAP_DMABUF; 569}PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE;
559 570
571#define DMABUF_IMPORT_MAX_FDS 3
560/****************************************************************************** 572/******************************************************************************
561 * 'bridge in' map ion handle 573 * 'bridge in' map dmabuf
562 *****************************************************************************/ 574 *****************************************************************************/
563#define ION_IMPORT_MAX_FDS 3 575typedef struct _PVRSRV_BRIDGE_IN_MAP_DMABUF_
564#define ION_IMPORT_MAX_CHUNK_COUNT 3
565typedef struct _PVRSRV_BRIDGE_IN_MAP_ION_HANDLE_
566{ 576{
567 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ 577 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */
568 IMG_UINT32 ui32NumFDs; 578 IMG_UINT32 ui32NumFDs;
569 IMG_INT32 ai32BufferFDs[ION_IMPORT_MAX_FDS]; 579 IMG_INT32 ai32FD[DMABUF_IMPORT_MAX_FDS];
580 IMG_SIZE_T auiOffset[DMABUF_IMPORT_MAX_FDS];
581 IMG_SIZE_T auiSize[DMABUF_IMPORT_MAX_FDS];
570 IMG_UINT32 ui32Attribs; 582 IMG_UINT32 ui32Attribs;
571 IMG_UINT32 ui32ChunkCount;
572 IMG_SIZE_T auiOffset[ION_IMPORT_MAX_CHUNK_COUNT];
573 IMG_SIZE_T auiSize[ION_IMPORT_MAX_CHUNK_COUNT];
574 IMG_HANDLE hDevCookie; 583 IMG_HANDLE hDevCookie;
575 IMG_HANDLE hDevMemHeap; 584 IMG_HANDLE hDevMemHeap;
576} PVRSRV_BRIDGE_IN_MAP_ION_HANDLE; 585} PVRSRV_BRIDGE_IN_MAP_DMABUF;
577 586
578/****************************************************************************** 587/******************************************************************************
579 * 'bridge in' unmap ion handle 588 * 'bridge in' unmap dmabuf
580 *****************************************************************************/ 589 *****************************************************************************/
581typedef struct PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE_TAG 590typedef struct PVRSRV_BRIDGE_IN_UNMAP_DMABUF_TAG
582{ 591{
583 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */ 592 IMG_UINT32 ui32BridgeFlags; /* Must be first member of structure */
584 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; 593 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
585}PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE; 594}PVRSRV_BRIDGE_IN_UNMAP_DMABUF;
586 595
587/****************************************************************************** 596/******************************************************************************
588 * 'bridge in' get free device memory 597 * 'bridge in' get free device memory
@@ -1418,6 +1427,19 @@ typedef struct PVRSRV_BRIDGE_OUT_ALLOCDEVICEMEM_TAG
1418 1427
1419 1428
1420/****************************************************************************** 1429/******************************************************************************
1430 * 'bridge out' free device memory
1431 *****************************************************************************/
1432typedef struct PVRSRV_BRIDGE_OUT_FREEDEVICEMEM_TAG
1433{
1434 PVRSRV_ERROR eError;
1435#if defined (PVRSRV_DEVMEM_TIME_STATS)
1436 IMG_UINT32 ui32TimeToDevUnmap;
1437#endif
1438
1439} PVRSRV_BRIDGE_OUT_FREEDEVICEMEM;
1440
1441
1442/******************************************************************************
1421 * 'bridge out' export device memory 1443 * 'bridge out' export device memory
1422 *****************************************************************************/ 1444 *****************************************************************************/
1423typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG 1445typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG
@@ -1432,31 +1454,30 @@ typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG
1432 1454
1433 1455
1434/****************************************************************************** 1456/******************************************************************************
1435 * 'bridge out' map dmabuf 1457 * 'bridge out' map ion handle
1436 *****************************************************************************/ 1458 *****************************************************************************/
1437typedef struct _PVRSRV_BRIDGE_OUT_MAP_DMABUF_ 1459typedef struct _PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE_
1438{ 1460{
1439 PVRSRV_ERROR eError; 1461 PVRSRV_ERROR eError;
1440 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; 1462 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
1441 PVRSRV_CLIENT_MEM_INFO sClientMemInfo; 1463 PVRSRV_CLIENT_MEM_INFO sClientMemInfo;
1442 PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; 1464 PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo;
1443 IMG_SIZE_T uiDmabufBufferSize; 1465 IMG_SIZE_T uiIonBufferSize;
1444 1466
1445} PVRSRV_BRIDGE_OUT_MAP_DMABUF; 1467} PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE;
1446 1468
1447/****************************************************************************** 1469/******************************************************************************
1448 * 'bridge out' map ion handle 1470 * 'bridge out' map dmabuf
1449 *****************************************************************************/ 1471 *****************************************************************************/
1450typedef struct _PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE_ 1472typedef struct _PVRSRV_BRIDGE_OUT_MAP_DMABUF_
1451{ 1473{
1452 PVRSRV_ERROR eError; 1474 PVRSRV_ERROR eError;
1453 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; 1475 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
1454 PVRSRV_CLIENT_MEM_INFO sClientMemInfo; 1476 PVRSRV_CLIENT_MEM_INFO sClientMemInfo;
1455 PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; 1477 PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo;
1456 IMG_SIZE_T uiIonBufferSize; 1478 IMG_SIZE_T uiSize;
1457 1479 IMG_SIZE_T auiOffset[DMABUF_IMPORT_MAX_FDS];
1458} PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE; 1480} PVRSRV_BRIDGE_OUT_MAP_DMABUF;
1459
1460 1481
1461/****************************************************************************** 1482/******************************************************************************
1462 * 'bridge out' map meminfo to user mode 1483 * 'bridge out' map meminfo to user mode
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge_km.h b/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge_km.h
index 28c1268..d93e530 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge_km.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge_km.h
@@ -145,9 +145,9 @@ IMG_IMPORT
145PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie, 145PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie,
146 PVRSRV_KERNEL_MEM_INFO *psMemInfo); 146 PVRSRV_KERNEL_MEM_INFO *psMemInfo);
147 147
148#if defined(SUPPORT_DRM_GEM) 148#if defined(SUPPORT_ION)
149IMG_IMPORT 149IMG_IMPORT
150PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc, 150PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
151 IMG_HANDLE hDevCookie, 151 IMG_HANDLE hDevCookie,
152 IMG_HANDLE hDevMemHeap, 152 IMG_HANDLE hDevMemHeap,
153 IMG_UINT32 ui32NumFDs, 153 IMG_UINT32 ui32NumFDs,
@@ -161,27 +161,27 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
161 IMG_UINT64 *pui64Stamp); 161 IMG_UINT64 *pui64Stamp);
162 162
163IMG_IMPORT 163IMG_IMPORT
164PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmabufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); 164PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapIonHandleKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
165#endif /* SUPPORT_DRM_GEM */ 165#endif /* SUPPORT_ION */
166 166
167#if defined(SUPPORT_ION) 167#if defined(SUPPORT_DMABUF)
168IMG_IMPORT 168IMG_IMPORT
169PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, 169PVRSRV_ERROR PVRSRVMapDmaBufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
170 IMG_HANDLE hDevCookie, 170 IMG_HANDLE hDevCookie,
171 IMG_HANDLE hDevMemHeap, 171 IMG_HANDLE hDevMemHeap,
172 IMG_UINT32 ui32NumFDs,
173 IMG_INT32 *pai32BufferFDs,
174 IMG_UINT32 ui32Flags, 172 IMG_UINT32 ui32Flags,
175 IMG_UINT32 ui32ChunkCount, 173 IMG_UINT32 ui32NumFDs,
176 IMG_SIZE_T *pauiOffset, 174 IMG_INT32 *pui32DmaBufFD,
177 IMG_SIZE_T *pauiSize, 175 IMG_SIZE_T *puiDmaBufOffset,
178 IMG_SIZE_T *puiIonBufferSize, 176 IMG_SIZE_T *puiDmaBufSize,
179 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo, 177 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo,
178 IMG_SIZE_T *puiSize,
179 IMG_SIZE_T *puiMemInfoOffset,
180 IMG_UINT64 *pui64Stamp); 180 IMG_UINT64 *pui64Stamp);
181 181
182IMG_IMPORT 182IMG_IMPORT
183PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapIonHandleKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); 183PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmaBufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
184#endif /* SUPPORT_ION */ 184#endif /* SUPPORT_DMABUF */
185 185
186IMG_IMPORT 186IMG_IMPORT
187PVRSRV_ERROR IMG_CALLCONV PVRSRVDissociateDeviceMemKM(IMG_HANDLE hDevCookie, 187PVRSRV_ERROR IMG_CALLCONV PVRSRVDissociateDeviceMemKM(IMG_HANDLE hDevCookie,
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/servicesint.h b/jacinto6/sgx_src/eurasia_km/services4/include/servicesint.h
index 4e16475..fa3c0b2 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/servicesint.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/servicesint.h
@@ -152,7 +152,11 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_
152 /* ptr to associated kernel sync info - NULL if no sync */ 152 /* ptr to associated kernel sync info - NULL if no sync */
153 struct _PVRSRV_KERNEL_SYNC_INFO_ *psKernelSyncInfo; 153 struct _PVRSRV_KERNEL_SYNC_INFO_ *psKernelSyncInfo;
154 154
155 IMG_HANDLE hExternalSyncInfo; 155 IMG_HANDLE hIonSyncInfo;
156
157#if defined(SUPPORT_DMABUF)
158 IMG_HANDLE hDmaBufSyncInfo;
159#endif
156 160
157 PVRSRV_MEMTYPE memType; 161 PVRSRV_MEMTYPE memType;
158 162
@@ -186,6 +190,10 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_
186#if defined (MEM_TRACK_INFO_DEBUG) 190#if defined (MEM_TRACK_INFO_DEBUG)
187 IMG_CHAR heapId[128]; 191 IMG_CHAR heapId[128];
188#endif 192#endif
193#if defined (PVRSRV_DEVMEM_TIME_STATS)
194 IMG_UINT32 ui32TimeToDevMap;
195 IMG_UINT32 *pui32TimeToDevUnmap; /* API user to provide space for storing "unmap" time */
196#endif
189} PVRSRV_KERNEL_MEM_INFO; 197} PVRSRV_KERNEL_MEM_INFO;
190 198
191 199
@@ -220,6 +228,9 @@ typedef struct _PVRSRV_KERNEL_SYNC_INFO_
220 /* Unique ID of the sync object */ 228 /* Unique ID of the sync object */
221 IMG_UINT32 ui32UID; 229 IMG_UINT32 ui32UID;
222 230
231#if defined(SUPPORT_DMABUF)
232 IMG_HANDLE hFenceContext;
233#endif
223 /* Pointer for list manager */ 234 /* Pointer for list manager */
224 struct _PVRSRV_KERNEL_SYNC_INFO_ *psNext; 235 struct _PVRSRV_KERNEL_SYNC_INFO_ *psNext;
225 struct _PVRSRV_KERNEL_SYNC_INFO_ **ppsThis; 236 struct _PVRSRV_KERNEL_SYNC_INFO_ **ppsThis;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/sgx_mkif_km.h b/jacinto6/sgx_src/eurasia_km/services4/include/sgx_mkif_km.h
index baab80d..2defa73 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/sgx_mkif_km.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/sgx_mkif_km.h
@@ -91,7 +91,7 @@ typedef struct _PVRSRV_SGX_KERNEL_CCB_
91 *****************************************************************************/ 91 *****************************************************************************/
92typedef struct _PVRSRV_SGX_CCB_CTL_ 92typedef struct _PVRSRV_SGX_CCB_CTL_
93{ 93{
94 IMG_UINT32 ui32WriteOffset; /*!< write offset into array of commands (MUST be alligned to 16 bytes!) */ 94 IMG_UINT32 ui32WriteOffset; /*!< write offset into array of commands (MUST be aligned to 16 bytes!) */
95 IMG_UINT32 ui32ReadOffset; /*!< read offset into array of commands */ 95 IMG_UINT32 ui32ReadOffset; /*!< read offset into array of commands */
96} PVRSRV_SGX_CCB_CTL; 96} PVRSRV_SGX_CCB_CTL;
97 97
@@ -177,19 +177,9 @@ typedef struct _SGXMKIF_CMDTA_SHARED_
177 /* sync criteria used for TA/3D dependency synchronisation */ 177 /* sync criteria used for TA/3D dependency synchronisation */
178 PVRSRV_DEVICE_SYNC_OBJECT sTA3DDependency; 178 PVRSRV_DEVICE_SYNC_OBJECT sTA3DDependency;
179 179
180#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
181 /* SRC and DST syncs */
182 IMG_UINT32 ui32NumTASrcSyncs;
183 PVRSRV_DEVICE_SYNC_OBJECT asTASrcSyncs[SGX_MAX_TA_SRC_SYNCS];
184 IMG_UINT32 ui32NumTADstSyncs;
185 PVRSRV_DEVICE_SYNC_OBJECT asTADstSyncs[SGX_MAX_TA_DST_SYNCS];
186 IMG_UINT32 ui32Num3DSrcSyncs;
187 PVRSRV_DEVICE_SYNC_OBJECT as3DSrcSyncs[SGX_MAX_3D_SRC_SYNCS];
188#else
189 /* source dependency details */ 180 /* source dependency details */
190 IMG_UINT32 ui32NumSrcSyncs; 181 IMG_UINT32 ui32NumSrcSyncs;
191 PVRSRV_DEVICE_SYNC_OBJECT asSrcSyncs[SGX_MAX_SRC_SYNCS_TA]; 182 PVRSRV_DEVICE_SYNC_OBJECT asSrcSyncs[SGX_MAX_SRC_SYNCS_TA];
192#endif
193 183
194 CTL_STATUS sCtlTAStatusInfo[SGX_MAX_TA_STATUS_VALS]; 184 CTL_STATUS sCtlTAStatusInfo[SGX_MAX_TA_STATUS_VALS];
195 CTL_STATUS sCtl3DStatusInfo[SGX_MAX_3D_STATUS_VALS]; 185 CTL_STATUS sCtl3DStatusInfo[SGX_MAX_3D_STATUS_VALS];
@@ -293,8 +283,8 @@ typedef struct _SGXMKIF_HWDEVICE_SYNC_LIST_
293 *****************************************************************************/ 283 *****************************************************************************/
294#define PVRSRV_USSE_EDM_POWMAN_IDLE_COMPLETE (1UL << 2) /*!< Signal from ukernel->Host indicating SGX is idle */ 284#define PVRSRV_USSE_EDM_POWMAN_IDLE_COMPLETE (1UL << 2) /*!< Signal from ukernel->Host indicating SGX is idle */
295#define PVRSRV_USSE_EDM_POWMAN_POWEROFF_COMPLETE (1UL << 3) /*!< Signal from ukernel->Host indicating SGX can be powered down */ 285#define PVRSRV_USSE_EDM_POWMAN_POWEROFF_COMPLETE (1UL << 3) /*!< Signal from ukernel->Host indicating SGX can be powered down */
296#define PVRSRV_USSE_EDM_POWMAN_POWEROFF_RESTART_IMMEDIATE (1UL << 4) /*!< Signal from ukernel->Host indicating there is work to do immediately */ 286#define PVRSRV_USSE_EDM_POWMAN_POWEROFF_RESTART_IMMEDIATE (1UL << 4) /*!< Signal from ukernel->Host indicating there is work to be done immediately */
297#define PVRSRV_USSE_EDM_POWMAN_NO_WORK (1UL << 5) /*!< Signal from ukernel->Host indicating no work to do */ 287#define PVRSRV_USSE_EDM_POWMAN_NO_WORK (1UL << 5) /*!< Signal from ukernel->Host indicating nothing to do */
298 288
299/*! 289/*!
300 ***************************************************************************** 290 *****************************************************************************
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/sgx_ukernel_status_codes.h b/jacinto6/sgx_src/eurasia_km/services4/include/sgx_ukernel_status_codes.h
index e8c1626..75f186d 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/sgx_ukernel_status_codes.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/sgx_ukernel_status_codes.h
@@ -261,6 +261,11 @@ MKTC_ST(MKTC_KICKTA_CHKPT_RESET_COMPLETE)
261#define MKTC_KICKTA_CHKPT_CHECK_SWITCH 0xAD0008A6 261#define MKTC_KICKTA_CHKPT_CHECK_SWITCH 0xAD0008A6
262MKTC_ST(MKTC_KICKTA_CHKPT_CHECK_SWITCH) 262MKTC_ST(MKTC_KICKTA_CHKPT_CHECK_SWITCH)
263 263
264#define MKTC_KICK_MEM_BURSTER_WA_VDM_START 0xAD0008B1
265MKTC_ST(MKTC_KICK_MEM_BURSTER_WA_VDM_START)
266#define MKTC_TAFINISHED_MEM_BURSTER_WA 0xAD0008B2
267MKTC_ST(MKTC_TAFINISHED_MEM_BURSTER_WA)
268
264#define MKTC_HOSTKICK_START 0xAD000900 269#define MKTC_HOSTKICK_START 0xAD000900
265MKTC_ST(MKTC_HOSTKICK_START) 270MKTC_ST(MKTC_HOSTKICK_START)
266#define MKTC_HOSTKICK_END 0xAD000901 271#define MKTC_HOSTKICK_END 0xAD000901
diff --git a/jacinto6/sgx_src/eurasia_km/services4/include/sgxinfo.h b/jacinto6/sgx_src/eurasia_km/services4/include/sgxinfo.h
index 7ffdbc7..513cf3d 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/include/sgxinfo.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/include/sgxinfo.h
@@ -142,6 +142,9 @@ typedef struct _SGX_BRIDGE_INIT_INFO_
142 IMG_UINT32 ui32MasterClkGateStatus2Mask; 142 IMG_UINT32 ui32MasterClkGateStatus2Mask;
143#endif /* SGX_FEATURE_MP */ 143#endif /* SGX_FEATURE_MP */
144 144
145#if defined(SGX_FEATURE_AUTOCLOCKGATING)
146 IMG_BOOL bDisableClockGating;
147#endif
145 IMG_UINT32 ui32CacheControl; 148 IMG_UINT32 ui32CacheControl;
146 149
147 IMG_UINT32 asInitDevData[SGX_MAX_DEV_DATA]; 150 IMG_UINT32 asInitDevData[SGX_MAX_DEV_DATA];
@@ -206,19 +209,9 @@ typedef struct _SGX_CCB_KICK_
206 /* CCB offset of data structure associated with this kick */ 209 /* CCB offset of data structure associated with this kick */
207 IMG_UINT32 ui32CCBOffset; 210 IMG_UINT32 ui32CCBOffset;
208 211
209#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
210 /* SRC and DST syncs */
211 IMG_UINT32 ui32NumTASrcSyncs;
212 IMG_HANDLE ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS];
213 IMG_UINT32 ui32NumTADstSyncs;
214 IMG_HANDLE ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS];
215 IMG_UINT32 ui32Num3DSrcSyncs;
216 IMG_HANDLE ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS];
217#else
218 /* SRC syncs */ 212 /* SRC syncs */
219 IMG_UINT32 ui32NumSrcSyncs; 213 IMG_UINT32 ui32NumSrcSyncs;
220 IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS_TA]; 214 IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS_TA];
221#endif
222 215
223 /* TA/3D dependency data */ 216 /* TA/3D dependency data */
224 IMG_BOOL bTADependency; 217 IMG_BOOL bTADependency;
@@ -269,7 +262,6 @@ typedef struct _SGX_CLIENT_INFO_
269 *****************************************************************************/ 262 *****************************************************************************/
270typedef struct _SGX_INTERNAL_DEVINFO_ 263typedef struct _SGX_INTERNAL_DEVINFO_
271{ 264{
272 IMG_UINT32 ui32Flags;
273 IMG_HANDLE hHostCtlKernelMemInfoHandle; 265 IMG_HANDLE hHostCtlKernelMemInfoHandle;
274 IMG_BOOL bForcePTOff; 266 IMG_BOOL bForcePTOff;
275} SGX_INTERNAL_DEVINFO; 267} SGX_INTERNAL_DEVINFO;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.c
index 40c969c..4a1a758 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.c
@@ -89,10 +89,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
89 89
90 90
91#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 91#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
92#include <linux/fcntl.h>
92#include <linux/file.h> 93#include <linux/file.h>
93#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0))
94#include <asm/fcntl.h>
95#endif
96#include <linux/version.h> 94#include <linux/version.h>
97#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) 95#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
98#include <linux/sync.h> 96#include <linux/sync.h>
@@ -667,7 +665,9 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID,
667 psAllocDeviceMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; 665 psAllocDeviceMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags;
668 psAllocDeviceMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; 666 psAllocDeviceMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize;
669 psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; 667 psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle;
670 668#if defined (PVRSRV_DEVMEM_TIME_STATS)
669 psAllocDeviceMemOUT->sClientMemInfo.sDevMemTimingStats.sDevMemMapTimes.ui32TimeToDevMap = psMemInfo->ui32TimeToDevMap;
670#endif
671 PVRSRVAllocHandleNR(psPerProc->psHandleBase, 671 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
672 &psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo, 672 &psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo,
673 psMemInfo, 673 psMemInfo,
@@ -722,43 +722,54 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID,
722static IMG_INT 722static IMG_INT
723PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, 723PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID,
724 PVRSRV_BRIDGE_IN_FREEDEVICEMEM *psFreeDeviceMemIN, 724 PVRSRV_BRIDGE_IN_FREEDEVICEMEM *psFreeDeviceMemIN,
725 PVRSRV_BRIDGE_RETURN *psRetOUT, 725 PVRSRV_BRIDGE_OUT_FREEDEVICEMEM *psFreeDeviceMemOUT,
726 PVRSRV_PER_PROCESS_DATA *psPerProc) 726 PVRSRV_PER_PROCESS_DATA *psPerProc)
727{ 727{
728 IMG_HANDLE hDevCookieInt; 728 IMG_HANDLE hDevCookieInt;
729 IMG_VOID *pvKernelMemInfo; 729 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
730#if defined (PVRSRV_DEVMEM_TIME_STATS)
731 IMG_UINT32 ui32TimeToDevUnmap;
732#endif
730 733
731 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_FREE_DEVICEMEM); 734 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_FREE_DEVICEMEM);
732 735
733 psRetOUT->eError = 736 psFreeDeviceMemOUT->eError =
734 PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, 737 PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt,
735 psFreeDeviceMemIN->hDevCookie, 738 psFreeDeviceMemIN->hDevCookie,
736 PVRSRV_HANDLE_TYPE_DEV_NODE); 739 PVRSRV_HANDLE_TYPE_DEV_NODE);
737 740
738 if(psRetOUT->eError != PVRSRV_OK) 741 if(psFreeDeviceMemOUT->eError != PVRSRV_OK)
739 { 742 {
740 return 0; 743 return 0;
741 } 744 }
742 745
743 psRetOUT->eError = 746 psFreeDeviceMemOUT->eError =
744 PVRSRVLookupHandle(psPerProc->psHandleBase, 747 PVRSRVLookupHandle(psPerProc->psHandleBase,
745 &pvKernelMemInfo, 748 (IMG_PVOID *)&psKernelMemInfo,
746 psFreeDeviceMemIN->psKernelMemInfo, 749 psFreeDeviceMemIN->psKernelMemInfo,
747 PVRSRV_HANDLE_TYPE_MEM_INFO); 750 PVRSRV_HANDLE_TYPE_MEM_INFO);
748 751
749 if(psRetOUT->eError != PVRSRV_OK) 752 if(psFreeDeviceMemOUT->eError != PVRSRV_OK)
750 { 753 {
751 return 0; 754 return 0;
752 } 755 }
753 756
754 psRetOUT->eError = PVRSRVFreeDeviceMemKM(hDevCookieInt, pvKernelMemInfo); 757#if defined (PVRSRV_DEVMEM_TIME_STATS)
758 psKernelMemInfo->pui32TimeToDevUnmap = &ui32TimeToDevUnmap;
759#endif
755 760
756 if(psRetOUT->eError != PVRSRV_OK) 761 psFreeDeviceMemOUT->eError = PVRSRVFreeDeviceMemKM(hDevCookieInt, psKernelMemInfo);
762
763 if(psFreeDeviceMemOUT->eError != PVRSRV_OK)
757 { 764 {
758 return 0; 765 return 0;
759 } 766 }
760 767
761 psRetOUT->eError = 768#if defined (PVRSRV_DEVMEM_TIME_STATS)
769 psFreeDeviceMemOUT->ui32TimeToDevUnmap = ui32TimeToDevUnmap;
770#endif
771
772 psFreeDeviceMemOUT->eError =
762 PVRSRVReleaseHandle(psPerProc->psHandleBase, 773 PVRSRVReleaseHandle(psPerProc->psHandleBase,
763 psFreeDeviceMemIN->psKernelMemInfo, 774 psFreeDeviceMemIN->psKernelMemInfo,
764 PVRSRV_HANDLE_TYPE_MEM_INFO); 775 PVRSRV_HANDLE_TYPE_MEM_INFO);
@@ -1395,301 +1406,306 @@ PVRSRVUnwrapExtMemoryBW(IMG_UINT32 ui32BridgeID,
1395 return 0; 1406 return 0;
1396} 1407}
1397 1408
1398#if defined(SUPPORT_DRM_GEM) 1409#if defined(SUPPORT_ION)
1399static IMG_INT 1410static IMG_INT
1400PVRSRVMapDmabufBW(IMG_UINT32 ui32BridgeID, 1411PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID,
1401 PVRSRV_BRIDGE_IN_MAP_DMABUF *psMapDmabufIN, 1412 PVRSRV_BRIDGE_IN_MAP_ION_HANDLE *psMapIonIN,
1402 PVRSRV_BRIDGE_OUT_MAP_DMABUF *psMapDmabufOUT, 1413 PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE *psMapIonOUT,
1403 PVRSRV_PER_PROCESS_DATA *psPerProc) 1414 PVRSRV_PER_PROCESS_DATA *psPerProc)
1404{ 1415{
1405 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; 1416 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
1406 IMG_UINT64 ui64Stamp; 1417 IMG_UINT64 ui64Stamp;
1407 1418
1408 psMapDmabufOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 1419 psMapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1409 &psMapDmabufIN->hDevCookie, 1420 &psMapIonIN->hDevCookie,
1410 psMapDmabufIN->hDevCookie, 1421 psMapIonIN->hDevCookie,
1411 PVRSRV_HANDLE_TYPE_DEV_NODE); 1422 PVRSRV_HANDLE_TYPE_DEV_NODE);
1412 if (psMapDmabufOUT->eError != PVRSRV_OK) 1423 if (psMapIonOUT->eError != PVRSRV_OK)
1413 { 1424 {
1414 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup device node handle", __FUNCTION__)); 1425 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup device node handle", __FUNCTION__));
1415 return 0; 1426 return 0;
1416 } 1427 }
1417 1428
1418 psMapDmabufOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 1429 psMapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1419 &psMapDmabufIN->hDevMemHeap, 1430 &psMapIonIN->hDevMemHeap,
1420 psMapDmabufIN->hDevMemHeap, 1431 psMapIonIN->hDevMemHeap,
1421 PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); 1432 PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP);
1422 if (psMapDmabufOUT->eError != PVRSRV_OK) 1433 if (psMapIonOUT->eError != PVRSRV_OK)
1423 { 1434 {
1424 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup memory context handle", __FUNCTION__)); 1435 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup memory context handle", __FUNCTION__));
1425 return 0; 1436 return 0;
1426 } 1437 }
1427 1438
1428 psMapDmabufOUT->eError = PVRSRVMapDmabufKM(psPerProc, 1439 psMapIonOUT->eError = PVRSRVMapIonHandleKM(psPerProc,
1429 psMapDmabufIN->hDevCookie, 1440 psMapIonIN->hDevCookie,
1430 psMapDmabufIN->hDevMemHeap, 1441 psMapIonIN->hDevMemHeap,
1431 psMapDmabufIN->ui32NumFDs, 1442 psMapIonIN->ui32NumFDs,
1432 psMapDmabufIN->ai32BufferFDs, 1443 psMapIonIN->ai32BufferFDs,
1433 psMapDmabufIN->ui32Attribs, 1444 psMapIonIN->ui32Attribs,
1434 psMapDmabufIN->ui32ChunkCount, 1445 psMapIonIN->ui32ChunkCount,
1435 psMapDmabufIN->auiOffset, 1446 psMapIonIN->auiOffset,
1436 psMapDmabufIN->auiSize, 1447 psMapIonIN->auiSize,
1437 &psMapDmabufOUT->uiDmabufBufferSize, 1448 &psMapIonOUT->uiIonBufferSize,
1438 &psKernelMemInfo, 1449 &psKernelMemInfo,
1439 &ui64Stamp); 1450 &ui64Stamp);
1440 if (psMapDmabufOUT->eError != PVRSRV_OK) 1451 if (psMapIonOUT->eError != PVRSRV_OK)
1441 { 1452 {
1442 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to map ion handle", __FUNCTION__)); 1453 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to map ion handle", __FUNCTION__));
1443 return 0; 1454 return 0;
1444 } 1455 }
1445 1456
1446 OSMemSet(&psMapDmabufOUT->sClientMemInfo, 1457 OSMemSet(&psMapIonOUT->sClientMemInfo,
1447 0, 1458 0,
1448 sizeof(psMapDmabufOUT->sClientMemInfo)); 1459 sizeof(psMapIonOUT->sClientMemInfo));
1449 1460
1450 psMapDmabufOUT->sClientMemInfo.pvLinAddrKM = 1461 psMapIonOUT->sClientMemInfo.pvLinAddrKM =
1451 psKernelMemInfo->pvLinAddrKM; 1462 psKernelMemInfo->pvLinAddrKM;
1452 1463
1453 psMapDmabufOUT->sClientMemInfo.pvLinAddr = 0; 1464 psMapIonOUT->sClientMemInfo.pvLinAddr = 0;
1454 psMapDmabufOUT->sClientMemInfo.sDevVAddr = psKernelMemInfo->sDevVAddr; 1465 psMapIonOUT->sClientMemInfo.sDevVAddr = psKernelMemInfo->sDevVAddr;
1455 psMapDmabufOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags; 1466 psMapIonOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags;
1456 psMapDmabufOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize; 1467 psMapIonOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize;
1457 1468
1458 /* No mapping info, we map through ion */ 1469 /* No mapping info, we map through ion */
1459 psMapDmabufOUT->sClientMemInfo.hMappingInfo = IMG_NULL; 1470 psMapIonOUT->sClientMemInfo.hMappingInfo = IMG_NULL;
1460 1471
1461#if defined(SUPPORT_MEMINFO_IDS) 1472#if defined(SUPPORT_MEMINFO_IDS)
1462 psMapDmabufOUT->sClientMemInfo.ui64Stamp = ui64Stamp; 1473 psMapIonOUT->sClientMemInfo.ui64Stamp = ui64Stamp;
1463#endif 1474#endif
1464 1475
1465 PVRSRVAllocHandleNR(psPerProc->psHandleBase, 1476 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
1466 &psMapDmabufOUT->sClientMemInfo.hKernelMemInfo, 1477 &psMapIonOUT->sClientMemInfo.hKernelMemInfo,
1467 psKernelMemInfo, 1478 psKernelMemInfo,
1468 PVRSRV_HANDLE_TYPE_MEM_INFO, 1479 PVRSRV_HANDLE_TYPE_MEM_INFO,
1469 PVRSRV_HANDLE_ALLOC_FLAG_NONE); 1480 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
1470 1481
1471 if(psMapDmabufIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ) 1482 if(psMapIonIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ)
1472 { 1483 {
1473 /* signal no syncinfo */ 1484 /* signal no syncinfo */
1474 OSMemSet(&psMapDmabufOUT->sClientSyncInfo, 1485 OSMemSet(&psMapIonOUT->sClientSyncInfo,
1475 0, 1486 0,
1476 sizeof (PVRSRV_CLIENT_SYNC_INFO)); 1487 sizeof (PVRSRV_CLIENT_SYNC_INFO));
1477 psMapDmabufOUT->sClientMemInfo.psClientSyncInfo = IMG_NULL; 1488 psMapIonOUT->sClientMemInfo.psClientSyncInfo = IMG_NULL;
1478 } 1489 }
1479 else 1490 else
1480 { 1491 {
1481 /* and setup the sync info */ 1492 /* and setup the sync info */
1482#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) 1493#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS)
1483 psMapDmabufOUT->sClientSyncInfo.psSyncData = 1494 psMapIonOUT->sClientSyncInfo.psSyncData =
1484 psKernelMemInfo->psKernelSyncInfo->psSyncData; 1495 psKernelMemInfo->psKernelSyncInfo->psSyncData;
1485 psMapDmabufOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr = 1496 psMapIonOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr =
1486 psKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; 1497 psKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr;
1487 psMapDmabufOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr = 1498 psMapIonOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr =
1488 psKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; 1499 psKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr;
1489 psMapDmabufOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = 1500 psMapIonOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr =
1490 psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; 1501 psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr;
1491 1502
1492 psMapDmabufOUT->sClientSyncInfo.hMappingInfo = 1503 psMapIonOUT->sClientSyncInfo.hMappingInfo =
1493 psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; 1504 psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle;
1494#endif 1505#endif
1495 1506
1496 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, 1507 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
1497 &psMapDmabufOUT->sClientSyncInfo.hKernelSyncInfo, 1508 &psMapIonOUT->sClientSyncInfo.hKernelSyncInfo,
1498 psKernelMemInfo->psKernelSyncInfo, 1509 psKernelMemInfo->psKernelSyncInfo,
1499 PVRSRV_HANDLE_TYPE_SYNC_INFO, 1510 PVRSRV_HANDLE_TYPE_SYNC_INFO,
1500 PVRSRV_HANDLE_ALLOC_FLAG_NONE, 1511 PVRSRV_HANDLE_ALLOC_FLAG_NONE,
1501 psMapDmabufOUT->sClientMemInfo.hKernelMemInfo); 1512 psMapIonOUT->sClientMemInfo.hKernelMemInfo);
1502 1513
1503 psMapDmabufOUT->sClientMemInfo.psClientSyncInfo = 1514 psMapIonOUT->sClientMemInfo.psClientSyncInfo =
1504 &psMapDmabufOUT->sClientSyncInfo; 1515 &psMapIonOUT->sClientSyncInfo;
1505 } 1516 }
1506 return 0; 1517 return 0;
1507} 1518}
1508 1519
1509static IMG_INT 1520static IMG_INT
1510PVRSRVUnmapDmabufBW(IMG_UINT32 ui32BridgeID, 1521PVRSRVUnmapIonHandleBW(IMG_UINT32 ui32BridgeID,
1511 PVRSRV_BRIDGE_IN_UNMAP_DMABUF *psUnmapDmabufIN, 1522 PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE *psUnmapIonIN,
1512 PVRSRV_BRIDGE_RETURN *psUnmapDmabufOUT, 1523 PVRSRV_BRIDGE_RETURN *psUnmapIonOUT,
1513 PVRSRV_PER_PROCESS_DATA *psPerProc) 1524 PVRSRV_PER_PROCESS_DATA *psPerProc)
1514{ 1525{
1515 IMG_VOID *pvKernelMemInfo; 1526 IMG_VOID *pvKernelMemInfo;
1516 1527
1517 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_UNMAP_DMABUF); 1528 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_UNMAP_ION_HANDLE);
1518 1529
1519 psUnmapDmabufOUT->eError = 1530 psUnmapIonOUT->eError =
1520 PVRSRVLookupHandle(psPerProc->psHandleBase, 1531 PVRSRVLookupHandle(psPerProc->psHandleBase,
1521 &pvKernelMemInfo, 1532 &pvKernelMemInfo,
1522 psUnmapDmabufIN->psKernelMemInfo, 1533 psUnmapIonIN->psKernelMemInfo,
1523 PVRSRV_HANDLE_TYPE_MEM_INFO); 1534 PVRSRV_HANDLE_TYPE_MEM_INFO);
1524 1535
1525 if(psUnmapDmabufOUT->eError != PVRSRV_OK) 1536 if(psUnmapIonOUT->eError != PVRSRV_OK)
1526 { 1537 {
1527 return 0; 1538 return 0;
1528 } 1539 }
1529 1540
1530 psUnmapDmabufOUT->eError = PVRSRVUnmapDmabufKM(pvKernelMemInfo); 1541 psUnmapIonOUT->eError = PVRSRVUnmapIonHandleKM(pvKernelMemInfo);
1531 1542
1532 if(psUnmapDmabufOUT->eError != PVRSRV_OK) 1543 if(psUnmapIonOUT->eError != PVRSRV_OK)
1533 { 1544 {
1534 return 0; 1545 return 0;
1535 } 1546 }
1536 1547
1537 psUnmapDmabufOUT->eError = 1548 psUnmapIonOUT->eError =
1538 PVRSRVReleaseHandle(psPerProc->psHandleBase, 1549 PVRSRVReleaseHandle(psPerProc->psHandleBase,
1539 psUnmapDmabufIN->psKernelMemInfo, 1550 psUnmapIonIN->psKernelMemInfo,
1540 PVRSRV_HANDLE_TYPE_MEM_INFO); 1551 PVRSRV_HANDLE_TYPE_MEM_INFO);
1541 1552
1542 return 0; 1553 return 0;
1543} 1554}
1544#endif /* SUPPORT_ION */ 1555#endif /* SUPPORT_ION */
1545 1556
1546#if defined(SUPPORT_ION) 1557#if defined(SUPPORT_DMABUF)
1547static IMG_INT 1558static IMG_INT
1548PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID, 1559PVRSRVMapDmaBufBW(IMG_UINT32 ui32BridgeID,
1549 PVRSRV_BRIDGE_IN_MAP_ION_HANDLE *psMapIonIN, 1560 PVRSRV_BRIDGE_IN_MAP_DMABUF *psMapDmaBufIN,
1550 PVRSRV_BRIDGE_OUT_MAP_ION_HANDLE *psMapIonOUT, 1561 PVRSRV_BRIDGE_OUT_MAP_DMABUF *psMapDmaBufOUT,
1551 PVRSRV_PER_PROCESS_DATA *psPerProc) 1562 PVRSRV_PER_PROCESS_DATA *psPerProc)
1552{ 1563{
1553 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; 1564 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo;
1554 IMG_UINT64 ui64Stamp; 1565 IMG_UINT64 ui64Stamp;
1555 1566
1556 psMapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 1567 psMapDmaBufOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1557 &psMapIonIN->hDevCookie, 1568 &psMapDmaBufIN->hDevCookie,
1558 psMapIonIN->hDevCookie, 1569 psMapDmaBufIN->hDevCookie,
1559 PVRSRV_HANDLE_TYPE_DEV_NODE); 1570 PVRSRV_HANDLE_TYPE_DEV_NODE);
1560 if (psMapIonOUT->eError != PVRSRV_OK) 1571 if (psMapDmaBufOUT->eError != PVRSRV_OK)
1561 { 1572 {
1562 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup device node handle", __FUNCTION__)); 1573 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup device node handle", __FUNCTION__));
1563 return 0; 1574 return 0;
1564 } 1575 }
1565 1576
1566 psMapIonOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 1577 psMapDmaBufOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1567 &psMapIonIN->hDevMemHeap, 1578 &psMapDmaBufIN->hDevMemHeap,
1568 psMapIonIN->hDevMemHeap, 1579 psMapDmaBufIN->hDevMemHeap,
1569 PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); 1580 PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP);
1570 if (psMapIonOUT->eError != PVRSRV_OK) 1581 if (psMapDmaBufOUT->eError != PVRSRV_OK)
1571 { 1582 {
1572 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup memory context handle", __FUNCTION__)); 1583 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup memory context handle", __FUNCTION__));
1573 return 0; 1584 return 0;
1574 } 1585 }
1575 1586
1576 psMapIonOUT->eError = PVRSRVMapIonHandleKM(psPerProc, 1587 psMapDmaBufOUT->eError = PVRSRVMapDmaBufKM(psPerProc,
1577 psMapIonIN->hDevCookie, 1588 psMapDmaBufIN->hDevCookie,
1578 psMapIonIN->hDevMemHeap, 1589 psMapDmaBufIN->hDevMemHeap,
1579 psMapIonIN->ui32NumFDs, 1590 psMapDmaBufIN->ui32Attribs,
1580 psMapIonIN->ai32BufferFDs, 1591 psMapDmaBufIN->ui32NumFDs,
1581 psMapIonIN->ui32Attribs, 1592 psMapDmaBufIN->ai32FD,
1582 psMapIonIN->ui32ChunkCount, 1593 psMapDmaBufIN->auiOffset,
1583 psMapIonIN->auiOffset, 1594 psMapDmaBufIN->auiSize,
1584 psMapIonIN->auiSize,
1585 &psMapIonOUT->uiIonBufferSize,
1586 &psKernelMemInfo, 1595 &psKernelMemInfo,
1596 &psMapDmaBufOUT->uiSize,
1597 psMapDmaBufOUT->auiOffset,
1587 &ui64Stamp); 1598 &ui64Stamp);
1588 if (psMapIonOUT->eError != PVRSRV_OK) 1599 if (psMapDmaBufOUT->eError != PVRSRV_OK)
1589 { 1600 {
1590 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to map ion handle", __FUNCTION__)); 1601 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to map dma-buf handle", __FUNCTION__));
1591 return 0; 1602 return 0;
1592 } 1603 }
1593 1604
1594 OSMemSet(&psMapIonOUT->sClientMemInfo, 1605 OSMemSet(&psMapDmaBufOUT->sClientMemInfo,
1595 0, 1606 0,
1596 sizeof(psMapIonOUT->sClientMemInfo)); 1607 sizeof(psMapDmaBufOUT->sClientMemInfo));
1597 1608
1598 psMapIonOUT->sClientMemInfo.pvLinAddrKM = 1609 psMapDmaBufOUT->sClientMemInfo.pvLinAddrKM =
1599 psKernelMemInfo->pvLinAddrKM; 1610 psKernelMemInfo->pvLinAddrKM;
1600 1611
1601 psMapIonOUT->sClientMemInfo.pvLinAddr = 0; 1612 psMapDmaBufOUT->sClientMemInfo.pvLinAddr = 0;
1602 psMapIonOUT->sClientMemInfo.sDevVAddr = psKernelMemInfo->sDevVAddr; 1613 psMapDmaBufOUT->sClientMemInfo.sDevVAddr = psKernelMemInfo->sDevVAddr;
1603 psMapIonOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags; 1614 psMapDmaBufOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags;
1604 psMapIonOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize; 1615 psMapDmaBufOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize;
1605 1616
1606 /* No mapping info, we map through ion */ 1617 /* No mapping info, we map through dma_buf */
1607 psMapIonOUT->sClientMemInfo.hMappingInfo = IMG_NULL; 1618 psMapDmaBufOUT->sClientMemInfo.hMappingInfo = IMG_NULL;
1608 1619
1609#if defined(SUPPORT_MEMINFO_IDS) 1620#if defined(SUPPORT_MEMINFO_IDS)
1610 psMapIonOUT->sClientMemInfo.ui64Stamp = ui64Stamp; 1621 psMapDmaBufOUT->sClientMemInfo.ui64Stamp = ui64Stamp;
1611#endif 1622#endif
1612 1623
1613 PVRSRVAllocHandleNR(psPerProc->psHandleBase, 1624 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
1614 &psMapIonOUT->sClientMemInfo.hKernelMemInfo, 1625 &psMapDmaBufOUT->sClientMemInfo.hKernelMemInfo,
1615 psKernelMemInfo, 1626 psKernelMemInfo,
1616 PVRSRV_HANDLE_TYPE_MEM_INFO, 1627 PVRSRV_HANDLE_TYPE_MEM_INFO,
1617 PVRSRV_HANDLE_ALLOC_FLAG_NONE); 1628 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
1618 1629
1619 if(psMapIonIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ) 1630 if(psMapDmaBufIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ)
1620 { 1631 {
1621 /* signal no syncinfo */ 1632 /* signal no syncinfo */
1622 OSMemSet(&psMapIonOUT->sClientSyncInfo, 1633 OSMemSet(&psMapDmaBufOUT->sClientSyncInfo,
1623 0, 1634 0,
1624 sizeof (PVRSRV_CLIENT_SYNC_INFO)); 1635 sizeof (PVRSRV_CLIENT_SYNC_INFO));
1625 psMapIonOUT->sClientMemInfo.psClientSyncInfo = IMG_NULL; 1636 psMapDmaBufOUT->sClientMemInfo.psClientSyncInfo = IMG_NULL;
1626 } 1637 }
1627 else 1638 else
1628 { 1639 {
1629 /* and setup the sync info */ 1640 /* and setup the sync info */
1630#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) 1641#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS)
1631 psMapIonOUT->sClientSyncInfo.psSyncData = 1642 psMapDmaBufOUT->sClientSyncInfo.psSyncData =
1632 psKernelMemInfo->psKernelSyncInfo->psSyncData; 1643 psKernelMemInfo->psKernelSyncInfo->psSyncData;
1633 psMapIonOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr = 1644 psMapDmaBufOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr =
1634 psKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; 1645 psKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr;
1635 psMapIonOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr = 1646 psMapDmaBufOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr =
1636 psKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; 1647 psKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr;
1637 psMapIonOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = 1648 psMapDmaBufOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr =
1638 psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; 1649 psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr;
1639 1650
1640 psMapIonOUT->sClientSyncInfo.hMappingInfo = 1651 psMapDmaBufOUT->sClientSyncInfo.hMappingInfo =
1641 psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; 1652 psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle;
1642#endif 1653#endif
1643 1654
1655 /*
1656 * If the DMA Buffer is imported into the same process that
1657 * exported it, there will be two handles for the same sync
1658 * info, hence the PVRSRV_HANDLE_ALLOC_FLAG_MULTI flag.
1659 */
1644 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, 1660 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
1645 &psMapIonOUT->sClientSyncInfo.hKernelSyncInfo, 1661 &psMapDmaBufOUT->sClientSyncInfo.hKernelSyncInfo,
1646 psKernelMemInfo->psKernelSyncInfo, 1662 psKernelMemInfo->psKernelSyncInfo,
1647 PVRSRV_HANDLE_TYPE_SYNC_INFO, 1663 PVRSRV_HANDLE_TYPE_SYNC_INFO,
1648 PVRSRV_HANDLE_ALLOC_FLAG_NONE, 1664 PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
1649 psMapIonOUT->sClientMemInfo.hKernelMemInfo); 1665 psMapDmaBufOUT->sClientMemInfo.hKernelMemInfo);
1650 1666
1651 psMapIonOUT->sClientMemInfo.psClientSyncInfo = 1667 psMapDmaBufOUT->sClientMemInfo.psClientSyncInfo =
1652 &psMapIonOUT->sClientSyncInfo; 1668 &psMapDmaBufOUT->sClientSyncInfo;
1653 } 1669 }
1654 return 0; 1670 return 0;
1655} 1671}
1656 1672
1657static IMG_INT 1673static IMG_INT
1658PVRSRVUnmapIonHandleBW(IMG_UINT32 ui32BridgeID, 1674PVRSRVUnmapDmaBufBW(IMG_UINT32 ui32BridgeID,
1659 PVRSRV_BRIDGE_IN_UNMAP_ION_HANDLE *psUnmapIonIN, 1675 PVRSRV_BRIDGE_IN_UNMAP_DMABUF *psUnmapDmaBufIN,
1660 PVRSRV_BRIDGE_RETURN *psUnmapIonOUT, 1676 PVRSRV_BRIDGE_RETURN *psUnmapDmaBufOUT,
1661 PVRSRV_PER_PROCESS_DATA *psPerProc) 1677 PVRSRV_PER_PROCESS_DATA *psPerProc)
1662{ 1678{
1663 IMG_VOID *pvKernelMemInfo; 1679 IMG_VOID *pvKernelMemInfo;
1664 1680
1665 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_UNMAP_ION_HANDLE); 1681 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_UNMAP_DMABUF);
1666 1682
1667 psUnmapIonOUT->eError = 1683 psUnmapDmaBufOUT->eError =
1668 PVRSRVLookupHandle(psPerProc->psHandleBase, 1684 PVRSRVLookupHandle(psPerProc->psHandleBase,
1669 &pvKernelMemInfo, 1685 &pvKernelMemInfo,
1670 psUnmapIonIN->psKernelMemInfo, 1686 psUnmapDmaBufIN->psKernelMemInfo,
1671 PVRSRV_HANDLE_TYPE_MEM_INFO); 1687 PVRSRV_HANDLE_TYPE_MEM_INFO);
1672 1688
1673 if(psUnmapIonOUT->eError != PVRSRV_OK) 1689 if(psUnmapDmaBufOUT->eError != PVRSRV_OK)
1674 { 1690 {
1675 return 0; 1691 return 0;
1676 } 1692 }
1677 1693
1678 psUnmapIonOUT->eError = PVRSRVUnmapIonHandleKM(pvKernelMemInfo); 1694 psUnmapDmaBufOUT->eError = PVRSRVUnmapDmaBufKM(pvKernelMemInfo);
1679 1695
1680 if(psUnmapIonOUT->eError != PVRSRV_OK) 1696 if(psUnmapDmaBufOUT->eError != PVRSRV_OK)
1681 { 1697 {
1682 return 0; 1698 return 0;
1683 } 1699 }
1684 1700
1685 psUnmapIonOUT->eError = 1701 psUnmapDmaBufOUT->eError =
1686 PVRSRVReleaseHandle(psPerProc->psHandleBase, 1702 PVRSRVReleaseHandle(psPerProc->psHandleBase,
1687 psUnmapIonIN->psKernelMemInfo, 1703 psUnmapDmaBufIN->psKernelMemInfo,
1688 PVRSRV_HANDLE_TYPE_MEM_INFO); 1704 PVRSRV_HANDLE_TYPE_MEM_INFO);
1689 1705
1690 return 0; 1706 return 0;
1691} 1707}
1692#endif /* SUPPORT_ION */ 1708#endif /* SUPPORT_DMABUF */
1693 1709
1694static IMG_INT 1710static IMG_INT
1695PVRSRVGetFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, 1711PVRSRVGetFreeDeviceMemBW(IMG_UINT32 ui32BridgeID,
@@ -2275,15 +2291,6 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID,
2275 return 0; 2291 return 0;
2276 } 2292 }
2277 2293
2278 if((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT) != 0)
2279 {
2280 PVR_DPF((PVR_DBG_ERROR, "Get DRM FD BW"));
2281 }
2282 if((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT) != 0)
2283 {
2284 PVR_DPF((PVR_DBG_ERROR, "Set DRM FD BW"));
2285 }
2286
2287 if (((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_MEMSTATS_PRESENT) != 0) || 2294 if (((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_MEMSTATS_PRESENT) != 0) ||
2288 ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_DDKVERSION_PRESENT) != 0) || 2295 ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_DDKVERSION_PRESENT) != 0) ||
2289 ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) != 0)) 2296 ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) != 0))
@@ -3035,11 +3042,7 @@ PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID,
3035 IMG_UINT32 i; 3042 IMG_UINT32 i;
3036 3043
3037#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 3044#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
3038#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0))
3039 int iReleaseFd = get_unused_fd_flags(O_CLOEXEC); 3045 int iReleaseFd = get_unused_fd_flags(O_CLOEXEC);
3040#else
3041 int iReleaseFd = get_unused_fd();
3042#endif
3043 if(iReleaseFd < 0) 3046 if(iReleaseFd < 0)
3044 { 3047 {
3045 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to find unused fd (%d)", 3048 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to find unused fd (%d)",
@@ -3126,7 +3129,7 @@ PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID,
3126 3129
3127 if(psSwapDispClassBufferIN->ui32PrivDataLength > 0) 3130 if(psSwapDispClassBufferIN->ui32PrivDataLength > 0)
3128 { 3131 {
3129 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, 3132 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
3130 psSwapDispClassBufferIN->ui32PrivDataLength, 3133 psSwapDispClassBufferIN->ui32PrivDataLength,
3131 (IMG_VOID **)&pvPrivData, IMG_NULL, 3134 (IMG_VOID **)&pvPrivData, IMG_NULL,
3132 "Swap Command Private Data") != PVRSRV_OK) 3135 "Swap Command Private Data") != PVRSRV_OK)
@@ -3142,7 +3145,7 @@ PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID,
3142 psSwapDispClassBufferIN->ui32PrivDataLength) != PVRSRV_OK) 3145 psSwapDispClassBufferIN->ui32PrivDataLength) != PVRSRV_OK)
3143 { 3146 {
3144 PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to copy private data")); 3147 PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to copy private data"));
3145 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, 3148 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
3146 psSwapDispClassBufferIN->ui32PrivDataLength, 3149 psSwapDispClassBufferIN->ui32PrivDataLength,
3147 pvPrivData, IMG_NULL); 3150 pvPrivData, IMG_NULL);
3148 return -EFAULT; 3151 return -EFAULT;
@@ -4653,14 +4656,14 @@ CommonBridgeInit(IMG_VOID)
4653 SetDispatchTableEntry(PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS, PVRSRVChangeDeviceMemoryAttributesBW); 4656 SetDispatchTableEntry(PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS, PVRSRVChangeDeviceMemoryAttributesBW);
4654 SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY_2, PVRSRVMapDeviceMemoryBW); 4657 SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY_2, PVRSRVMapDeviceMemoryBW);
4655 SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2, PVRSRVExportDeviceMemBW); 4658 SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2, PVRSRVExportDeviceMemBW);
4656#if defined(SUPPORT_DRM_GEM)
4657 SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DMABUF, PVRSRVMapDmabufBW);
4658 SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DMABUF, PVRSRVUnmapDmabufBW);
4659#endif
4660#if defined(SUPPORT_ION) 4659#if defined(SUPPORT_ION)
4661 SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_ION_HANDLE, PVRSRVMapIonHandleBW); 4660 SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_ION_HANDLE, PVRSRVMapIonHandleBW);
4662 SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_ION_HANDLE, PVRSRVUnmapIonHandleBW); 4661 SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_ION_HANDLE, PVRSRVUnmapIonHandleBW);
4663#endif 4662#endif
4663#if defined(SUPPORT_DMABUF)
4664 SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DMABUF, PVRSRVMapDmaBufBW);
4665 SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DMABUF, PVRSRVUnmapDmaBufBW);
4666#endif
4664 4667
4665 /* SIM */ 4668 /* SIM */
4666 SetDispatchTableEntry(PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT, DummyBW); 4669 SetDispatchTableEntry(PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT, DummyBW);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c
index f23fd49..31d40e7 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c
@@ -265,69 +265,6 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID,
265 } 265 }
266 } 266 }
267 267
268
269#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
270 /* SRC and DST sync details */
271 if (psDoKickIN->sCCBKick.ui32NumTASrcSyncs > SGX_MAX_TA_SRC_SYNCS)
272 {
273 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
274 return 0;
275 }
276
277 for(i=0; i<psDoKickIN->sCCBKick.ui32NumTASrcSyncs; i++)
278 {
279 psRetOUT->eError =
280 PVRSRVLookupHandle(psPerProc->psHandleBase,
281 &psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i],
282 psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i],
283 PVRSRV_HANDLE_TYPE_SYNC_INFO);
284
285 if(psRetOUT->eError != PVRSRV_OK)
286 {
287 return 0;
288 }
289 }
290
291 if (psDoKickIN->sCCBKick.ui32NumTADstSyncs > SGX_MAX_TA_DST_SYNCS)
292 {
293 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
294 return 0;
295 }
296
297 for(i=0; i<psDoKickIN->sCCBKick.ui32NumTADstSyncs; i++)
298 {
299 psRetOUT->eError =
300 PVRSRVLookupHandle(psPerProc->psHandleBase,
301 &psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i],
302 psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i],
303 PVRSRV_HANDLE_TYPE_SYNC_INFO);
304
305 if(psRetOUT->eError != PVRSRV_OK)
306 {
307 return 0;
308 }
309 }
310
311 if (psDoKickIN->sCCBKick.ui32Num3DSrcSyncs > SGX_MAX_3D_SRC_SYNCS)
312 {
313 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
314 return 0;
315 }
316
317 for(i=0; i<psDoKickIN->sCCBKick.ui32Num3DSrcSyncs; i++)
318 {
319 psRetOUT->eError =
320 PVRSRVLookupHandle(psPerProc->psHandleBase,
321 &psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i],
322 psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i],
323 PVRSRV_HANDLE_TYPE_SYNC_INFO);
324
325 if(psRetOUT->eError != PVRSRV_OK)
326 {
327 return 0;
328 }
329 }
330#else/* #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */
331 /* texture dependency details */ 268 /* texture dependency details */
332 if (psDoKickIN->sCCBKick.ui32NumSrcSyncs > SGX_MAX_SRC_SYNCS_TA) 269 if (psDoKickIN->sCCBKick.ui32NumSrcSyncs > SGX_MAX_SRC_SYNCS_TA)
333 { 270 {
@@ -350,7 +287,6 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID,
350 } 287 }
351 } 288 }
352#endif /* !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ 289#endif /* !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */
353#endif /* defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */
354 290
355 if (psDoKickIN->sCCBKick.ui32NumTAStatusVals > SGX_MAX_TA_STATUS_VALS) 291 if (psDoKickIN->sCCBKick.ui32NumTAStatusVals > SGX_MAX_TA_STATUS_VALS)
356 { 292 {
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/buffer_manager.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/buffer_manager.c
index 1013542..e33337f 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/buffer_manager.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/buffer_manager.c
@@ -1,5 +1,5 @@
1/*************************************************************************/ /*! 1/*************************************************************************/ /*!
2@Title Buffer management functions for Linux 2@Title Buffer management functions
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved 3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@Description Manages buffers mapped into two memory spaces - cpu and device, 4@Description Manages buffers mapped into two memory spaces - cpu and device,
5 either of which can be virtual or physical. 5 either of which can be virtual or physical.
@@ -96,6 +96,8 @@ DevMemoryFree (BM_MAPPING *pMapping);
96 @Input pvPrivData - opaque private data passed through to allocator 96 @Input pvPrivData - opaque private data passed through to allocator
97 @Input ui32PrivDataLength - length of opaque private data 97 @Input ui32PrivDataLength - length of opaque private data
98 98
99 @Output pui32TimeToDevMap - Time taken in us to map the allocated
100 buffer to device MMU.
99 @Output pBuf - receives a pointer to a descriptor of the allocated 101 @Output pBuf - receives a pointer to a descriptor of the allocated
100 buffer. 102 buffer.
101 @Return IMG_TRUE - Success 103 @Return IMG_TRUE - Success
@@ -115,6 +117,9 @@ AllocMemory (BM_CONTEXT *pBMContext,
115 IMG_UINT32 ui32NumVirtChunks, 117 IMG_UINT32 ui32NumVirtChunks,
116 IMG_UINT32 ui32NumPhysChunks, 118 IMG_UINT32 ui32NumPhysChunks,
117 IMG_BOOL *pabMapChunk, 119 IMG_BOOL *pabMapChunk,
120 #if defined (PVRSRV_DEVMEM_TIME_STATS)
121 IMG_UINT32 *pui32TimeToDevMap,
122 #endif
118 BM_BUF *pBuf) 123 BM_BUF *pBuf)
119{ 124{
120 BM_MAPPING *pMapping; 125 BM_MAPPING *pMapping;
@@ -126,7 +131,7 @@ AllocMemory (BM_CONTEXT *pBMContext,
126 uSize, ui32Flags, uDevVAddrAlignment)); 131 uSize, ui32Flags, uDevVAddrAlignment));
127 132
128 /* 133 /*
129 what to do depends on combination of DevVaddr generation 134 Decision depends on combination of DevVaddr generation
130 and backing RAM requirement 135 and backing RAM requirement
131 */ 136 */
132 if(ui32Flags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) 137 if(ui32Flags & PVRSRV_MEM_RAM_BACKED_ALLOCATION)
@@ -160,8 +165,11 @@ AllocMemory (BM_CONTEXT *pBMContext,
160 { 165 {
161 IMG_BOOL bSuccess; 166 IMG_BOOL bSuccess;
162 IMG_SIZE_T uActualSize; 167 IMG_SIZE_T uActualSize;
168#if defined (PVRSRV_DEVMEM_TIME_STATS)
169 IMG_UINT64 ui64TimeStart;
170#endif
163 171
164 /* Allocate physcial memory */ 172 /* Allocate physical memory */
165 bSuccess = BM_ImportMemory(psBMHeap, 173 bSuccess = BM_ImportMemory(psBMHeap,
166 ui32ChunkSize * ui32NumPhysChunks, 174 ui32ChunkSize * ui32NumPhysChunks,
167 &uActualSize, 175 &uActualSize,
@@ -180,7 +188,7 @@ AllocMemory (BM_CONTEXT *pBMContext,
180 if (uActualSize != ui32ChunkSize * ui32NumPhysChunks) 188 if (uActualSize != ui32ChunkSize * ui32NumPhysChunks)
181 { 189 {
182 /* 190 /*
183 Most likley the chunksize was not host page multiple so 191 Most likely the chunksize was not host page multiple so
184 return with an error 192 return with an error
185 */ 193 */
186 PVR_DPF((PVR_DBG_ERROR, "AllocMemory: Failed to allocate memory for sparse allocation")); 194 PVR_DPF((PVR_DBG_ERROR, "AllocMemory: Failed to allocate memory for sparse allocation"));
@@ -195,6 +203,9 @@ AllocMemory (BM_CONTEXT *pBMContext,
195 pMapping->ui32NumPhysChunks = ui32NumPhysChunks; 203 pMapping->ui32NumPhysChunks = ui32NumPhysChunks;
196 pMapping->pabMapChunk = pabMapChunk; 204 pMapping->pabMapChunk = pabMapChunk;
197 205
206#if defined (PVRSRV_DEVMEM_TIME_STATS)
207 ui64TimeStart = OSClockMonotonicus();
208#endif
198 /* Allocate VA space and map in the physical memory */ 209 /* Allocate VA space and map in the physical memory */
199 bSuccess = DevMemoryAlloc (pBMContext, 210 bSuccess = DevMemoryAlloc (pBMContext,
200 pMapping, 211 pMapping,
@@ -209,7 +220,10 @@ AllocMemory (BM_CONTEXT *pBMContext,
209 BM_FreeMemory(pArena, IMG_NULL, pMapping); 220 BM_FreeMemory(pArena, IMG_NULL, pMapping);
210 return IMG_FALSE; 221 return IMG_FALSE;
211 } 222 }
212 223
224#if defined (PVRSRV_DEVMEM_TIME_STATS)
225 pMapping->ui32TimeToDevMap = OSClockMonotonicus() - ui64TimeStart;
226#endif
213 /* uDevVAddrAlignment is currently set to zero so QAC generates warning which we override */ 227 /* uDevVAddrAlignment is currently set to zero so QAC generates warning which we override */
214 /* PRQA S 3356,3358 1 */ 228 /* PRQA S 3356,3358 1 */
215 PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); 229 PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1);
@@ -340,6 +354,10 @@ AllocMemory (BM_CONTEXT *pBMContext,
340 pMapping->hOSMemHandle = 0; 354 pMapping->hOSMemHandle = 0;
341 } 355 }
342 356
357#if defined (PVRSRV_DEVMEM_TIME_STATS)
358 *pui32TimeToDevMap = pMapping->ui32TimeToDevMap;
359#endif
360
343 /* Record the arena pointer in the mapping. */ 361 /* Record the arena pointer in the mapping. */
344 pMapping->pArena = pArena; 362 pMapping->pArena = pArena;
345 363
@@ -567,7 +585,7 @@ WrapMemory (BM_HEAP *psBMHeap,
567 { 585 {
568 if(!ZeroBuf(pBuf, pMapping, uSize, ui32Flags)) 586 if(!ZeroBuf(pBuf, pMapping, uSize, ui32Flags))
569 { 587 {
570 return IMG_FALSE; 588 goto fail_cleanup;
571 } 589 }
572 } 590 }
573 591
@@ -588,7 +606,8 @@ fail_cleanup:
588 OSReleaseSubMemHandle(pBuf->hOSMemHandle, ui32Attribs); 606 OSReleaseSubMemHandle(pBuf->hOSMemHandle, ui32Attribs);
589 } 607 }
590 608
591 if(pMapping && (pMapping->CpuVAddr || pMapping->hOSMemHandle)) 609 /* pMapping must be valid: if the allocation failed, we'd have returned */
610 if(pMapping->CpuVAddr || pMapping->hOSMemHandle)
592 { 611 {
593 switch(pMapping->eCpuMemoryOrigin) 612 switch(pMapping->eCpuMemoryOrigin)
594 { 613 {
@@ -711,12 +730,18 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T uBytes, IMG_UINT32 ui32Fl
711 @Input ui32Flags - flags 730 @Input ui32Flags - flags
712 @Input bFromAllocator - Is this being called by the 731 @Input bFromAllocator - Is this being called by the
713 allocator? 732 allocator?
733 @Output pui32TimeToDevUnmap - When not NULL, this receives time taken in
734 microseconds to unmap the buffer from Device MMU
714 735
715 @Return None. 736 @Return None.
716 737
717 *****************************************************************************/ 738 *****************************************************************************/
718static IMG_VOID 739static IMG_VOID
719FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) 740FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator
741 #if defined (PVRSRV_DEVMEM_TIME_STATS)
742 ,IMG_UINT32 *pui32TimeToDevUnmap
743 #endif
744 )
720{ 745{
721 BM_MAPPING *pMapping; 746 BM_MAPPING *pMapping;
722 PVRSRV_DEVICE_NODE *psDeviceNode; 747 PVRSRV_DEVICE_NODE *psDeviceNode;
@@ -728,6 +753,17 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator)
728 753
729 /* record mapping */ 754 /* record mapping */
730 pMapping = pBuf->pMapping; 755 pMapping = pBuf->pMapping;
756#if defined (PVRSRV_DEVMEM_TIME_STATS)
757 /* Pass in the storage where we wish to receive the device "unmap" timing info */
758 pMapping->pui32TimeToDevUnmap = pui32TimeToDevUnmap;
759
760 /* Initialise unmap timing to 'zero'. If the mapping is deleted from Device MMU
761 * we'll get legit value on return */
762 if (pMapping->pui32TimeToDevUnmap)
763 {
764 *(pMapping->pui32TimeToDevUnmap) = 0;
765 }
766#endif
731 767
732 psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode; 768 psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode;
733 if (psDeviceNode->pfnCacheInvalidate) 769 if (psDeviceNode->pfnCacheInvalidate)
@@ -873,7 +909,7 @@ static PVRSRV_ERROR BM_DestroyContext_AnyCb(BM_HEAP *psBMHeap)
873 @Function BM_DestroyContext 909 @Function BM_DestroyContext
874 910
875 @Description Destroy a buffer manager context. All allocated buffers must be 911 @Description Destroy a buffer manager context. All allocated buffers must be
876 free'd before calling this function. This function is called 912 freed before calling this function. This function is called
877 also to perform cleanup during aborted initialisations so it's 913 also to perform cleanup during aborted initialisations so it's
878 fairly careful not to assume any given resource has really been 914 fairly careful not to assume any given resource has really been
879 created/allocated. 915 created/allocated.
@@ -1529,6 +1565,9 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap,
1529 IMG_UINT32 ui32NumVirtChunks, 1565 IMG_UINT32 ui32NumVirtChunks,
1530 IMG_UINT32 ui32NumPhysChunks, 1566 IMG_UINT32 ui32NumPhysChunks,
1531 IMG_BOOL *pabMapChunk, 1567 IMG_BOOL *pabMapChunk,
1568 #if defined (PVRSRV_DEVMEM_TIME_STATS)
1569 IMG_UINT32 *pui32TimeToDevMap,
1570 #endif
1532 BM_HANDLE *phBuf) 1571 BM_HANDLE *phBuf)
1533{ 1572{
1534 BM_BUF *pBuf; 1573 BM_BUF *pBuf;
@@ -1588,6 +1627,9 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap,
1588 ui32NumVirtChunks, 1627 ui32NumVirtChunks,
1589 ui32NumPhysChunks, 1628 ui32NumPhysChunks,
1590 pabMapChunk, 1629 pabMapChunk,
1630 #if defined (PVRSRV_DEVMEM_TIME_STATS)
1631 pui32TimeToDevMap,
1632 #endif
1591 pBuf) != IMG_TRUE) 1633 pBuf) != IMG_TRUE)
1592 { 1634 {
1593 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof (BM_BUF), pBuf, IMG_NULL); 1635 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof (BM_BUF), pBuf, IMG_NULL);
@@ -1869,7 +1911,11 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap,
1869 1911
1870 if (!HASH_Insert (psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr, (IMG_UINTPTR_T)pBuf)) 1912 if (!HASH_Insert (psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr, (IMG_UINTPTR_T)pBuf))
1871 { 1913 {
1872 FreeBuf (pBuf, ui32Flags, IMG_TRUE); 1914 FreeBuf (pBuf, ui32Flags, IMG_TRUE
1915 #if defined (PVRSRV_DEVMEM_TIME_STATS)
1916 , IMG_NULL
1917 #endif
1918 );
1873 PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: HASH_Insert FAILED")); 1919 PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: HASH_Insert FAILED"));
1874 return IMG_FALSE; 1920 return IMG_FALSE;
1875 } 1921 }
@@ -1917,11 +1963,12 @@ BM_Export (BM_HANDLE hBuf)
1917 1963
1918/*! 1964/*!
1919****************************************************************************** 1965******************************************************************************
1920 @Function BM_Export 1966 @Function BM_FreeExport
1921 1967
1922 @Description Export a buffer previously allocated via BM_Alloc. 1968 @Description Free a buffer previously exported via BM_Export.
1923 1969
1924 @Input hBuf - buffer handle. 1970 @Input hBuf - buffer handle.
1971 @Input ui32Flags - flags
1925 1972
1926 @Return None. 1973 @Return None.
1927**************************************************************************/ 1974**************************************************************************/
@@ -1932,14 +1979,18 @@ BM_FreeExport(BM_HANDLE hBuf,
1932 BM_BUF *pBuf = (BM_BUF *)hBuf; 1979 BM_BUF *pBuf = (BM_BUF *)hBuf;
1933 1980
1934 PVRSRVBMBufDecExport(pBuf); 1981 PVRSRVBMBufDecExport(pBuf);
1935 FreeBuf (pBuf, ui32Flags, IMG_FALSE); 1982 FreeBuf (pBuf, ui32Flags, IMG_FALSE
1983 #if defined (PVRSRV_DEVMEM_TIME_STATS)
1984 , IMG_NULL
1985 #endif
1986 );
1936} 1987}
1937 1988
1938/*! 1989/*!
1939****************************************************************************** 1990******************************************************************************
1940 @Function BM_FreeExport 1991 @Function BM_Free
1941 1992
1942 @Description Free a buffer previously exported via BM_Export. 1993 @Description Free a buffer previously allocated via BM_Alloc
1943 1994
1944 @Input hBuf - buffer handle. 1995 @Input hBuf - buffer handle.
1945 @Input ui32Flags - flags 1996 @Input ui32Flags - flags
@@ -1948,7 +1999,11 @@ BM_FreeExport(BM_HANDLE hBuf,
1948**************************************************************************/ 1999**************************************************************************/
1949IMG_VOID 2000IMG_VOID
1950BM_Free (BM_HANDLE hBuf, 2001BM_Free (BM_HANDLE hBuf,
1951 IMG_UINT32 ui32Flags) 2002 IMG_UINT32 ui32Flags
2003 #if defined (PVRSRV_DEVMEM_TIME_STATS)
2004 ,IMG_UINT32 *pui32TimeToDevUnmap
2005 #endif
2006 )
1952{ 2007{
1953 BM_BUF *pBuf = (BM_BUF *)hBuf; 2008 BM_BUF *pBuf = (BM_BUF *)hBuf;
1954 SYS_DATA *psSysData; 2009 SYS_DATA *psSysData;
@@ -1974,7 +2029,11 @@ BM_Free (BM_HANDLE hBuf,
1974 2029
1975 HASH_Remove (pBuf->pMapping->pBMHeap->pBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddr.uiAddr); 2030 HASH_Remove (pBuf->pMapping->pBMHeap->pBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddr.uiAddr);
1976 } 2031 }
1977 FreeBuf (pBuf, ui32Flags, IMG_TRUE); 2032 FreeBuf (pBuf, ui32Flags, IMG_TRUE
2033 #if defined(PVRSRV_DEVMEM_TIME_STATS)
2034 ,pui32TimeToDevUnmap
2035 #endif
2036 );
1978 } 2037 }
1979} 2038}
1980 2039
@@ -1984,7 +2043,7 @@ BM_Free (BM_HANDLE hBuf,
1984 2043
1985 @Function BM_HandleToCpuVaddr 2044 @Function BM_HandleToCpuVaddr
1986 2045
1987 @Description Retreive the cpu virtual address associated with a buffer. 2046 @Description Retrieve the cpu virtual address associated with a buffer.
1988 2047
1989 @Input buffer handle. 2048 @Input buffer handle.
1990 2049
@@ -2015,7 +2074,7 @@ BM_HandleToCpuVaddr (BM_HANDLE hBuf)
2015 2074
2016 @Function BM_HandleToDevVaddr 2075 @Function BM_HandleToDevVaddr
2017 2076
2018 @Description Retreive the device virtual address associated with a buffer. 2077 @Description Retrieve the device virtual address associated with a buffer.
2019 2078
2020 @Input hBuf - buffer handle. 2079 @Input hBuf - buffer handle.
2021 2080
@@ -2045,7 +2104,7 @@ BM_HandleToDevVaddr (BM_HANDLE hBuf)
2045 2104
2046 @Function BM_HandleToSysPaddr 2105 @Function BM_HandleToSysPaddr
2047 2106
2048 @Description Retreive the system physical address associated with a buffer. 2107 @Description Retrieve the system physical address associated with a buffer.
2049 2108
2050 @Input hBuf - buffer handle. 2109 @Input hBuf - buffer handle.
2051 2110
@@ -2075,7 +2134,7 @@ BM_HandleToSysPaddr (BM_HANDLE hBuf)
2075 2134
2076 @Function BM_HandleToMemOSHandle 2135 @Function BM_HandleToMemOSHandle
2077 2136
2078 @Description Retreive the underlying memory handle associated with a buffer. 2137 @Description Retrieve the underlying memory handle associated with a buffer.
2079 2138
2080 @Input hBuf - buffer handle. 2139 @Input hBuf - buffer handle.
2081 2140
@@ -2746,9 +2805,12 @@ BM_ImportMemory (IMG_VOID *pH,
2746 } 2805 }
2747 pMapping->pBMHeap = pBMHeap; 2806 pMapping->pBMHeap = pBMHeap;
2748 pMapping->ui32Flags = ui32Flags; 2807 pMapping->ui32Flags = ui32Flags;
2808#if defined (PVRSRV_DEVMEM_TIME_STATS)
2809 pMapping->pui32TimeToDevUnmap = IMG_NULL;
2810#endif
2749 2811
2750 /* 2812 /*
2751 * If anyone want's to know, pass back the actual size of our allocation. 2813 * If anyone wants to know, pass back the actual size of our allocation.
2752 * There could be up to an extra page's worth of memory which will be marked 2814 * There could be up to an extra page's worth of memory which will be marked
2753 * as free in the RA. 2815 * as free in the RA.
2754 */ 2816 */
@@ -2781,7 +2843,7 @@ BM_ImportMemory (IMG_VOID *pH,
2781 2843
2782 if (uPSize % uDevVAddrAlignment != 0) 2844 if (uPSize % uDevVAddrAlignment != 0)
2783 { 2845 {
2784 PVR_DPF((PVR_DBG_ERROR, "Cannot use use this memory sharing workaround with allocations that might be suballocated")); 2846 PVR_DPF((PVR_DBG_ERROR, "Cannot use this memory sharing workaround with allocations that might be suballocated"));
2785 goto fail_mapping_alloc; 2847 goto fail_mapping_alloc;
2786 } 2848 }
2787 uDevVAddrAlignment = 0; /* FIXME: find out why it doesn't work if alignment is specified */ 2849 uDevVAddrAlignment = 0; /* FIXME: find out why it doesn't work if alignment is specified */
@@ -2825,7 +2887,7 @@ BM_ImportMemory (IMG_VOID *pH,
2825 2887
2826 if (uPSize % uDevVAddrAlignment != 0) 2888 if (uPSize % uDevVAddrAlignment != 0)
2827 { 2889 {
2828 PVR_DPF((PVR_DBG_ERROR, "Cannot use use this memory sharing workaround with allocations that might be suballocated")); 2890 PVR_DPF((PVR_DBG_ERROR, "Cannot use this memory sharing workaround with allocations that might be suballocated"));
2829 goto fail_mapping_alloc; 2891 goto fail_mapping_alloc;
2830 } 2892 }
2831 uDevVAddrAlignment = 0; /* FIXME: find out why it doesn't work if alignment is specified */ 2893 uDevVAddrAlignment = 0; /* FIXME: find out why it doesn't work if alignment is specified */
@@ -2983,6 +3045,10 @@ BM_ImportMemory (IMG_VOID *pH,
2983 */ 3045 */
2984 if ((ui32Flags & PVRSRV_MEM_SPARSE) == 0) 3046 if ((ui32Flags & PVRSRV_MEM_SPARSE) == 0)
2985 { 3047 {
3048#if defined (PVRSRV_DEVMEM_TIME_STATS)
3049 IMG_UINT64 ui64TimeStart;
3050 ui64TimeStart = OSClockMonotonicus();
3051#endif
2986 bResult = DevMemoryAlloc (pBMContext, 3052 bResult = DevMemoryAlloc (pBMContext,
2987 pMapping, 3053 pMapping,
2988 IMG_NULL, 3054 IMG_NULL,
@@ -2996,7 +3062,10 @@ BM_ImportMemory (IMG_VOID *pH,
2996 pMapping->uSize)); 3062 pMapping->uSize));
2997 goto fail_dev_mem_alloc; 3063 goto fail_dev_mem_alloc;
2998 } 3064 }
2999 3065#if defined (PVRSRV_DEVMEM_TIME_STATS)
3066 pMapping->ui32TimeToDevMap = OSClockMonotonicus() - ui64TimeStart;
3067#endif
3068
3000 /* uDevVAddrAlignment is currently set to zero so QAC generates warning which we override */ 3069 /* uDevVAddrAlignment is currently set to zero so QAC generates warning which we override */
3001 /* PRQA S 3356,3358 1 */ 3070 /* PRQA S 3356,3358 1 */
3002 PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); 3071 PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1);
@@ -3010,7 +3079,8 @@ BM_ImportMemory (IMG_VOID *pH,
3010 return IMG_TRUE; 3079 return IMG_TRUE;
3011 3080
3012fail_dev_mem_alloc: 3081fail_dev_mem_alloc:
3013 if (pMapping && (pMapping->CpuVAddr || pMapping->hOSMemHandle)) 3082 /* pMapping must be valid: if the allocation failed, we'd have jumped to fail_exit */
3083 if (pMapping->CpuVAddr || pMapping->hOSMemHandle)
3014 { 3084 {
3015 /* the size is double the actual size for interleaved allocations */ 3085 /* the size is double the actual size for interleaved allocations */
3016 if(pMapping->ui32Flags & PVRSRV_MEM_INTERLEAVED) 3086 if(pMapping->ui32Flags & PVRSRV_MEM_INTERLEAVED)
@@ -3105,7 +3175,21 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping)
3105 */ 3175 */
3106 if (psMapping->DevVAddr.uiAddr) 3176 if (psMapping->DevVAddr.uiAddr)
3107 { 3177 {
3178#if defined (PVRSRV_DEVMEM_TIME_STATS)
3179 unsigned long ulTimeStart = 0;
3180 if (psMapping->pui32TimeToDevUnmap)
3181 {
3182 /* NON-NULL pointer signifies user has provided space to get timings info in */
3183 ulTimeStart = OSClockMonotonicus();
3184 }
3185#endif
3108 DevMemoryFree (psMapping); 3186 DevMemoryFree (psMapping);
3187#if defined (PVRSRV_DEVMEM_TIME_STATS)
3188 if (psMapping->pui32TimeToDevUnmap)
3189 {
3190 *(psMapping->pui32TimeToDevUnmap) = OSClockMonotonicus() - ulTimeStart;
3191 }
3192#endif
3109 } 3193 }
3110 3194
3111 /* the size is double the actual for interleaved */ 3195 /* the size is double the actual for interleaved */
@@ -3329,8 +3413,8 @@ IMG_UINT32 BM_GetVirtualSize(IMG_HANDLE hBMHandle)
3329****************************************************************************** 3413******************************************************************************
3330 @Function BM_MapPageAtOffset 3414 @Function BM_MapPageAtOffset
3331 3415
3332 @Description utility function check if the specificed offset in a BM mapping 3416 @Description utility function check if the specified offset in a BM mapping
3333 is a page that needs tp be mapped 3417 is a page that needs to be mapped
3334 3418
3335 @Input hBMHandle - Handle to BM mapping 3419 @Input hBMHandle - Handle to BM mapping
3336 3420
@@ -3354,10 +3438,10 @@ IMG_BOOL BM_MapPageAtOffset(IMG_HANDLE hBMHandle, IMG_UINT32 ui32Offset)
3354 3438
3355/*! 3439/*!
3356****************************************************************************** 3440******************************************************************************
3357 @Function BM_VirtOffsetToPhyscial 3441 @Function BM_VirtOffsetToPhysical
3358 3442
3359 @Description utility function find of physical offset of a sparse allocation 3443 @Description utility function find of physical offset of a sparse allocation
3360 from it's virtual offset. 3444 from its virtual offset.
3361 3445
3362 @Input hBMHandle - Handle to BM mapping 3446 @Input hBMHandle - Handle to BM mapping
3363 3447
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/deviceclass.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/deviceclass.c
index 6ae3618..027e982 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/deviceclass.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/deviceclass.c
@@ -338,7 +338,7 @@ PVRSRV_ERROR PVRSRVRegisterDCDeviceKM (PVRSRV_DC_SRV2DISP_KMJTABLE *psFuncTable,
338 IMG_UINT32 *pui32DeviceID) 338 IMG_UINT32 *pui32DeviceID)
339{ 339{
340 PVRSRV_DISPLAYCLASS_INFO *psDCInfo = IMG_NULL; 340 PVRSRV_DISPLAYCLASS_INFO *psDCInfo = IMG_NULL;
341 PVRSRV_DEVICE_NODE *psDeviceNode; 341 PVRSRV_DEVICE_NODE *psDeviceNode = IMG_NULL;
342 SYS_DATA *psSysData; 342 SYS_DATA *psSysData;
343 343
344 /* 344 /*
@@ -439,6 +439,11 @@ ErrorExit:
439 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DISPLAYCLASS_INFO), psDCInfo, IMG_NULL); 439 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DISPLAYCLASS_INFO), psDCInfo, IMG_NULL);
440 /*not nulling pointer, out of scope*/ 440 /*not nulling pointer, out of scope*/
441 441
442 if(psDeviceNode)
443 {
444 OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), psDeviceNode, IMG_NULL);
445 }
446
442 return PVRSRV_ERROR_OUT_OF_MEMORY; 447 return PVRSRV_ERROR_OUT_OF_MEMORY;
443} 448}
444 449
@@ -538,7 +543,7 @@ PVRSRV_ERROR PVRSRVRegisterBCDeviceKM (PVRSRV_BC_SRV2BUFFER_KMJTABLE *psFuncTabl
538 IMG_UINT32 *pui32DeviceID) 543 IMG_UINT32 *pui32DeviceID)
539{ 544{
540 PVRSRV_BUFFERCLASS_INFO *psBCInfo = IMG_NULL; 545 PVRSRV_BUFFERCLASS_INFO *psBCInfo = IMG_NULL;
541 PVRSRV_DEVICE_NODE *psDeviceNode; 546 PVRSRV_DEVICE_NODE *psDeviceNode = IMG_NULL;
542 SYS_DATA *psSysData; 547 SYS_DATA *psSysData;
543 /* 548 /*
544 IN: 549 IN:
@@ -627,13 +632,18 @@ ErrorExit:
627 632
628 if(psBCInfo->psFuncTable) 633 if(psBCInfo->psFuncTable)
629 { 634 {
630 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PPVRSRV_BC_SRV2BUFFER_KMJTABLE), psBCInfo->psFuncTable, IMG_NULL); 635 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_BC_SRV2BUFFER_KMJTABLE), psBCInfo->psFuncTable, IMG_NULL);
631 psBCInfo->psFuncTable = IMG_NULL; 636 psBCInfo->psFuncTable = IMG_NULL;
632 } 637 }
633 638
634 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_BUFFERCLASS_INFO), psBCInfo, IMG_NULL); 639 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_BUFFERCLASS_INFO), psBCInfo, IMG_NULL);
635 /*not nulling shared pointer, wasn't allocated to this point*/ 640 /*not nulling shared pointer, wasn't allocated to this point*/
636 641
642 if(psDeviceNode)
643 {
644 OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), psDeviceNode, IMG_NULL);
645 }
646
637 return PVRSRV_ERROR_OUT_OF_MEMORY; 647 return PVRSRV_ERROR_OUT_OF_MEMORY;
638} 648}
639 649
@@ -850,7 +860,6 @@ PVRSRV_ERROR PVRSRVOpenDCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc,
850 860
851 if(psDCInfo->ui32RefCount++ == 0) 861 if(psDCInfo->ui32RefCount++ == 0)
852 { 862 {
853
854 psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie; 863 psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie;
855 864
856 /* store the device kernel context to map into */ 865 /* store the device kernel context to map into */
@@ -863,8 +872,7 @@ PVRSRV_ERROR PVRSRVOpenDCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc,
863 if(eError != PVRSRV_OK) 872 if(eError != PVRSRV_OK)
864 { 873 {
865 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenDCDeviceKM: Failed sync info alloc")); 874 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenDCDeviceKM: Failed sync info alloc"));
866 psDCInfo->ui32RefCount--; 875 goto ErrorExit;
867 return eError;
868 } 876 }
869 877
870 /* open the external device */ 878 /* open the external device */
@@ -874,9 +882,7 @@ PVRSRV_ERROR PVRSRVOpenDCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc,
874 if(eError != PVRSRV_OK) 882 if(eError != PVRSRV_OK)
875 { 883 {
876 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenDCDeviceKM: Failed to open external DC device")); 884 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenDCDeviceKM: Failed to open external DC device"));
877 psDCInfo->ui32RefCount--; 885 goto ErrorExitSyncInfo;
878 PVRSRVKernelSyncInfoDecRef(psDCInfo->sSystemBuffer.sDeviceClassBuffer.psKernelSyncInfo, IMG_NULL);
879 return eError;
880 } 886 }
881 887
882 psDCPerContextInfo->psDCInfo = psDCInfo; 888 psDCPerContextInfo->psDCInfo = psDCInfo;
@@ -884,9 +890,7 @@ PVRSRV_ERROR PVRSRVOpenDCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc,
884 if(eError != PVRSRV_OK) 890 if(eError != PVRSRV_OK)
885 { 891 {
886 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenDCDeviceKM: Failed to get system buffer")); 892 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenDCDeviceKM: Failed to get system buffer"));
887 psDCInfo->ui32RefCount--; 893 goto ErrorExitCloseDevice;
888 PVRSRVKernelSyncInfoDecRef(psDCInfo->sSystemBuffer.sDeviceClassBuffer.psKernelSyncInfo, IMG_NULL);
889 return eError;
890 } 894 }
891 psDCInfo->sSystemBuffer.sDeviceClassBuffer.ui32MemMapRefCount = 0; 895 psDCInfo->sSystemBuffer.sDeviceClassBuffer.ui32MemMapRefCount = 0;
892 } 896 }
@@ -905,6 +909,17 @@ PVRSRV_ERROR PVRSRVOpenDCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc,
905 *phDeviceKM = (IMG_HANDLE)psDCPerContextInfo; 909 *phDeviceKM = (IMG_HANDLE)psDCPerContextInfo;
906 910
907 return PVRSRV_OK; 911 return PVRSRV_OK;
912
913ErrorExitCloseDevice:
914 psDCInfo->psFuncTable->pfnCloseDCDevice(psDCInfo->hExtDevice);
915
916ErrorExitSyncInfo:
917 PVRSRVKernelSyncInfoDecRef(psDCInfo->sSystemBuffer.sDeviceClassBuffer.psKernelSyncInfo, IMG_NULL);
918
919ErrorExit:
920 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DISPLAYCLASS_PERCONTEXT_INFO), psDCPerContextInfo, IMG_NULL);
921 psDCInfo->ui32RefCount = 0;
922 return eError;
908} 923}
909 924
910 925
@@ -1252,6 +1267,12 @@ static PVRSRV_ERROR PVRSRVCreateDCSwapChainRefKM(PVRSRV_PER_PROCESS_DATA *psPerP
1252 psSwapChainRef, 1267 psSwapChainRef,
1253 0, 1268 0,
1254 &DestroyDCSwapChainRefCallBack); 1269 &DestroyDCSwapChainRefCallBack);
1270 if (psSwapChainRef->hResItem == IMG_NULL)
1271 {
1272 PVR_DPF ((PVR_DBG_ERROR, "PVRSRVCreateDCSwapChainRefKM: ResManRegisterRes failed"));
1273 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DC_SWAPCHAIN_REF), psSwapChainRef, IMG_NULL);
1274 return PVRSRV_ERROR_INVALID_PARAMS;
1275 }
1255 *ppsSwapChainRef = psSwapChainRef; 1276 *ppsSwapChainRef = psSwapChainRef;
1256 1277
1257 return PVRSRV_OK; 1278 return PVRSRV_OK;
@@ -1779,14 +1800,18 @@ static IMG_VOID FreePrivateData(IMG_HANDLE hCallbackData)
1779 1800
1780 if(psCallbackData->ui32PrivDataLength) 1801 if(psCallbackData->ui32PrivDataLength)
1781 { 1802 {
1782 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psCallbackData->ui32PrivDataLength, 1803 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
1804 psCallbackData->ui32PrivDataLength,
1783 psCallbackData->pvPrivData, IMG_NULL); 1805 psCallbackData->pvPrivData, IMG_NULL);
1784 } 1806 }
1785 1807
1786 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, 1808 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
1787 sizeof(IMG_VOID *) * psCallbackData->ui32NumMemInfos, 1809 sizeof(IMG_VOID *) * psCallbackData->ui32NumMemInfos,
1788 psCallbackData->ppvMemInfos, IMG_NULL); 1810 psCallbackData->ppvMemInfos, IMG_NULL);
1789 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(CALLBACK_DATA), hCallbackData, IMG_NULL); 1811
1812 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
1813 sizeof(CALLBACK_DATA),
1814 hCallbackData, IMG_NULL);
1790} 1815}
1791 1816
1792IMG_EXPORT 1817IMG_EXPORT
@@ -1813,7 +1838,6 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM,
1813 IMG_PVOID *ppvMemInfos; 1838 IMG_PVOID *ppvMemInfos;
1814 PVRSRV_ERROR eError; 1839 PVRSRV_ERROR eError;
1815 SYS_DATA *psSysData; 1840 SYS_DATA *psSysData;
1816
1817#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 1841#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
1818 struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA] = {}; 1842 struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA] = {};
1819#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ 1843#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */
@@ -1836,7 +1860,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM,
1836 return PVRSRV_ERROR_INVALID_SWAPINTERVAL; 1860 return PVRSRV_ERROR_INVALID_SWAPINTERVAL;
1837 } 1861 }
1838 1862
1839 eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, 1863 eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
1840 sizeof(CALLBACK_DATA), 1864 sizeof(CALLBACK_DATA),
1841 (IMG_VOID **)&psCallbackData, IMG_NULL, 1865 (IMG_VOID **)&psCallbackData, IMG_NULL,
1842 "PVRSRVSwapToDCBuffer2KM callback data"); 1866 "PVRSRVSwapToDCBuffer2KM callback data");
@@ -1848,9 +1872,9 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM,
1848 psCallbackData->pvPrivData = pvPrivData; 1872 psCallbackData->pvPrivData = pvPrivData;
1849 psCallbackData->ui32PrivDataLength = ui32PrivDataLength; 1873 psCallbackData->ui32PrivDataLength = ui32PrivDataLength;
1850 1874
1851 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, 1875 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
1852 sizeof(IMG_VOID *) * ui32NumMemInfos, 1876 sizeof(void *) * ui32NumMemInfos,
1853 (IMG_VOID **)&ppvMemInfos, IMG_NULL, 1877 (void **)&ppvMemInfos, IMG_NULL,
1854 "Swap Command Meminfos") != PVRSRV_OK) 1878 "Swap Command Meminfos") != PVRSRV_OK)
1855 { 1879 {
1856 PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); 1880 PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list"));
@@ -2216,11 +2240,11 @@ Exit:
2216 { 2240 {
2217 if(psCallbackData->ppvMemInfos) 2241 if(psCallbackData->ppvMemInfos)
2218 { 2242 {
2219 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, 2243 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION,
2220 sizeof(IMG_VOID *) * psCallbackData->ui32NumMemInfos, 2244 sizeof(IMG_VOID *) * psCallbackData->ui32NumMemInfos,
2221 psCallbackData->ppvMemInfos, IMG_NULL); 2245 psCallbackData->ppvMemInfos, IMG_NULL);
2222 } 2246 }
2223 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(CALLBACK_DATA), psCallbackData, IMG_NULL); 2247 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP | PVRSRV_SWAP_BUFFER_ALLOCATION, sizeof(CALLBACK_DATA), psCallbackData, IMG_NULL);
2224 } 2248 }
2225 if(eError == PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE) 2249 if(eError == PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE)
2226 { 2250 {
@@ -2703,7 +2727,7 @@ FoundDevice:
2703 if(eError != PVRSRV_OK) 2727 if(eError != PVRSRV_OK)
2704 { 2728 {
2705 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed to open external BC device")); 2729 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed to open external BC device"));
2706 return eError; 2730 goto ErrorExit;
2707 } 2731 }
2708 2732
2709 /* get information about the buffers */ 2733 /* get information about the buffers */
@@ -2711,7 +2735,7 @@ FoundDevice:
2711 if(eError != PVRSRV_OK) 2735 if(eError != PVRSRV_OK)
2712 { 2736 {
2713 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM : Failed to get BC Info")); 2737 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM : Failed to get BC Info"));
2714 return eError; 2738 goto ErrorExitCloseDevice;
2715 } 2739 }
2716 2740
2717 /* interpret and store info */ 2741 /* interpret and store info */
@@ -2726,7 +2750,7 @@ FoundDevice:
2726 if(eError != PVRSRV_OK) 2750 if(eError != PVRSRV_OK)
2727 { 2751 {
2728 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed to allocate BC buffers")); 2752 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed to allocate BC buffers"));
2729 return eError; 2753 goto ErrorExitCloseDevice;
2730 } 2754 }
2731 OSMemSet (psBCInfo->psBuffer, 2755 OSMemSet (psBCInfo->psBuffer,
2732 0, 2756 0,
@@ -2741,7 +2765,7 @@ FoundDevice:
2741 if(eError != PVRSRV_OK) 2765 if(eError != PVRSRV_OK)
2742 { 2766 {
2743 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed sync info alloc")); 2767 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed sync info alloc"));
2744 goto ErrorExit; 2768 goto ErrorExitBuffers;
2745 } 2769 }
2746 2770
2747 /* 2771 /*
@@ -2755,7 +2779,7 @@ FoundDevice:
2755 if(eError != PVRSRV_OK) 2779 if(eError != PVRSRV_OK)
2756 { 2780 {
2757 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed to get BC buffers")); 2781 PVR_DPF((PVR_DBG_ERROR,"PVRSRVOpenBCDeviceKM: Failed to get BC buffers"));
2758 goto ErrorExit; 2782 goto ErrorExitBuffers;
2759 } 2783 }
2760 2784
2761 /* setup common device class info */ 2785 /* setup common device class info */
@@ -2778,8 +2802,7 @@ FoundDevice:
2778 2802
2779 return PVRSRV_OK; 2803 return PVRSRV_OK;
2780 2804
2781ErrorExit: 2805ErrorExitBuffers:
2782
2783 /* free syncinfos */ 2806 /* free syncinfos */
2784 for(i=0; i<psBCInfo->ui32BufferCount; i++) 2807 for(i=0; i<psBCInfo->ui32BufferCount; i++)
2785 { 2808 {
@@ -2790,12 +2813,15 @@ ErrorExit:
2790 } 2813 }
2791 2814
2792 /* free buffers */ 2815 /* free buffers */
2793 if(psBCInfo->psBuffer) 2816 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_BC_BUFFER), psBCInfo->psBuffer, IMG_NULL);
2794 { 2817 psBCInfo->psBuffer = IMG_NULL;
2795 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_BC_BUFFER), psBCInfo->psBuffer, IMG_NULL);
2796 psBCInfo->psBuffer = IMG_NULL;
2797 }
2798 2818
2819ErrorExitCloseDevice:
2820 psBCInfo->psFuncTable->pfnCloseBCDevice(psBCInfo->ui32DeviceID, psBCInfo->hExtDevice);
2821
2822ErrorExit:
2823 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_BUFFERCLASS_PERCONTEXT_INFO), psBCPerContextInfo, IMG_NULL);
2824 psBCInfo->ui32RefCount = 0;
2799 return eError; 2825 return eError;
2800} 2826}
2801 2827
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/devicemem.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/devicemem.c
index d28136f..f6d4463 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/devicemem.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/devicemem.c
@@ -49,21 +49,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49#include "osfunc.h" 49#include "osfunc.h"
50#include "devicemem.h" 50#include "devicemem.h"
51 51
52#if defined(SUPPORT_DRM_GEM)
53#include "dmabuf.h"
54#endif
55
56#if defined(SUPPORT_ION) 52#if defined(SUPPORT_ION)
57#include "ion.h" 53#include "ion.h"
58#include "env_perproc.h" 54#include "env_perproc.h"
55#include "ion_sync.h"
56
57/* Start size of the g_IonSyncHash hash table */
58#define ION_SYNC_HASH_SIZE 20
59HASH_TABLE *g_psIonSyncHash = IMG_NULL;
59#endif 60#endif
60 61
61#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 62#if defined(SUPPORT_DMABUF)
62#include "external_sync.h" 63#include "dmabuf.h"
64#include "dmabuf_sync.h"
65#include "pvr_linux_fence.h"
63 66
64/* Start size of the g_ExternalSyncHash hash table */ 67/* Start size of the g_DmaBufSyncHash hash table */
65#define EXTERNAL_SYNC_HASH_SIZE 20 68#define DMABUF_SYNC_HASH_SIZE 20
66HASH_TABLE *g_psExternalSyncHash = IMG_NULL; 69HASH_TABLE *g_psDmaBufSyncHash = IMG_NULL;
67#endif 70#endif
68 71
69#include "lists.h" 72#include "lists.h"
@@ -114,8 +117,8 @@ typedef struct _PVRSRV_DC_MAPINFO_
114 117
115static IMG_UINT32 g_ui32SyncUID = 0; 118static IMG_UINT32 g_ui32SyncUID = 0;
116#if defined (MEM_TRACK_INFO_DEBUG) 119#if defined (MEM_TRACK_INFO_DEBUG)
117PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoHead = NULL; 120PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoHead = IMG_NULL;
118PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoTail = NULL; 121PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoTail = IMG_NULL;
119IMG_UINT32 g_ui32NumOfOpsRecorded = 0; 122IMG_UINT32 g_ui32NumOfOpsRecorded = 0;
120#endif 123#endif
121 124
@@ -182,7 +185,7 @@ IMG_EXPORT
182IMG_VOID IMG_CALLCONV PVRSRVPrintMemTrackInfo(IMG_UINT32 ui32FaultAddr) 185IMG_VOID IMG_CALLCONV PVRSRVPrintMemTrackInfo(IMG_UINT32 ui32FaultAddr)
183{ 186{
184 PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; 187 PVRSRV_MEM_TRACK_INFO *psMemTrackInfo;
185 const IMG_CHAR *apszMemOpNames[] = {"UNKNOWN", "DEVICE", "DEVICECLASS", "WRAPPED", "MAPPED", "ION", "ALLOC", "FREE"}; 188 static const IMG_CHAR * const apszMemOpNames[] = {"UNKNOWN", "DEVICE", "DEVICECLASS", "WRAPPED", "MAPPED", "ION", "DMA-BUF" "ALLOC", "FREE"};
186 psMemTrackInfo = g_psMemTrackInfoHead; 189 psMemTrackInfo = g_psMemTrackInfoHead;
187 190
188 PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVMemTrackInfo: Dumping mem tracking info\n")); 191 PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVMemTrackInfo: Dumping mem tracking info\n"));
@@ -619,6 +622,9 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie,
619 ui32NumVirtChunks, 622 ui32NumVirtChunks,
620 ui32NumPhysChunks, 623 ui32NumPhysChunks,
621 pabMapChunk, 624 pabMapChunk,
625 #if defined (PVRSRV_DEVMEM_TIME_STATS)
626 &psMemInfo->ui32TimeToDevMap,
627 #endif
622 &hBuffer); 628 &hBuffer);
623 629
624 if (!bBMError) 630 if (!bBMError)
@@ -679,7 +685,12 @@ static PVRSRV_ERROR FreeDeviceMem2(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVRSRV_FRE
679 switch(eCallbackOrigin) 685 switch(eCallbackOrigin)
680 { 686 {
681 case PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR: 687 case PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR:
682 BM_Free(hBuffer, psMemInfo->ui32Flags); 688 BM_Free(hBuffer,
689 psMemInfo->ui32Flags
690 #if defined(PVRSRV_DEVMEM_TIME_STATS)
691 ,psMemInfo->pui32TimeToDevUnmap
692 #endif
693 );
683 break; 694 break;
684 case PVRSRV_FREE_CALLBACK_ORIGIN_IMPORTER: 695 case PVRSRV_FREE_CALLBACK_ORIGIN_IMPORTER:
685 BM_FreeExport(hBuffer, psMemInfo->ui32Flags); 696 BM_FreeExport(hBuffer, psMemInfo->ui32Flags);
@@ -712,7 +723,11 @@ static PVRSRV_ERROR FreeDeviceMem(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
712 723
713 hBuffer = psMemInfo->sMemBlk.hBuffer; 724 hBuffer = psMemInfo->sMemBlk.hBuffer;
714 725
715 BM_Free(hBuffer, psMemInfo->ui32Flags); 726 BM_Free(hBuffer, psMemInfo->ui32Flags
727 #if defined(PVRSRV_DEVMEM_TIME_STATS)
728 , IMG_NULL
729 #endif
730 );
716 731
717 if(psMemInfo->pvSysBackupBuffer) 732 if(psMemInfo->pvSysBackupBuffer)
718 { 733 {
@@ -814,6 +829,10 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie,
814 psSyncData->ui32LastReadOpDumpVal = 0; 829 psSyncData->ui32LastReadOpDumpVal = 0;
815 psSyncData->ui64LastWrite = 0; 830 psSyncData->ui64LastWrite = 0;
816 831
832#if defined(SUPPORT_DMABUF)
833 psKernelSyncInfo->hFenceContext = IMG_NULL;
834#endif
835
817#if defined(SUPPORT_PER_SYNC_DEBUG) 836#if defined(SUPPORT_PER_SYNC_DEBUG)
818 psKernelSyncInfo->ui32OperationMask = 0; 837 psKernelSyncInfo->ui32OperationMask = 0;
819 memset(psKernelSyncInfo->aui32OpInfo, 0, sizeof(psKernelSyncInfo->aui32OpInfo)); 838 memset(psKernelSyncInfo->aui32OpInfo, 0, sizeof(psKernelSyncInfo->aui32OpInfo));
@@ -963,21 +982,21 @@ static IMG_VOID freeExternal(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
963 OSReleasePhysPageAddr(hOSWrapMem); 982 OSReleasePhysPageAddr(hOSWrapMem);
964 } 983 }
965 } 984 }
966#if defined(SUPPORT_DRM_GEM) 985#if defined(SUPPORT_ION)
967 else if (psMemInfo->memType == PVRSRV_MEMTYPE_DMABUF) 986 else if (psMemInfo->memType == PVRSRV_MEMTYPE_ION)
968 { 987 {
969 if (hOSWrapMem) 988 if (hOSWrapMem)
970 { 989 {
971 DmabufUnimportBufferAndReleasePhysAddr(hOSWrapMem); 990 IonUnimportBufferAndReleasePhysAddr(hOSWrapMem);
972 } 991 }
973 } 992 }
974#endif 993#endif
975#if defined(SUPPORT_ION) 994#if defined(SUPPORT_DMABUF)
976 else if (psMemInfo->memType == PVRSRV_MEMTYPE_ION) 995 else if (psMemInfo->memType == PVRSRV_MEMTYPE_DMABUF)
977 { 996 {
978 if (hOSWrapMem) 997 if (hOSWrapMem)
979 { 998 {
980 IonUnimportBufferAndReleasePhysAddr(hOSWrapMem); 999 DmaBufUnimportAndReleasePhysAddr(hOSWrapMem);
981 } 1000 }
982 } 1001 }
983#endif 1002#endif
@@ -1071,14 +1090,21 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
1071 freeExternal(psMemInfo); 1090 freeExternal(psMemInfo);
1072 case PVRSRV_MEMTYPE_DEVICE: 1091 case PVRSRV_MEMTYPE_DEVICE:
1073 case PVRSRV_MEMTYPE_DEVICECLASS: 1092 case PVRSRV_MEMTYPE_DEVICECLASS:
1074#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 1093#if defined(SUPPORT_ION)
1075 if (psMemInfo->hExternalSyncInfo) 1094 if (psMemInfo->hIonSyncInfo)
1076 { 1095 {
1077 /* 1096 /*
1078 For syncs attached to Ion imported buffers we handle 1097 For syncs attached to Ion imported buffers we handle
1079 things a little differently 1098 things a little differently
1080 */ 1099 */
1081 PVRSRVExternalBufferSyncInfoDecRef(psMemInfo->hExternalSyncInfo, psMemInfo); 1100 PVRSRVIonBufferSyncInfoDecRef(psMemInfo->hIonSyncInfo, psMemInfo);
1101 }
1102 else
1103#endif
1104#if defined(SUPPORT_DMABUF)
1105 if (psMemInfo->hDmaBufSyncInfo)
1106 {
1107 PVRSRVDmaBufSyncInfoDecRef(psMemInfo->hDmaBufSyncInfo, psMemInfo);
1082 } 1108 }
1083 else 1109 else
1084#endif 1110#endif
@@ -1090,7 +1116,7 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
1090 } 1116 }
1091 break; 1117 break;
1092 default: 1118 default:
1093 PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: Unknown memType: %d", psMemInfo->memType)); 1119 PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: Unknown memType"));
1094 eError = PVRSRV_ERROR_INVALID_MEMINFO; 1120 eError = PVRSRV_ERROR_INVALID_MEMINFO;
1095 } 1121 }
1096 } 1122 }
@@ -1393,24 +1419,35 @@ free_mainalloc:
1393 return eError; 1419 return eError;
1394} 1420}
1395 1421
1396#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 1422#if defined(SUPPORT_ION)
1397PVRSRV_ERROR PVRSRVExternalBufferSyncAcquire(IMG_HANDLE hUnique, 1423static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam,
1424 IMG_UINT32 ui32Param,
1425 IMG_BOOL bDummy)
1426{
1427 PVRSRV_KERNEL_MEM_INFO *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam;
1428
1429 PVR_UNREFERENCED_PARAMETER(bDummy);
1430
1431 return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR);
1432}
1433
1434PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique,
1398 IMG_HANDLE hDevCookie, 1435 IMG_HANDLE hDevCookie,
1399 IMG_HANDLE hDevMemContext, 1436 IMG_HANDLE hDevMemContext,
1400 PVRSRV_EXTERNAL_SYNC_INFO **ppsExternalSyncInfo) 1437 PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo)
1401{ 1438{
1402 PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo; 1439 PVRSRV_ION_SYNC_INFO *psIonSyncInfo;
1403 PVRSRV_ERROR eError; 1440 PVRSRV_ERROR eError;
1404 IMG_BOOL bRet; 1441 IMG_BOOL bRet;
1405 1442
1406 /* Check the hash to see if we already have a sync for this buffer */ 1443 /* Check the hash to see if we already have a sync for this buffer */
1407 psExternalSyncInfo = (PVRSRV_EXTERNAL_SYNC_INFO *) HASH_Retrieve(g_psExternalSyncHash, (IMG_UINTPTR_T) hUnique); 1444 psIonSyncInfo = (PVRSRV_ION_SYNC_INFO *) HASH_Retrieve(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique);
1408 if (psExternalSyncInfo == 0) 1445 if (psIonSyncInfo == 0)
1409 { 1446 {
1410 /* This buffer is new to us, create the syncinfo for it */ 1447 /* This buffer is new to us, create the syncinfo for it */
1411 eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, 1448 eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT,
1412 sizeof(PVRSRV_EXTERNAL_SYNC_INFO), 1449 sizeof(PVRSRV_ION_SYNC_INFO),
1413 (IMG_VOID **)&psExternalSyncInfo, IMG_NULL, 1450 (IMG_VOID **)&psIonSyncInfo, IMG_NULL,
1414 "Ion Synchronization Info"); 1451 "Ion Synchronization Info");
1415 if (eError != PVRSRV_OK) 1452 if (eError != PVRSRV_OK)
1416 { 1453 {
@@ -1419,109 +1456,96 @@ PVRSRV_ERROR PVRSRVExternalBufferSyncAcquire(IMG_HANDLE hUnique,
1419 1456
1420 eError = PVRSRVAllocSyncInfoKM(hDevCookie, 1457 eError = PVRSRVAllocSyncInfoKM(hDevCookie,
1421 hDevMemContext, 1458 hDevMemContext,
1422 &psExternalSyncInfo->psSyncInfo); 1459 &psIonSyncInfo->psSyncInfo);
1423 if (eError != PVRSRV_OK) 1460 if (eError != PVRSRV_OK)
1424 { 1461 {
1425 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 1462 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1426 sizeof(PVRSRV_EXTERNAL_SYNC_INFO), 1463 sizeof(PVRSRV_ION_SYNC_INFO),
1427 psExternalSyncInfo, 1464 psIonSyncInfo,
1428 IMG_NULL); 1465 IMG_NULL);
1429 1466
1430 return eError; 1467 return eError;
1431 } 1468 }
1432#if defined(SUPPORT_MEMINFO_IDS) 1469#if defined(SUPPORT_MEMINFO_IDS)
1433 psExternalSyncInfo->ui64Stamp = ++g_ui64MemInfoID; 1470 psIonSyncInfo->ui64Stamp = ++g_ui64MemInfoID;
1434#else 1471#else
1435 psExternalSyncInfo->ui64Stamp = 0; 1472 psIonSyncInfo->ui64Stamp = 0;
1436#endif 1473#endif
1437 bRet = HASH_Insert(g_psExternalSyncHash, (IMG_UINTPTR_T) hUnique, (IMG_UINTPTR_T) psExternalSyncInfo); 1474 bRet = HASH_Insert(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique, (IMG_UINTPTR_T) psIonSyncInfo);
1438 if (!bRet) 1475 if (!bRet)
1439 { 1476 {
1440 eError = PVRSRV_ERROR_OUT_OF_MEMORY; 1477 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1441 1478
1442 PVRSRVKernelSyncInfoDecRef(psExternalSyncInfo->psSyncInfo, IMG_NULL); 1479 PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL);
1443 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 1480 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1444 sizeof(PVRSRV_EXTERNAL_SYNC_INFO), 1481 sizeof(PVRSRV_ION_SYNC_INFO),
1445 psExternalSyncInfo, 1482 psIonSyncInfo,
1446 IMG_NULL); 1483 IMG_NULL);
1447 1484
1448 return eError; 1485 return eError;
1449 } 1486 }
1450 1487
1451 psExternalSyncInfo->ui32RefCount = 0; 1488 psIonSyncInfo->ui32RefCount = 0;
1452 psExternalSyncInfo->hUnique = hUnique; 1489 psIonSyncInfo->hUnique = hUnique;
1453 } 1490 }
1454 1491
1455 psExternalSyncInfo->ui32RefCount++; 1492 psIonSyncInfo->ui32RefCount++;
1456 *ppsExternalSyncInfo = psExternalSyncInfo; 1493 *ppsIonSyncInfo = psIonSyncInfo;
1457 return PVRSRV_OK; 1494 return PVRSRV_OK;
1458} 1495}
1459 1496
1460IMG_VOID PVRSRVExternalBufferSyncRelease(PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo) 1497IMG_VOID PVRSRVIonBufferSyncRelease(PVRSRV_ION_SYNC_INFO *psIonSyncInfo)
1461{ 1498{
1462 psExternalSyncInfo->ui32RefCount--; 1499 psIonSyncInfo->ui32RefCount--;
1463 1500
1464 if (psExternalSyncInfo->ui32RefCount == 0) 1501 if (psIonSyncInfo->ui32RefCount == 0)
1465 { 1502 {
1466 PVRSRV_EXTERNAL_SYNC_INFO *psLookup; 1503 PVRSRV_ION_SYNC_INFO *psLookup;
1467 /* 1504 /*
1468 If we're holding the last reference to the syncinfo 1505 If we're holding the last reference to the syncinfo
1469 then free it 1506 then free it
1470 */ 1507 */
1471 psLookup = (PVRSRV_EXTERNAL_SYNC_INFO *) HASH_Remove(g_psExternalSyncHash, (IMG_UINTPTR_T) psExternalSyncInfo->hUnique); 1508 psLookup = (PVRSRV_ION_SYNC_INFO *) HASH_Remove(g_psIonSyncHash, (IMG_UINTPTR_T) psIonSyncInfo->hUnique);
1472 PVR_ASSERT(psLookup == psExternalSyncInfo); 1509 PVR_ASSERT(psLookup == psIonSyncInfo);
1473 PVRSRVKernelSyncInfoDecRef(psExternalSyncInfo->psSyncInfo, IMG_NULL); 1510 PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL);
1474 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 1511 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1475 sizeof(PVRSRV_EXTERNAL_SYNC_INFO), 1512 sizeof(PVRSRV_ION_SYNC_INFO),
1476 psExternalSyncInfo, 1513 psIonSyncInfo,
1477 IMG_NULL); 1514 IMG_NULL);
1478 } 1515 }
1479} 1516}
1480#endif //defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
1481
1482#if defined(SUPPORT_DRM_GEM)
1483static PVRSRV_ERROR DmabufUnmapCallback(IMG_PVOID pvParam,
1484 IMG_UINT32 ui32Param,
1485 IMG_BOOL bDummy)
1486{
1487 PVRSRV_KERNEL_MEM_INFO *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam;
1488
1489 PVR_UNREFERENCED_PARAMETER(bDummy);
1490
1491 return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR);
1492}
1493 1517
1494/*! 1518/*!
1495****************************************************************************** 1519******************************************************************************
1496 1520
1497 @Function PVRSRVMapDmabufKM 1521 @Function PVRSRVMapIonHandleKM
1498 1522
1499 @Description 1523 @Description
1500 1524
1501 Map a DMABUF buffer into the specified device memory context 1525 Map an ION buffer into the specified device memory context
1502 1526
1503 @Input psPerProc : PerProcess data 1527 @Input psPerProc : PerProcess data
1504 @Input hDevCookie : Device node cookie 1528 @Input hDevCookie : Device node cookie
1505 @Input hDevMemHeap : Heap dmabuf handles are mapped into 1529 @Input hDevMemHeap : Heap ion handles are mapped into
1506 @Input ui32NumBuffers : Number of dmabuf handles to map. (If one handle is being 1530 @Input ui32NumBuffers : Number of ion handles to map. (If one handle is being
1507 mapped, this should be 1, not 0.) 1531 mapped, this should be 1, not 0.)
1508 @Input phDmabuf : Array of ui32NumBuffers dmabuf handles (fds) 1532 @Input phIon : Array of ui32NumBuffers ion handles (fds)
1509 @Input ui32Flags : Mapping flags 1533 @Input ui32Flags : Mapping flags
1510 @Input ui32ChunkCount : If ui32NumBuffers is 1, this is the number of 1534 @Input ui32ChunkCount : If ui32NumBuffers is 1, this is the number of
1511 "chunks" specified to be mapped into device-virtual 1535 "chunks" specified to be mapped into device-virtual
1512 address space. If ui32NumBuffers > 1, it is ignored. 1536 address space. If ui32NumBuffers > 1, it is ignored.
1513 @Input pauiOffset : Array of offsets in device-virtual address space to map 1537 @Input pauiOffset : Array of offsets in device-virtual address space to map
1514 "chunks" of physical from the dmabuf allocation. 1538 "chunks" of physical from the ion allocation.
1515 @Input pauiSize : Array of sizes in bytes of device-virtual address space to 1539 @Input pauiSize : Array of sizes in bytes of device-virtual address space to
1516 map "chunks" of physical from the dmabuf allocation. 1540 map "chunks" of physical from the ion allocation.
1517 @Input puiDmabufBufferSize : Size in bytes of resulting device-virtual mapping. 1541 @Input puiIonBufferSize : Size in bytes of resulting device-virtual mapping.
1518 @Output ppsKernelMemInfo: Output kernel meminfo if successful 1542 @Output ppsKernelMemInfo: Output kernel meminfo if successful
1519 1543
1520 @Return PVRSRV_ERROR : 1544 @Return PVRSRV_ERROR :
1521 1545
1522******************************************************************************/ 1546******************************************************************************/
1523IMG_EXPORT 1547IMG_EXPORT
1524PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc, 1548PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1525 IMG_HANDLE hDevCookie, 1549 IMG_HANDLE hDevCookie,
1526 IMG_HANDLE hDevMemHeap, 1550 IMG_HANDLE hDevMemHeap,
1527 IMG_UINT32 ui32NumFDs, 1551 IMG_UINT32 ui32NumFDs,
@@ -1530,10 +1554,11 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1530 IMG_UINT32 ui32ChunkCount, 1554 IMG_UINT32 ui32ChunkCount,
1531 IMG_SIZE_T *pauiOffset, 1555 IMG_SIZE_T *pauiOffset,
1532 IMG_SIZE_T *pauiSize, 1556 IMG_SIZE_T *pauiSize,
1533 IMG_SIZE_T *puiDmabufBufferSize, 1557 IMG_SIZE_T *puiIonBufferSize,
1534 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo, 1558 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo,
1535 IMG_UINT64 *pui64Stamp) 1559 IMG_UINT64 *pui64Stamp)
1536{ 1560{
1561 PVRSRV_ENV_PER_PROCESS_DATA *psPerProcEnv = PVRSRVProcessPrivateData(psPerProc);
1537 PVRSRV_DEVICE_NODE *psDeviceNode; 1562 PVRSRV_DEVICE_NODE *psDeviceNode;
1538 PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo; 1563 PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo;
1539 IMG_SYS_PHYADDR *pasSysPhysAddr; 1564 IMG_SYS_PHYADDR *pasSysPhysAddr;
@@ -1550,7 +1575,8 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1550 IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ)?IMG_FALSE:IMG_TRUE; 1575 IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ)?IMG_FALSE:IMG_TRUE;
1551 1576
1552 if ((hDevCookie == IMG_NULL) || (ui32ChunkCount == 0) 1577 if ((hDevCookie == IMG_NULL) || (ui32ChunkCount == 0)
1553 || (hDevMemHeap == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)) 1578 || (hDevMemHeap == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)
1579 || (psPerProcEnv == IMG_NULL))
1554 { 1580 {
1555 PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__)); 1581 PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__));
1556 return PVRSRV_ERROR_INVALID_PARAMS; 1582 return PVRSRV_ERROR_INVALID_PARAMS;
@@ -1584,8 +1610,9 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1584 } 1610 }
1585 OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO)); 1611 OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO));
1586 1612
1587 /* Import the DMABUF buffer into our dmabuf_client and DMA map it */ 1613 /* Import the ION buffer into our ion_client and DMA map it */
1588 eError = DmabufImportBufferAndAcquirePhysAddr(ui32NumFDs, 1614 eError = IonImportBufferAndAcquirePhysAddr(psPerProcEnv->psIONClient,
1615 ui32NumFDs,
1589 pi32BufferFDs, 1616 pi32BufferFDs,
1590 &ui32PageCount, 1617 &ui32PageCount,
1591 &pasSysPhysAddr, 1618 &pasSysPhysAddr,
@@ -1594,31 +1621,31 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1594 &hUnique); 1621 &hUnique);
1595 if (eError != PVRSRV_OK) 1622 if (eError != PVRSRV_OK)
1596 { 1623 {
1597 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get dmabuf buffer/buffer phys addr", __FUNCTION__)); 1624 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ion buffer/buffer phys addr", __FUNCTION__));
1598 goto exitFailedImport; 1625 goto exitFailedImport;
1599 } 1626 }
1600 1627
1601 /* 1628 /*
1602 Make sure the number of pages detected by the dmabuf import are at least 1629 Make sure the number of pages detected by the ion import are at least
1603 the size of the total chunked region 1630 the size of the total chunked region
1604 */ 1631 */
1605 if(ui32PageCount * PAGE_SIZE < uiMapSize) 1632 if(ui32PageCount * PAGE_SIZE < uiMapSize)
1606 { 1633 {
1607 PVR_DPF((PVR_DBG_ERROR, "%s: dmabuf allocator returned fewer page addresses " 1634 PVR_DPF((PVR_DBG_ERROR, "%s: ion allocator returned fewer page addresses "
1608 "than specified chunk size(s)", __FUNCTION__)); 1635 "than specified chunk size(s)", __FUNCTION__));
1609 eError = PVRSRV_ERROR_INVALID_PARAMS; 1636 eError = PVRSRV_ERROR_INVALID_PARAMS;
1610 goto exitFailedAdjustedAlloc; 1637 goto exitFailedAdjustedAlloc;
1611 } 1638 }
1612 1639
1613 /* 1640 /*
1614 An Dmabuf buffer might have a number of "chunks" in it which need to be 1641 An Ion buffer might have a number of "chunks" in it which need to be
1615 mapped virtually continuous so we need to create a new array of 1642 mapped virtually continuous so we need to create a new array of
1616 addresses based on this chunk data for the actual wrap 1643 addresses based on this chunk data for the actual wrap
1617 */ 1644 */
1618 if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, 1645 if(OSAllocMem(PVRSRV_PAGEABLE_SELECT,
1619 sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()), 1646 sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()),
1620 (IMG_VOID **)&pasAdjustedSysPhysAddr, IMG_NULL, 1647 (IMG_VOID **)&pasAdjustedSysPhysAddr, IMG_NULL,
1621 "Dmabuf adjusted system address array") != PVRSRV_OK) 1648 "Ion adjusted system address array") != PVRSRV_OK)
1622 { 1649 {
1623 PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for adjusted array", __FUNCTION__)); 1650 PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for adjusted array", __FUNCTION__));
1624 goto exitFailedAdjustedAlloc; 1651 goto exitFailedAdjustedAlloc;
@@ -1644,7 +1671,7 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1644 &ui32Flags, /* This function clobbers our bits in ui32Flags */ 1671 &ui32Flags, /* This function clobbers our bits in ui32Flags */
1645 &hBuffer)) 1672 &hBuffer))
1646 { 1673 {
1647 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to wrap dmabuf buffer", __FUNCTION__)); 1674 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to wrap ion buffer", __FUNCTION__));
1648 eError = PVRSRV_ERROR_OUT_OF_MEMORY; 1675 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1649 goto exitFailedWrap; 1676 goto exitFailedWrap;
1650 } 1677 }
@@ -1660,7 +1687,7 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1660 psNewKernelMemInfo->ui32Flags = ui32Flags; 1687 psNewKernelMemInfo->ui32Flags = ui32Flags;
1661 psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; 1688 psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr;
1662 psNewKernelMemInfo->uAllocSize = uiMapSize; 1689 psNewKernelMemInfo->uAllocSize = uiMapSize;
1663 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_DMABUF; 1690 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION;
1664 PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo); 1691 PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo);
1665 1692
1666 /* Clear the Backup buffer pointer as we do not have one at this point. We only allocate this as we are going up/down */ 1693 /* Clear the Backup buffer pointer as we do not have one at this point. We only allocate this as we are going up/down */
@@ -1672,63 +1699,67 @@ PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1672 } 1699 }
1673 else 1700 else
1674 { 1701 {
1675 PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo; 1702 PVRSRV_ION_SYNC_INFO *psIonSyncInfo;
1676 BM_HEAP *psBMHeap; 1703 BM_HEAP *psBMHeap;
1677 IMG_HANDLE hDevMemContext; 1704 IMG_HANDLE hDevMemContext;
1678 1705
1679 psBMHeap = (BM_HEAP*)hDevMemHeap; 1706 psBMHeap = (BM_HEAP*)hDevMemHeap;
1680 hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; 1707 hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext;
1681 1708
1682 eError = PVRSRVExternalBufferSyncInfoIncRef(hUnique, 1709 eError = PVRSRVIonBufferSyncInfoIncRef(hUnique,
1683 hDevCookie, 1710 hDevCookie,
1684 hDevMemContext, 1711 hDevMemContext,
1685 &psExternalSyncInfo, 1712 &psIonSyncInfo,
1686 psNewKernelMemInfo); 1713 psNewKernelMemInfo);
1687 if(eError != PVRSRV_OK) 1714 if(eError != PVRSRV_OK)
1688 { 1715 {
1689 goto exitFailedSync; 1716 goto exitFailedSync;
1690 } 1717 }
1691 psNewKernelMemInfo->hExternalSyncInfo = psExternalSyncInfo; 1718 psNewKernelMemInfo->hIonSyncInfo = psIonSyncInfo;
1692 psNewKernelMemInfo->psKernelSyncInfo = ExternalBufferSyncGetKernelSyncInfo(psExternalSyncInfo); 1719 psNewKernelMemInfo->psKernelSyncInfo = IonBufferSyncGetKernelSyncInfo(psIonSyncInfo);
1693 *pui64Stamp = ExternalBufferSyncGetStamp(psExternalSyncInfo); 1720 *pui64Stamp = IonBufferSyncGetStamp(psIonSyncInfo);
1694 } 1721 }
1695 1722
1696 /* register with the resman */ 1723 /* register with the resman */
1697 psNewKernelMemInfo->sMemBlk.hResItem = ResManRegisterRes(psPerProc->hResManContext, 1724 psNewKernelMemInfo->sMemBlk.hResItem = ResManRegisterRes(psPerProc->hResManContext,
1698 RESMAN_TYPE_DEVICEMEM_DMABUF, 1725 RESMAN_TYPE_DEVICEMEM_ION,
1699 psNewKernelMemInfo, 1726 psNewKernelMemInfo,
1700 0, 1727 0,
1701 &DmabufUnmapCallback); 1728 &IonUnmapCallback);
1702 if (psNewKernelMemInfo->sMemBlk.hResItem == IMG_NULL) 1729 if (psNewKernelMemInfo->sMemBlk.hResItem == IMG_NULL)
1703 { 1730 {
1704 eError = PVRSRV_ERROR_OUT_OF_MEMORY; 1731 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1705 goto exitFailedResman; 1732 goto exitFailedResman;
1706 } 1733 }
1707 1734
1708 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_DMABUF; 1735 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION;
1709 1736
1710 /* 1737 /*
1711 As the user doesn't tell us the size, just the "chunk" information 1738 As the user doesn't tell us the size, just the "chunk" information
1712 return actual size of the Dmabuf buffer so we can mmap it. 1739 return actual size of the Ion buffer so we can mmap it.
1713 */ 1740 */
1714 *puiDmabufBufferSize = ui32PageCount * HOST_PAGESIZE(); 1741 *puiIonBufferSize = ui32PageCount * HOST_PAGESIZE();
1715 *ppsKernelMemInfo = psNewKernelMemInfo; 1742 *ppsKernelMemInfo = psNewKernelMemInfo;
1716 return PVRSRV_OK; 1743 return PVRSRV_OK;
1717 1744
1718exitFailedResman: 1745exitFailedResman:
1719 if (psNewKernelMemInfo->psKernelSyncInfo) 1746 if (psNewKernelMemInfo->psKernelSyncInfo)
1720 { 1747 {
1721 PVRSRVExternalBufferSyncInfoDecRef(psNewKernelMemInfo->hExternalSyncInfo, psNewKernelMemInfo); 1748 PVRSRVIonBufferSyncInfoDecRef(psNewKernelMemInfo->hIonSyncInfo, psNewKernelMemInfo);
1722 } 1749 }
1723exitFailedSync: 1750exitFailedSync:
1724 BM_Free(hBuffer, ui32Flags); 1751 BM_Free(hBuffer, ui32Flags
1752 #if defined (PVRSRV_DEVMEM_TIME_STATS)
1753 , IMG_NULL
1754 #endif
1755 );
1725exitFailedWrap: 1756exitFailedWrap:
1726 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 1757 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1727 sizeof(IMG_SYS_PHYADDR) * uiAdjustOffset, 1758 sizeof(IMG_SYS_PHYADDR) * uiAdjustOffset,
1728 pasAdjustedSysPhysAddr, 1759 pasAdjustedSysPhysAddr,
1729 IMG_NULL); 1760 IMG_NULL);
1730exitFailedAdjustedAlloc: 1761exitFailedAdjustedAlloc:
1731 DmabufUnimportBufferAndReleasePhysAddr(hPriv); 1762 IonUnimportBufferAndReleasePhysAddr(hPriv);
1732exitFailedImport: 1763exitFailedImport:
1733 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 1764 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1734 sizeof(PVRSRV_KERNEL_MEM_INFO), 1765 sizeof(PVRSRV_KERNEL_MEM_INFO),
@@ -1741,11 +1772,11 @@ exitFailedImport:
1741/*! 1772/*!
1742****************************************************************************** 1773******************************************************************************
1743 1774
1744 @Function PVRSRVUnmapDmabufKM 1775 @Function PVRSRVUnmapIonHandleKM
1745 1776
1746 @Description 1777 @Description
1747 1778
1748 Frees a dmabuf buffer mapped with PVRSRVMapDmabufKM, including the mem_info structure 1779 Frees an ion buffer mapped with PVRSRVMapIonHandleKM, including the mem_info structure
1749 1780
1750 @Input psMemInfo : 1781 @Input psMemInfo :
1751 1782
@@ -1753,7 +1784,7 @@ exitFailedImport:
1753 1784
1754******************************************************************************/ 1785******************************************************************************/
1755IMG_EXPORT 1786IMG_EXPORT
1756PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmabufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo) 1787PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapIonHandleKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
1757{ 1788{
1758 if (!psMemInfo) 1789 if (!psMemInfo)
1759 { 1790 {
@@ -1762,10 +1793,10 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmabufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
1762 1793
1763 return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); 1794 return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL);
1764} 1795}
1765#endif /* SUPPORT_DRM_GEM */ 1796#endif /* SUPPORT_ION */
1766 1797
1767#if defined(SUPPORT_ION) 1798#if defined(SUPPORT_DMABUF)
1768static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, 1799static PVRSRV_ERROR DmaBufUnmapCallback(IMG_PVOID pvParam,
1769 IMG_UINT32 ui32Param, 1800 IMG_UINT32 ui32Param,
1770 IMG_BOOL bDummy) 1801 IMG_BOOL bDummy)
1771{ 1802{
@@ -1776,91 +1807,168 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam,
1776 return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR); 1807 return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR);
1777} 1808}
1778 1809
1810PVRSRV_ERROR PVRSRVDmaBufSyncAcquire(IMG_HANDLE hUnique,
1811 IMG_HANDLE hPriv,
1812 IMG_HANDLE hDevCookie,
1813 IMG_HANDLE hDevMemContext,
1814 PVRSRV_DMABUF_SYNC_INFO **ppsDmaBufSyncInfo)
1815{
1816 PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo;
1817 PVRSRV_ERROR eError;
1818 IMG_BOOL bRet;
1819
1820 /*
1821 * If the import has a unique handle, check the hash to see if we
1822 * already have a sync for the buffer.
1823 */
1824 psDmaBufSyncInfo = hUnique ? (PVRSRV_DMABUF_SYNC_INFO *) HASH_Retrieve(g_psDmaBufSyncHash, (IMG_UINTPTR_T)hUnique) : NULL;
1825 if (!psDmaBufSyncInfo)
1826 {
1827 /* Create the syncinfo for the import */
1828 eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT,
1829 sizeof(PVRSRV_DMABUF_SYNC_INFO),
1830 (IMG_VOID **)&psDmaBufSyncInfo, IMG_NULL,
1831 "DMA-BUF Synchronization Info");
1832 if (eError != PVRSRV_OK)
1833 {
1834 goto ErrorAllocDmaBufSyncInfo;
1835 }
1836
1837 eError = PVRSRVAllocSyncInfoKM(hDevCookie,
1838 hDevMemContext,
1839 &psDmaBufSyncInfo->psSyncInfo);
1840 if (eError != PVRSRV_OK)
1841 {
1842 goto ErrorAllocSyncInfo;
1843 }
1844#if defined(SUPPORT_MEMINFO_IDS)
1845 psDmaBufSyncInfo->ui64Stamp = ++g_ui64MemInfoID;
1846#else
1847 psDmaBufSyncInfo->ui64Stamp = 0;
1848#endif
1849 psDmaBufSyncInfo->ui32RefCount = 0;
1850 psDmaBufSyncInfo->hUnique = hUnique;
1851
1852 psDmaBufSyncInfo->psSyncInfo->hFenceContext = PVRLinuxFenceContextCreate(psDmaBufSyncInfo->psSyncInfo, hPriv);
1853 if (!psDmaBufSyncInfo->psSyncInfo->hFenceContext)
1854 {
1855 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1856 goto ErrorCreateFenceContext;
1857 }
1858
1859 if (hUnique)
1860 {
1861 bRet = HASH_Insert(g_psDmaBufSyncHash, (IMG_UINTPTR_T)hUnique, (IMG_UINTPTR_T) psDmaBufSyncInfo);
1862 if (!bRet)
1863 {
1864 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1865 goto ErrorHashInsert;
1866 }
1867 }
1868 }
1869
1870 psDmaBufSyncInfo->ui32RefCount++;
1871 *ppsDmaBufSyncInfo = psDmaBufSyncInfo;
1872 return PVRSRV_OK;
1873
1874ErrorHashInsert:
1875 PVRLinuxFenceContextDestroy(psDmaBufSyncInfo->psSyncInfo->hFenceContext);
1876ErrorCreateFenceContext:
1877 PVRSRVKernelSyncInfoDecRef(psDmaBufSyncInfo->psSyncInfo, IMG_NULL);
1878ErrorAllocSyncInfo:
1879 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1880 sizeof(PVRSRV_DMABUF_SYNC_INFO),
1881 psDmaBufSyncInfo,
1882 IMG_NULL);
1883ErrorAllocDmaBufSyncInfo:
1884 return eError;
1885}
1886
1887IMG_VOID PVRSRVDmaBufSyncRelease(PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo)
1888{
1889 psDmaBufSyncInfo->ui32RefCount--;
1890
1891 if (psDmaBufSyncInfo->ui32RefCount == 0)
1892 {
1893 /*
1894 If we're holding the last reference to the syncinfo
1895 then free it
1896 */
1897 if (psDmaBufSyncInfo->hUnique)
1898 {
1899 PVRSRV_DMABUF_SYNC_INFO *psLookup = (PVRSRV_DMABUF_SYNC_INFO *) HASH_Remove(g_psDmaBufSyncHash, (IMG_UINTPTR_T) psDmaBufSyncInfo->hUnique);
1900 (void)psLookup;
1901 PVR_ASSERT(psLookup == psDmaBufSyncInfo);
1902 }
1903 PVRLinuxFenceContextDestroy(psDmaBufSyncInfo->psSyncInfo->hFenceContext);
1904 PVRSRVKernelSyncInfoDecRef(psDmaBufSyncInfo->psSyncInfo, IMG_NULL);
1905 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
1906 sizeof(PVRSRV_DMABUF_SYNC_INFO),
1907 psDmaBufSyncInfo,
1908 IMG_NULL);
1909 }
1910}
1911
1779/*! 1912/*!
1780****************************************************************************** 1913******************************************************************************
1781 1914
1782 @Function PVRSRVMapIonHandleKM 1915 @Function PVRSRVMapDmaBufKM
1783 1916
1784 @Description 1917 @Description
1785 1918
1786 Map an ION buffer into the specified device memory context 1919 Map a dma_buf into the specified device memory context
1787 1920
1788 @Input psPerProc : PerProcess data 1921 @Input psPerProc : PerProcess data.
1789 @Input hDevCookie : Device node cookie 1922 @Input hDevCookie : Device node cookie.
1790 @Input hDevMemHeap : Heap ion handles are mapped into 1923 @Input hDevMemHeap : Heap the buffers are mapped into.
1791 @Input ui32NumBuffers : Number of ion handles to map. (If one handle is being 1924 @Input ui32NumFDs : Number of DMA Buf FDs.
1792 mapped, this should be 1, not 0.) 1925 @Input pi32DmaBufFD : Array of DMA Buf FDs.
1793 @Input phIon : Array of ui32NumBuffers ion handles (fds) 1926 @Input puiDmaBufOffset : Array of offsets into each DMA Buf.
1794 @Input ui32Flags : Mapping flags 1927 @Input puiSize : Array of sizes of each DMA Buf chunk.
1795 @Input ui32ChunkCount : If ui32NumBuffers is 1, this is the number of 1928 @Input ui32Flags : Mapping flags.
1796 "chunks" specified to be mapped into device-virtual 1929 @Input puiDmaBufSize : Size in bytes of resulting device-virtual mapping.
1797 address space. If ui32NumBuffers > 1, it is ignored. 1930 @Output ppsKernelMemInfo: Output kernel meminfo if successful.
1798 @Input pauiOffset : Array of offsets in device-virtual address space to map 1931 @Output puiMemInfoOffset : Array of offsets of each chunk in the meminfo.
1799 "chunks" of physical from the ion allocation.
1800 @Input pauiSize : Array of sizes in bytes of device-virtual address space to
1801 map "chunks" of physical from the ion allocation.
1802 @Input puiIonBufferSize : Size in bytes of resulting device-virtual mapping.
1803 @Output ppsKernelMemInfo: Output kernel meminfo if successful
1804 1932
1805 @Return PVRSRV_ERROR : 1933 @Return PVRSRV_ERROR :
1806 1934
1807******************************************************************************/ 1935******************************************************************************/
1808IMG_EXPORT 1936IMG_EXPORT
1809PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, 1937PVRSRV_ERROR PVRSRVMapDmaBufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1810 IMG_HANDLE hDevCookie, 1938 IMG_HANDLE hDevCookie,
1811 IMG_HANDLE hDevMemHeap, 1939 IMG_HANDLE hDevMemHeap,
1812 IMG_UINT32 ui32NumFDs,
1813 IMG_INT32 *pi32BufferFDs,
1814 IMG_UINT32 ui32Flags, 1940 IMG_UINT32 ui32Flags,
1815 IMG_UINT32 ui32ChunkCount, 1941 IMG_UINT32 ui32NumFDs,
1816 IMG_SIZE_T *pauiOffset, 1942 IMG_INT32 *pi32DmaBufFD,
1817 IMG_SIZE_T *pauiSize, 1943 IMG_SIZE_T *puiDmaBufOffset,
1818 IMG_SIZE_T *puiIonBufferSize, 1944 IMG_SIZE_T *puiDmaBufSize,
1819 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo, 1945 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo,
1946 IMG_SIZE_T *puiSize,
1947 IMG_SIZE_T *puiMemInfoOffset,
1820 IMG_UINT64 *pui64Stamp) 1948 IMG_UINT64 *pui64Stamp)
1821{ 1949{
1822 PVRSRV_ENV_PER_PROCESS_DATA *psPerProcEnv = PVRSRVProcessPrivateData(psPerProc);
1823 PVRSRV_DEVICE_NODE *psDeviceNode; 1950 PVRSRV_DEVICE_NODE *psDeviceNode;
1824 PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo; 1951 PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo;
1825 IMG_SYS_PHYADDR *pasSysPhysAddr; 1952 IMG_SYS_PHYADDR *pasSysPhysAddr;
1826 IMG_SYS_PHYADDR *pasAdjustedSysPhysAddr;
1827 PVRSRV_MEMBLK *psMemBlock; 1953 PVRSRV_MEMBLK *psMemBlock;
1828 PVRSRV_ERROR eError; 1954 PVRSRV_ERROR eError;
1829 IMG_HANDLE hPriv; 1955 IMG_HANDLE hPriv;
1830 IMG_HANDLE hUnique; 1956 IMG_HANDLE hUnique;
1831 BM_HANDLE hBuffer; 1957 BM_HANDLE hBuffer;
1832 IMG_SIZE_T uiMapSize = 0; 1958 IMG_SIZE_T uiMapSize = 0;
1833 IMG_SIZE_T uiAdjustOffset = 0;
1834 IMG_UINT32 ui32PageCount; 1959 IMG_UINT32 ui32PageCount;
1835 IMG_UINT32 i; 1960 IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ) ? IMG_FALSE : IMG_TRUE;
1836 IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ)?IMG_FALSE:IMG_TRUE;
1837 1961
1838 if ((hDevCookie == IMG_NULL) || (ui32ChunkCount == 0) 1962 if ((hDevCookie == IMG_NULL) || (hDevMemHeap == IMG_NULL)
1839 || (hDevMemHeap == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)) 1963 || (ppsKernelMemInfo == IMG_NULL))
1840 { 1964 {
1841 PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__)); 1965 PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__));
1842 return PVRSRV_ERROR_INVALID_PARAMS; 1966 return PVRSRV_ERROR_INVALID_PARAMS;
1843 } 1967 }
1844 1968
1845 for (i=0;i<ui32ChunkCount;i++)
1846 {
1847 if ((pauiOffset[i] & HOST_PAGEMASK) != 0)
1848 {
1849 PVR_DPF((PVR_DBG_ERROR,"%s: Chunk offset is not page aligned", __FUNCTION__));
1850 return PVRSRV_ERROR_INVALID_PARAMS;
1851 }
1852
1853 if ((pauiSize[i] & HOST_PAGEMASK) != 0)
1854 {
1855 PVR_DPF((PVR_DBG_ERROR,"%s: Chunk size is not page aligned", __FUNCTION__));
1856 return PVRSRV_ERROR_INVALID_PARAMS;
1857 }
1858 uiMapSize += pauiSize[i];
1859 }
1860
1861 psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie; 1969 psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie;
1862 1970
1863 if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, 1971 if (OSAllocMem(PVRSRV_PAGEABLE_SELECT,
1864 sizeof(PVRSRV_KERNEL_MEM_INFO), 1972 sizeof(PVRSRV_KERNEL_MEM_INFO),
1865 (IMG_VOID **)&psNewKernelMemInfo, IMG_NULL, 1973 (IMG_VOID **)&psNewKernelMemInfo, IMG_NULL,
1866 "Kernel Memory Info") != PVRSRV_OK) 1974 "Kernel Memory Info") != PVRSRV_OK)
@@ -1870,68 +1978,36 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1870 } 1978 }
1871 OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO)); 1979 OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO));
1872 1980
1873 /* Import the ION buffer into our ion_client and DMA map it */ 1981 /* Import the DMA Buffer */
1874 eError = IonImportBufferAndAcquirePhysAddr(psPerProcEnv->psIONClient, 1982 eError = DmaBufImportAndAcquirePhysAddr(ui32NumFDs,
1875 ui32NumFDs, 1983 pi32DmaBufFD,
1876 pi32BufferFDs, 1984 puiDmaBufOffset,
1985 puiDmaBufSize,
1877 &ui32PageCount, 1986 &ui32PageCount,
1878 &pasSysPhysAddr, 1987 &pasSysPhysAddr,
1988 puiMemInfoOffset,
1879 &psNewKernelMemInfo->pvLinAddrKM, 1989 &psNewKernelMemInfo->pvLinAddrKM,
1880 &hPriv, 1990 &hPriv,
1881 &hUnique); 1991 &hUnique);
1882 if (eError != PVRSRV_OK) 1992 if (eError != PVRSRV_OK)
1883 { 1993 {
1884 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ion buffer/buffer phys addr", __FUNCTION__)); 1994 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get dma-buf phys addr", __FUNCTION__));
1885 goto exitFailedImport; 1995 goto exitFailedImport;
1886 } 1996 }
1887 1997
1888 /* 1998 uiMapSize = ui32PageCount * HOST_PAGESIZE();
1889 Make sure the number of pages detected by the ion import are at least
1890 the size of the total chunked region
1891 */
1892 if(ui32PageCount * PAGE_SIZE < uiMapSize)
1893 {
1894 PVR_DPF((PVR_DBG_ERROR, "%s: ion allocator returned fewer page addresses "
1895 "than specified chunk size(s)", __FUNCTION__));
1896 eError = PVRSRV_ERROR_INVALID_PARAMS;
1897 goto exitFailedAdjustedAlloc;
1898 }
1899
1900 /*
1901 An Ion buffer might have a number of "chunks" in it which need to be
1902 mapped virtually continuous so we need to create a new array of
1903 addresses based on this chunk data for the actual wrap
1904 */
1905 if(OSAllocMem(PVRSRV_PAGEABLE_SELECT,
1906 sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()),
1907 (IMG_VOID **)&pasAdjustedSysPhysAddr, IMG_NULL,
1908 "Ion adjusted system address array") != PVRSRV_OK)
1909 {
1910 PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for adjusted array", __FUNCTION__));
1911 goto exitFailedAdjustedAlloc;
1912 }
1913 OSMemSet(pasAdjustedSysPhysAddr, 0, sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()));
1914
1915 for (i=0;i<ui32ChunkCount;i++)
1916 {
1917 OSMemCopy(&pasAdjustedSysPhysAddr[uiAdjustOffset],
1918 &pasSysPhysAddr[pauiOffset[i]/HOST_PAGESIZE()],
1919 (pauiSize[i]/HOST_PAGESIZE()) * sizeof(IMG_SYS_PHYADDR));
1920
1921 uiAdjustOffset += pauiSize[i]/HOST_PAGESIZE();
1922 }
1923 1999
1924 /* Wrap the returned addresses into our memory context */ 2000 /* Wrap the returned addresses into our memory context */
1925 if (!BM_Wrap(hDevMemHeap, 2001 if (!BM_Wrap(hDevMemHeap,
1926 uiMapSize, 2002 uiMapSize,
1927 0, 2003 0,
1928 IMG_FALSE, 2004 IMG_FALSE,
1929 pasAdjustedSysPhysAddr, 2005 pasSysPhysAddr,
1930 IMG_NULL, 2006 IMG_NULL,
1931 &ui32Flags, /* This function clobbers our bits in ui32Flags */ 2007 &ui32Flags, /* This function clobbers our bits in ui32Flags */
1932 &hBuffer)) 2008 &hBuffer))
1933 { 2009 {
1934 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to wrap ion buffer", __FUNCTION__)); 2010 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to wrap dma-buf", __FUNCTION__));
1935 eError = PVRSRV_ERROR_OUT_OF_MEMORY; 2011 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1936 goto exitFailedWrap; 2012 goto exitFailedWrap;
1937 } 2013 }
@@ -1942,80 +2018,75 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
1942 psMemBlock->hOSMemHandle = BM_HandleToOSMemHandle(hBuffer); 2018 psMemBlock->hOSMemHandle = BM_HandleToOSMemHandle(hBuffer);
1943 psMemBlock->hBuffer = (IMG_HANDLE) hBuffer; 2019 psMemBlock->hBuffer = (IMG_HANDLE) hBuffer;
1944 psMemBlock->hOSWrapMem = hPriv; /* Saves creating a new element as we know hOSWrapMem will not be used */ 2020 psMemBlock->hOSWrapMem = hPriv; /* Saves creating a new element as we know hOSWrapMem will not be used */
1945 psMemBlock->psIntSysPAddr = pasAdjustedSysPhysAddr; 2021 psMemBlock->psIntSysPAddr = pasSysPhysAddr;
1946 2022
1947 psNewKernelMemInfo->ui32Flags = ui32Flags; 2023 psNewKernelMemInfo->ui32Flags = ui32Flags;
1948 psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; 2024 psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr;
1949 psNewKernelMemInfo->uAllocSize = uiMapSize; 2025 psNewKernelMemInfo->uAllocSize = uiMapSize;
1950 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION; 2026 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_DMABUF;
1951 PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo); 2027 PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo);
1952 2028
1953 /* Clear the Backup buffer pointer as we do not have one at this point. We only allocate this as we are going up/down */
1954 psNewKernelMemInfo->pvSysBackupBuffer = IMG_NULL;
1955
1956 if (!bAllocSync) 2029 if (!bAllocSync)
1957 { 2030 {
1958 psNewKernelMemInfo->psKernelSyncInfo = IMG_NULL; 2031 psNewKernelMemInfo->psKernelSyncInfo = IMG_NULL;
1959 } 2032 }
1960 else 2033 else
1961 { 2034 {
1962 PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo; 2035 PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo;
1963 BM_HEAP *psBMHeap; 2036 BM_HEAP *psBMHeap;
1964 IMG_HANDLE hDevMemContext; 2037 IMG_HANDLE hDevMemContext;
1965 2038
1966 psBMHeap = (BM_HEAP*)hDevMemHeap; 2039 psBMHeap = (BM_HEAP*)hDevMemHeap;
1967 hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; 2040 hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext;
1968 2041
1969 eError = PVRSRVExternalBufferSyncInfoIncRef(hUnique, 2042 eError = PVRSRVDmaBufSyncInfoIncRef(hUnique,
2043 hPriv,
1970 hDevCookie, 2044 hDevCookie,
1971 hDevMemContext, 2045 hDevMemContext,
1972 &psExternalSyncInfo, 2046 &psDmaBufSyncInfo,
1973 psNewKernelMemInfo); 2047 psNewKernelMemInfo);
1974 if(eError != PVRSRV_OK) 2048 if(eError != PVRSRV_OK)
1975 { 2049 {
1976 goto exitFailedSync; 2050 goto exitFailedSync;
1977 } 2051 }
1978 psNewKernelMemInfo->hExternalSyncInfo = psExternalSyncInfo; 2052 psNewKernelMemInfo->hDmaBufSyncInfo = psDmaBufSyncInfo;
1979 psNewKernelMemInfo->psKernelSyncInfo = ExternalBufferSyncGetKernelSyncInfo(psExternalSyncInfo); 2053 psNewKernelMemInfo->psKernelSyncInfo = psDmaBufSyncInfo->psSyncInfo;
1980 *pui64Stamp = ExternalBufferSyncGetStamp(psExternalSyncInfo); 2054 *pui64Stamp = DmaBufSyncGetStamp(psDmaBufSyncInfo);
1981 } 2055 }
1982 2056
1983 /* register with the resman */ 2057 /* register with the resman */
1984 psNewKernelMemInfo->sMemBlk.hResItem = ResManRegisterRes(psPerProc->hResManContext, 2058 psNewKernelMemInfo->sMemBlk.hResItem = ResManRegisterRes(psPerProc->hResManContext,
1985 RESMAN_TYPE_DEVICEMEM_ION, 2059 RESMAN_TYPE_DEVICEMEM_DMABUF,
1986 psNewKernelMemInfo, 2060 psNewKernelMemInfo,
1987 0, 2061 0,
1988 &IonUnmapCallback); 2062 &DmaBufUnmapCallback);
1989 if (psNewKernelMemInfo->sMemBlk.hResItem == IMG_NULL) 2063 if (psNewKernelMemInfo->sMemBlk.hResItem == IMG_NULL)
1990 { 2064 {
1991 eError = PVRSRV_ERROR_OUT_OF_MEMORY; 2065 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1992 goto exitFailedResman; 2066 goto exitFailedResman;
1993 } 2067 }
1994 2068
1995 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION; 2069 psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_DMABUF;
1996 2070
1997 /* 2071 /* Return actual size of the imported memory so we can mmap it */
1998 As the user doesn't tell us the size, just the "chunk" information 2072 *puiSize = uiMapSize;
1999 return actual size of the Ion buffer so we can mmap it.
2000 */
2001 *puiIonBufferSize = ui32PageCount * HOST_PAGESIZE();
2002 *ppsKernelMemInfo = psNewKernelMemInfo; 2073 *ppsKernelMemInfo = psNewKernelMemInfo;
2003 return PVRSRV_OK; 2074 return PVRSRV_OK;
2004 2075
2005exitFailedResman: 2076exitFailedResman:
2006 if (psNewKernelMemInfo->psKernelSyncInfo) 2077 if (psNewKernelMemInfo->psKernelSyncInfo)
2007 { 2078 {
2008 PVRSRVExternalBufferSyncInfoDecRef(psNewKernelMemInfo->hExternalSyncInfo, psNewKernelMemInfo); 2079 PVRSRVDmaBufSyncInfoDecRef(psNewKernelMemInfo->hDmaBufSyncInfo, psNewKernelMemInfo);
2009 } 2080 }
2010exitFailedSync: 2081exitFailedSync:
2011 BM_Free(hBuffer, ui32Flags); 2082 BM_Free(hBuffer, ui32Flags
2083 #if defined (PVRSRV_DEVMEM_TIME_STATS)
2084 , IMG_NULL
2085 #endif
2086 );
2087
2012exitFailedWrap: 2088exitFailedWrap:
2013 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 2089 DmaBufUnimportAndReleasePhysAddr(hPriv);
2014 sizeof(IMG_SYS_PHYADDR) * uiAdjustOffset,
2015 pasAdjustedSysPhysAddr,
2016 IMG_NULL);
2017exitFailedAdjustedAlloc:
2018 IonUnimportBufferAndReleasePhysAddr(hPriv);
2019exitFailedImport: 2090exitFailedImport:
2020 OSFreeMem(PVRSRV_PAGEABLE_SELECT, 2091 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
2021 sizeof(PVRSRV_KERNEL_MEM_INFO), 2092 sizeof(PVRSRV_KERNEL_MEM_INFO),
@@ -2028,11 +2099,11 @@ exitFailedImport:
2028/*! 2099/*!
2029****************************************************************************** 2100******************************************************************************
2030 2101
2031 @Function PVRSRVUnmapIonHandleKM 2102 @Function PVRSRVUnmapDmaBufKM
2032 2103
2033 @Description 2104 @Description
2034 2105
2035 Frees an ion buffer mapped with PVRSRVMapIonHandleKM, including the mem_info structure 2106 Releases a dma_buf mapped with PVRSRVMapDmaBufKM, including the mem_info structure
2036 2107
2037 @Input psMemInfo : 2108 @Input psMemInfo :
2038 2109
@@ -2040,7 +2111,7 @@ exitFailedImport:
2040 2111
2041******************************************************************************/ 2112******************************************************************************/
2042IMG_EXPORT 2113IMG_EXPORT
2043PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapIonHandleKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo) 2114PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmaBufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
2044{ 2115{
2045 if (!psMemInfo) 2116 if (!psMemInfo)
2046 { 2117 {
@@ -2049,7 +2120,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapIonHandleKM(PVRSRV_KERNEL_MEM_INFO *psMemIn
2049 2120
2050 return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); 2121 return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL);
2051} 2122}
2052#endif /* SUPPORT_ION */ 2123#endif /* SUPPORT_DMABUF */
2053 2124
2054/*! 2125/*!
2055****************************************************************************** 2126******************************************************************************
@@ -2294,7 +2365,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie,
2294 } 2365 }
2295 else 2366 else
2296 { 2367 {
2297 PVR_DPF((PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter, no address specificed")); 2368 PVR_DPF((PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter, no address specified"));
2298 } 2369 }
2299 return PVRSRV_ERROR_INVALID_PARAMS; 2370 return PVRSRV_ERROR_INVALID_PARAMS;
2300 } 2371 }
@@ -2404,7 +2475,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie,
2404 &psMemInfo->psKernelSyncInfo); 2475 &psMemInfo->psKernelSyncInfo);
2405 if(eError != PVRSRV_OK) 2476 if(eError != PVRSRV_OK)
2406 { 2477 {
2407 goto ErrorExitPhase4; 2478 FreeDeviceMem(psMemInfo);
2479 /* FreeDeviceMem will free the meminfo so jump straight to ErrorExitPhase2 */
2480 goto ErrorExitPhase2;
2408 } 2481 }
2409 2482
2410 /* increment the refcount */ 2483 /* increment the refcount */
@@ -2447,27 +2520,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie,
2447 return PVRSRV_OK; 2520 return PVRSRV_OK;
2448 2521
2449 /* error handling: */ 2522 /* error handling: */
2450
2451ErrorExitPhase4:
2452 if(psMemInfo)
2453 {
2454 FreeDeviceMem(psMemInfo);
2455 /*
2456 FreeDeviceMem will free the meminfo so set
2457 it to NULL to avoid double free below
2458 */
2459 psMemInfo = IMG_NULL;
2460 }
2461
2462ErrorExitPhase3: 2523ErrorExitPhase3:
2463 if(psMemInfo) 2524 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_MEM_INFO), psMemInfo, IMG_NULL);
2464 { 2525 /*not nulling pointer, out of scope*/
2465 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_MEM_INFO), psMemInfo, IMG_NULL);
2466 /*not nulling pointer, out of scope*/
2467 }
2468 2526
2469ErrorExitPhase2: 2527ErrorExitPhase2:
2470 if(psIntSysPAddr) 2528 if(hOSWrapMem)
2471 { 2529 {
2472 OSReleasePhysPageAddr(hOSWrapMem); 2530 OSReleasePhysPageAddr(hOSWrapMem);
2473 } 2531 }
@@ -3116,7 +3174,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA *
3116 if (eError != PVRSRV_OK) 3174 if (eError != PVRSRV_OK)
3117 { 3175 {
3118 PVR_DPF((PVR_DBG_ERROR,"PVRSRVMapDeviceClassMemoryKM: AllocMemTilingRange failed")); 3176 PVR_DPF((PVR_DBG_ERROR,"PVRSRVMapDeviceClassMemoryKM: AllocMemTilingRange failed"));
3119 goto ErrorExitPhase3; 3177
3178 if (psMemInfo->psKernelSyncInfo)
3179 {
3180 PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo);
3181 }
3182 FreeDeviceMem(psMemInfo);
3183
3184 /* FreeDeviceMem will free the meminfo so jump straight to the final exit */
3185 goto ErrorExitPhase1;
3120 } 3186 }
3121 } 3187 }
3122#endif 3188#endif
@@ -3178,36 +3244,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA *
3178#endif 3244#endif
3179 return PVRSRV_OK; 3245 return PVRSRV_OK;
3180 3246
3181#if defined(SUPPORT_MEMORY_TILING)
3182ErrorExitPhase3:
3183 if(psMemInfo)
3184 {
3185 if (psMemInfo->psKernelSyncInfo)
3186 {
3187 PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo);
3188 }
3189
3190 FreeDeviceMem(psMemInfo);
3191 /*
3192 FreeDeviceMem will free the meminfo so set
3193 it to NULL to avoid double free below
3194 */
3195 psMemInfo = IMG_NULL;
3196 }
3197#endif
3198
3199ErrorExitPhase2: 3247ErrorExitPhase2:
3200 if(psMemInfo) 3248 OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), psMemInfo, IMG_NULL);
3201 {
3202 OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), psMemInfo, IMG_NULL);
3203 }
3204 3249
3205ErrorExitPhase1: 3250ErrorExitPhase1:
3206 if(psDCMapInfo) 3251 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DC_MAPINFO), psDCMapInfo, IMG_NULL);
3207 {
3208 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_MEM_INFO), psDCMapInfo, IMG_NULL);
3209 }
3210
3211 return eError; 3252 return eError;
3212} 3253}
3213 3254
@@ -3241,27 +3282,53 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInitDeviceMem(IMG_VOID)
3241{ 3282{
3242 PVRSRV_ERROR eError = PVRSRV_OK; 3283 PVRSRV_ERROR eError = PVRSRV_OK;
3243 3284
3244#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM) 3285#if defined(SUPPORT_ION)
3245 /* 3286 /*
3246 For Ion and GEM buffers we need to store which ones we know about so 3287 For Ion buffers we need to store which ones we know about so
3247 we don't give the same buffer a different sync 3288 we don't give the same buffer a different sync
3248 */ 3289 */
3249 PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitDeviceMem: Creating external hash")); 3290 g_psIonSyncHash = HASH_Create(ION_SYNC_HASH_SIZE);
3250 g_psExternalSyncHash = HASH_Create(EXTERNAL_SYNC_HASH_SIZE); 3291 if (!g_psIonSyncHash)
3251 if (g_psExternalSyncHash == IMG_NULL) 3292 {
3293 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
3294 goto Error;
3295 }
3296#endif
3297#if defined(SUPPORT_DMABUF)
3298 g_psDmaBufSyncHash = HASH_Create(DMABUF_SYNC_HASH_SIZE);
3299 if (!g_psDmaBufSyncHash)
3252 { 3300 {
3253 PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitDeviceMem: Creating external hash failed"));
3254 eError = PVRSRV_ERROR_OUT_OF_MEMORY; 3301 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
3302 goto Error;
3255 } 3303 }
3256#endif 3304#endif
3257 3305
3306#if defined(SUPPORT_ION) || defined(SUPPORT_DMABUF)
3307 return PVRSRV_OK;
3308Error:
3309#endif
3310#if defined(SUPPORT_DMABUF)
3311 if (g_psDmaBufSyncHash)
3312 {
3313 HASH_Delete(g_psDmaBufSyncHash);
3314 }
3315#endif
3316#if defined(SUPPORT_ION)
3317 if (g_psIonSyncHash)
3318 {
3319 HASH_Delete(g_psIonSyncHash);
3320 }
3321#endif
3258 return eError; 3322 return eError;
3259} 3323}
3260 3324
3261IMG_VOID IMG_CALLCONV PVRSRVDeInitDeviceMem(IMG_VOID) 3325IMG_VOID IMG_CALLCONV PVRSRVDeInitDeviceMem(IMG_VOID)
3262{ 3326{
3263#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM) 3327#if defined(SUPPORT_DMABUF)
3264 HASH_Delete(g_psExternalSyncHash); 3328 HASH_Delete(g_psDmaBufSyncHash);
3329#endif
3330#if defined(SUPPORT_ION)
3331 HASH_Delete(g_psIonSyncHash);
3265#endif 3332#endif
3266} 3333}
3267 3334
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/handle.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/handle.c
index b9facfd..b1ac749 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/handle.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/handle.c
@@ -48,7 +48,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48 * threaded environment. In particular, it is assumed that the code will 48 * threaded environment. In particular, it is assumed that the code will
49 * never be called from an interrupt handler. 49 * never be called from an interrupt handler.
50 * 50 *
51 * The implmentation supports movable handle structures, allowing the address 51 * The implementation supports movable handle structures, allowing the address
52 * of a handle structure to change without having to fix up pointers in 52 * of a handle structure to change without having to fix up pointers in
53 * any of the handle structures. For example, the linked list mechanism 53 * any of the handle structures. For example, the linked list mechanism
54 * used to link subhandles together uses handle array indices rather than 54 * used to link subhandles together uses handle array indices rather than
@@ -1137,7 +1137,7 @@ static PVRSRV_ERROR FreeHandle(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psHan
1137 else 1137 else
1138 { 1138 {
1139 /* 1139 /*
1140 * Put the handle pointer on the end of the the free 1140 * Put the handle pointer on the end of the free
1141 * handle pointer linked list. 1141 * handle pointer linked list.
1142 */ 1142 */
1143 PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne != 0); 1143 PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne != 0);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/hash.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/hash.c
index 72432fd..8dcedf9 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/hash.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/hash.c
@@ -285,6 +285,7 @@ _Resize (HASH_TABLE *pHash, IMG_UINT32 uNewSize)
285 285
286 if (_Rehash (pHash, pHash->ppBucketTable, pHash->uSize, ppNewTable, uNewSize) != PVRSRV_OK) 286 if (_Rehash (pHash, pHash->ppBucketTable, pHash->uSize, ppNewTable, uNewSize) != PVRSRV_OK)
287 { 287 {
288 OSFreeMem (PVRSRV_PAGEABLE_SELECT, sizeof(BUCKET *) * uNewSize, ppNewTable, IMG_NULL);
288 return IMG_FALSE; 289 return IMG_FALSE;
289 } 290 }
290 291
@@ -396,7 +397,7 @@ HASH_Delete (HASH_TABLE *pHash)
396 if(pHash->uCount != 0) 397 if(pHash->uCount != 0)
397 { 398 {
398 PVR_DPF ((PVR_DBG_ERROR, "HASH_Delete: leak detected in hash table!")); 399 PVR_DPF ((PVR_DBG_ERROR, "HASH_Delete: leak detected in hash table!"));
399 PVR_DPF ((PVR_DBG_ERROR, "Likely Cause: client drivers not freeing alocations before destroying devmemcontext")); 400 PVR_DPF ((PVR_DBG_ERROR, "Likely Cause: client drivers not freeing allocations before destroying devmemcontext"));
400 } 401 }
401 OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(BUCKET *)*pHash->uSize, pHash->ppBucketTable, IMG_NULL); 402 OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(BUCKET *)*pHash->uSize, pHash->ppBucketTable, IMG_NULL);
402 pHash->ppBucketTable = IMG_NULL; 403 pHash->ppBucketTable = IMG_NULL;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pdump_common.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pdump_common.c
index efedb61..232d19c 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pdump_common.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pdump_common.c
@@ -83,10 +83,7 @@ IMG_BOOL _PDumpIsProcessActive(IMG_VOID)
83 PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); 83 PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData();
84 if(psPerProc == IMG_NULL) 84 if(psPerProc == IMG_NULL)
85 { 85 {
86 /* FIXME: kernel process logs some comments when kernel module is 86 return IMG_FALSE;
87 * loaded, want to keep those.
88 */
89 return IMG_TRUE;
90 } 87 }
91 return psPerProc->bPDumpActive; 88 return psPerProc->bPDumpActive;
92} 89}
@@ -932,6 +929,7 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
932static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, 929static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr,
933 PVRSRV_KERNEL_MEM_INFO *psMemInfo, 930 PVRSRV_KERNEL_MEM_INFO *psMemInfo,
934 IMG_UINT32 ui32Offset, 931 IMG_UINT32 ui32Offset,
932 IMG_UINT32 ui32PhyOffset,
935 IMG_UINT32 ui32Bytes, 933 IMG_UINT32 ui32Bytes,
936 IMG_UINT32 ui32Flags, 934 IMG_UINT32 ui32Flags,
937 IMG_HANDLE hUniqueTag) 935 IMG_HANDLE hUniqueTag)
@@ -1043,11 +1041,23 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr,
1043 query the buffer manager for the physical pages that back the 1041 query the buffer manager for the physical pages that back the
1044 virtual address 1042 virtual address
1045 */ 1043 */
1046 PDumpOSCPUVAddrToPhysPages(psMemInfo->sMemBlk.hOSMemHandle, 1044
1047 ui32Offset, 1045 if (psMemInfo->ui32Flags & PVRSRV_MEM_SPARSE)
1048 pui8LinAddr, 1046 {
1049 psMMUAttrib->ui32DataPageMask, 1047 PDumpOSCPUVAddrToPhysPages(psMemInfo->sMemBlk.hOSMemHandle,
1050 &ui32PageByteOffset); 1048 ui32PhyOffset,
1049 pui8LinAddr,
1050 psMMUAttrib->ui32DataPageMask,
1051 &ui32PageByteOffset);
1052 }
1053 else
1054 {
1055 PDumpOSCPUVAddrToPhysPages(psMemInfo->sMemBlk.hOSMemHandle,
1056 ui32Offset,
1057 pui8LinAddr,
1058 psMMUAttrib->ui32DataPageMask,
1059 &ui32PageByteOffset);
1060 }
1051 ui32DataPageSize = psMMUAttrib->ui32DataPageMask + 1; 1061 ui32DataPageSize = psMMUAttrib->ui32DataPageMask + 1;
1052 ui32NumPages = (ui32PageByteOffset + ui32Bytes + psMMUAttrib->ui32DataPageMask) / ui32DataPageSize; 1062 ui32NumPages = (ui32PageByteOffset + ui32Bytes + psMMUAttrib->ui32DataPageMask) / ui32DataPageSize;
1053 1063
@@ -1156,6 +1166,7 @@ PVRSRV_ERROR PDumpMemKM(IMG_PVOID pvAltLinAddr,
1156 return _PDumpMemIntKM(pvAltLinAddr, 1166 return _PDumpMemIntKM(pvAltLinAddr,
1157 psMemInfo, 1167 psMemInfo,
1158 ui32Offset, 1168 ui32Offset,
1169 0,
1159 ui32Bytes, 1170 ui32Bytes,
1160 ui32Flags, 1171 ui32Flags,
1161 hUniqueTag); 1172 hUniqueTag);
@@ -2531,13 +2542,30 @@ PVRSRV_ERROR PDumpMemUM(PVRSRV_PER_PROCESS_DATA *psPerProc,
2531 if the a page exists at that address 2542 if the a page exists at that address
2532 */ 2543 */
2533 IMG_UINT32 ui32BytesRemain = ui32Bytes; 2544 IMG_UINT32 ui32BytesRemain = ui32Bytes;
2545 IMG_UINT32 ui32BytesToCopy = 0;
2534 IMG_UINT32 ui32InPageStart = ui32Offset & (~HOST_PAGEMASK); 2546 IMG_UINT32 ui32InPageStart = ui32Offset & (~HOST_PAGEMASK);
2535 IMG_UINT32 ui32PageOffset = ui32Offset & (HOST_PAGEMASK); 2547 IMG_UINT32 ui32PageOffset = ui32Offset & (HOST_PAGEMASK);
2536 IMG_UINT32 ui32BytesToCopy = MIN(HOST_PAGESIZE() - ui32InPageStart, ui32BytesRemain); 2548 IMG_UINT32 ui32InPhyPageStart = 0;
2549
2550 if(ui32InPageStart != 0)
2551 {
2552 IMG_UINT32 ui32DummyInPageStart = 0;
2553
2554 while(ui32DummyInPageStart != ui32InPageStart)
2555 {
2556 if (BM_MapPageAtOffset(BM_MappingHandleFromBuffer(psMemInfo->sMemBlk.hBuffer), ui32DummyInPageStart))
2557 {
2558 ui32InPhyPageStart += HOST_PAGESIZE();
2559 }
2560 ui32DummyInPageStart += HOST_PAGESIZE();
2561 }
2562 }
2537 2563
2538 do 2564 do
2539 { 2565 {
2540 if (BM_MapPageAtOffset(BM_MappingHandleFromBuffer(psMemInfo->sMemBlk.hBuffer), ui32PageOffset)) 2566 ui32BytesToCopy = MIN(HOST_PAGESIZE() - ui32PageOffset, ui32BytesRemain);
2567
2568 if (BM_MapPageAtOffset(BM_MappingHandleFromBuffer(psMemInfo->sMemBlk.hBuffer), ui32InPageStart))
2541 { 2569 {
2542 eError = OSCopyFromUser(psPerProc, 2570 eError = OSCopyFromUser(psPerProc,
2543 pvAddrKM, 2571 pvAddrKM,
@@ -2556,6 +2584,7 @@ PVRSRV_ERROR PDumpMemUM(PVRSRV_PER_PROCESS_DATA *psPerProc,
2556 eError = _PDumpMemIntKM(pvAddrKM, 2584 eError = _PDumpMemIntKM(pvAddrKM,
2557 psMemInfo, 2585 psMemInfo,
2558 ui32PageOffset + ui32InPageStart, 2586 ui32PageOffset + ui32InPageStart,
2587 ui32PageOffset + ui32InPhyPageStart,
2559 ui32BytesToCopy, 2588 ui32BytesToCopy,
2560 ui32Flags, 2589 ui32Flags,
2561 hUniqueTag); 2590 hUniqueTag);
@@ -2573,12 +2602,14 @@ PVRSRV_ERROR PDumpMemUM(PVRSRV_PER_PROCESS_DATA *psPerProc,
2573 PVR_ASSERT(ui32BytesToCopy == 0); 2602 PVR_ASSERT(ui32BytesToCopy == 0);
2574 return eError; 2603 return eError;
2575 } 2604 }
2605 ui32InPhyPageStart += HOST_PAGESIZE();
2576 } 2606 }
2577 2607
2578 VPTR_INC(pvAddrUM, ui32BytesToCopy); 2608 VPTR_INC(pvAddrUM, ui32BytesToCopy);
2579 ui32BytesRemain -= ui32BytesToCopy; 2609 ui32BytesRemain -= ui32BytesToCopy;
2580 ui32InPageStart = 0; 2610 ui32InPageStart += HOST_PAGESIZE();
2581 ui32PageOffset += HOST_PAGESIZE(); 2611 ui32PageOffset = 0;
2612
2582 } while(ui32BytesRemain); 2613 } while(ui32BytesRemain);
2583 } 2614 }
2584 else 2615 else
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pvrsrv.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pvrsrv.c
index 1ebb95e..28cc574 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pvrsrv.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pvrsrv.c
@@ -59,7 +59,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
59#include "lists.h" 59#include "lists.h"
60 60
61IMG_UINT32 g_ui32InitFlags; 61IMG_UINT32 g_ui32InitFlags;
62IMG_UINT32 g_iDrmFd = -1;
63 62
64/* mark which parts of Services were initialised */ 63/* mark which parts of Services were initialised */
65#define INIT_DATA_ENABLE_PDUMPINIT 0x1U 64#define INIT_DATA_ENABLE_PDUMPINIT 0x1U
@@ -459,7 +458,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData)
459 g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; 458 g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT;
460#endif 459#endif
461 460
462#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM) 461#if defined(SUPPORT_ION) || defined(SUPPORT_DMABUF)
463 eError = PVRSRVInitDeviceMem(); 462 eError = PVRSRVInitDeviceMem();
464 if (eError != PVRSRV_OK) 463 if (eError != PVRSRV_OK)
465 goto Error; 464 goto Error;
@@ -503,7 +502,7 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData)
503 PERFDEINIT(); 502 PERFDEINIT();
504 503
505 504
506#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM) 505#if defined(SUPPORT_ION) || defined(SUPPORT_DMABUF)
507 if ((g_ui32InitFlags & INIT_DATA_ENABLE_DEVMEM) > 0) 506 if ((g_ui32InitFlags & INIT_DATA_ENABLE_DEVMEM) > 0)
508 { 507 {
509 PVRSRVDeInitDeviceMem(); 508 PVRSRVDeInitDeviceMem();
@@ -1016,19 +1015,24 @@ PVRSRV_ERROR IMG_CALLCONV PollForValueKM (volatile IMG_UINT32* pui32LinMemAddr,
1016 /* For the Emulator we want the system to stop when a lock-up is detected so the state can be analysed. 1015 /* For the Emulator we want the system to stop when a lock-up is detected so the state can be analysed.
1017 * Also the Emulator is much slower than real silicon so timeouts are not valid. 1016 * Also the Emulator is much slower than real silicon so timeouts are not valid.
1018 */ 1017 */
1019 do 1018 if((*pui32LinMemAddr & ui32Mask) == ui32Value)
1020 { 1019 {
1021 if((*pui32LinMemAddr & ui32Mask) == ui32Value) 1020 return PVRSRV_OK;
1022 { 1021 }
1023 return PVRSRV_OK;
1024 }
1025 1022
1023 do
1024 {
1026 #if defined(__linux__) 1025 #if defined(__linux__)
1027 OSWaitus(ui32PollPeriodus); 1026 OSWaitus(ui32PollPeriodus);
1028 #else 1027 #else
1029 OSReleaseThreadQuanta(); 1028 OSReleaseThreadQuanta();
1030 #endif 1029 #endif
1031 1030
1031 if((*pui32LinMemAddr & ui32Mask) == ui32Value)
1032 {
1033 return PVRSRV_OK;
1034 }
1035
1032 } while (ui32Timeoutus); /* Endless loop only for the Emulator */ 1036 } while (ui32Timeoutus); /* Endless loop only for the Emulator */
1033 } 1037 }
1034#else 1038#else
@@ -1040,15 +1044,15 @@ PVRSRV_ERROR IMG_CALLCONV PollForValueKM (volatile IMG_UINT32* pui32LinMemAddr,
1040 PVR_ASSERT(ui32PollPeriodus >= 1000); 1044 PVR_ASSERT(ui32PollPeriodus >= 1000);
1041 } 1045 }
1042 1046
1047 ui32ActualValue = (*pui32LinMemAddr & ui32Mask);
1048 if(ui32ActualValue == ui32Value)
1049 {
1050 return PVRSRV_OK;
1051 }
1052
1043 /* PRQA S 3415,4109 1 */ /* macro format critical - leave alone */ 1053 /* PRQA S 3415,4109 1 */ /* macro format critical - leave alone */
1044 LOOP_UNTIL_TIMEOUT(ui32Timeoutus) 1054 LOOP_UNTIL_TIMEOUT(ui32Timeoutus)
1045 { 1055 {
1046 ui32ActualValue = (*pui32LinMemAddr & ui32Mask);
1047 if(ui32ActualValue == ui32Value)
1048 {
1049 return PVRSRV_OK;
1050 }
1051
1052 if (bAllowPreemption) 1056 if (bAllowPreemption)
1053 { 1057 {
1054 OSSleepms(ui32PollPeriodus / 1000); 1058 OSSleepms(ui32PollPeriodus / 1000);
@@ -1057,6 +1061,13 @@ PVRSRV_ERROR IMG_CALLCONV PollForValueKM (volatile IMG_UINT32* pui32LinMemAddr,
1057 { 1061 {
1058 OSWaitus(ui32PollPeriodus); 1062 OSWaitus(ui32PollPeriodus);
1059 } 1063 }
1064
1065 ui32ActualValue = (*pui32LinMemAddr & ui32Mask);
1066 if(ui32ActualValue == ui32Value)
1067 {
1068 return PVRSRV_OK;
1069 }
1070
1060 } END_LOOP_UNTIL_TIMEOUT(); 1071 } END_LOOP_UNTIL_TIMEOUT();
1061 1072
1062 PVR_DPF((PVR_DBG_ERROR,"PollForValueKM: Timeout. Expected 0x%x but found 0x%x (mask 0x%x).", 1073 PVR_DPF((PVR_DBG_ERROR,"PollForValueKM: Timeout. Expected 0x%x but found 0x%x (mask 0x%x).",
@@ -1217,9 +1228,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo)
1217 |PVRSRV_MISC_INFO_FREEMEM_PRESENT 1228 |PVRSRV_MISC_INFO_FREEMEM_PRESENT
1218 |PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT 1229 |PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT
1219 |PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT 1230 |PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT
1220 |PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT 1231 |PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT))
1221 |PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT
1222 |PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT))
1223 { 1232 {
1224 PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: invalid state request flags")); 1233 PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: invalid state request flags"));
1225 return PVRSRV_ERROR_INVALID_PARAMS; 1234 return PVRSRV_ERROR_INVALID_PARAMS;
@@ -1413,12 +1422,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo)
1413 1422
1414 if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH) 1423 if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH)
1415 { 1424 {
1416 if(!OSFlushCPUCacheRangeKM(psKernelMemInfo->sMemBlk.hOSMemHandle, 1425 if(psMiscInfo->sCacheOpCtl.ui32Length!=0)
1417 0,
1418 psMiscInfo->sCacheOpCtl.pvBaseVAddr,
1419 psMiscInfo->sCacheOpCtl.ui32Length))
1420 { 1426 {
1421 return PVRSRV_ERROR_CACHEOP_FAILED; 1427 if(!OSFlushCPUCacheRangeKM(psKernelMemInfo->sMemBlk.hOSMemHandle,
1428 0,
1429 psMiscInfo->sCacheOpCtl.pvBaseVAddr,
1430 psMiscInfo->sCacheOpCtl.ui32Length))
1431 {
1432 return PVRSRV_ERROR_CACHEOP_FAILED;
1433 }
1422 } 1434 }
1423 } 1435 }
1424 else if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_CLEAN) 1436 else if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_CLEAN)
@@ -1480,18 +1492,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo)
1480 psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT; 1492 psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT;
1481 } 1493 }
1482#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ 1494#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */
1483 if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT) != 0UL)
1484 {
1485 PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: GetDrmFD: %d", g_iDrmFd));
1486 psMiscInfo->iDrmFd = g_iDrmFd;
1487 psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT;
1488 }
1489 if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT) != 0UL)
1490 {
1491 g_iDrmFd = psMiscInfo->iDrmFd;
1492 PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: SetDrmFD: %d", g_iDrmFd));
1493 psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT;
1494 }
1495 1495
1496 return PVRSRV_OK; 1496 return PVRSRV_OK;
1497} 1497}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/queue.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/queue.c
index cddd6f9..1274e5a 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/queue.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/queue.c
@@ -52,6 +52,63 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52#else 52#else
53#include <../drivers/staging/android/sw_sync.h> 53#include <../drivers/staging/android/sw_sync.h>
54#endif 54#endif
55
56#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
57#include <linux/list.h>
58#include <linux/workqueue.h>
59
60typedef struct _PVR_QUEUE_SYNC_KERNEL_SYNC_INFO_
61{
62 /* Base services sync info structure */
63 PVRSRV_KERNEL_SYNC_INFO *psBase;
64
65 struct list_head sHead;
66} PVR_QUEUE_SYNC_KERNEL_SYNC_INFO;
67
68static IMG_BOOL PVRSyncIsSyncInfoInUse(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo)
69{
70 return !(psSyncInfo->psSyncData->ui32WriteOpsPending == psSyncInfo->psSyncData->ui32WriteOpsComplete &&
71 psSyncInfo->psSyncData->ui32ReadOpsPending == psSyncInfo->psSyncData->ui32ReadOpsComplete &&
72 psSyncInfo->psSyncData->ui32ReadOps2Pending == psSyncInfo->psSyncData->ui32ReadOps2Complete);
73}
74
75/* Defer Workqueue for releasing command kernel sync info */
76static struct workqueue_struct *gpsWorkQueue;
77
78/* Linux work struct for workqueue. */
79static struct work_struct gsWork;
80
81/* The "defer-free" sync object list. */
82static LIST_HEAD(gSyncInfoFreeList);
83static DEFINE_SPINLOCK(gSyncInfoFreeListLock);
84
85static void PVRSyncWorkQueueFunction(struct work_struct *data)
86{
87 struct list_head sFreeList, *psEntry, *n;
88 PVR_QUEUE_SYNC_KERNEL_SYNC_INFO *psSyncInfo;
89
90 INIT_LIST_HEAD(&sFreeList);
91 spin_lock(&gSyncInfoFreeListLock);
92 list_for_each_safe(psEntry, n, &gSyncInfoFreeList)
93 {
94 psSyncInfo = container_of(psEntry, PVR_QUEUE_SYNC_KERNEL_SYNC_INFO, sHead);
95
96 if(!PVRSyncIsSyncInfoInUse(psSyncInfo->psBase))
97 list_move_tail(psEntry, &sFreeList);
98 }
99 spin_unlock(&gSyncInfoFreeListLock);
100
101 list_for_each_safe(psEntry, n, &sFreeList)
102 {
103 psSyncInfo = container_of(psEntry, PVR_QUEUE_SYNC_KERNEL_SYNC_INFO, sHead);
104
105 list_del(psEntry);
106
107 PVRSRVKernelSyncInfoDecRef(psSyncInfo->psBase, IMG_NULL);
108 }
109}
110#endif
111
55static struct sync_fence *AllocQueueFence(struct sw_sync_timeline *psTimeline, IMG_UINT32 ui32FenceValue, const char *szName) 112static struct sync_fence *AllocQueueFence(struct sw_sync_timeline *psTimeline, IMG_UINT32 ui32FenceValue, const char *szName)
56{ 113{
57 struct sync_fence *psFence = IMG_NULL; 114 struct sync_fence *psFence = IMG_NULL;
@@ -425,7 +482,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize,
425 482
426 if (ui32NoOfSwapchainCreated >= DC_NUM_COMMANDS_PER_TYPE) 483 if (ui32NoOfSwapchainCreated >= DC_NUM_COMMANDS_PER_TYPE)
427 { 484 {
428 PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateCommandQueueKM: Swapchain already exists, increament DC_MAX_SUPPORTED_QUEUES to support more than one swapchain")); 485 PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateCommandQueueKM: Swapchain already exists, increment DC_MAX_SUPPORTED_QUEUES to support more than one swapchain"));
429 return PVRSRV_ERROR_FLIP_CHAIN_EXISTS; 486 return PVRSRV_ERROR_FLIP_CHAIN_EXISTS;
430 } 487 }
431 488
@@ -486,8 +543,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize,
486 } 543 }
487 544
488 /* Ensure we don't corrupt queue list, by blocking access */ 545 /* Ensure we don't corrupt queue list, by blocking access */
546#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
547 eError = OSLockResourceAndBlockMISR(&psSysData->sQProcessResource,
548 KERNEL_ID);
549#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
489 eError = OSLockResource(&psSysData->sQProcessResource, 550 eError = OSLockResource(&psSysData->sQProcessResource,
490 KERNEL_ID); 551 KERNEL_ID);
552#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
491 if (eError != PVRSRV_OK) 553 if (eError != PVRSRV_OK)
492 { 554 {
493 goto ErrorExit; 555 goto ErrorExit;
@@ -496,7 +558,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize,
496 psQueueInfo->psNextKM = psSysData->psQueueList; 558 psQueueInfo->psNextKM = psSysData->psQueueList;
497 psSysData->psQueueList = psQueueInfo; 559 psSysData->psQueueList = psQueueInfo;
498 560
561#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
562 eError = OSUnlockResourceAndUnblockMISR(&psSysData->sQProcessResource, KERNEL_ID);
563#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
499 eError = OSUnlockResource(&psSysData->sQProcessResource, KERNEL_ID); 564 eError = OSUnlockResource(&psSysData->sQProcessResource, KERNEL_ID);
565#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
500 if (eError != PVRSRV_OK) 566 if (eError != PVRSRV_OK)
501 { 567 {
502 goto ErrorExit; 568 goto ErrorExit;
@@ -504,6 +570,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize,
504 570
505 *ppsQueueInfo = psQueueInfo; 571 *ppsQueueInfo = psQueueInfo;
506 572
573#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
574 if(!ui32NoOfSwapchainCreated)
575 {
576 gpsWorkQueue = create_freezable_workqueue("flip_pvr_sync_workqueue");
577 if(!gpsWorkQueue)
578 {
579 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to create flip_pvr_sync workqueue", __func__));
580 goto ErrorExit;
581 }
582 INIT_WORK(&gsWork, PVRSyncWorkQueueFunction);
583 }
584#endif
507 ui32NoOfSwapchainCreated++; 585 ui32NoOfSwapchainCreated++;
508 586
509 return PVRSRV_OK; 587 return PVRSRV_OK;
@@ -577,8 +655,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue
577 } 655 }
578 656
579 /* Ensure we don't corrupt queue list, by blocking access */ 657 /* Ensure we don't corrupt queue list, by blocking access */
658#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
659 eError = OSLockResourceAndBlockMISR(&psSysData->sQProcessResource,
660 KERNEL_ID);
661#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
580 eError = OSLockResource(&psSysData->sQProcessResource, 662 eError = OSLockResource(&psSysData->sQProcessResource,
581 KERNEL_ID); 663 KERNEL_ID);
664#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
582 if (eError != PVRSRV_OK) 665 if (eError != PVRSRV_OK)
583 { 666 {
584 goto ErrorExit; 667 goto ErrorExit;
@@ -632,7 +715,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue
632 715
633 if(!psQueue) 716 if(!psQueue)
634 { 717 {
718#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
719 eError = OSUnlockResourceAndUnblockMISR(&psSysData->sQProcessResource, KERNEL_ID);
720#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
635 eError = OSUnlockResource(&psSysData->sQProcessResource, KERNEL_ID); 721 eError = OSUnlockResource(&psSysData->sQProcessResource, KERNEL_ID);
722#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
636 if (eError != PVRSRV_OK) 723 if (eError != PVRSRV_OK)
637 { 724 {
638 goto ErrorExit; 725 goto ErrorExit;
@@ -643,7 +730,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue
643 } 730 }
644 731
645 /* unlock the Q list lock resource */ 732 /* unlock the Q list lock resource */
733#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
734 eError = OSUnlockResourceAndUnblockMISR(&psSysData->sQProcessResource, KERNEL_ID);
735#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
646 eError = OSUnlockResource(&psSysData->sQProcessResource, KERNEL_ID); 736 eError = OSUnlockResource(&psSysData->sQProcessResource, KERNEL_ID);
737#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
647 if (eError != PVRSRV_OK) 738 if (eError != PVRSRV_OK)
648 { 739 {
649 goto ErrorExit; 740 goto ErrorExit;
@@ -659,6 +750,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue
659 } 750 }
660 } 751 }
661 752
753#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
754 if(!ui32NoOfSwapchainCreated && gpsWorkQueue)
755 {
756 destroy_workqueue(gpsWorkQueue);
757 }
758#endif
662ErrorExit: 759ErrorExit:
663 760
664 return eError; 761 return eError;
@@ -849,6 +946,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue,
849 /* setup dst sync objects and their sync dependencies */ 946 /* setup dst sync objects and their sync dependencies */
850 for (i=0; i<ui32DstSyncCount; i++) 947 for (i=0; i<ui32DstSyncCount; i++)
851 { 948 {
949#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
950 PVR_QUEUE_SYNC_KERNEL_SYNC_INFO *psQueueSync = (PVR_QUEUE_SYNC_KERNEL_SYNC_INFO*)kmalloc(sizeof(PVR_QUEUE_SYNC_KERNEL_SYNC_INFO),GFP_KERNEL);
951 psQueueSync->psBase = apsDstSync[i];
952 spin_lock(&gSyncInfoFreeListLock);
953 list_add_tail(&psQueueSync->sHead, &gSyncInfoFreeList);
954 spin_unlock(&gSyncInfoFreeListLock);
955#endif
852 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_DST_SYNC, 956 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_DST_SYNC,
853 apsDstSync[i], PVRSRV_SYNCOP_SAMPLE); 957 apsDstSync[i], PVRSRV_SYNCOP_SAMPLE);
854 958
@@ -868,6 +972,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue,
868 /* setup src sync objects and their sync dependencies */ 972 /* setup src sync objects and their sync dependencies */
869 for (i=0; i<ui32SrcSyncCount; i++) 973 for (i=0; i<ui32SrcSyncCount; i++)
870 { 974 {
975#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
976 PVR_QUEUE_SYNC_KERNEL_SYNC_INFO *psQueueSync = (PVR_QUEUE_SYNC_KERNEL_SYNC_INFO*)kmalloc(sizeof(PVR_QUEUE_SYNC_KERNEL_SYNC_INFO),GFP_KERNEL);
977 psQueueSync->psBase = apsSrcSync[i];
978 spin_lock(&gSyncInfoFreeListLock);
979 list_add_tail(&psQueueSync->sHead, &gSyncInfoFreeList);
980 spin_unlock(&gSyncInfoFreeListLock);
981#endif
982
871 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_DST_SYNC, 983 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_DST_SYNC,
872 apsSrcSync[i], PVRSRV_SYNCOP_SAMPLE); 984 apsSrcSync[i], PVRSRV_SYNCOP_SAMPLE);
873 985
@@ -1221,7 +1333,17 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush)
1221 /* Ensure we don't corrupt queue list, by blocking access. This is required for OSs where 1333 /* Ensure we don't corrupt queue list, by blocking access. This is required for OSs where
1222 multiple ISR threads may exist simultaneously (eg WinXP DPC routines) 1334 multiple ISR threads may exist simultaneously (eg WinXP DPC routines)
1223 */ 1335 */
1336 if (psSysData->psQueueList == IMG_NULL)
1337 {
1338 PVR_DPF((PVR_DBG_MESSAGE,"No Queues installed - cannot process commands"));
1339 return PVRSRV_OK;
1340 }
1341
1342#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
1343 while (OSLockResourceAndBlockMISR(&psSysData->sQProcessResource, ISR_ID) != PVRSRV_OK)
1344#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
1224 while (OSLockResource(&psSysData->sQProcessResource, ISR_ID) != PVRSRV_OK) 1345 while (OSLockResource(&psSysData->sQProcessResource, ISR_ID) != PVRSRV_OK)
1346#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
1225 { 1347 {
1226 OSWaitus(1); 1348 OSWaitus(1);
1227 }; 1349 };
@@ -1265,7 +1387,11 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush)
1265 List_PVRSRV_DEVICE_NODE_ForEach(psSysData->psDeviceNodeList, 1387 List_PVRSRV_DEVICE_NODE_ForEach(psSysData->psDeviceNodeList,
1266 &PVRSRVProcessQueues_ForEachCb); 1388 &PVRSRVProcessQueues_ForEachCb);
1267 1389
1390#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
1391 OSUnlockResourceAndUnblockMISR(&psSysData->sQProcessResource, ISR_ID);
1392#else /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
1268 OSUnlockResource(&psSysData->sQProcessResource, ISR_ID); 1393 OSUnlockResource(&psSysData->sQProcessResource, ISR_ID);
1394#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
1269 1395
1270 return PVRSRV_OK; 1396 return PVRSRV_OK;
1271} 1397}
@@ -1309,7 +1435,9 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie,
1309 { 1435 {
1310 psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->psSyncData->ui32WriteOpsComplete++; 1436 psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->psSyncData->ui32WriteOpsComplete++;
1311 1437
1438#if !(defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS))
1312 PVRSRVKernelSyncInfoDecRef(psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM, IMG_NULL); 1439 PVRSRVKernelSyncInfoDecRef(psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM, IMG_NULL);
1440#endif
1313 1441
1314 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_UPDATE_DST, 1442 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_UPDATE_DST,
1315 psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM, 1443 psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM,
@@ -1327,7 +1455,9 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie,
1327 { 1455 {
1328 psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->psSyncData->ui32ReadOps2Complete++; 1456 psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->psSyncData->ui32ReadOps2Complete++;
1329 1457
1458#if !(defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS))
1330 PVRSRVKernelSyncInfoDecRef(psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM, IMG_NULL); 1459 PVRSRVKernelSyncInfoDecRef(psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM, IMG_NULL);
1460#endif
1331 1461
1332 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_UPDATE_SRC, 1462 PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_UPDATE_SRC,
1333 psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM, 1463 psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM,
@@ -1340,6 +1470,14 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie,
1340 psCmdCompleteData->psSrcSync[i].ui32WriteOpsPending)); 1470 psCmdCompleteData->psSrcSync[i].ui32WriteOpsPending));
1341 } 1471 }
1342 1472
1473#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
1474 if(psCmdCompleteData->ui32DstSyncCount || psCmdCompleteData->ui32SrcSyncCount)
1475 {
1476 /* Add work to worker thread for checking and freeing of kernel sync */
1477 queue_work(gpsWorkQueue, &gsWork);
1478 }
1479#endif
1480
1343 PVR_TTRACE(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_CMD_COMP_END, 1481 PVR_TTRACE(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_CMD_COMP_END,
1344 QUEUE_TOKEN_COMMAND_COMPLETE); 1482 QUEUE_TOKEN_COMMAND_COMPLETE);
1345 1483
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/ra.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/ra.c
index 37c7176..e05910c 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/ra.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/ra.c
@@ -1294,7 +1294,7 @@ RA_Delete (RA_ARENA *pArena)
1294 if (pBT->type != btt_free) 1294 if (pBT->type != btt_free)
1295 { 1295 {
1296 PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: allocations still exist in the arena that is being destroyed")); 1296 PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: allocations still exist in the arena that is being destroyed"));
1297 PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing alocations before destroying devmemcontext")); 1297 PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing allocations before destroying devmemcontext"));
1298 PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", pBT->base, pBT->uSize)); 1298 PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", pBT->base, pBT->uSize));
1299 } 1299 }
1300 1300
@@ -1518,9 +1518,22 @@ RA_Alloc (RA_ARENA *pArena,
1518 } 1518 }
1519 } 1519 }
1520 } 1520 }
1521#if defined PVRSRV_DEVMEM_TIME_STATS
1522 else
1523 {
1524 /* If sub-allocation succeeded, the allocation was already mapped to Device MMU. So change timing to '0' */
1525 if (ppsMapping)
1526 {
1527 (*ppsMapping)->ui32TimeToDevMap = 0;
1528 }
1529 }
1530#endif
1531
1521#ifdef RA_STATS 1532#ifdef RA_STATS
1522 if (bResult) 1533 if (bResult)
1534 {
1523 pArena->sStatistics.uCumulativeAllocs++; 1535 pArena->sStatistics.uCumulativeAllocs++;
1536 }
1524#endif 1537#endif
1525 1538
1526 PVR_DPF ((PVR_DBG_MESSAGE, 1539 PVR_DPF ((PVR_DBG_MESSAGE,
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c
index 28f671a..aacb94c 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c
@@ -72,10 +72,12 @@ static DEFINE_SPINLOCK(gsCCBLock);
72#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 16) 72#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 16)
73#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 17) 73#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 17)
74#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC (1U << 18) 74#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC (1U << 18)
75#define PVRSRV_REFCOUNT_CCB_DEBUG_DMABUF_SYNC (1U << 19)
75#else 76#else
76#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP 0 77#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP 0
77#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 0 78#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 0
78#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC 0 79#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC 0
80#define PVRSRV_REFCOUNT_CCB_DEBUG_DMABUF_SYNC 0
79#endif 81#endif
80 82
81#define PVRSRV_REFCOUNT_CCB_DEBUG_ALL ~0U 83#define PVRSRV_REFCOUNT_CCB_DEBUG_ALL ~0U
@@ -83,9 +85,12 @@ static DEFINE_SPINLOCK(gsCCBLock);
83/*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/ 85/*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/
84static const IMG_UINT guiDebugMask = 86static const IMG_UINT guiDebugMask =
85 PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO | 87 PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO |
86#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 88#if defined(SUPPORT_ION)
87 PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC | 89 PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC |
88#endif 90#endif
91#if defined(SUPPORT_DMABUF)
92 PVRSRV_REFCOUNT_CCB_DEBUG_DMABUF_SYNC |
93#endif
89 PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2; 94 PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2;
90 95
91typedef struct 96typedef struct
@@ -588,8 +593,8 @@ skip:
588 psOffsetStruct->ui32Mapped--; 593 psOffsetStruct->ui32Mapped--;
589} 594}
590 595
591#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 596#if defined(SUPPORT_ION)
592PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, 597PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
593 IMG_HANDLE hUnique, 598 IMG_HANDLE hUnique,
594 IMG_HANDLE hDevCookie, 599 IMG_HANDLE hDevCookie,
595 IMG_HANDLE hDevMemContext, 600 IMG_HANDLE hDevMemContext,
@@ -601,7 +606,7 @@ PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_IN
601 /* 606 /*
602 We have to do the call 1st as we need to Ion syninfo which it returns 607 We have to do the call 1st as we need to Ion syninfo which it returns
603 */ 608 */
604 eError = PVRSRVExternalBufferSyncAcquire(hUnique, 609 eError = PVRSRVIonBufferSyncAcquire(hUnique,
605 hDevCookie, 610 hDevCookie,
606 hDevMemContext, 611 hDevMemContext,
607 ppsIonSyncInfo); 612 ppsIonSyncInfo);
@@ -637,7 +642,7 @@ skip:
637 return eError; 642 return eError;
638} 643}
639 644
640void PVRSRVExternalBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, 645void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
641 PVRSRV_ION_SYNC_INFO *psIonSyncInfo, 646 PVRSRV_ION_SYNC_INFO *psIonSyncInfo,
642 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) 647 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
643{ 648{
@@ -665,11 +670,91 @@ void PVRSRVExternalBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
665 670
666 PVRSRV_UNLOCK_CCB(); 671 PVRSRV_UNLOCK_CCB();
667skip: 672skip:
668 PVRSRVExternalBufferSyncRelease(psIonSyncInfo); 673 PVRSRVIonBufferSyncRelease(psIonSyncInfo);
669} 674}
670 675
671#endif /* defined (SUPPORT_ION) */ 676#endif /* defined (SUPPORT_ION) */
672 677
678#if defined(SUPPORT_DMABUF)
679PVRSRV_ERROR PVRSRVDmaBufSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
680 IMG_HANDLE hUnique,
681 IMG_HANDLE hPriv,
682 IMG_HANDLE hDevCookie,
683 IMG_HANDLE hDevMemContext,
684 PVRSRV_DMABUF_SYNC_INFO **ppsDmaBufSyncInfo,
685 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
686{
687 PVRSRV_ERROR eError;
688
689 eError = PVRSRVDmaBufSyncAcquire(hUnique,
690 hPriv,
691 hDevCookie,
692 hDevMemContext,
693 ppsDmaBufSyncInfo);
694
695 if (eError == PVRSRV_OK)
696 {
697 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_DMABUF_SYNC))
698 goto skip;
699
700 PVRSRV_LOCK_CCB();
701
702 gsRefCountCCB[giOffset].pszFile = pszFile;
703 gsRefCountCCB[giOffset].iLine = iLine;
704 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
705 snprintf(gsRefCountCCB[giOffset].pcMesg,
706 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
707 PVRSRV_REFCOUNT_CCB_FMT_STRING,
708 "DMA-BUF_SYNC",
709 (*ppsDmaBufSyncInfo)->psSyncInfo,
710 psKernelMemInfo,
711 NULL,
712 *ppsDmaBufSyncInfo,
713 (*ppsDmaBufSyncInfo)->ui32RefCount - 1,
714 (*ppsDmaBufSyncInfo)->ui32RefCount,
715 0);
716 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
717 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
718
719 PVRSRV_UNLOCK_CCB();
720 }
721
722skip:
723 return eError;
724}
725
726void PVRSRVDmaBufSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
727 PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo,
728 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
729{
730 if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_DMABUF_SYNC))
731 goto skip;
732
733 PVRSRV_LOCK_CCB();
734
735 gsRefCountCCB[giOffset].pszFile = pszFile;
736 gsRefCountCCB[giOffset].iLine = iLine;
737 gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
738 snprintf(gsRefCountCCB[giOffset].pcMesg,
739 PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
740 PVRSRV_REFCOUNT_CCB_FMT_STRING,
741 "DMA-BUF_SYNC",
742 psDmaBufSyncInfo->psSyncInfo,
743 psKernelMemInfo,
744 NULL,
745 psDmaBufSyncInfo,
746 psDmaBufSyncInfo->ui32RefCount,
747 psDmaBufSyncInfo->ui32RefCount - 1,
748 0);
749 gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
750 giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
751
752 PVRSRV_UNLOCK_CCB();
753skip:
754 PVRSRVDmaBufSyncRelease(psDmaBufSyncInfo);
755}
756#endif /* defined (SUPPORT_DMABUF) */
757
673#endif /* defined(__linux__) */ 758#endif /* defined(__linux__) */
674 759
675#endif /* defined(PVRSRV_REFCOUNT_DEBUG) */ 760#endif /* defined(PVRSRV_REFCOUNT_DEBUG) */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/resman.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/resman.c
index 302efb2..a8b8a2f 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/resman.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/common/resman.c
@@ -359,12 +359,12 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext,
359 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_MAPPING, 0, 0, IMG_TRUE); 359 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_MAPPING, 0, 0, IMG_TRUE);
360 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_KERNEL_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE); 360 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_KERNEL_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE);
361 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE); 361 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE);
362#if defined(SUPPORT_DRM_GEM)
363 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_DMABUF, 0, 0, IMG_TRUE);
364#endif
365#if defined(SUPPORT_ION) 362#if defined(SUPPORT_ION)
366 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ION, 0, 0, IMG_TRUE); 363 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ION, 0, 0, IMG_TRUE);
367#endif 364#endif
365#if defined(SUPPORT_DMABUF)
366 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_DMABUF, 0, 0, IMG_TRUE);
367#endif
368 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_CONTEXT, 0, 0, IMG_TRUE); 368 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_CONTEXT, 0, 0, IMG_TRUE);
369 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_MEM_INFO, 0, 0, IMG_TRUE); 369 FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_MEM_INFO, 0, 0, IMG_TRUE);
370 370
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/mmu.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/mmu.c
index 8e4f159..b506167 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/mmu.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/mmu.c
@@ -307,8 +307,7 @@ static IMG_VOID DumpPT(MMU_PT_INFO *psPTInfoList)
307 /* 1024 entries in a 4K page table */ 307 /* 1024 entries in a 4K page table */
308 for(i = 0; i < 1024; i += 8) 308 for(i = 0; i < 1024; i += 8)
309 { 309 {
310 PVR_DPF((PVR_DBG_ERROR, 310 PVR_LOG(("%08X %08X %08X %08X %08X %08X %08X %08X",
311 "%08X %08X %08X %08X %08X %08X %08X %08X\n",
312 p[i + 0], p[i + 1], p[i + 2], p[i + 3], 311 p[i + 0], p[i + 1], p[i + 2], p[i + 3],
313 p[i + 4], p[i + 5], p[i + 6], p[i + 7])); 312 p[i + 4], p[i + 5], p[i + 6], p[i + 7]));
314 } 313 }
@@ -333,7 +332,7 @@ static IMG_VOID CheckPT(MMU_PT_INFO *psPTInfoList)
333 332
334 if(psPTInfoList->ui32ValidPTECount != ui32Count) 333 if(psPTInfoList->ui32ValidPTECount != ui32Count)
335 { 334 {
336 PVR_DPF((PVR_DBG_ERROR, "ui32ValidPTECount: %u ui32Count: %u\n", 335 PVR_DPF((PVR_DBG_ERROR, "ui32ValidPTECount: %u ui32Count: %u",
337 psPTInfoList->ui32ValidPTECount, ui32Count)); 336 psPTInfoList->ui32ValidPTECount, ui32Count));
338 DumpPT(psPTInfoList); 337 DumpPT(psPTInfoList);
339 PVR_DBG_BREAK; 338 PVR_DBG_BREAK;
@@ -1754,13 +1753,14 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1754{ 1753{
1755 IMG_UINT32 *pui32Tmp; 1754 IMG_UINT32 *pui32Tmp;
1756 IMG_UINT32 i; 1755 IMG_UINT32 i;
1757 IMG_CPU_VIRTADDR pvPDCpuVAddr; 1756 IMG_CPU_VIRTADDR pvPDCpuVAddr = IMG_NULL;
1758 IMG_DEV_PHYADDR sPDDevPAddr; 1757 IMG_DEV_PHYADDR sPDDevPAddr = {0};
1759 IMG_CPU_PHYADDR sCpuPAddr; 1758 IMG_CPU_PHYADDR sCpuPAddr;
1760 MMU_CONTEXT *psMMUContext; 1759 MMU_CONTEXT *psMMUContext;
1761 IMG_HANDLE hPDOSMemHandle = IMG_NULL; 1760 IMG_HANDLE hPDOSMemHandle = IMG_NULL;
1762 SYS_DATA *psSysData; 1761 SYS_DATA *psSysData;
1763 PVRSRV_SGXDEV_INFO *psDevInfo; 1762 PVRSRV_SGXDEV_INFO *psDevInfo;
1763 PVRSRV_ERROR eError = PVRSRV_OK;
1764#if defined(PDUMP) 1764#if defined(PDUMP)
1765 PDUMP_MMU_ATTRIB sMMUAttrib; 1765 PDUMP_MMU_ATTRIB sMMUAttrib;
1766#endif 1766#endif
@@ -1806,7 +1806,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1806 &hPDOSMemHandle) != PVRSRV_OK) 1806 &hPDOSMemHandle) != PVRSRV_OK)
1807 { 1807 {
1808 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); 1808 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed"));
1809 return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; 1809 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES;
1810 goto exit_setting_values;
1810 } 1811 }
1811 1812
1812 if(pvPDCpuVAddr) 1813 if(pvPDCpuVAddr)
@@ -1841,7 +1842,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1841 &psDevInfo->hDummyPTPageOSMemHandle) != PVRSRV_OK) 1842 &psDevInfo->hDummyPTPageOSMemHandle) != PVRSRV_OK)
1842 { 1843 {
1843 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); 1844 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed"));
1844 return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; 1845 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES;
1846 goto exit_setting_values;
1845 } 1847 }
1846 1848
1847 if(psDevInfo->pvDummyPTPageCpuVAddr) 1849 if(psDevInfo->pvDummyPTPageCpuVAddr)
@@ -1868,7 +1870,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1868 &psDevInfo->hDummyDataPageOSMemHandle) != PVRSRV_OK) 1870 &psDevInfo->hDummyDataPageOSMemHandle) != PVRSRV_OK)
1869 { 1871 {
1870 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); 1872 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed"));
1871 return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; 1873 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES;
1874 goto exit_setting_values;
1872 } 1875 }
1873 1876
1874 if(psDevInfo->pvDummyDataPageCpuVAddr) 1877 if(psDevInfo->pvDummyDataPageCpuVAddr)
@@ -1899,7 +1902,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1899 &psDevInfo->hBRN31620DummyPageOSMemHandle) != PVRSRV_OK) 1902 &psDevInfo->hBRN31620DummyPageOSMemHandle) != PVRSRV_OK)
1900 { 1903 {
1901 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); 1904 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed"));
1902 return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; 1905 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES;
1906 goto exit_setting_values;
1903 } 1907 }
1904 1908
1905 /* Get a physical address */ 1909 /* Get a physical address */
@@ -1933,7 +1937,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1933 &psDevInfo->hBRN31620DummyPTOSMemHandle) != PVRSRV_OK) 1937 &psDevInfo->hBRN31620DummyPTOSMemHandle) != PVRSRV_OK)
1934 { 1938 {
1935 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); 1939 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed"));
1936 return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; 1940 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES;
1941 goto exit_setting_values;
1937 } 1942 }
1938 1943
1939 /* Get a physical address */ 1944 /* Get a physical address */
@@ -1979,7 +1984,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1979 &uiLocalPAddr)!= IMG_TRUE) 1984 &uiLocalPAddr)!= IMG_TRUE)
1980 { 1985 {
1981 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); 1986 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed"));
1982 return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; 1987 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY;
1988 goto exit_setting_values;
1983 } 1989 }
1984 1990
1985 /* Munge the local PAddr back into the SysPAddr */ 1991 /* Munge the local PAddr back into the SysPAddr */
@@ -1995,7 +2001,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
1995 if(!pvPDCpuVAddr) 2001 if(!pvPDCpuVAddr)
1996 { 2002 {
1997 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); 2003 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables"));
1998 return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; 2004 eError = PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE;
2005 goto exit_setting_values;
1999 } 2006 }
2000 2007
2001 #if PAGE_TEST 2008 #if PAGE_TEST
@@ -2019,7 +2026,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2019 &uiLocalPAddr)!= IMG_TRUE) 2026 &uiLocalPAddr)!= IMG_TRUE)
2020 { 2027 {
2021 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); 2028 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed"));
2022 return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; 2029 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY;
2030 goto exit_setting_values;
2023 } 2031 }
2024 2032
2025 /* Munge the local PAddr back into the SysPAddr */ 2033 /* Munge the local PAddr back into the SysPAddr */
@@ -2035,7 +2043,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2035 if(!psDevInfo->pvDummyPTPageCpuVAddr) 2043 if(!psDevInfo->pvDummyPTPageCpuVAddr)
2036 { 2044 {
2037 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); 2045 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables"));
2038 return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; 2046 eError = PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE;
2047 goto exit_setting_values;
2039 } 2048 }
2040 2049
2041 /* Dummy Data page */ 2050 /* Dummy Data page */
@@ -2051,7 +2060,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2051 &uiLocalPAddr)!= IMG_TRUE) 2060 &uiLocalPAddr)!= IMG_TRUE)
2052 { 2061 {
2053 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); 2062 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed"));
2054 return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; 2063 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY;
2064 goto exit_setting_values;
2055 } 2065 }
2056 2066
2057 /* Munge the local PAddr back into the SysPAddr */ 2067 /* Munge the local PAddr back into the SysPAddr */
@@ -2067,7 +2077,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2067 if(!psDevInfo->pvDummyDataPageCpuVAddr) 2077 if(!psDevInfo->pvDummyDataPageCpuVAddr)
2068 { 2078 {
2069 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); 2079 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables"));
2070 return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; 2080 eError = PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE;
2081 goto exit_setting_values;
2071 } 2082 }
2072 } 2083 }
2073#endif /* #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) */ 2084#endif /* #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) */
@@ -2089,7 +2100,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2089 &uiLocalPAddr)!= IMG_TRUE) 2100 &uiLocalPAddr)!= IMG_TRUE)
2090 { 2101 {
2091 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); 2102 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed"));
2092 return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; 2103 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY;
2104 goto exit_setting_values;
2093 } 2105 }
2094 2106
2095 /* Munge the local PAddr back into the SysPAddr */ 2107 /* Munge the local PAddr back into the SysPAddr */
@@ -2105,7 +2117,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2105 if(!psDevInfo->pvBRN31620DummyPageCpuVAddr) 2117 if(!psDevInfo->pvBRN31620DummyPageCpuVAddr)
2106 { 2118 {
2107 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); 2119 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables"));
2108 return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; 2120 eError = PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE;
2121 goto exit_setting_values;
2109 } 2122 }
2110 2123
2111 MakeKernelPageReadWrite(psDevInfo->pvBRN31620DummyPageCpuVAddr); 2124 MakeKernelPageReadWrite(psDevInfo->pvBRN31620DummyPageCpuVAddr);
@@ -2130,7 +2143,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2130 &uiLocalPAddr)!= IMG_TRUE) 2143 &uiLocalPAddr)!= IMG_TRUE)
2131 { 2144 {
2132 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); 2145 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed"));
2133 return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; 2146 eError = PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY;
2147 goto exit_setting_values;
2134 } 2148 }
2135 2149
2136 /* Munge the local PAddr back into the SysPAddr */ 2150 /* Munge the local PAddr back into the SysPAddr */
@@ -2147,7 +2161,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2147 if(!psDevInfo->pvBRN31620DummyPTCpuVAddr) 2161 if(!psDevInfo->pvBRN31620DummyPTCpuVAddr)
2148 { 2162 {
2149 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); 2163 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables"));
2150 return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; 2164 eError = PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE;
2165 goto exit_setting_values;
2151 } 2166 }
2152 2167
2153 OSMemSet(psDevInfo->pvBRN31620DummyPTCpuVAddr,0,SGX_MMU_PAGE_SIZE); 2168 OSMemSet(psDevInfo->pvBRN31620DummyPTCpuVAddr,0,SGX_MMU_PAGE_SIZE);
@@ -2199,7 +2214,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2199 else 2214 else
2200 { 2215 {
2201 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: pvPDCpuVAddr invalid")); 2216 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: pvPDCpuVAddr invalid"));
2202 return PVRSRV_ERROR_INVALID_CPU_ADDR; 2217 eError = PVRSRV_ERROR_INVALID_CPU_ADDR;
2218 goto exit_setting_values;
2203 } 2219 }
2204 2220
2205 2221
@@ -2230,7 +2246,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2230 MakeKernelPageReadOnly(psDevInfo->pvDummyPTPageCpuVAddr); 2246 MakeKernelPageReadOnly(psDevInfo->pvDummyPTPageCpuVAddr);
2231 /* pdump the Dummy PT Page */ 2247 /* pdump the Dummy PT Page */
2232 PDUMPCOMMENT("Dummy Page table contents"); 2248 PDUMPCOMMENT("Dummy Page table contents");
2233 PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hDummyPTOSMemHandle, psDevInfo->pvDummyPTPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); 2249 PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hDummyPTPageOSMemHandle, psDevInfo->pvDummyPTPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG);
2234 2250
2235 /* 2251 /*
2236 write a signature to the dummy data page 2252 write a signature to the dummy data page
@@ -2244,7 +2260,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2244 MakeKernelPageReadOnly(psDevInfo->pvDummyDataPageCpuVAddr); 2260 MakeKernelPageReadOnly(psDevInfo->pvDummyDataPageCpuVAddr);
2245 /* pdump the Dummy Data Page */ 2261 /* pdump the Dummy Data Page */
2246 PDUMPCOMMENT("Dummy Data Page contents"); 2262 PDUMPCOMMENT("Dummy Data Page contents");
2247 PDUMPMEMPTENTRIES(PVRSRV_DEVICE_TYPE_SGX, psDevInfo->hDummyDataPageOSMemHandle, psDevInfo->pvDummyDataPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); 2263 PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hDummyDataPageOSMemHandle, psDevInfo->pvDummyDataPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG);
2248 } 2264 }
2249#else /* #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) */ 2265#else /* #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) */
2250 /* initialise the PD to invalid address state */ 2266 /* initialise the PD to invalid address state */
@@ -2330,7 +2346,6 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2330#if defined(PDUMP) 2346#if defined(PDUMP)
2331 /* pdump set MMU context */ 2347 /* pdump set MMU context */
2332 { 2348 {
2333 PVRSRV_ERROR eError;
2334 /* default MMU type is 1, 4k page */ 2349 /* default MMU type is 1, 4k page */
2335 IMG_UINT32 ui32MMUType = 1; 2350 IMG_UINT32 ui32MMUType = 1;
2336 2351
@@ -2352,7 +2367,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2352 if (eError != PVRSRV_OK) 2367 if (eError != PVRSRV_OK)
2353 { 2368 {
2354 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to PDumpSetMMUContext failed")); 2369 PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to PDumpSetMMUContext failed"));
2355 return eError; 2370 goto exit_setting_values;
2356 } 2371 }
2357 } 2372 }
2358 2373
@@ -2376,6 +2391,9 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2376 psMMUContext->apsPTInfoListSave[i] = IMG_NULL; 2391 psMMUContext->apsPTInfoListSave[i] = IMG_NULL;
2377 } 2392 }
2378#endif 2393#endif
2394
2395exit_setting_values:
2396
2379 /* store PD info in the MMU context */ 2397 /* store PD info in the MMU context */
2380 psMMUContext->pvPDCpuVAddr = pvPDCpuVAddr; 2398 psMMUContext->pvPDCpuVAddr = pvPDCpuVAddr;
2381 psMMUContext->sPDDevPAddr = sPDDevPAddr; 2399 psMMUContext->sPDDevPAddr = sPDDevPAddr;
@@ -2401,7 +2419,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I
2401 DisableHostAccess(psMMUContext); 2419 DisableHostAccess(psMMUContext);
2402#endif 2420#endif
2403 2421
2404 return PVRSRV_OK; 2422 return eError;
2405} 2423}
2406 2424
2407/*! 2425/*!
@@ -2427,31 +2445,37 @@ MMU_Finalise (MMU_CONTEXT *psMMUContext)
2427 SysAcquireData(&psSysData); 2445 SysAcquireData(&psSysData);
2428 2446
2429#if defined(PDUMP) 2447#if defined(PDUMP)
2430 /* pdump the MMU context clear */ 2448 {
2431 PDUMPCOMMENT("Clear MMU context (MMU Context ID == %u)", psMMUContext->ui32PDumpMMUContextID); 2449 IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
2432 PDUMPCLEARMMUCONTEXT(PVRSRV_DEVICE_TYPE_SGX, psMMUContext->psDeviceNode->sDevId.pszPDumpDevName, psMMUContext->ui32PDumpMMUContextID, 2); 2450 /* pdump the MMU context clear */
2451 PDUMPCOMMENT("Clear MMU context (MMU Context ID == %u)", psMMUContext->ui32PDumpMMUContextID);
2452 PDUMPCLEARMMUCONTEXT(PVRSRV_DEVICE_TYPE_SGX, psMMUContext->psDeviceNode->sDevId.pszPDumpDevName, psMMUContext->ui32PDumpMMUContextID, 2);
2433 2453
2434 /* pdump the PD free */ 2454 /* pdump the PD free */
2435 PDUMPCOMMENT("Free page directory (PDDevPAddr == 0x" DEVPADDR_FMT ")", 2455 PDUMPCOMMENT("Free page directory (PDDevPAddr == 0x" DEVPADDR_FMT ")",
2436 psMMUContext->sPDDevPAddr.uiAddr); 2456 psMMUContext->sPDDevPAddr.uiAddr);
2437#endif /* PDUMP */
2438 2457
2439 PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psMMUContext->hPDOSMemHandle, psMMUContext->pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); 2458 PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psMMUContext->hPDOSMemHandle, psMMUContext->pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, ui32Flags, PDUMP_PT_UNIQUETAG);
2440#if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) 2459#if defined(SUPPORT_SGX_MMU_DUMMY_PAGE)
2441 PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hDummyPTPageOSMemHandle, psDevInfo->pvDummyPTPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); 2460 PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hDummyPTPageOSMemHandle, psDevInfo->pvDummyPTPageCpuVAddr, SGX_MMU_PAGE_SIZE, ui32Flags, PDUMP_PT_UNIQUETAG);
2442 PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hDummyDataPageOSMemHandle, psDevInfo->pvDummyDataPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); 2461 PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hDummyDataPageOSMemHandle, psDevInfo->pvDummyDataPageCpuVAddr, SGX_MMU_PAGE_SIZE, ui32Flags, PDUMP_PT_UNIQUETAG);
2443#endif 2462#endif
2463 }
2464#endif /* PDUMP */
2444 2465
2445 pui32Tmp = (IMG_UINT32 *)psMMUContext->pvPDCpuVAddr; 2466 pui32Tmp = (IMG_UINT32 *)psMMUContext->pvPDCpuVAddr;
2446 2467
2447 MakeKernelPageReadWrite(psMMUContext->pvPDCpuVAddr); 2468 if (pui32Tmp)
2448 /* initialise the PD to invalid address state */
2449 for(i=0; i<SGX_MMU_PD_SIZE; i++)
2450 { 2469 {
2451 /* invalid, no read, no write, no cache consistency */ 2470 MakeKernelPageReadWrite(psMMUContext->pvPDCpuVAddr);
2452 pui32Tmp[i] = 0; 2471 /* initialise the PD to invalid address state */
2472 for(i=0; i<SGX_MMU_PD_SIZE; i++)
2473 {
2474 /* invalid, no read, no write, no cache consistency */
2475 pui32Tmp[i] = 0;
2476 }
2477 MakeKernelPageReadOnly(psMMUContext->pvPDCpuVAddr);
2453 } 2478 }
2454 MakeKernelPageReadOnly(psMMUContext->pvPDCpuVAddr);
2455 2479
2456 /* 2480 /*
2457 free the PD: 2481 free the PD:
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxconfig.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxconfig.h
index 632ab51..009a8d7 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxconfig.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxconfig.h
@@ -58,6 +58,94 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58 58
59 59
60#if SGX_FEATURE_ADDRESS_SPACE_SIZE == 32 60#if SGX_FEATURE_ADDRESS_SPACE_SIZE == 32
61
62#if defined (SGX_FEATURE_ADDRESS_SPACE_EXTENSION)
63/*
64 * Constraints: (Additional to above ones)
65 * -GENERAL, PDS, USE_CODE, KERNEL_DATA heaps should be within [0-256MB] range only.
66 * -(3DPARAMETERS_HEAP_BASE+TADATA_HEAP) <= 256MB, within same 256MB range.
67 *
68 * BIF_REQ_BASE Setting:
69 * -PDS_REQ_BASE = USCE_REQ_BASE = VDM_REQ_BASE = 0x00000000
70 * 3D Task:
71 * -ISPP_REQ_BASE = ISPZ_REQ_BASE = 3D_REQ_BASE = 3DPARAMETERS_HEAP_BASE
72 * TA Task:
73 * -TA_COMMON_REQ_BASE = TA_REQ_BASE = 3DPARAMETERS_HEAP_BASE
74 * TQ Task:
75 * -3D_REQ_BASE = ISPP_REQ_BASE = ISPZ_REQ_BASE = ISP stream CCB base
76 */
77#if defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP)
78 #define SGX_GENERAL_MAPPING_HEAP_BASE 0x00001000
79 #define SGX_GENERAL_MAPPING_HEAP_SIZE (0x01400000-0x00001000-0x00001000)
80
81 #define SGX_GENERAL_HEAP_BASE 0x01400000
82 #define SGX_GENERAL_HEAP_SIZE (0x07000000-0x00001000)
83
84#else
85 #define SGX_GENERAL_HEAP_BASE 0x00001000
86 #define SGX_GENERAL_HEAP_SIZE (0x08400000-0x00001000-0x00001000)
87#endif
88
89 #define SGX_PDSPIXEL_CODEDATA_HEAP_BASE 0x08400000
90 #define SGX_PDSPIXEL_CODEDATA_HEAP_SIZE (0x02000000-0x00001000)
91
92 #define SGX_KERNEL_CODE_HEAP_BASE 0x0A400000
93 #define SGX_KERNEL_CODE_HEAP_SIZE (0x00080000-0x00001000)
94
95 #define SGX_PDSVERTEX_CODEDATA_HEAP_BASE 0x0A800000
96 #define SGX_PDSVERTEX_CODEDATA_HEAP_SIZE (0x01C00000-0x00001000)
97
98 #define SGX_PIXELSHADER_HEAP_BASE 0x0C400000
99 #define SGX_PIXELSHADER_HEAP_SIZE (0x00800000-0x00001000)
100
101 #define SGX_VERTEXSHADER_HEAP_BASE 0x0CC00000
102 #define SGX_VERTEXSHADER_HEAP_SIZE (0x00400000-0x00001000)
103
104 #define SGX_KERNEL_DATA_HEAP_BASE (0x0D000000+SGX_KERNEL_DATA_HEAP_OFFSET)
105 #define SGX_KERNEL_DATA_HEAP_SIZE (0x02F00000-(0x00001000+SGX_KERNEL_DATA_HEAP_OFFSET))
106
107 /* ==== Heaps 256MB onwards ==== */
108
109 #define SGX_3DPARAMETERS_HEAP_SIZE 0x04000000
110
111 /* By default we split the PB 50/50 */
112#if !defined(HYBRID_SHARED_PB_SIZE)
113 #define HYBRID_SHARED_PB_SIZE (SGX_3DPARAMETERS_HEAP_SIZE >> 1)
114#endif
115#if defined(SUPPORT_HYBRID_PB)
116 #define SGX_SHARED_3DPARAMETERS_SIZE (HYBRID_SHARED_PB_SIZE)
117 #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (HYBRID_SHARED_PB_SIZE-0x00001000)
118 #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - SGX_SHARED_3DPARAMETERS_SIZE - 0x00001000)
119#else
120#if defined(SUPPORT_PERCONTEXT_PB)
121 #define SGX_SHARED_3DPARAMETERS_SIZE 0
122 #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE 0
123 #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000)
124#endif
125#if defined(SUPPORT_SHARED_PB)
126 #define SGX_SHARED_3DPARAMETERS_SIZE SGX_3DPARAMETERS_HEAP_SIZE
127 #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000)
128 #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE 0
129#endif
130#endif
131
132 #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0x10000000
133
134 /* Size is defined above */
135
136 #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE (SGX_SHARED_3DPARAMETERS_HEAP_BASE + SGX_SHARED_3DPARAMETERS_SIZE)
137 /* Size is defined above */
138
139 #define SGX_TADATA_HEAP_BASE 0x14000000
140 #define SGX_TADATA_HEAP_SIZE (0x04000000-0x00001000)
141
142 #define SGX_SYNCINFO_HEAP_BASE 0x18000000
143 #define SGX_SYNCINFO_HEAP_SIZE (0x01000000-0x00001000)
144
145 #define SGX_TEXTURE_HEAP_BASE 0x19000000
146 #define SGX_TEXTURE_HEAP_SIZE (0xE6000000-0x00001000)
147
148#else /* defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION) */
61#if defined(FIX_HW_BRN_31620) 149#if defined(FIX_HW_BRN_31620)
62 #if defined(SGX_FEATURE_2D_HARDWARE) 150 #if defined(SGX_FEATURE_2D_HARDWARE)
63 #define SGX_2D_HEAP_BASE 0x04000000 151 #define SGX_2D_HEAP_BASE 0x04000000
@@ -233,6 +321,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
233 #define SGX_VERTEXSHADER_HEAP_SIZE (0x02000000-0x00001000) 321 #define SGX_VERTEXSHADER_HEAP_SIZE (0x02000000-0x00001000)
234#endif /* FIX_HW_BRN_31620 */ 322#endif /* FIX_HW_BRN_31620 */
235 /* signal we've identified the core by the build */ 323 /* signal we've identified the core by the build */
324#endif /* defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION) */
236 #define SGX_CORE_IDENTIFIED 325 #define SGX_CORE_IDENTIFIED
237#endif /* SGX_FEATURE_ADDRESS_SPACE_SIZE == 32 */ 326#endif /* SGX_FEATURE_ADDRESS_SPACE_SIZE == 32 */
238 327
@@ -335,6 +424,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
335 #error "sgxconfig.h: ERROR: unspecified SGX Core version" 424 #error "sgxconfig.h: ERROR: unspecified SGX Core version"
336#endif 425#endif
337 426
427#if !defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION)
338/********************************************************************************* 428/*********************************************************************************
339 * 429 *
340 * SGX_PDSPIXEL_CODEDATA_HEAP_BASE + 64MB range must include PDSVERTEX_CODEDATA and KERNEL_CODE heaps 430 * SGX_PDSPIXEL_CODEDATA_HEAP_BASE + 64MB range must include PDSVERTEX_CODEDATA and KERNEL_CODE heaps
@@ -449,7 +539,105 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
449#if ((SGX_VERTEXSHADER_HEAP_BASE + SGX_VERTEXSHADER_HEAP_SIZE) < SGX_VERTEXSHADER_HEAP_BASE) 539#if ((SGX_VERTEXSHADER_HEAP_BASE + SGX_VERTEXSHADER_HEAP_SIZE) < SGX_VERTEXSHADER_HEAP_BASE)
450 #error "sgxconfig.h: ERROR: SGX_VERTEXSHADER_HEAP_BASE size cause wraparound" 540 #error "sgxconfig.h: ERROR: SGX_VERTEXSHADER_HEAP_BASE size cause wraparound"
451#endif 541#endif
542#else /* !defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION) */
543
544/*********************************************************************************
545 *
546 * SGX_PDSPIXEL_CODEDATA_HEAP_BASE + 64MB range must include PDSVERTEX_CODEDATA and KERNEL_CODE heaps
547 *
548 ********************************************************************************/
549#if !defined (SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE)
550 #if ((SGX_KERNEL_CODE_HEAP_BASE + SGX_KERNEL_CODE_HEAP_SIZE - SGX_PDSPIXEL_CODEDATA_HEAP_BASE) > 0x4000000)
551 #error "sgxconfig.h: ERROR: SGX_KERNEL_CODE_HEAP_BASE out of range of SGX_PDSPIXEL_CODEDATA_HEAP_BASE"
552 #endif
553
554 #if ((SGX_PDSVERTEX_CODEDATA_HEAP_BASE + SGX_PDSVERTEX_CODEDATA_HEAP_SIZE - SGX_PDSPIXEL_CODEDATA_HEAP_BASE) > 0x4000000)
555 #error "sgxconfig.h: ERROR: SGX_PDSVERTEX_CODEDATA_HEAP_BASE out of range of SGX_PDSPIXEL_CODEDATA_HEAP_BASE"
556 #endif
557#endif
558
559/*********************************************************************************
560 *
561 * The kernel code heap base must be aligned to a USSE code page
562 *
563 ********************************************************************************/
564#if defined (EURASIA_USE_CODE_PAGE_SIZE)
565 #if ((SGX_KERNEL_CODE_HEAP_BASE & (EURASIA_USE_CODE_PAGE_SIZE - 1)) != 0)
566 #error "sgxconfig.h: ERROR: Kernel code heap base misalignment"
567 #endif
568#endif
569
570/*********************************************************************************
571 *
572 * Heap overlap check
573 *
574 ********************************************************************************/
575#if defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP)
576 #if ((SGX_GENERAL_MAPPING_HEAP_BASE + SGX_GENERAL_MAPPING_HEAP_SIZE) >= SGX_GENERAL_HEAP_BASE)
577 #error "sgxconfig.h: ERROR: SGX_GENERAL_MAPPING_HEAP overlaps SGX_GENERAL_HEAP"
578 #endif
579#endif
580
581#if ((SGX_GENERAL_HEAP_BASE + SGX_GENERAL_HEAP_SIZE) >= SGX_PDSPIXEL_CODEDATA_HEAP_BASE)
582 #error "sgxconfig.h: ERROR: SGX_GENERAL_HEAP overlaps SGX_PDSPIXEL_CODEDATA_HEAP"
583#endif
584
585#if ((SGX_PDSPIXEL_CODEDATA_HEAP_BASE + SGX_PDSPIXEL_CODEDATA_HEAP_SIZE) >= SGX_KERNEL_CODE_HEAP_BASE)
586 #error "sgxconfig.h: ERROR: SGX_PDSPIXEL_CODEDATA_HEAP overlaps SGX_KERNEL_CODE_HEAP"
587#endif
588
589#if ((SGX_KERNEL_CODE_HEAP_BASE + SGX_KERNEL_CODE_HEAP_SIZE) >= SGX_PDSVERTEX_CODEDATA_HEAP_BASE)
590 #error "sgxconfig.h: ERROR: SGX_KERNEL_CODE_HEAP overlaps SGX_PDSVERTEX_CODEDATA_HEAP"
591#endif
592
593#if ((SGX_PDSVERTEX_CODEDATA_HEAP_BASE + SGX_PDSVERTEX_CODEDATA_HEAP_SIZE) >= SGX_PIXELSHADER_HEAP_BASE)
594 #error "sgxconfig.h: ERROR: SGX_PDSVERTEX_CODEDATA_HEAP overlaps SGX_KERNEL_DATA_HEAP"
595#endif
596
597#if ((SGX_PIXELSHADER_HEAP_BASE + SGX_PIXELSHADER_HEAP_SIZE) >= SGX_VERTEXSHADER_HEAP_BASE)
598 #error "sgxconfig.h: ERROR: SGX_PIXELSHADER_HEAP overlaps SGX_VERTEXSHADER_HEAP"
599#endif
600
601#if ((SGX_VERTEXSHADER_HEAP_BASE + SGX_VERTEXSHADER_HEAP_SIZE) >= SGX_KERNEL_DATA_HEAP_BASE)
602 #error "sgxconfig.h: ERROR: SGX_VERTEXSHADER_HEAP_BASE size overlaps SGX_KERNEL_DATA_HEAP"
603#endif
604
605/* check if last heap in 0-256MB spill out of 256MB */
606#if ((SGX_KERNEL_DATA_HEAP_BASE + SGX_KERNEL_DATA_HEAP_SIZE) > 0x0FFFFFFF)
607 #error "sgxconfig.h: ERROR: SGX_KERNEL_DATA_HEAP spill out of 256MB"
608#endif
609
610
611/* check for heaps out 0f 0-256MB range */
612
613
614#if ((SGX_SHARED_3DPARAMETERS_HEAP_BASE < 0x0FFFFFFF))
615 #error "sgxconfig.h: ERROR: put SGX_SHARED_3DPARAMETERS_HEAP out side of 0-256MB"
616#endif
617
618#if defined(SUPPORT_HYBRID_PB)
619 #if ((HYBRID_SHARED_PB_SIZE + 0x000001000) > SGX_3DPARAMETERS_HEAP_SIZE)
620 #error "sgxconfig.h: ERROR: HYBRID_SHARED_PB_SIZE too large"
621 #endif
622#endif
623
624#if (((SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE + SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE) >= SGX_TADATA_HEAP_BASE) && (SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE > 0))
625 #error "sgxconfig.h: ERROR: SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE overlaps SGX_TADATA_HEAP"
626#endif
627
628#if ((SGX_TADATA_HEAP_BASE + SGX_TADATA_HEAP_SIZE) >= SGX_SYNCINFO_HEAP_BASE)
629 #error "sgxconfig.h: ERROR: SGX_TADATA_HEAP overlaps SGX_SYNCINFO_HEAP"
630#endif
631
632#if ((SGX_SYNCINFO_HEAP_BASE + SGX_SYNCINFO_HEAP_SIZE) >= SGX_TEXTURE_HEAP_BASE)
633 #error "sgxconfig.h: ERROR: SGX_SYNCINFO_HEAP overlaps SGX_TEXTURE_HEAP_BASE"
634#endif
635
636#if ((SGX_TEXTURE_HEAP_BASE + SGX_TEXTURE_HEAP_SIZE) < SGX_TEXTURE_HEAP_BASE)
637 #error "sgxconfig.h: ERROR: SGX_TEXTURE_HEAP size cause wraparound"
638#endif
452 639
640#endif /* !defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION) */
453#endif /* __SGXCONFIG_H__ */ 641#endif /* __SGXCONFIG_H__ */
454 642
455/***************************************************************************** 643/*****************************************************************************
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinfokm.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinfokm.h
index 9a1ffcd..ce30182 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinfokm.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinfokm.h
@@ -220,6 +220,9 @@ typedef struct _PVRSRV_SGXDEV_INFO_
220 IMG_UINT32 ui32MasterClkGateStatus2Reg; 220 IMG_UINT32 ui32MasterClkGateStatus2Reg;
221 IMG_UINT32 ui32MasterClkGateStatus2Mask; 221 IMG_UINT32 ui32MasterClkGateStatus2Mask;
222#endif /* SGX_FEATURE_MP */ 222#endif /* SGX_FEATURE_MP */
223#if defined(SGX_FEATURE_AUTOCLOCKGATING)
224 IMG_BOOL bDisableClockGating;
225#endif
223 SGX_INIT_SCRIPTS sScripts; 226 SGX_INIT_SCRIPTS sScripts;
224 227
225 /* Members associated with dummy PD needed for BIF reset */ 228 /* Members associated with dummy PD needed for BIF reset */
@@ -252,8 +255,6 @@ typedef struct _PVRSRV_SGXDEV_INFO_
252 PVRSRV_KERNEL_MEM_INFO *psKernelSGXPTLAWriteBackMemInfo; 255 PVRSRV_KERNEL_MEM_INFO *psKernelSGXPTLAWriteBackMemInfo;
253#endif 256#endif
254 257
255 IMG_UINT32 ui32Flags;
256
257 /* memory tiling range usage */ 258 /* memory tiling range usage */
258 IMG_UINT32 ui32MemTilingUsage; 259 IMG_UINT32 ui32MemTilingUsage;
259 260
@@ -471,19 +472,9 @@ typedef struct _SGX_CCB_KICK_KM_
471 /* CCB offset of data structure associated with this kick */ 472 /* CCB offset of data structure associated with this kick */
472 IMG_UINT32 ui32CCBOffset; 473 IMG_UINT32 ui32CCBOffset;
473 474
474#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
475 /* SRC and DST syncs */
476 IMG_UINT32 ui32NumTASrcSyncs;
477 IMG_HANDLE ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS];
478 IMG_UINT32 ui32NumTADstSyncs;
479 IMG_HANDLE ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS];
480 IMG_UINT32 ui32Num3DSrcSyncs;
481 IMG_HANDLE ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS];
482#else
483 /* SRC syncs */ 475 /* SRC syncs */
484 IMG_UINT32 ui32NumSrcSyncs; 476 IMG_UINT32 ui32NumSrcSyncs;
485 IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS_TA]; 477 IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS_TA];
486#endif
487 478
488 /* TA/3D dependency data */ 479 /* TA/3D dependency data */
489 IMG_BOOL bTADependency; 480 IMG_BOOL bTADependency;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinit.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinit.c
index 8614c45..c6736a1 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinit.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxinit.c
@@ -298,6 +298,9 @@ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc,
298 psDevInfo->ui32MasterClkGateStatus2Reg = psInitInfo->ui32MasterClkGateStatus2Reg; 298 psDevInfo->ui32MasterClkGateStatus2Reg = psInitInfo->ui32MasterClkGateStatus2Reg;
299 psDevInfo->ui32MasterClkGateStatus2Mask = psInitInfo->ui32MasterClkGateStatus2Mask; 299 psDevInfo->ui32MasterClkGateStatus2Mask = psInitInfo->ui32MasterClkGateStatus2Mask;
300#endif /* SGX_FEATURE_MP */ 300#endif /* SGX_FEATURE_MP */
301#if defined(SGX_FEATURE_AUTOCLOCKGATING)
302 psDevInfo->bDisableClockGating = psInitInfo->bDisableClockGating;
303#endif
301 304
302 305
303 /* Initialise Dev Data */ 306 /* Initialise Dev Data */
@@ -1377,7 +1380,11 @@ IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo,
1377 host thinks the fault is correct 1380 host thinks the fault is correct
1378 */ 1381 */
1379 ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_INT_STAT); 1382 ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_INT_STAT);
1383 #if defined(EUR_CR_BIF_INT_STAT_PF_N_RW_MASK)
1380 if (ui32RegVal & EUR_CR_BIF_INT_STAT_PF_N_RW_MASK) 1384 if (ui32RegVal & EUR_CR_BIF_INT_STAT_PF_N_RW_MASK)
1385 #else
1386 if (ui32RegVal & EUR_CR_BIF_INT_STAT_FAULT_TYPE_MASK)
1387 #endif
1381 { 1388 {
1382 ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_FAULT); 1389 ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_FAULT);
1383 ui32RegVal &= EUR_CR_BIF_FAULT_ADDR_MASK; 1390 ui32RegVal &= EUR_CR_BIF_FAULT_ADDR_MASK;
@@ -2102,12 +2109,10 @@ static IMG_VOID SGX_MISRHandler (IMG_VOID *pvData)
2102 HWRecoveryResetSGX(psDeviceNode, 0, ISR_ID); 2109 HWRecoveryResetSGX(psDeviceNode, 0, ISR_ID);
2103 } 2110 }
2104 2111
2105#if defined(OS_SUPPORTS_IN_LISR)
2106 if (psDeviceNode->bReProcessDeviceCommandComplete) 2112 if (psDeviceNode->bReProcessDeviceCommandComplete)
2107 { 2113 {
2108 SGXScheduleProcessQueuesKM(psDeviceNode); 2114 SGXScheduleProcessQueuesKM(psDeviceNode);
2109 } 2115 }
2110#endif
2111 2116
2112 SGXTestActivePowerEvent(psDeviceNode, ISR_ID); 2117 SGXTestActivePowerEvent(psDeviceNode, ISR_ID);
2113 2118
@@ -2307,12 +2312,34 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode)
2307 psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT; 2312 psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT;
2308 /* set the default (4k). System can override these as required */ 2313 /* set the default (4k). System can override these as required */
2309 psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE; 2314 psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE;
2310#if !defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP) 2315#if !defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP) && !defined(SGX5300)
2311 /* specify the mapping heap ID for this device */ 2316 /* specify the mapping heap ID for this device */
2312 psDevMemoryInfo->ui32MappingHeapID = (IMG_UINT32)(psDeviceMemoryHeap - psDevMemoryInfo->psDeviceMemoryHeap); 2317 psDevMemoryInfo->ui32MappingHeapID = (IMG_UINT32)(psDeviceMemoryHeap - psDevMemoryInfo->psDeviceMemoryHeap);
2313#endif 2318#endif
2314 psDeviceMemoryHeap++;/* advance to the next heap */ 2319 psDeviceMemoryHeap++;/* advance to the next heap */
2315 2320
2321#if defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION)
2322 /************* Texture Heap ***************/
2323 psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_TEXTURE_HEAP_ID);
2324 psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_TEXTURE_HEAP_BASE;
2325 psDeviceMemoryHeap->ui32HeapSize = SGX_TEXTURE_HEAP_SIZE;
2326 psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE
2327 | PVRSRV_MEM_RAM_BACKED_ALLOCATION
2328 | PVRSRV_HAP_SINGLE_PROCESS;
2329
2330 psDeviceMemoryHeap->pszName = "Texture";
2331 psDeviceMemoryHeap->pszBSName = "Texture BS";
2332 psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT;
2333 /* set the default (4k). System can override these as required */
2334 psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE;
2335 /* The mapping heap ID should be texture heap for SGX5300 */
2336#if !defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP) && defined(SGX5300)
2337 /* specify the mapping heap ID for this device */
2338 psDevMemoryInfo->ui32MappingHeapID = (IMG_UINT32)(psDeviceMemoryHeap - psDevMemoryInfo->psDeviceMemoryHeap);
2339#endif
2340 psDeviceMemoryHeap++;/* advance to the next heap */
2341#endif
2342
2316#if defined(SUPPORT_MEMORY_TILING) 2343#if defined(SUPPORT_MEMORY_TILING)
2317 /************* VPB tiling ***************/ 2344 /************* VPB tiling ***************/
2318 psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_VPB_TILED_HEAP_ID); 2345 psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_VPB_TILED_HEAP_ID);
@@ -2686,16 +2713,16 @@ PVRSRV_ERROR SGXDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode)
2686 ui32BuildOptionsMismatch = ui32BuildOptions ^ psDevInfo->ui32ClientBuildOptions; 2713 ui32BuildOptionsMismatch = ui32BuildOptions ^ psDevInfo->ui32ClientBuildOptions;
2687 if ( (psDevInfo->ui32ClientBuildOptions & ui32BuildOptionsMismatch) != 0) 2714 if ( (psDevInfo->ui32ClientBuildOptions & ui32BuildOptionsMismatch) != 0)
2688 { 2715 {
2689 PVR_LOG(("(FAIL) SGXInit: Mismatch in client-side and KM driver build options; " 2716 PVR_LOG(("(FAIL) SGXInit: Mismatch in client-side and KM driver build options."));
2690 "extra options present in client-side driver: (0x%x). Please check sgx_options.h", 2717 PVR_LOG(("Extra options present in client-side driver: (0x%x). Please check sgx_options.h",
2691 psDevInfo->ui32ClientBuildOptions & ui32BuildOptionsMismatch )); 2718 psDevInfo->ui32ClientBuildOptions & ui32BuildOptionsMismatch));
2692 } 2719 }
2693 2720
2694 if ( (ui32BuildOptions & ui32BuildOptionsMismatch) != 0) 2721 if ( (ui32BuildOptions & ui32BuildOptionsMismatch) != 0)
2695 { 2722 {
2696 PVR_LOG(("(FAIL) SGXInit: Mismatch in client-side and KM driver build options; " 2723 PVR_LOG(("(FAIL) SGXInit: Mismatch in client-side and KM driver build options."));
2697 "extra options present in KM: (0x%x). Please check sgx_options.h", 2724 PVR_LOG(("Extra options present in KM: (0x%x). Please check sgx_options.h",
2698 ui32BuildOptions & ui32BuildOptionsMismatch )); 2725 ui32BuildOptions & ui32BuildOptionsMismatch));
2699 } 2726 }
2700 eError = PVRSRV_ERROR_BUILD_MISMATCH; 2727 eError = PVRSRV_ERROR_BUILD_MISMATCH;
2701 goto chk_exit; 2728 goto chk_exit;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxkick.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxkick.c
index a03f51a..878cdd6 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxkick.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxkick.c
@@ -61,6 +61,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61#include "systrace.h" 61#include "systrace.h"
62#endif 62#endif
63 63
64#if defined(SUPPORT_DMABUF)
65#include "pvr_linux_fence.h"
66#endif
67
64/*! 68/*!
65****************************************************************************** 69******************************************************************************
66 70
@@ -84,6 +88,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
84 SGXMKIF_CMDTA_SHARED *psTACmd; 88 SGXMKIF_CMDTA_SHARED *psTACmd;
85 IMG_UINT32 i; 89 IMG_UINT32 i;
86 IMG_HANDLE hDevMemContext = IMG_NULL; 90 IMG_HANDLE hDevMemContext = IMG_NULL;
91#if defined(SUPPORT_DMABUF)
92 IMG_UINT32 ui32FenceTag = 0;
93#endif
87#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE) 94#if defined(SUPPORT_PVRSRV_ANDROID_SYSTRACE)
88 PVRSRV_DEVICE_NODE *psDeviceNode; 95 PVRSRV_DEVICE_NODE *psDeviceNode;
89 PVRSRV_SGXDEV_INFO *psDevInfo; 96 PVRSRV_SGXDEV_INFO *psDevInfo;
@@ -210,50 +217,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
210 } 217 }
211 218
212 219
213#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
214 /* SRC and DST sync dependencies */
215 psTACmd->ui32NumTASrcSyncs = psCCBKick->ui32NumTASrcSyncs;
216 for (i=0; i<psCCBKick->ui32NumTASrcSyncs; i++)
217 {
218 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTASrcKernelSyncInfo[i];
219
220 psTACmd->asTASrcSyncs[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr;
221 psTACmd->asTASrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr;
222
223 /* Get ui32ReadOpsPending snapshot and copy into the CCB - before incrementing. */
224 psTACmd->asTASrcSyncs[i].ui32ReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
225 /* Copy ui32WriteOpsPending snapshot into the CCB. */
226 psTACmd->asTASrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending;
227 }
228
229 psTACmd->ui32NumTADstSyncs = psCCBKick->ui32NumTADstSyncs;
230 for (i=0; i<psCCBKick->ui32NumTADstSyncs; i++)
231 {
232 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTADstKernelSyncInfo[i];
233
234 psTACmd->asTADstSyncs[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr;
235 psTACmd->asTADstSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr;
236
237 /* Get ui32ReadOpsPending snapshot and copy into the CCB */
238 psTACmd->asTADstSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending;
239 /* Copy ui32WriteOpsPending snapshot into the CCB - before incrementing */
240 psTACmd->asTADstSyncs[i].ui32WriteOpsPendingVal = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
241 }
242
243 psTACmd->ui32Num3DSrcSyncs = psCCBKick->ui32Num3DSrcSyncs;
244 for (i=0; i<psCCBKick->ui32Num3DSrcSyncs; i++)
245 {
246 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ah3DSrcKernelSyncInfo[i];
247
248 psTACmd->as3DSrcSyncs[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr;
249 psTACmd->as3DSrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr;
250
251 /* Get ui32ReadOpsPending snapshot and copy into the CCB - before incrementing. */
252 psTACmd->as3DSrcSyncs[i].ui32ReadOpsPendingVal = SyncTakeReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
253 /* Copy ui32WriteOpsPending snapshot into the CCB. */
254 psTACmd->as3DSrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending;
255 }
256#else /* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
257 /* texture dependencies */ 220 /* texture dependencies */
258#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 221#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
259 eError = PVRSyncPatchCCBKickSyncInfos(psCCBKick->ahSrcKernelSyncInfo, 222 eError = PVRSyncPatchCCBKickSyncInfos(psCCBKick->ahSrcKernelSyncInfo,
@@ -290,6 +253,19 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
290 return eError; 253 return eError;
291 } 254 }
292#else /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ 255#else /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */
256#if defined(SUPPORT_DMABUF)
257 eError = PVRLinuxFenceProcess(&ui32FenceTag,
258 psCCBKick->ui32NumSrcSyncs,
259 psCCBKick->ahSrcKernelSyncInfo,
260 NULL,
261 psCCBKick->bFirstKickOrResume ? psCCBKick->ui32NumDstSyncObjects : 0,
262 psCCBKick->pahDstSyncHandles,
263 NULL);
264 if (eError != PVRSRV_OK)
265 {
266 return eError;
267 }
268#endif
293 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++) 269 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++)
294 { 270 {
295 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; 271 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i];
@@ -307,7 +283,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
307 } 283 }
308#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ 284#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */
309 psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs; 285 psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs;
310#endif /* defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */
311 286
312 if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0) 287 if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0)
313 { 288 {
@@ -451,109 +426,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
451 0, 426 0,
452 MAKEUNIQUETAG(psCCBMemInfo)); 427 MAKEUNIQUETAG(psCCBMemInfo));
453 428
454#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
455 for (i=0; i<psCCBKick->ui32NumTASrcSyncs; i++)
456 {
457 IMG_UINT32 ui32ModifiedValue;
458 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTASrcKernelSyncInfo[i];
459
460 psSyncInfo->psSyncData->ui32LastReadOpDumpVal++;
461
462 ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastReadOpDumpVal - 1;
463
464 PDUMPCOMMENT("Modify TA SrcSync %d ROpsPendingVal\r\n", i);
465
466 PDUMPMEM(&ui32ModifiedValue,
467 psCCBMemInfo,
468 psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, asTASrcSyncs) +
469 (i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT)) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal),
470 sizeof(IMG_UINT32),
471 0,
472 MAKEUNIQUETAG(psCCBMemInfo));
473
474 PDUMPCOMMENT("Modify TA SrcSync %d WOpPendingVal\r\n", i);
475
476 PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal,
477 psCCBMemInfo,
478 psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, asTASrcSyncs) +
479 (i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT)) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal),
480 sizeof(IMG_UINT32),
481 0,
482 MAKEUNIQUETAG(psCCBMemInfo));
483 }
484
485 for (i=0; i<psCCBKick->ui32NumTADstSyncs; i++)
486 {
487 IMG_UINT32 ui32ModifiedValue;
488 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTADstKernelSyncInfo[i];
489
490 psSyncInfo->psSyncData->ui32LastOpDumpVal++;
491
492 ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastOpDumpVal - 1;
493
494 PDUMPCOMMENT("Modify TA DstSync %d WOpPendingVal\r\n", i);
495
496#if defined(SUPPORT_PDUMP_SYNC_DEBUG)
497 PDUMPCOMMENT("TA TADst: PDump sync sample: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n",
498 psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr
499 ui32ModifiedValue;
500#endif
501
502 PDUMPMEM(&ui32ModifiedValue,
503 psCCBMemInfo,
504 psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, asTADstSyncs) +
505 (i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT)) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal),
506 sizeof(IMG_UINT32),
507 0,
508 MAKEUNIQUETAG(psCCBMemInfo));
509
510 PDUMPCOMMENT("Modify TA DstSync %d ROpsPendingVal\r\n", i);
511
512 PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal,
513 psCCBMemInfo,
514 psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, asTADstSyncs) +
515 (i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT)) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal),
516 sizeof(IMG_UINT32),
517 0,
518 MAKEUNIQUETAG(psCCBMemInfo));
519
520#if defined(SUPPORT_PDUMP_SYNC_DEBUG)
521 PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_PERSISTENT, "TA TADst: PDump sync update: uiAddr = 0x%08x, ui32LastOpDumpVal = 0x%08x\r\n",
522 psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr
523 psSyncInfo->psSyncData->ui32LastOpDumpVal);
524#endif
525 }
526
527 for (i=0; i<psCCBKick->ui32Num3DSrcSyncs; i++)
528 {
529 IMG_UINT32 ui32ModifiedValue;
530 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ah3DSrcKernelSyncInfo[i];
531
532 psSyncInfo->psSyncData->ui32LastReadOpDumpVal++;
533
534 ui32ModifiedValue = psSyncInfo->psSyncData->ui32LastReadOpDumpVal - 1;
535
536 PDUMPCOMMENT("Modify 3D SrcSync %d ROpsPendingVal\r\n", i);
537
538 PDUMPMEM(&ui32ModifiedValue,
539 psCCBMemInfo,
540 psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, as3DSrcSyncs) +
541 (i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT)) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal),
542 sizeof(IMG_UINT32),
543 0,
544 MAKEUNIQUETAG(psCCBMemInfo));
545
546 PDUMPCOMMENT("Modify 3D SrcSync %d WOpPendingVal\r\n", i);
547
548 PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal,
549 psCCBMemInfo,
550 psCCBKick->ui32CCBDumpWOff + offsetof(SGXMKIF_CMDTA_SHARED, as3DSrcSyncs) +
551 (i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT)) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal),
552 sizeof(IMG_UINT32),
553 0,
554 MAKEUNIQUETAG(psCCBMemInfo));
555 }
556#else/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
557 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++) 429 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++)
558 { 430 {
559 IMG_UINT32 ui32ModifiedValue; 431 IMG_UINT32 ui32ModifiedValue;
@@ -689,8 +561,6 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
689 psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; 561 psSyncInfo->psSyncData->ui32LastReadOpDumpVal++;
690 } 562 }
691 563
692#endif/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
693
694 for (i = 0; i < psCCBKick->ui32NumTAStatusVals; i++) 564 for (i = 0; i < psCCBKick->ui32NumTAStatusVals; i++)
695 { 565 {
696#if !defined(SUPPORT_SGX_NEW_STATUS_VALS) 566#if !defined(SUPPORT_SGX_NEW_STATUS_VALS)
@@ -727,6 +597,15 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
727 eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_TA, &psCCBKick->sCommand, KERNEL_ID, 0, hDevMemContext, psCCBKick->bLastInScene); 597 eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_TA, &psCCBKick->sCommand, KERNEL_ID, 0, hDevMemContext, psCCBKick->bLastInScene);
728 if (eError == PVRSRV_ERROR_RETRY) 598 if (eError == PVRSRV_ERROR_RETRY)
729 { 599 {
600#if defined(SUPPORT_DMABUF)
601 PVRLinuxFenceRelease(ui32FenceTag,
602 psCCBKick->ui32NumSrcSyncs,
603 psCCBKick->ahSrcKernelSyncInfo,
604 NULL,
605 psCCBKick->bFirstKickOrResume ? psCCBKick->ui32NumDstSyncObjects : 0,
606 psCCBKick->pahDstSyncHandles,
607 NULL);
608#endif
730 if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0) 609 if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0)
731 { 610 {
732 for (i=0; i < psCCBKick->ui32NumDstSyncObjects; i++) 611 for (i=0; i < psCCBKick->ui32NumDstSyncObjects; i++)
@@ -748,33 +627,12 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
748 } 627 }
749 } 628 }
750 629
751#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
752 for (i=0; i<psCCBKick->ui32NumTASrcSyncs; i++)
753 {
754 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTASrcKernelSyncInfo[i];
755 psSyncInfo->psSyncData->ui32ReadOpsPending--;
756 SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
757 }
758 for (i=0; i<psCCBKick->ui32NumTADstSyncs; i++)
759 {
760 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTADstKernelSyncInfo[i];
761 psSyncInfo->psSyncData->ui32WriteOpsPending--;
762 SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
763 }
764 for (i=0; i<psCCBKick->ui32Num3DSrcSyncs; i++)
765 {
766 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ah3DSrcKernelSyncInfo[i];
767 psSyncInfo->psSyncData->ui32ReadOpsPending--;
768 SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
769 }
770#else/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
771 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++) 630 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++)
772 { 631 {
773 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; 632 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i];
774 psSyncInfo->psSyncData->ui32ReadOpsPending--; 633 psSyncInfo->psSyncData->ui32ReadOpsPending--;
775 SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA); 634 SyncRollBackReadOp(psSyncInfo, SYNC_OP_CLASS_KICKTA);
776 } 635 }
777#endif/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
778 636
779 if (psCCBKick->hTA3DSyncInfo) 637 if (psCCBKick->hTA3DSyncInfo)
780 { 638 {
@@ -806,6 +664,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
806 PVR_DPF((PVR_DBG_ERROR, "SGXDoKickKM: SGXScheduleCCBCommandKM failed.")); 664 PVR_DPF((PVR_DBG_ERROR, "SGXDoKickKM: SGXScheduleCCBCommandKM failed."));
807 PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, 665 PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT,
808 KICK_TOKEN_DOKICK); 666 KICK_TOKEN_DOKICK);
667#if defined(SUPPORT_DMABUF) && defined(NO_HARDWARE)
668 PVRLinuxFenceCheckAll();
669#endif
809 return eError; 670 return eError;
810 } 671 }
811 672
@@ -853,31 +714,12 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
853#endif 714#endif
854 } 715 }
855 716
856#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
857 /* SRC and DST dependencies */
858 for (i=0; i<psCCBKick->ui32NumTASrcSyncs; i++)
859 {
860 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTASrcKernelSyncInfo[i];
861 psSyncInfo->psSyncData->ui32ReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending;
862 }
863 for (i=0; i<psCCBKick->ui32NumTADstSyncs; i++)
864 {
865 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahTADstKernelSyncInfo[i];
866 psSyncInfo->psSyncData->ui32WriteOpsComplete = psSyncInfo->psSyncData->ui32WriteOpsPending;
867 }
868 for (i=0; i<psCCBKick->ui32Num3DSrcSyncs; i++)
869 {
870 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ah3DSrcKernelSyncInfo[i];
871 psSyncInfo->psSyncData->ui32ReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending;
872 }
873#else/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
874 /* texture dependencies */ 717 /* texture dependencies */
875 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++) 718 for (i=0; i<psCCBKick->ui32NumSrcSyncs; i++)
876 { 719 {
877 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; 720 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i];
878 psSyncInfo->psSyncData->ui32ReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending; 721 psSyncInfo->psSyncData->ui32ReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending;
879 } 722 }
880#endif/* SUPPORT_SGX_GENERALISED_SYNCOBJECTS */
881 723
882 if (psCCBKick->bTerminateOrAbort) 724 if (psCCBKick->bTerminateOrAbort)
883 { 725 {
@@ -910,6 +752,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick)
910#endif 752#endif
911 } 753 }
912 } 754 }
755#if defined(SUPPORT_DMABUF)
756 PVRLinuxFenceCheckAll();
757#endif
913#endif 758#endif
914 PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, 759 PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT,
915 KICK_TOKEN_DOKICK); 760 KICK_TOKEN_DOKICK);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxpower.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxpower.c
index a4ef276..75cdd06 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxpower.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxpower.c
@@ -227,6 +227,7 @@ static IMG_VOID SGXStartTimer(PVRSRV_SGXDEV_INFO *psDevInfo)
227} 227}
228 228
229 229
230#if defined(SGX_FEATURE_AUTOCLOCKGATING)
230/*! 231/*!
231****************************************************************************** 232******************************************************************************
232 233
@@ -274,6 +275,7 @@ static IMG_VOID SGXPollForClockGating (PVRSRV_SGXDEV_INFO *psDevInfo,
274 PDUMPCOMMENT("%s", pszComment); 275 PDUMPCOMMENT("%s", pszComment);
275 PDUMPREGPOL(SGX_PDUMPREG_NAME, ui32Register, 0, ui32RegisterValue, PDUMP_POLL_OPERATOR_EQUAL); 276 PDUMPREGPOL(SGX_PDUMPREG_NAME, ui32Register, 0, ui32RegisterValue, PDUMP_POLL_OPERATOR_EQUAL);
276} 277}
278#endif
277 279
278 280
279/*! 281/*!
@@ -304,8 +306,10 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle,
304 PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; 306 PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
305 IMG_UINT32 ui32PowerCmd, ui32CompleteStatus; 307 IMG_UINT32 ui32PowerCmd, ui32CompleteStatus;
306 SGXMKIF_COMMAND sCommand = {0}; 308 SGXMKIF_COMMAND sCommand = {0};
309#if defined(SGX_FEATURE_AUTOCLOCKGATING)
307 IMG_UINT32 ui32Core; 310 IMG_UINT32 ui32Core;
308 IMG_UINT32 ui32CoresEnabled; 311 IMG_UINT32 ui32CoresEnabled;
312#endif
309 313
310 #if defined(SUPPORT_HW_RECOVERY) 314 #if defined(SUPPORT_HW_RECOVERY)
311 /* Disable timer callback for HW recovery */ 315 /* Disable timer callback for HW recovery */
@@ -387,33 +391,39 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle,
387 PVR_DBG_BREAK; 391 PVR_DBG_BREAK;
388 } 392 }
389 #endif /* NO_HARDWARE && SUPPORT_LISR_MISR_SYNC*/ 393 #endif /* NO_HARDWARE && SUPPORT_LISR_MISR_SYNC*/
394
395#if defined(SGX_FEATURE_AUTOCLOCKGATING)
396 if(psDevInfo->bDisableClockGating == IMG_FALSE)
397 {
390#if defined(SGX_FEATURE_MP) 398#if defined(SGX_FEATURE_MP)
391 ui32CoresEnabled = ((OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE) & EUR_CR_MASTER_CORE_ENABLE_MASK) >> EUR_CR_MASTER_CORE_ENABLE_SHIFT) + 1; 399 ui32CoresEnabled = ((OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE) & EUR_CR_MASTER_CORE_ENABLE_MASK) >> EUR_CR_MASTER_CORE_ENABLE_SHIFT) + 1;
392#else 400#else
393 ui32CoresEnabled = 1; 401 ui32CoresEnabled = 1;
394#endif 402#endif
395 403
396 for (ui32Core = 0; ui32Core < ui32CoresEnabled; ui32Core++) 404 for (ui32Core = 0; ui32Core < ui32CoresEnabled; ui32Core++)
397 { 405 {
398 /* Wait for SGX clock gating. */ 406 /* Wait for SGX clock gating. */
407 SGXPollForClockGating(psDevInfo,
408 SGX_MP_CORE_SELECT(psDevInfo->ui32ClkGateStatusReg, ui32Core),
409 psDevInfo->ui32ClkGateStatusMask,
410 "Wait for SGX clock gating");
411 }
412
413#if defined(SGX_FEATURE_MP)
414 /* Wait for SGX master clock gating. */
399 SGXPollForClockGating(psDevInfo, 415 SGXPollForClockGating(psDevInfo,
400 SGX_MP_CORE_SELECT(psDevInfo->ui32ClkGateStatusReg, ui32Core), 416 psDevInfo->ui32MasterClkGateStatusReg,
401 psDevInfo->ui32ClkGateStatusMask, 417 psDevInfo->ui32MasterClkGateStatusMask,
402 "Wait for SGX clock gating"); 418 "Wait for SGX master clock gating");
403 }
404 419
405 #if defined(SGX_FEATURE_MP) 420 SGXPollForClockGating(psDevInfo,
406 /* Wait for SGX master clock gating. */ 421 psDevInfo->ui32MasterClkGateStatus2Reg,
407 SGXPollForClockGating(psDevInfo, 422 psDevInfo->ui32MasterClkGateStatus2Mask,
408 psDevInfo->ui32MasterClkGateStatusReg, 423 "Wait for SGX master clock gating (2)");
409 psDevInfo->ui32MasterClkGateStatusMask, 424#endif /* SGX_FEATURE_MP */
410 "Wait for SGX master clock gating"); 425 }
411 426#endif /* defined(SGX_FEATURE_AUTOCLOCKGATING) */
412 SGXPollForClockGating(psDevInfo,
413 psDevInfo->ui32MasterClkGateStatus2Reg,
414 psDevInfo->ui32MasterClkGateStatus2Mask,
415 "Wait for SGX master clock gating (2)");
416 #endif /* SGX_FEATURE_MP */
417 427
418 if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF) 428 if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF)
419 { 429 {
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxreset.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxreset.c
index 2b7aa4c..ecf0e62 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxreset.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxreset.c
@@ -649,6 +649,12 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo,
649 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_TWOD_REQ_BASE, SGX_2D_HEAP_BASE, ui32PDUMPFlags); 649 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_TWOD_REQ_BASE, SGX_2D_HEAP_BASE, ui32PDUMPFlags);
650#endif 650#endif
651 651
652#if defined(SGX_FEATURE_ADDRESS_SPACE_EXTENSION)
653 /*TODO: Set up USEC requestor base, here its set to ZERO (hard-coded) */
654 OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_USEC_REQ_BASE, 0);
655 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_USEC_REQ_BASE, 0, ui32PDUMPFlags);
656#endif
657
652 /* Invalidate BIF Directory cache. */ 658 /* Invalidate BIF Directory cache. */
653 SGXResetInvalDC(psDevInfo, ui32PDUMPFlags, IMG_TRUE); 659 SGXResetInvalDC(psDevInfo, ui32PDUMPFlags, IMG_TRUE);
654 660
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxtransfer.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxtransfer.c
index 74dbc99..430b750 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxtransfer.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxtransfer.c
@@ -62,6 +62,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62#include "pvr_sync.h" 62#include "pvr_sync.h"
63#endif 63#endif
64 64
65#if defined(SUPPORT_DMABUF)
66#include "pvr_linux_fence.h"
67#endif
68
65IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick) 69IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick)
66{ 70{
67 PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; 71 PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo;
@@ -76,22 +80,11 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF
76 IMG_BOOL abDstSyncEnable[SGX_MAX_TRANSFER_SYNC_OPS]; 80 IMG_BOOL abDstSyncEnable[SGX_MAX_TRANSFER_SYNC_OPS];
77 IMG_UINT32 ui32RealDstSyncNum = 0; 81 IMG_UINT32 ui32RealDstSyncNum = 0;
78 82
83#if defined(SUPPORT_DMABUF)
84 IMG_UINT32 ui32FenceTag;
85#endif
86
79 87
80#if defined(PDUMP)
81 IMG_BOOL bPersistentProcess = IMG_FALSE;
82 /*
83 * For persistent processes, the HW kicks should not go into the
84 * extended init phase; only keep memory transactions from the
85 * window system which are necessary to run the client app.
86 */
87 {
88 PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData();
89 if(psPerProc != IMG_NULL)
90 {
91 bPersistentProcess = psPerProc->bPDumpPersistent;
92 }
93 }
94#endif /* PDUMP */
95#if defined(FIX_HW_BRN_31620) 88#if defined(FIX_HW_BRN_31620)
96 hDevMemContext = psKick->hDevMemContext; 89 hDevMemContext = psKick->hDevMemContext;
97#endif 90#endif
@@ -214,6 +207,20 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF
214 { 207 {
215 IMG_UINT32 i = 0; 208 IMG_UINT32 i = 0;
216 209
210#if defined(SUPPORT_DMABUF)
211 eError = PVRLinuxFenceProcess(&ui32FenceTag,
212 psKick->ui32NumSrcSync,
213 psKick->ahSrcSyncInfo,
214 abSrcSyncEnable,
215 psKick->ui32NumDstSync,
216 psKick->ahDstSyncInfo,
217 abDstSyncEnable);
218
219 if (eError != PVRSRV_OK)
220 {
221 return eError;
222 }
223#endif
217 for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) 224 for (loop = 0; loop < psKick->ui32NumSrcSync; loop++)
218 { 225 {
219 if (abSrcSyncEnable[loop]) 226 if (abSrcSyncEnable[loop])
@@ -281,7 +288,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF
281 } 288 }
282 289
283#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 290#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
284 if (ui32RealDstSyncNum < SGX_MAX_TRANSFER_SYNC_OPS - 2 && psKick->iFenceFd > 0) 291 if (ui32RealDstSyncNum <= (SGX_MAX_DST_SYNCS_TQ - 1) && psKick->iFenceFd > 0)
285 { 292 {
286 IMG_HANDLE ahSyncInfo[SGX_MAX_SRC_SYNCS_TA]; 293 IMG_HANDLE ahSyncInfo[SGX_MAX_SRC_SYNCS_TA];
287 PVRSRV_DEVICE_SYNC_OBJECT *apsDevSyncs = &psSharedTransferCmd->asDstSyncs[ui32RealDstSyncNum]; 294 PVRSRV_DEVICE_SYNC_OBJECT *apsDevSyncs = &psSharedTransferCmd->asDstSyncs[ui32RealDstSyncNum];
@@ -561,6 +568,15 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF
561 /* Client will retry, so undo the sync ops pending increment(s) done above. */ 568 /* Client will retry, so undo the sync ops pending increment(s) done above. */
562 if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) 569 if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL)
563 { 570 {
571#if defined(SUPPORT_DMABUF)
572 PVRLinuxFenceRelease(ui32FenceTag,
573 psKick->ui32NumSrcSync,
574 psKick->ahSrcSyncInfo,
575 abSrcSyncEnable,
576 psKick->ui32NumDstSync,
577 psKick->ahDstSyncInfo,
578 abDstSyncEnable);
579#endif
564 for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) 580 for (loop = 0; loop < psKick->ui32NumSrcSync; loop++)
565 { 581 {
566 if (abSrcSyncEnable[loop]) 582 if (abSrcSyncEnable[loop])
@@ -607,15 +623,17 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF
607 SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D); 623 SyncRollBackWriteOp(psSyncInfo, SYNC_OP_CLASS_TQ_3D);
608 } 624 }
609 } 625 }
610
611 else if (PVRSRV_OK != eError) 626 else if (PVRSRV_OK != eError)
612 { 627 {
613 PVR_DPF((PVR_DBG_ERROR, "SGXSubmitTransferKM: SGXScheduleCCBCommandKM failed.")); 628 PVR_DPF((PVR_DBG_ERROR, "SGXSubmitTransferKM: SGXScheduleCCBCommandKM failed."));
614 PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, 629 PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_EXIT,
615 TRANSFER_TOKEN_SUBMIT); 630 TRANSFER_TOKEN_SUBMIT);
631#if defined(SUPPORT_DMABUF) && defined(NO_HARDWARE)
632 PVRLinuxFenceCheckAll();
633#endif
616 return eError; 634 return eError;
617 } 635 }
618 636
619 637
620#if defined(NO_HARDWARE) 638#if defined(NO_HARDWARE)
621 if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_NOSYNCUPDATE) == 0) 639 if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_NOSYNCUPDATE) == 0)
@@ -940,6 +958,9 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK
940 958
941 psSyncInfo->psSyncData->ui32WriteOpsComplete = psSyncInfo->psSyncData->ui32WriteOpsPending; 959 psSyncInfo->psSyncData->ui32WriteOpsComplete = psSyncInfo->psSyncData->ui32WriteOpsPending;
942 } 960 }
961#if defined(SUPPORT_DMABUF)
962 PVRLinuxFenceCheckAll();
963#endif
943#endif 964#endif
944 965
945 return eError; 966 return eError;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxutils.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxutils.c
index b1d2b13..bce7945 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxutils.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/devices/sgx/sgxutils.c
@@ -190,8 +190,10 @@ IMG_VOID SGXTestActivePowerEvent (PVRSRV_DEVICE_NODE *psDeviceNode,
190 /* Microkernel is idle and is requesting to be powered down. */ 190 /* Microkernel is idle and is requesting to be powered down. */
191 psSGXHostCtl->ui32InterruptClearFlags |= PVRSRV_USSE_EDM_INTERRUPT_ACTIVE_POWER; 191 psSGXHostCtl->ui32InterruptClearFlags |= PVRSRV_USSE_EDM_INTERRUPT_ACTIVE_POWER;
192 192
193 /* Suspend pdumping. */ 193#if !defined(SUPPORT_PDUMP_MULTI_PROCESS)
194 /* Suspend pdumping. */
194 PDUMPSUSPEND(); 195 PDUMPSUSPEND();
196#endif
195 197
196#if defined(SYS_CUSTOM_POWERDOWN) 198#if defined(SYS_CUSTOM_POWERDOWN)
197 /* 199 /*
@@ -207,8 +209,10 @@ IMG_VOID SGXTestActivePowerEvent (PVRSRV_DEVICE_NODE *psDeviceNode,
207 { 209 {
208 SGXPostActivePowerEvent(psDeviceNode, ui32CallerID); 210 SGXPostActivePowerEvent(psDeviceNode, ui32CallerID);
209 } 211 }
212#if !defined(SUPPORT_PDUMP_MULTI_PROCESS)
210 /* Resume pdumping */ 213 /* Resume pdumping */
211 PDUMPRESUME(); 214 PDUMPRESUME();
215#endif
212 } 216 }
213 217
214 PVRSRVPowerUnlock(ui32CallerID); 218 PVRSRVPowerUnlock(ui32CallerID);
@@ -325,7 +329,7 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode,
325#if defined(FIX_HW_BRN_28889) 329#if defined(FIX_HW_BRN_28889)
326 /* 330 /*
327 If the data cache and bif cache need invalidating there has been a cleanup 331 If the data cache and bif cache need invalidating there has been a cleanup
328 request. Therefore, we need to send the invalidate seperately and wait 332 request. Therefore, we need to send the invalidate separately and wait
329 for it to complete. 333 for it to complete.
330 */ 334 */
331 if ( (eCmdType != SGXMKIF_CMD_PROCESS_QUEUES) && 335 if ( (eCmdType != SGXMKIF_CMD_PROCESS_QUEUES) &&
@@ -699,6 +703,9 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode,
699 return eError; 703 return eError;
700 } 704 }
701 705
706#if defined(SUPPORT_PDUMP_MULTI_PROCESS)
707 PDUMP_LOCK();
708#endif
702 /* Note that a power-up has been dumped in the init phase. */ 709 /* Note that a power-up has been dumped in the init phase. */
703 PDUMPSUSPEND(); 710 PDUMPSUSPEND();
704 711
@@ -707,6 +714,9 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode,
707 PVRSRV_DEV_POWER_STATE_ON); 714 PVRSRV_DEV_POWER_STATE_ON);
708 715
709 PDUMPRESUME(); 716 PDUMPRESUME();
717#if defined(SUPPORT_PDUMP_MULTI_PROCESS)
718 PDUMP_UNLOCK();
719#endif
710 720
711 if (eError == PVRSRV_OK) 721 if (eError == PVRSRV_OK)
712 { 722 {
@@ -759,7 +769,7 @@ PVRSRV_ERROR SGXScheduleProcessQueuesKM(PVRSRV_DEVICE_NODE *psDeviceNode)
759 ui32PowerStatus = psHostCtl->ui32PowerStatus; 769 ui32PowerStatus = psHostCtl->ui32PowerStatus;
760 if ((ui32PowerStatus & PVRSRV_USSE_EDM_POWMAN_NO_WORK) != 0) 770 if ((ui32PowerStatus & PVRSRV_USSE_EDM_POWMAN_NO_WORK) != 0)
761 { 771 {
762 /* The ukernel has no work to do so don't waste power. */ 772 /* The ukernel has no work to be done, so don't waste power. */
763 return PVRSRV_OK; 773 return PVRSRV_OK;
764 } 774 }
765 775
@@ -815,7 +825,6 @@ PVRSRV_ERROR SGXGetInternalDevInfoKM(IMG_HANDLE hDevCookie,
815{ 825{
816 PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookie)->pvDevice; 826 PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookie)->pvDevice;
817 827
818 psSGXInternalDevInfo->ui32Flags = psDevInfo->ui32Flags;
819 psSGXInternalDevInfo->bForcePTOff = (IMG_BOOL)psDevInfo->bForcePTOff; 828 psSGXInternalDevInfo->bForcePTOff = (IMG_BOOL)psDevInfo->bForcePTOff;
820 829
821 /* This should be patched up by OS bridge code */ 830 /* This should be patched up by OS bridge code */
@@ -888,9 +897,9 @@ PVRSRV_ERROR SGXCleanupRequest(PVRSRV_DEVICE_NODE *psDeviceNode,
888 Pdump the poll as well. 897 Pdump the poll as well.
889 Note: 898 Note:
890 We don't expect the cleanup to report busy as the client should have 899 We don't expect the cleanup to report busy as the client should have
891 ensured the the resource has been finished with before requesting 900 ensured the resource has been finished with before requesting it's
892 it's cleanup. This isn't true of the abnormal termination case but 901 cleanup. This isn't true of the abnormal termination case but we
893 we don't expect to PDump that. Unless/until PDump has flow control 902 don't expect to PDump that. Unless/until PDump has flow control
894 there isn't anything else we can do. 903 there isn't anything else we can do.
895 */ 904 */
896 PDUMPCOMMENTWITHFLAGS(0, "Host Control - Poll for clean-up request to complete"); 905 PDUMPCOMMENTWITHFLAGS(0, "Host Control - Poll for clean-up request to complete");
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/Kbuild.mk b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/Kbuild.mk
index 857206e..36fd164 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/Kbuild.mk
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/Kbuild.mk
@@ -78,14 +78,19 @@ pvrsrvkm-y += \
78 services4/srvkm/common/queue.o 78 services4/srvkm/common/queue.o
79endif 79endif
80 80
81ifeq ($(SUPPORT_DRM_GEM),1) 81ifeq ($(SUPPORT_ION),1)
82pvrsrvkm-y += \
83 services4/srvkm/env/linux/ion.o
84ifeq ($(LMA),1)
82pvrsrvkm-y += \ 85pvrsrvkm-y += \
83 services4/srvkm/env/linux/dmabuf.o 86 services4/srvkm/env/linux/lma_heap_ion.o
87endif
84endif 88endif
85 89
86ifeq ($(SUPPORT_ION),1) 90ifeq ($(SUPPORT_DMABUF),1)
87pvrsrvkm-y += \ 91pvrsrvkm-y += \
88 services4/srvkm/env/linux/ion.o 92 services4/srvkm/env/linux/dmabuf.o \
93 services4/srvkm/env/linux/pvr_linux_fence.o
89endif 94endif
90 95
91ifeq ($(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC),1) 96ifeq ($(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC),1)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.c
index 4b9023e..a59ae6f 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.c
@@ -1,5 +1,5 @@
1/*************************************************************************/ /*! 1/*************************************************************************/ /*!
2@Title Ion driver inter-operability code. 2@Title Dma_buf support code.
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved 3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2 4@License Dual MIT/GPLv2
5 5
@@ -40,270 +40,348 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/ /**************************************************************************/ 40*/ /**************************************************************************/
41 41
42#include "dmabuf.h" 42#include "dmabuf.h"
43#include <linux/platform_device.h> 43
44#include <linux/dma-buf.h> 44#if defined(SUPPORT_DMABUF)
45#include <linux/dma-direction.h> 45
46#include <linux/scatterlist.h>
47#include <linux/kernel.h> 46#include <linux/kernel.h>
48#include <linux/slab.h> 47#include <linux/slab.h>
49#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/dma-buf.h>
50#include <linux/scatterlist.h>
51#if defined(SUPPORT_DRI_DRM)
52#include <drm/drmP.h>
53#endif
50 54
51extern struct platform_device *gpsPVRLDMDev; 55#include "services_headers.h"
52 56#include "pvr_debug.h"
53#define MAX_IMPORT_DMABUF_FDS 3 57#include "linkage.h"
58#include "pvr_bridge.h"
54 59
55typedef struct _DMABUF_IMPORT_DATA_ 60struct dmabuf_import
56{ 61{
57 /* Number of dma_buf handles represented by this import */ 62 unsigned num_fds;
58 IMG_UINT32 ui32NumHandles;
59 63
60 /* Array of dma_buf handles in use by services */ 64 struct dma_buf *dma_buf[DMABUF_IMPORT_MAX_FDS];
61 struct dma_buf *apsDmaBuf[MAX_IMPORT_DMABUF_FDS]; 65
66 struct dma_buf_attachment *attachment[DMABUF_IMPORT_MAX_FDS];
67
68 struct sg_table *sg_table[DMABUF_IMPORT_MAX_FDS];
69
70#if defined(PDUMP)
71 void *kvaddr;
72#endif /* defined(PDUMP) */
73};
74
75#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
76struct dmabuf_resvinfo
77{
78 unsigned num_resvs;
62 79
63 /* Array of dma_buf attachments */ 80 struct reservation_object *resv[DMABUF_IMPORT_MAX_FDS];
64 struct dma_buf_attachment *apsDmaBufAttachment[MAX_IMPORT_DMABUF_FDS]; 81};
82#endif
65 83
66 /* Array of sg_tables */ 84IMG_VOID DmaBufUnimportAndReleasePhysAddr(IMG_HANDLE hImport)
67 struct sg_table *apsSgTable[MAX_IMPORT_DMABUF_FDS]; 85{
86 struct dmabuf_import *import;
87 unsigned buf;
68 88
69 /* Array of physical addresses represented by these buffers */ 89 import = (struct dmabuf_import *)hImport;
70 IMG_SYS_PHYADDR *psSysPhysAddr;
71 90
72#if defined(PDUMP) 91#if defined(PDUMP)
73 /* FIXME: Not sure if this is needed here */ 92 if (import->kvaddr)
74 IMG_PVOID pvKernAddr0; 93 {
94 dma_buf_vunmap(import->dma_buf[0], import->kvaddr);
95 dma_buf_end_cpu_access(import->dma_buf[0], 0,
96 import->dma_buf[0]->size,
97 DMA_BIDIRECTIONAL);
98 }
75#endif /* defined(PDUMP) */ 99#endif /* defined(PDUMP) */
100
101 for (buf = 0; buf < import->num_fds; buf++)
102 {
103 if (!IS_ERR_OR_NULL(import->sg_table[buf]))
104 {
105 dma_buf_unmap_attachment(import->attachment[buf],
106 import->sg_table[buf],
107 DMA_BIDIRECTIONAL);
108 }
109
110 if (!IS_ERR_OR_NULL(import->attachment[buf]))
111 {
112 dma_buf_detach(import->dma_buf[buf], import->attachment[buf]);
113 }
114
115 if (!IS_ERR_OR_NULL(import->dma_buf[buf]))
116 {
117 dma_buf_put(import->dma_buf[buf]);
118 }
119 }
120
121 kfree(import);
76} 122}
77DMABUF_IMPORT_DATA;
78 123
79PVRSRV_ERROR DmabufImportBufferAndAcquirePhysAddr(IMG_UINT32 ui32NumFDs, 124PVRSRV_ERROR DmaBufImportAndAcquirePhysAddr(const IMG_UINT32 ui32NumFDs,
80 IMG_INT32 *pai32BufferFDs, 125 const IMG_INT32 *pi32FD,
126 const IMG_SIZE_T *puiDmaBufOffset,
127 const IMG_SIZE_T *puiSize,
81 IMG_UINT32 *pui32PageCount, 128 IMG_UINT32 *pui32PageCount,
82 IMG_SYS_PHYADDR **ppsSysPhysAddr, 129 IMG_SYS_PHYADDR **ppsSysPhysAddr,
83 IMG_PVOID *ppvKernAddr0, 130 IMG_SIZE_T *puiMemInfoOffset,
84 IMG_HANDLE *phPriv, 131 IMG_PVOID *ppvKernAddr,
132 IMG_HANDLE *phImport,
85 IMG_HANDLE *phUnique) 133 IMG_HANDLE *phUnique)
86{ 134{
87 struct scatterlist *psTemp, *psScatterList[MAX_IMPORT_DMABUF_FDS] = {}; 135 struct dmabuf_import *import = NULL;
88 PVRSRV_ERROR eError = PVRSRV_ERROR_OUT_OF_MEMORY; 136 struct device *dev = NULL;
89 IMG_UINT32 i, k, ui32PageCount = 0; 137 struct scatterlist *sg;
90 DMABUF_IMPORT_DATA *psImportData; 138 size_t buf_size[DMABUF_IMPORT_MAX_FDS];
91 139 size_t meminfo_offset;
92 if(ui32NumFDs > MAX_IMPORT_DMABUF_FDS) 140 unsigned npages = 0;
141 unsigned pti = 0;
142 IMG_SYS_PHYADDR *spaddr = NULL;
143 unsigned i;
144 unsigned buf;
145 PVRSRV_ERROR eError = PVRSRV_ERROR_INVALID_PARAMS;
146
147 if (ui32NumFDs < 1 || ui32NumFDs > DMABUF_IMPORT_MAX_FDS)
93 { 148 {
94 printk(KERN_ERR "%s: More passed in than supported " 149 PVR_DPF((PVR_DBG_ERROR, "%s: Number of FDs is %u", __func__, (unsigned)ui32NumFDs));
95 "(%d provided, %d max)", __func__, ui32NumFDs, 150 eError = PVRSRV_ERROR_INVALID_PARAMS;
96 MAX_IMPORT_DMABUF_FDS); 151 goto error;
97 return PVRSRV_ERROR_INVALID_PARAMS;
98 } 152 }
99 153
100 psImportData = kzalloc(sizeof(DMABUF_IMPORT_DATA), GFP_KERNEL); 154 import = kzalloc(sizeof(*import), GFP_KERNEL);
101 if (psImportData == NULL) 155 if (!import)
102 { 156 {
103 goto exitFailKMallocImportData; 157 PVR_DPF((PVR_DBG_ERROR, "%s: Out of memory", __func__));
158 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
159 goto error;
104 } 160 }
161 import->num_fds = ui32NumFDs;
105 162
106 /* Set up import data for free call */ 163 dev = PVRLDMGetDevice();
107 psImportData->ui32NumHandles = ui32NumFDs; 164 if (!dev)
108
109 for(i = 0; i < ui32NumFDs; i++)
110 { 165 {
111 int fd = (int)pai32BufferFDs[i]; 166 PVR_DPF((PVR_DBG_ERROR, "%s: Couldn't get device", __func__));
167 eError = PVRSRV_ERROR_NOT_SUPPORTED;
168 goto error;
169 }
112 170
113 /* connect to the buffer */ 171 for (buf = 0; buf < ui32NumFDs; buf++)
114 psImportData->apsDmaBuf[i] = dma_buf_get(fd); 172 {
115 if (IS_ERR_OR_NULL(psImportData->apsDmaBuf[i])) 173 import->dma_buf[buf] = dma_buf_get((int)pi32FD[buf]);
174 if (IS_ERR(import->dma_buf[buf]))
116 { 175 {
117 dev_err(&gpsPVRLDMDev->dev, 176 PVR_DPF((PVR_DBG_ERROR, "%s: dma_buf_get failed: %ld", __func__, PTR_ERR(import->dma_buf[buf])));
118 "dma_buf_get() returned bad dma_buf handle\n");
119 eError = PVRSRV_ERROR_BAD_MAPPING; 177 eError = PVRSRV_ERROR_BAD_MAPPING;
120 goto exitFailImport; 178 goto error;
121 } 179 }
122 180
123 psImportData->apsDmaBufAttachment[i] = dma_buf_attach(psImportData->apsDmaBuf[i], 181 buf_size[buf] = puiSize[buf] ? puiSize[buf] : import->dma_buf[buf]->size;
124 &gpsPVRLDMDev->dev);
125 if (IS_ERR_OR_NULL(psImportData->apsDmaBufAttachment[i]))
126 {
127 dev_err(&gpsPVRLDMDev->dev,
128 "dma_buf_attach() returned bad attachment struct\n");
129 eError = PVRSRV_ERROR_BAD_MAPPING;
130 goto exitFailImport;
131 }
132 182
133 /* requesting access to the buffer */ 183 if ((puiDmaBufOffset[buf] + buf_size[buf]) > import->dma_buf[buf]->size ||
134 psImportData->apsSgTable[i] = dma_buf_map_attachment(psImportData->apsDmaBufAttachment[i], 184 (size_t)(puiDmaBufOffset[buf] + buf_size[buf]) < buf_size[buf])
135 DMA_BIDIRECTIONAL);
136 if (IS_ERR_OR_NULL(psImportData->apsSgTable[i]))
137 {
138 dev_err(&gpsPVRLDMDev->dev,
139 "dma_buf_map_attachment returned stale sgtable: %d\n",
140 (int)psImportData->apsSgTable[i]);
141#if defined(DEBUG)
142 /* lets dump the stack trace here */
143 WARN_ON(true);
144 /* TODO: print all the current omap bo info */
145#endif
146 dma_buf_detach(psImportData->apsDmaBuf[i],
147 psImportData->apsDmaBufAttachment[i]);
148 eError = PVRSRV_ERROR_OUT_OF_MEMORY;
149 goto exitFailImport;
150 }
151
152 psScatterList[i] = psImportData->apsSgTable[i]->sgl;
153 if (psScatterList[i] == NULL)
154 { 185 {
186 PVR_DPF((PVR_DBG_ERROR, "%s: Bad size and/or offset for FD %u", __func__, buf));
155 eError = PVRSRV_ERROR_INVALID_PARAMS; 187 eError = PVRSRV_ERROR_INVALID_PARAMS;
156 goto exitFailImport; 188 goto error;
157 } 189 }
158 190
159 /* Although all heaps will provide an sg_table, the tables cannot 191 import->attachment[buf] = dma_buf_attach(import->dma_buf[buf], dev);
160 * always be trusted because sg_lists are just pointers to "struct 192 if (IS_ERR(import->attachment[buf]))
161 * page" values, and some memory e.g. carveout may not have valid
162 * "struct page" values. In particular, on ARM, carveout is
163 * generally reserved with memblock_remove(), which leaves the
164 * "struct page" entries uninitialized when SPARSEMEM is enabled.
165 * The effect of this is that page_to_pfn(pfn_to_page(pfn)) != pfn.
166 *
167 * There's more discussion on this mailing list thread:
168 * http://lists.linaro.org/pipermail/linaro-mm-sig/2012-August/002440.html
169 *
170 * probably a contiguous allocator. If the phys() function is
171 * implemented, we'll use it to check sg_table->sgl[0]. If we find
172 * they don't agree, we'll assume phys() is more reliable and use
173 * that.
174 *
175 * Some heaps out there will implement phys() even though they are
176 * not for physically contiguous allocations (so the sg_table must
177 * be used). Therefore use the sg_table if the phys() and first
178 * sg_table entry match. This should be reliable because for most
179 * contiguous allocators, the sg_table should be a single span
180 * from 'start' to 'start+size'.
181 *
182 * Also, ion prints out an error message if the heap doesn't implement
183 * ->phys(), which we want to avoid, so only use ->phys() if the
184 * sg_table contains a single span and therefore could plausibly
185 * be a contiguous allocator.
186 */
187 #if 0
188 if(!sg_next(psScatterList[i]))
189 { 193 {
190 ion_phys_addr_t sPhyAddr; 194 PVR_DPF((PVR_DBG_ERROR, "%s: dma_buf_attach failed: %ld", __func__, PTR_ERR(import->attachment[buf])));
191 size_t sLength; 195 eError = PVRSRV_ERROR_BAD_MAPPING;
192 196 goto error;
193 if(!ion_phys(psIonClient, psImportData->apsIonHandle[i],
194 &sPhyAddr, &sLength))
195 {
196 BUG_ON(sLength & ~PAGE_MASK);
197
198 if(sg_phys(psScatterList[i]) != sPhyAddr)
199 {
200 psScatterList[i] = IMG_NULL;
201 ui32PageCount += sLength / PAGE_SIZE;
202 }
203 }
204 } 197 }
205 #endif 198
206 for(psTemp = psScatterList[i]; psTemp; psTemp = sg_next(psTemp)) 199 import->sg_table[buf] = dma_buf_map_attachment(import->attachment[buf],
200 DMA_BIDIRECTIONAL);
201 if (IS_ERR(import->sg_table[buf]))
207 { 202 {
208 IMG_UINT32 j; 203 PVR_DPF((PVR_DBG_ERROR, "%s: dma_buf_map_attachment failed: %ld", __func__, PTR_ERR(import->sg_table[buf])));
209 for (j = 0; j < psTemp->length; j += PAGE_SIZE) 204 eError = PVRSRV_ERROR_BAD_MAPPING;
210 { 205 goto error;
211 ui32PageCount++;
212 }
213 } 206 }
214 } 207 }
215 208
216 BUG_ON(ui32PageCount == 0); 209 for (buf = 0, meminfo_offset = 0; buf < ui32NumFDs; buf++)
217
218 psImportData->psSysPhysAddr = kmalloc(sizeof(IMG_SYS_PHYADDR) * ui32PageCount, GFP_KERNEL);
219 if (psImportData->psSysPhysAddr == NULL)
220 { 210 {
221 goto exitFailImport; 211 size_t start_offset = PAGE_MASK & puiDmaBufOffset[buf];
212 size_t end_offset = PAGE_ALIGN(puiDmaBufOffset[buf] + buf_size[buf]);
213
214 puiMemInfoOffset[buf] = meminfo_offset + (puiDmaBufOffset[buf] - start_offset);
215
216 meminfo_offset += (end_offset - start_offset);
222 } 217 }
218 npages = meminfo_offset >> PAGE_SHIFT;
219
220 /* The following allocation will be freed by the caller */
221 eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
222 npages * sizeof(IMG_SYS_PHYADDR),
223 (IMG_VOID **)&spaddr, IMG_NULL,
224 "Array of Page Addresses");
225 if (eError != PVRSRV_OK)
226 {
227 PVR_DPF((PVR_DBG_ERROR, "%s: OSAllocMem failed: %s", __func__, PVRSRVGetErrorStringKM(eError)));
228 goto error;
229 }
223 230
224 for(i = 0, k = 0; i < ui32NumFDs; i++) 231 for (buf = 0; buf < ui32NumFDs; buf++)
225 { 232 {
226 if(psScatterList[i]) 233 size_t buf_offset = 0;
234 size_t remainder = buf_size[buf];
235 size_t start_offset = PAGE_MASK & puiDmaBufOffset[buf];
236 size_t end_offset = PAGE_ALIGN(puiDmaBufOffset[buf] + buf_size[buf]);
237
238 for_each_sg(import->sg_table[buf]->sgl, sg, import->sg_table[buf]->nents, i)
227 { 239 {
228 for(psTemp = psScatterList[i]; psTemp; psTemp = sg_next(psTemp)) 240 if (buf_offset >= end_offset)
229 { 241 {
230 IMG_UINT32 j; 242 break;
231 for (j = 0; j < psTemp->length; j += PAGE_SIZE)
232 {
233 psImportData->psSysPhysAddr[k].uiAddr = sg_phys(psTemp) + j;
234 k++;
235 }
236 } 243 }
237 }
238#if 0
239 else
240 {
241 ion_phys_addr_t sPhyAddr;
242 size_t sLength, j;
243 244
244 ion_phys(psIonClient, psImportData->apsIonHandle[i], 245 if ((start_offset >= buf_offset) && (start_offset < buf_offset + sg_dma_len(sg)))
245 &sPhyAddr, &sLength); 246 {
247 size_t sg_start;
248 size_t sg_pos;
249 size_t sg_remainder;
250
251 sg_start = start_offset - buf_offset;
246 252
247 for(j = 0; j < sLength; j += PAGE_SIZE) 253 sg_remainder = MIN(sg_dma_len(sg) - sg_start, remainder);
254
255 for (sg_pos = sg_start; sg_pos < sg_start + sg_remainder; sg_pos += PAGE_SIZE)
256 {
257 IMG_CPU_PHYADDR cpaddr;
258
259 cpaddr.uiAddr = PAGE_MASK & (sg_phys(sg) + sg_pos);
260 BUG_ON(pti >= npages);
261
262 spaddr[pti++] = SysCpuPAddrToSysPAddr(cpaddr);
263 }
264
265 remainder -= sg_remainder;
266 buf_offset += sg_dma_len(sg);
267 start_offset = buf_offset;
268 }
269 else
248 { 270 {
249 psImportData->psSysPhysAddr[k].uiAddr = sPhyAddr + j; 271 buf_offset += sg_dma_len(sg);
250 k++;
251 } 272 }
252 } 273 }
253#endif 274 BUG_ON(remainder);
254 } 275 }
255 276
256 *pui32PageCount = ui32PageCount;
257 *ppsSysPhysAddr = psImportData->psSysPhysAddr;
258
259#if defined(PDUMP) 277#if defined(PDUMP)
260 if(ui32NumFDs == 1) 278 if (ui32NumFDs == 1)
261 { 279 {
262 /*FIXME */ 280 int err = dma_buf_begin_cpu_access(import->dma_buf[0], 0,
263 /* Need to handle kernel mapping */ 281 import->dma_buf[0]->size,
282 DMA_BIDIRECTIONAL);
283 if (err)
284 {
285 PVR_DPF((PVR_DBG_MESSAGE, "%s: dma_buf_begin_cpu_access failed: %d", __func__, err));
286 }
287 else
288 {
289 import->kvaddr = dma_buf_vmap(import->dma_buf[0]);
290 *ppvKernAddr = import->kvaddr;
291 }
264 } 292 }
265 else 293 else
266#endif /* defined(PDUMP) */
267 { 294 {
268 *ppvKernAddr0 = NULL; 295 *ppvKernAddr = NULL;
269 } 296 }
297#else /* defined(PDUMP) */
298 *ppvKernAddr = NULL;
299#endif /* defined(PDUMP) */
270 300
271 *phPriv = psImportData; 301 *pui32PageCount = pti;
272 *phUnique = (IMG_HANDLE)psImportData->psSysPhysAddr[0].uiAddr; 302 *ppsSysPhysAddr = spaddr;
303 *phImport = (IMG_HANDLE)import;
304 *phUnique = (ui32NumFDs == 1) ? (IMG_HANDLE)import->dma_buf[0] : NULL;
273 305
274 return PVRSRV_OK; 306 return PVRSRV_OK;
307error:
308 if (import)
309 {
310 DmaBufUnimportAndReleasePhysAddr((IMG_HANDLE)import);
311 }
275 312
276exitFailImport: 313 if (spaddr)
277 for(i = 0; psImportData->apsDmaBuf[i] != NULL; i++)
278 { 314 {
279 dma_buf_put(psImportData->apsDmaBuf[i]); 315 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
316 npages * sizeof(IMG_SYS_PHYADDR),
317 (IMG_VOID **)&spaddr, IMG_NULL);
280 } 318 }
281 kfree(psImportData); 319
282exitFailKMallocImportData:
283 return eError; 320 return eError;
284} 321}
285 322
286IMG_VOID DmabufUnimportBufferAndReleasePhysAddr(IMG_HANDLE hPriv) 323#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
324IMG_HANDLE DmaBufGetNativeSyncHandle(IMG_HANDLE hImport)
287{ 325{
288 DMABUF_IMPORT_DATA *psImportData = hPriv; 326 struct dmabuf_import *import;
289 IMG_UINT32 i; 327 struct dmabuf_resvinfo *info;
290 328
291#if defined(PDUMP) 329 import = (struct dmabuf_import *)hImport;
292 if (psImportData->pvKernAddr0) 330
293 { 331 info = kzalloc(sizeof(*info), GFP_KERNEL);
294 //FIXME 332
295 } 333 if (info)
296#endif /* defined(PDUMP) */
297 for(i = 0; i < psImportData->ui32NumHandles; i++)
298 { 334 {
299 dma_buf_unmap_attachment(psImportData->apsDmaBufAttachment[i], 335 unsigned i;
300 psImportData->apsSgTable[i], 336
301 DMA_BIDIRECTIONAL); 337 info->num_resvs = import->num_fds;
302 dma_buf_detach(psImportData->apsDmaBuf[i], 338
303 psImportData->apsDmaBufAttachment[i]); 339 for(i = 0; i < info->num_resvs; i++)
304 dma_buf_put(psImportData->apsDmaBuf[i]); 340 {
341 info->resv[i] = import->dma_buf[i]->resv;
342 }
305 } 343 }
306 344
307 kfree(psImportData->psSysPhysAddr); 345 return (IMG_HANDLE)info;
308 kfree(psImportData);
309} 346}
347
348void DmaBufFreeNativeSyncHandle(IMG_HANDLE hSync)
349{
350 struct dmabuf_resvinfo *info;
351
352 info = (struct dmabuf_resvinfo *)hSync;
353
354 kfree(info);
355}
356
357void *DmaBufGetReservationObject(IMG_HANDLE hSync, unsigned uIndex)
358{
359 struct dmabuf_resvinfo *info;
360
361 info = (struct dmabuf_resvinfo *)hSync;
362
363 return (uIndex < info->num_resvs) ? info->resv[uIndex] : NULL;
364}
365#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) */
366IMG_HANDLE DmaBufGetNativeSyncHandle(IMG_HANDLE hImport)
367{
368 (void) hImport;
369
370 return IMG_NULL;
371}
372
373void DmaBufFreeNativeSyncHandle(IMG_HANDLE hSync)
374{
375 (void) hSync;
376}
377
378void *DmaBufGetReservationObject(IMG_HANDLE hSync, unsigned uIndex)
379{
380 (void) hSync;
381 (void) uIndex;
382
383 return NULL;
384}
385#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) */
386
387#endif /* defined(SUPPORT_DMABUF) */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.h
index 4ea3ff1..5447655 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/dmabuf.h
@@ -1,5 +1,5 @@
1/*************************************************************************/ /*! 1/*************************************************************************/ /*!
2@Title Ion driver inter-operability code. 2@Title DmaBuf driver inter-operability code.
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved 3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2 4@License Dual MIT/GPLv2
5 5
@@ -42,17 +42,32 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42#ifndef __IMG_LINUX_DMABUF_H__ 42#ifndef __IMG_LINUX_DMABUF_H__
43#define __IMG_LINUX_DMABUF_H__ 43#define __IMG_LINUX_DMABUF_H__
44 44
45#if defined(SUPPORT_DMABUF)
46
45#include "img_types.h" 47#include "img_types.h"
46#include "servicesext.h" 48#include "servicesext.h"
47 49
48PVRSRV_ERROR DmabufImportBufferAndAcquirePhysAddr(IMG_UINT32 ui32NumFDs, 50PVRSRV_ERROR DmaBufInit(IMG_VOID);
49 IMG_INT32 *pi32BufferFDs, 51
52IMG_VOID DmaBufDeinit(IMG_VOID);
53
54PVRSRV_ERROR DmaBufImportAndAcquirePhysAddr(const IMG_UINT32 ui32NumFDs,
55 const IMG_INT32 *pi32DmaBufFD,
56 const IMG_SIZE_T *puiDmaBufOffset,
57 const IMG_SIZE_T *puiSize,
50 IMG_UINT32 *pui32PageCount, 58 IMG_UINT32 *pui32PageCount,
51 IMG_SYS_PHYADDR **ppsSysPhysAddr, 59 IMG_SYS_PHYADDR **ppsSysPhysAddr,
52 IMG_PVOID *ppvKernAddr0, 60 IMG_SIZE_T *puiMemInfoOffset,
53 IMG_HANDLE *phPriv, 61 IMG_PVOID *ppvKernAddr,
62 IMG_HANDLE *phImport,
54 IMG_HANDLE *phUnique); 63 IMG_HANDLE *phUnique);
55 64
56IMG_VOID DmabufUnimportBufferAndReleasePhysAddr(IMG_HANDLE hPriv); 65IMG_VOID DmaBufUnimportAndReleasePhysAddr(IMG_HANDLE hImport);
66
67IMG_HANDLE DmaBufGetNativeSyncHandle(IMG_HANDLE hImport);
68void DmaBufFreeNativeSyncHandle(IMG_HANDLE hSync);
69
70void *DmaBufGetReservationObject(IMG_HANDLE hSync, unsigned uIndex);
71#endif /* defined(SUPPORT_DMABUF) */
57 72
58#endif /* __IMG_LINUX_DMABUF_H__ */ 73#endif /* __IMG_LINUX_DMABUF_H__ */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.c
index 2f08f27..8d3ddfa 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.c
@@ -140,69 +140,141 @@ IMG_VOID IonDeinit(IMG_VOID)
140 140
141#else /* defined(CONFIG_ION_INCDHAD1) */ 141#else /* defined(CONFIG_ION_INCDHAD1) */
142 142
143#if defined(CONFIG_ION_DUMMY) 143/* "Reference" ion implementation */
144 144
145/* Real ion with sharing (dummy) */ 145#include SUPPORT_ION_PRIV_HEADER
146#include <linux/version.h>
147#include "ion_sys_private.h"
148#include "lma_heap_ion.h"
146 149
147extern struct ion_device *idev; 150static struct ion_heap **gapsIonHeaps;
148struct ion_device *gpsIonDev; 151struct ion_device *gpsIonDev;
149 152
150PVRSRV_ERROR IonInit(IMG_VOID) 153#if defined(LMA)
154struct ion_platform_data gsTCIonConfig = {
155 .nr = 1,
156 .heaps =
157#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,39))
158#else
159 (struct ion_platform_heap [])
160#endif
161 {
162 {
163 /* This heap must be first. The base address and size are filled
164 in from data passed down by sysconfig.c. */
165 .type = ION_HEAP_TYPE_CUSTOM,
166 .name = "tc_local_mem",
167 .id = ION_HEAP_TYPE_CUSTOM,
168 .base = 0, /* filled in later */
169 .size = 0, /* filled in later */
170 }
171 }
172};
173
174PVRSRV_ERROR IonInit(void *pvPrivateData)
151{ 175{
152 gpsIonDev = idev; 176 PVRSRV_ERROR eError = PVRSRV_OK;
153 return PVRSRV_OK; 177 int i;
178
179 ION_TC_PRIVATE_DATA sPrivateData = *(ION_TC_PRIVATE_DATA *)pvPrivateData;
180
181 /* Fill in the heap base and size according to the private data. */
182 gsTCIonConfig.heaps[0].base = sPrivateData.uiHeapBase;
183 gsTCIonConfig.heaps[0].size = sPrivateData.uiHeapSize;
184
185 gapsIonHeaps = kzalloc(sizeof(struct ion_heap *) * gsTCIonConfig.nr,
186 GFP_KERNEL);
187 gpsIonDev = ion_device_create(NULL);
188 if (IS_ERR_OR_NULL(gpsIonDev))
189 {
190 kfree(gapsIonHeaps);
191 return PVRSRV_ERROR_OUT_OF_MEMORY;
192 }
193
194 for (i = 0; i < gsTCIonConfig.nr; i++)
195 {
196 struct ion_platform_heap *psPlatHeapData = &gsTCIonConfig.heaps[i];
197
198 switch (psPlatHeapData->type)
199 {
200 case ION_HEAP_TYPE_CUSTOM:
201 /* Custom heap: this is used to mean a TC-specific heap,
202 which allocates from local memory. */
203 gapsIonHeaps[i] = lma_heap_create(psPlatHeapData);
204 break;
205 default:
206 /* For any other type of heap, hand this to ion to create as
207 appropriate. We don't necessarily need any of these -
208 this just gives us the flexibility to have another kind
209 of heap if necessary. */
210 gapsIonHeaps[i] = ion_heap_create(psPlatHeapData);
211 break;
212 }
213
214 if (IS_ERR_OR_NULL(gapsIonHeaps[i]))
215 {
216 printk("%s: Failed to create ion heap '%s'", __func__, psPlatHeapData->name);
217 IonDeinit();
218 return PVRSRV_ERROR_OUT_OF_MEMORY;
219 }
220
221 ion_device_add_heap(gpsIonDev, gapsIonHeaps[i]);
222 }
223
224 return eError;
154} 225}
155 226
156 227void IonDeinit(void)
157IMG_VOID IonDeinit(IMG_VOID)
158{ 228{
159 gpsIonDev = IMG_NULL; 229 int i;
230 for (i = 0; i < gsTCIonConfig.nr; i++)
231 if (gapsIonHeaps[i])
232 ion_heap_destroy(gapsIonHeaps[i]);
233 kfree(gapsIonHeaps);
234 ion_device_destroy(gpsIonDev);
160} 235}
161 236
162#else /* defined(CONFIG_ION_DUMMY) */ 237#else
163
164
165/* "Reference" ion implementation */
166
167#include SUPPORT_ION_PRIV_HEADER
168#include <linux/version.h>
169
170static struct ion_heap **gapsIonHeaps;
171struct ion_device *gpsIonDev;
172
173#ifndef ION_CARVEOUT_MEM_BASE
174#define ION_CARVEOUT_MEM_BASE 0
175#endif
176 238
177#ifndef ION_CARVEOUT_MEM_SIZE 239#if defined(ION_CARVEOUT_MEM_BASE) && defined(ION_CARVEOUT_MEM_SIZE)
178#define ION_CARVEOUT_MEM_SIZE 0 240/* Only define the carveout heap on boards with BASE and SIZE defined,
241 * otherwise crashes may be seen when empty cache flushes are issued
242 * (seen on the MIPS architecture).
243 */
244#define ION_HAS_CARVEOUT_HEAP
179#endif 245#endif
180 246
181static struct ion_platform_data gsGenericConfig = 247static struct ion_platform_data gsGenericConfig =
182{ 248{
249#if defined(ION_HAS_CARVEOUT_HEAP)
183 .nr = 3, 250 .nr = 3,
251#else
252 .nr = 2,
253#endif
184 .heaps = 254 .heaps =
185#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,39)) 255#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,39))
186 (struct ion_platform_heap []) 256 (struct ion_platform_heap [])
187#endif 257#endif
188 { 258 {
189 { 259 {
190 .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
191 .name = "system_contig",
192 .id = ION_HEAP_TYPE_SYSTEM_CONTIG,
193 },
194 {
195 .type = ION_HEAP_TYPE_SYSTEM, 260 .type = ION_HEAP_TYPE_SYSTEM,
196 .name = "system", 261 .name = "system",
197 .id = ION_HEAP_TYPE_SYSTEM, 262 .id = ION_HEAP_TYPE_SYSTEM,
198 }, 263 },
199 { 264 {
265 .type = ION_HEAP_TYPE_DMA,
266 .name = "dma",
267 .id = ION_HEAP_TYPE_DMA,
268 },
269#if defined(ION_HAS_CARVEOUT_HEAP)
270 {
200 .type = ION_HEAP_TYPE_CARVEOUT, 271 .type = ION_HEAP_TYPE_CARVEOUT,
201 .name = "carveout", 272 .name = "carveout",
202 .id = ION_HEAP_TYPE_CARVEOUT, 273 .id = ION_HEAP_TYPE_CARVEOUT,
203 .base = ION_CARVEOUT_MEM_BASE, 274 .base = ION_CARVEOUT_MEM_BASE,
204 .size = ION_CARVEOUT_MEM_SIZE, 275 .size = ION_CARVEOUT_MEM_SIZE,
205 }, 276 },
277#endif /* defined(ION_HAS_CARVEOUT_HEAP) */
206 } 278 }
207}; 279};
208 280
@@ -262,7 +334,8 @@ IMG_VOID IonDeinit(IMG_VOID)
262 kfree(gapsIonHeaps); 334 kfree(gapsIonHeaps);
263 ion_device_destroy(gpsIonDev); 335 ion_device_destroy(gpsIonDev);
264} 336}
265#endif /* defined(CONFIG_ION_DUMMY) */ 337
338#endif /* defined(LMA) */
266 339
267#endif /* defined(CONFIG_ION_INCDHAD1) */ 340#endif /* defined(CONFIG_ION_INCDHAD1) */
268 341
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.h
index b71ecd7..145ae12 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/ion.h
@@ -49,7 +49,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49#include "img_types.h" 49#include "img_types.h"
50#include "servicesext.h" 50#include "servicesext.h"
51 51
52#if defined(LMA)
53PVRSRV_ERROR IonInit(void *pvPrivateData);
54#else
52PVRSRV_ERROR IonInit(IMG_VOID); 55PVRSRV_ERROR IonInit(IMG_VOID);
56#endif
53 57
54IMG_VOID IonDeinit(IMG_VOID); 58IMG_VOID IonDeinit(IMG_VOID);
55 59
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/linkage.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/linkage.h
index 55cd4f0..99b1ea4 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/linkage.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/linkage.h
@@ -66,6 +66,8 @@ void ProcSeqShowPowerLevel(struct seq_file *sfile,void* el);
66 66
67#endif /* DEBUG */ 67#endif /* DEBUG */
68 68
69struct device *PVRLDMGetDevice(void);
70
69#endif /* __LINKAGE_H__ */ 71#endif /* __LINKAGE_H__ */
70/***************************************************************************** 72/*****************************************************************************
71 End of file (linkage.h) 73 End of file (linkage.h)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/lma_heap_ion.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/lma_heap_ion.h
new file mode 100644
index 0000000..c76effb
--- /dev/null
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/lma_heap_ion.h
@@ -0,0 +1,45 @@
1/*************************************************************************/ /*!
2@File lma_heap_ion.h
3@Title Ion heap for local memory
4@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
43#include SUPPORT_ION_HEADER
44
45struct ion_heap *lma_heap_create(struct ion_platform_heap *data);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.c
index c5a9b9b..8a1b00b 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.c
@@ -91,7 +91,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
91 91
92/* Decide whether or not DevMem allocs need __GFP_DMA32 */ 92/* Decide whether or not DevMem allocs need __GFP_DMA32 */
93#ifndef SGX_FEATURE_36BIT_MMU 93#ifndef SGX_FEATURE_36BIT_MMU
94# ifdef CONFIG_ZONE_DMA32 94# ifdef CONFIG_ZONE_DMA
95# if defined CONFIG_X86_PAE || defined CONFIG_ARM_LPAE || defined CONFIG_64BIT 95# if defined CONFIG_X86_PAE || defined CONFIG_ARM_LPAE || defined CONFIG_64BIT
96# define PVR_USE_DMA32_FOR_DEVMEM_ALLOCS 96# define PVR_USE_DMA32_FOR_DEVMEM_ALLOCS
97# endif 97# endif
@@ -117,6 +117,7 @@ typedef enum {
117#if defined(PVR_LINUX_MEM_AREA_USE_VMAP) 117#if defined(PVR_LINUX_MEM_AREA_USE_VMAP)
118 DEBUG_MEM_ALLOC_TYPE_VMAP, 118 DEBUG_MEM_ALLOC_TYPE_VMAP,
119#endif 119#endif
120 DEBUG_MEM_ALLOC_TYPE_SWAP,
120 DEBUG_MEM_ALLOC_TYPE_COUNT 121 DEBUG_MEM_ALLOC_TYPE_COUNT
121} DEBUG_MEM_ALLOC_TYPE; 122} DEBUG_MEM_ALLOC_TYPE;
122 123
@@ -144,6 +145,7 @@ static IMPLEMENT_LIST_REMOVE(DEBUG_MEM_ALLOC_REC)
144 145
145 146
146static DEBUG_MEM_ALLOC_REC *g_MemoryRecords; 147static DEBUG_MEM_ALLOC_REC *g_MemoryRecords;
148static DEBUG_MEM_ALLOC_REC *g_SwapMemoryRecords;
147 149
148static IMG_UINT32 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_COUNT]; 150static IMG_UINT32 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_COUNT];
149static IMG_UINT32 g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_COUNT]; 151static IMG_UINT32 g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_COUNT];
@@ -155,7 +157,7 @@ static IMG_UINT32 g_SysRAMHighWaterMark; /* *DOES* include page pool */
155static inline IMG_UINT32 157static inline IMG_UINT32
156SysRAMTrueWaterMark(void) 158SysRAMTrueWaterMark(void)
157{ 159{
158 return g_SysRAMWaterMark + PAGES_TO_BYTES(atomic_read(&g_sPagePoolEntryCount)); 160 return g_SysRAMWaterMark + PAGES_TO_BYTES(atomic_read(&g_sPagePoolEntryCount)) + g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_SWAP];
159} 161}
160 162
161/* ioremap + io */ 163/* ioremap + io */
@@ -219,6 +221,7 @@ static void* ProcSeqOff2ElementMemArea(struct seq_file *sfile, loff_t off);
219 221
220#if defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 222#if defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
221static PVRSRV_LINUX_MUTEX g_sDebugMutex; 223static PVRSRV_LINUX_MUTEX g_sDebugMutex;
224static PVRSRV_LINUX_MUTEX g_sSwapDebugMutex;
222#endif 225#endif
223 226
224#if (defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)) 227#if (defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS))
@@ -266,7 +269,7 @@ CanFreeToPool(LinuxMemArea *psLinuxMemArea)
266} 269}
267 270
268IMG_VOID * 271IMG_VOID *
269_KMallocWrapper(IMG_SIZE_T uiByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) 272_KMallocWrapper(IMG_SIZE_T uiByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line, IMG_BOOL bSwapAlloc)
270{ 273{
271 IMG_VOID *pvRet; 274 IMG_VOID *pvRet;
272 pvRet = kmalloc(uiByteSize, uFlags); 275 pvRet = kmalloc(uiByteSize, uFlags);
@@ -276,7 +279,7 @@ _KMallocWrapper(IMG_SIZE_T uiByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_
276 IMG_CPU_PHYADDR sCpuPAddr; 279 IMG_CPU_PHYADDR sCpuPAddr;
277 sCpuPAddr.uiAddr = 0; 280 sCpuPAddr.uiAddr = 0;
278 281
279 DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_KMALLOC, 282 DebugMemAllocRecordAdd(bSwapAlloc ? DEBUG_MEM_ALLOC_TYPE_SWAP : DEBUG_MEM_ALLOC_TYPE_KMALLOC,
280 (IMG_UINTPTR_T)pvRet, 283 (IMG_UINTPTR_T)pvRet,
281 pvRet, 284 pvRet,
282 sCpuPAddr, 285 sCpuPAddr,
@@ -289,23 +292,24 @@ _KMallocWrapper(IMG_SIZE_T uiByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_
289#else 292#else
290 PVR_UNREFERENCED_PARAMETER(pszFileName); 293 PVR_UNREFERENCED_PARAMETER(pszFileName);
291 PVR_UNREFERENCED_PARAMETER(ui32Line); 294 PVR_UNREFERENCED_PARAMETER(ui32Line);
295 PVR_UNREFERENCED_PARAMETER(bSwapAlloc);
292#endif 296#endif
293 return pvRet; 297 return pvRet;
294} 298}
295 299
296 300void
297IMG_VOID 301_KFreeWrapper(void *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line, IMG_BOOL bSwapAlloc)
298_KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line)
299{ 302{
300#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 303#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
301 DebugMemAllocRecordRemove( 304 DebugMemAllocRecordRemove(
302 DEBUG_MEM_ALLOC_TYPE_KMALLOC, 305 bSwapAlloc ? DEBUG_MEM_ALLOC_TYPE_SWAP : DEBUG_MEM_ALLOC_TYPE_KMALLOC,
303 (IMG_UINTPTR_T)pvCpuVAddr, 306 (IMG_UINTPTR_T)pvCpuVAddr,
304 pszFileName, 307 pszFileName,
305 ui32Line); 308 ui32Line);
306#else 309#else
307 PVR_UNREFERENCED_PARAMETER(pszFileName); 310 PVR_UNREFERENCED_PARAMETER(pszFileName);
308 PVR_UNREFERENCED_PARAMETER(ui32Line); 311 PVR_UNREFERENCED_PARAMETER(ui32Line);
312 PVR_UNREFERENCED_PARAMETER(bSwapAlloc);
309#endif 313#endif
310 kfree(pvCpuVAddr); 314 kfree(pvCpuVAddr);
311} 315}
@@ -324,8 +328,6 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType,
324{ 328{
325 DEBUG_MEM_ALLOC_REC *psRecord; 329 DEBUG_MEM_ALLOC_REC *psRecord;
326 330
327 LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
328
329 psRecord = kmalloc(sizeof(DEBUG_MEM_ALLOC_REC), GFP_KERNEL); 331 psRecord = kmalloc(sizeof(DEBUG_MEM_ALLOC_REC), GFP_KERNEL);
330 332
331 psRecord->eAllocType = eAllocType; 333 psRecord->eAllocType = eAllocType;
@@ -337,8 +339,25 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType,
337 psRecord->uiBytes = uiBytes; 339 psRecord->uiBytes = uiBytes;
338 psRecord->pszFileName = pszFileName; 340 psRecord->pszFileName = pszFileName;
339 psRecord->ui32Line = ui32Line; 341 psRecord->ui32Line = ui32Line;
342
343 if (eAllocType == DEBUG_MEM_ALLOC_TYPE_SWAP)
344 {
345 LinuxLockMutexNested(&g_sSwapDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
346
347 List_DEBUG_MEM_ALLOC_REC_Insert(&g_SwapMemoryRecords, psRecord);
348
349 g_WaterMarkData[eAllocType] += uiBytes;
350 if (g_WaterMarkData[eAllocType] > g_HighWaterMarkData[eAllocType])
351 {
352 g_HighWaterMarkData[eAllocType] = g_WaterMarkData[eAllocType];
353 }
354
355 LinuxUnLockMutex(&g_sSwapDebugMutex);
356 return;
357 }
340 358
341 List_DEBUG_MEM_ALLOC_REC_Insert(&g_MemoryRecords, psRecord); 359 LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
360 List_DEBUG_MEM_ALLOC_REC_Insert(&g_MemoryRecords, psRecord);
342 361
343 g_WaterMarkData[eAllocType] += uiBytes; 362 g_WaterMarkData[eAllocType] += uiBytes;
344 if (g_WaterMarkData[eAllocType] > g_HighWaterMarkData[eAllocType]) 363 if (g_WaterMarkData[eAllocType] > g_HighWaterMarkData[eAllocType])
@@ -386,7 +405,6 @@ static IMG_BOOL DebugMemAllocRecordRemove_AnyVaCb(DEBUG_MEM_ALLOC_REC *psCurrent
386 if (psCurrentRecord->eAllocType == eAllocType 405 if (psCurrentRecord->eAllocType == eAllocType
387 && psCurrentRecord->uiKey == uiKey) 406 && psCurrentRecord->uiKey == uiKey)
388 { 407 {
389 eAllocType = psCurrentRecord->eAllocType;
390 g_WaterMarkData[eAllocType] -= psCurrentRecord->uiBytes; 408 g_WaterMarkData[eAllocType] -= psCurrentRecord->uiBytes;
391 409
392 if (eAllocType == DEBUG_MEM_ALLOC_TYPE_KMALLOC 410 if (eAllocType == DEBUG_MEM_ALLOC_TYPE_KMALLOC
@@ -419,10 +437,10 @@ DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_UINTPTR_T uiKey,
419{ 437{
420/* DEBUG_MEM_ALLOC_REC **ppsCurrentRecord;*/ 438/* DEBUG_MEM_ALLOC_REC **ppsCurrentRecord;*/
421 439
422 LinuxLockMutexNested(&g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG); 440 LinuxLockMutexNested(eAllocType == DEBUG_MEM_ALLOC_TYPE_SWAP ? &g_sSwapDebugMutex : &g_sDebugMutex, PVRSRV_LOCK_CLASS_MM_DEBUG);
423 441
424 /* Locate the corresponding allocation entry */ 442 /* Locate the corresponding allocation entry */
425 if (!List_DEBUG_MEM_ALLOC_REC_IMG_BOOL_Any_va(g_MemoryRecords, 443 if (!List_DEBUG_MEM_ALLOC_REC_IMG_BOOL_Any_va(eAllocType == DEBUG_MEM_ALLOC_TYPE_SWAP ? g_SwapMemoryRecords : g_MemoryRecords,
426 DebugMemAllocRecordRemove_AnyVaCb, 444 DebugMemAllocRecordRemove_AnyVaCb,
427 eAllocType, 445 eAllocType,
428 uiKey)) 446 uiKey))
@@ -432,7 +450,7 @@ DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE eAllocType, IMG_UINTPTR_T uiKey,
432 pszFileName, ui32Line)); 450 pszFileName, ui32Line));
433 } 451 }
434 452
435 LinuxUnLockMutex(&g_sDebugMutex); 453 LinuxUnLockMutex(eAllocType == DEBUG_MEM_ALLOC_TYPE_SWAP ? &g_sSwapDebugMutex : &g_sDebugMutex);
436} 454}
437 455
438 456
@@ -450,6 +468,7 @@ DebugMemAllocRecordTypeToString(DEBUG_MEM_ALLOC_TYPE eAllocType)
450#if defined(PVR_LINUX_MEM_AREA_USE_VMAP) 468#if defined(PVR_LINUX_MEM_AREA_USE_VMAP)
451 "VMAP", 469 "VMAP",
452#endif 470#endif
471 "SWAPALLOC",
453 }; 472 };
454 return apszDebugMemoryRecordTypes[eAllocType]; 473 return apszDebugMemoryRecordTypes[eAllocType];
455} 474}
@@ -877,53 +896,59 @@ FreePagePool(IMG_VOID)
877static struct shrinker g_sShrinker; 896static struct shrinker g_sShrinker;
878#endif 897#endif
879 898
880static int 899static unsigned long
881ShrinkPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkControl) 900CountObjectsInPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkControl)
901{
902 PVR_ASSERT(psShrinker == &g_sShrinker);
903 (void)psShrinker;
904 (void)psShrinkControl;
905
906 return atomic_read(&g_sPagePoolEntryCount);
907}
908
909static unsigned long
910ScanObjectsInPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkControl)
882{ 911{
883 unsigned long uNumToScan = psShrinkControl->nr_to_scan; 912 unsigned long uNumToScan = psShrinkControl->nr_to_scan;
913 LinuxPagePoolEntry *psPagePoolEntry, *psTempPoolEntry;
884 914
885 PVR_ASSERT(psShrinker == &g_sShrinker); 915 PVR_ASSERT(psShrinker == &g_sShrinker);
886 (void)psShrinker; 916 (void)psShrinker;
887 917
888 if (uNumToScan != 0) 918 PVR_TRACE(("%s: Number to scan: %ld", __FUNCTION__, uNumToScan));
919 PVR_TRACE(("%s: Pages in pool before scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
920
921 if (!PagePoolTrylock())
889 { 922 {
890 LinuxPagePoolEntry *psPagePoolEntry, *psTempPoolEntry; 923 PVR_TRACE(("%s: Couldn't get page pool lock", __FUNCTION__));
924 return -1;
925 }
891 926
892 PVR_TRACE(("%s: Number to scan: %ld", __FUNCTION__, uNumToScan)); 927 list_for_each_entry_safe(psPagePoolEntry, psTempPoolEntry, &g_sPagePoolList, sPagePoolItem)
893 PVR_TRACE(("%s: Pages in pool before scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); 928 {
929 RemoveEntryFromPool(psPagePoolEntry);
894 930
895 if (!PagePoolTrylock()) 931 FreePageToLinux(psPagePoolEntry->psPage);
896 { 932 LinuxPagePoolEntryFree(psPagePoolEntry);
897 PVR_TRACE(("%s: Couldn't get page pool lock", __FUNCTION__));
898 return -1;
899 }
900 933
901 list_for_each_entry_safe(psPagePoolEntry, psTempPoolEntry, &g_sPagePoolList, sPagePoolItem) 934 if (--uNumToScan == 0)
902 { 935 {
903 RemoveEntryFromPool(psPagePoolEntry); 936 break;
904
905 FreePageToLinux(psPagePoolEntry->psPage);
906 LinuxPagePoolEntryFree(psPagePoolEntry);
907
908 if (--uNumToScan == 0)
909 {
910 break;
911 }
912 } 937 }
938 }
913 939
914 if (list_empty(&g_sPagePoolList)) 940 if (list_empty(&g_sPagePoolList))
915 { 941 {
916 PVR_ASSERT(atomic_read(&g_sPagePoolEntryCount) == 0); 942 PVR_ASSERT(atomic_read(&g_sPagePoolEntryCount) == 0);
917 } 943 }
918 944
919 PagePoolUnlock(); 945 PagePoolUnlock();
920 946
921 PVR_TRACE(("%s: Pages in pool after scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount))); 947 PVR_TRACE(("%s: Pages in pool after scan: %d", __FUNCTION__, atomic_read(&g_sPagePoolEntryCount)));
922 }
923 948
924 return atomic_read(&g_sPagePoolEntryCount); 949 return atomic_read(&g_sPagePoolEntryCount);
925} 950}
926#endif 951#endif /* defined(PVR_LINUX_MEM_AREA_POOL_ALLOW_SHRINK) */
927 952
928static IMG_BOOL 953static IMG_BOOL
929AllocPages(IMG_UINT32 ui32AreaFlags, struct page ***pppsPageList, IMG_HANDLE *phBlockPageList, IMG_UINT32 ui32NumPages, IMG_BOOL *pbFromPagePool) 954AllocPages(IMG_UINT32 ui32AreaFlags, struct page ***pppsPageList, IMG_HANDLE *phBlockPageList, IMG_UINT32 ui32NumPages, IMG_BOOL *pbFromPagePool)
@@ -2207,10 +2232,10 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el)
2207 2232
2208 seq_printf(sfile, "%-60s: %d bytes\n", 2233 seq_printf(sfile, "%-60s: %d bytes\n",
2209 "Current Water Mark of bytes allocated via kmalloc", 2234 "Current Water Mark of bytes allocated via kmalloc",
2210 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC]); 2235 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC] + g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_SWAP]);
2211 seq_printf(sfile, "%-60s: %d bytes\n", 2236 seq_printf(sfile, "%-60s: %d bytes\n",
2212 "Highest Water Mark of bytes allocated via kmalloc", 2237 "Highest Water Mark of bytes allocated via kmalloc",
2213 g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC]); 2238 g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC] + g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_SWAP]);
2214 seq_printf(sfile, "%-60s: %d bytes\n", 2239 seq_printf(sfile, "%-60s: %d bytes\n",
2215 "Current Water Mark of bytes allocated via vmalloc", 2240 "Current Water Mark of bytes allocated via vmalloc",
2216 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_VMALLOC]); 2241 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_VMALLOC]);
@@ -2289,10 +2314,10 @@ static void ProcSeqShowMemoryRecords(struct seq_file *sfile,void* el)
2289 seq_printf(sfile, "<meminfo>\n<meminfo_header>\n"); 2314 seq_printf(sfile, "<meminfo>\n<meminfo_header>\n");
2290 seq_printf(sfile, 2315 seq_printf(sfile,
2291 "<watermark key=\"mr0\" description=\"kmalloc_current\" bytes=\"%d\"/>\n", 2316 "<watermark key=\"mr0\" description=\"kmalloc_current\" bytes=\"%d\"/>\n",
2292 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC]); 2317 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC] + g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_SWAP]);
2293 seq_printf(sfile, 2318 seq_printf(sfile,
2294 "<watermark key=\"mr1\" description=\"kmalloc_high\" bytes=\"%d\"/>\n", 2319 "<watermark key=\"mr1\" description=\"kmalloc_high\" bytes=\"%d\"/>\n",
2295 g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC]); 2320 g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_KMALLOC] + g_HighWaterMarkData[DEBUG_MEM_ALLOC_TYPE_SWAP]);
2296 seq_printf(sfile, 2321 seq_printf(sfile,
2297 "<watermark key=\"mr2\" description=\"vmalloc_current\" bytes=\"%d\"/>\n", 2322 "<watermark key=\"mr2\" description=\"vmalloc_current\" bytes=\"%d\"/>\n",
2298 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_VMALLOC]); 2323 g_WaterMarkData[DEBUG_MEM_ALLOC_TYPE_VMALLOC]);
@@ -2521,6 +2546,9 @@ static IMG_VOID LinuxMMCleanup_MemRecords_ForEachVa(DEBUG_MEM_ALLOC_REC *psCurre
2521 psCurrentRecord->ui32Line)); 2546 psCurrentRecord->ui32Line));
2522 switch (psCurrentRecord->eAllocType) 2547 switch (psCurrentRecord->eAllocType)
2523 { 2548 {
2549 case DEBUG_MEM_ALLOC_TYPE_SWAP:
2550 _KFreeWrapper(psCurrentRecord->pvCpuVAddr, __FILE__, __LINE__, IMG_TRUE);
2551 break;
2524 case DEBUG_MEM_ALLOC_TYPE_KMALLOC: 2552 case DEBUG_MEM_ALLOC_TYPE_KMALLOC:
2525 KFreeWrapper(psCurrentRecord->pvCpuVAddr); 2553 KFreeWrapper(psCurrentRecord->pvCpuVAddr);
2526 break; 2554 break;
@@ -2553,11 +2581,34 @@ static IMG_VOID LinuxMMCleanup_MemRecords_ForEachVa(DEBUG_MEM_ALLOC_REC *psCurre
2553 2581
2554 2582
2555#if defined(PVR_LINUX_MEM_AREA_POOL_ALLOW_SHRINK) 2583#if defined(PVR_LINUX_MEM_AREA_POOL_ALLOW_SHRINK)
2584#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0))
2585static int
2586ShrinkPagePool(struct shrinker *psShrinker, struct shrink_control *psShrinkControl)
2587{
2588 if(psShrinkControl->nr_to_scan != 0)
2589 {
2590 return ScanObjectsInPagePool(psShrinker, psShrinkControl);
2591 }
2592 else
2593 {
2594 /* No pages are being reclaimed so just return the page count. */
2595 return CountObjectsInPagePool(psShrinker, psShrinkControl);
2596 }
2597}
2598
2556static struct shrinker g_sShrinker = 2599static struct shrinker g_sShrinker =
2557{ 2600{
2558 .shrink = ShrinkPagePool, 2601 .shrink = ShrinkPagePool,
2559 .seeks = DEFAULT_SEEKS 2602 .seeks = DEFAULT_SEEKS
2560}; 2603};
2604#else
2605static struct shrinker g_sShrinker =
2606{
2607 .count_objects = CountObjectsInPagePool,
2608 .scan_objects = ScanObjectsInPagePool,
2609 .seeks = DEFAULT_SEEKS
2610};
2611#endif
2561 2612
2562static IMG_BOOL g_bShrinkerRegistered; 2613static IMG_BOOL g_bShrinkerRegistered;
2563#endif 2614#endif
@@ -2603,6 +2654,7 @@ LinuxMMCleanup(IMG_VOID)
2603 * report an error, and simply brute force free anything we find. 2654 * report an error, and simply brute force free anything we find.
2604 */ 2655 */
2605 List_DEBUG_MEM_ALLOC_REC_ForEach(g_MemoryRecords, LinuxMMCleanup_MemRecords_ForEachVa); 2656 List_DEBUG_MEM_ALLOC_REC_ForEach(g_MemoryRecords, LinuxMMCleanup_MemRecords_ForEachVa);
2657 List_DEBUG_MEM_ALLOC_REC_ForEach(g_SwapMemoryRecords, LinuxMMCleanup_MemRecords_ForEachVa);
2606 2658
2607 if (g_SeqFileMemoryRecords) 2659 if (g_SeqFileMemoryRecords)
2608 { 2660 {
@@ -2627,6 +2679,7 @@ LinuxMMInit(IMG_VOID)
2627{ 2679{
2628#if defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 2680#if defined(DEBUG_LINUX_MEM_AREAS) || defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
2629 LinuxInitMutex(&g_sDebugMutex); 2681 LinuxInitMutex(&g_sDebugMutex);
2682 LinuxInitMutex(&g_sSwapDebugMutex);
2630#endif 2683#endif
2631 2684
2632#if defined(DEBUG_LINUX_MEM_AREAS) 2685#if defined(DEBUG_LINUX_MEM_AREAS)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.h
index 933420d..4e64dd6 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mm.h
@@ -236,12 +236,11 @@ IMG_VOID LinuxMMCleanup(IMG_VOID);
236 * @return 236 * @return
237 ******************************************************************************/ 237 ******************************************************************************/
238#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 238#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
239#define KMallocWrapper(uByteSize, uFlags) _KMallocWrapper(uByteSize, uFlags, __FILE__, __LINE__) 239#define KMallocWrapper(uByteSize, uFlags) _KMallocWrapper(uByteSize, uFlags, __FILE__, __LINE__, IMG_FALSE)
240#else 240#else
241#define KMallocWrapper(uByteSize, uFlags) _KMallocWrapper(uByteSize, uFlags, NULL, 0) 241#define KMallocWrapper(uByteSize, uFlags) _KMallocWrapper(uByteSize, uFlags, NULL, 0, IMG_FALSE)
242#endif 242#endif
243IMG_VOID *_KMallocWrapper(IMG_SIZE_T uByteSize, gfp_t uFlags, IMG_CHAR *szFileName, IMG_UINT32 ui32Line); 243void *_KMallocWrapper(IMG_SIZE_T uByteSize, gfp_t uFlags, IMG_CHAR *szFileName, IMG_UINT32 ui32Line, IMG_BOOL bSwapAlloc);
244
245 244
246/*! 245/*!
247 ******************************************************************************* 246 *******************************************************************************
@@ -252,12 +251,11 @@ IMG_VOID *_KMallocWrapper(IMG_SIZE_T uByteSize, gfp_t uFlags, IMG_CHAR *szFileNa
252 * @return 251 * @return
253 ******************************************************************************/ 252 ******************************************************************************/
254#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 253#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
255#define KFreeWrapper(pvCpuVAddr) _KFreeWrapper(pvCpuVAddr, __FILE__, __LINE__) 254#define KFreeWrapper(pvCpuVAddr) _KFreeWrapper(pvCpuVAddr, __FILE__, __LINE__, IMG_FALSE)
256#else 255#else
257#define KFreeWrapper(pvCpuVAddr) _KFreeWrapper(pvCpuVAddr, NULL, 0) 256#define KFreeWrapper(pvCpuVAddr) _KFreeWrapper(pvCpuVAddr, NULL, 0, IMG_FALSE)
258#endif 257#endif
259IMG_VOID _KFreeWrapper(IMG_VOID *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line); 258void _KFreeWrapper(void *pvCpuVAddr, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line, IMG_BOOL bSwapAlloc);
260
261 259
262/*! 260/*!
263 ******************************************************************************* 261 *******************************************************************************
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mmap.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mmap.c
index a0b8211..e7fb667 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mmap.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mmap.c
@@ -67,6 +67,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67#endif 67#endif
68#if defined(SUPPORT_DRI_DRM) 68#if defined(SUPPORT_DRI_DRM)
69#include <drm/drmP.h> 69#include <drm/drmP.h>
70#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
71#include <drm/drm_legacy.h>
72#endif
70#endif 73#endif
71 74
72#ifdef CONFIG_ARCH_OMAP5 75#ifdef CONFIG_ARCH_OMAP5
@@ -95,6 +98,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
95#error "The mmap code requires PVR_SECURE_HANDLES" 98#error "The mmap code requires PVR_SECURE_HANDLES"
96#endif 99#endif
97 100
101#if defined(SUPPORT_DRI_DRM) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
102static inline int drm_mmap(struct file *filp, struct vm_area_struct *vma)
103{
104 return drm_legacy_mmap(filp, vma);
105}
106#endif
107
98/* WARNING: 108/* WARNING:
99 * The mmap code has its own mutex, to prevent a possible deadlock, 109 * The mmap code has its own mutex, to prevent a possible deadlock,
100 * when using gPVRSRVLock. 110 * when using gPVRSRVLock.
@@ -1167,7 +1177,7 @@ unlock_and_return:
1167 1177
1168 LinuxUnLockMutex(&g_sMMapMutex); 1178 LinuxUnLockMutex(&g_sMMapMutex);
1169 1179
1170 if(psFlushMemArea) 1180 if(psFlushMemArea && uiFlushSize)
1171 { 1181 {
1172 OSInvalidateCPUCacheRangeKM(psFlushMemArea, uiByteOffset, pvBase, 1182 OSInvalidateCPUCacheRangeKM(psFlushMemArea, uiByteOffset, pvBase,
1173 uiFlushSize); 1183 uiFlushSize);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/module.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/module.c
index 4c9cf9e..5ce0a9b 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/module.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/module.c
@@ -73,10 +73,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73#define PVR_MOD_STATIC static 73#define PVR_MOD_STATIC static
74#endif 74#endif
75 75
76#if defined(PVR_LDM_PLATFORM_PRE_REGISTERED) 76#if (defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(PVR_LDM_DEVICE_TREE)) && !defined(NO_HARDWARE)
77#if !defined(NO_HARDWARE)
78#define PVR_USE_PRE_REGISTERED_PLATFORM_DEV 77#define PVR_USE_PRE_REGISTERED_PLATFORM_DEV
79#endif 78#endif
79
80#if defined(PVR_LDM_DEVICE_TREE) && !defined(NO_HARDWARE)
81#define PVR_USE_DEVICE_TREE
80#endif 82#endif
81 83
82#include <linux/init.h> 84#include <linux/init.h>
@@ -84,10 +86,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84#include <linux/module.h> 86#include <linux/module.h>
85#include <linux/fs.h> 87#include <linux/fs.h>
86 88
87#ifdef CONFIG_OF
88#include <linux/of.h>
89#endif
90
91#if defined(SUPPORT_DRI_DRM) 89#if defined(SUPPORT_DRI_DRM)
92#include <drm/drmP.h> 90#include <drm/drmP.h>
93#if defined(PVR_SECURE_DRM_AUTH_EXPORT) 91#if defined(PVR_SECURE_DRM_AUTH_EXPORT)
@@ -143,6 +141,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
143#if defined(SUPPORT_DRI_DRM) 141#if defined(SUPPORT_DRI_DRM)
144#include "pvr_drm.h" 142#include "pvr_drm.h"
145#endif 143#endif
144
145#if defined(SUPPORT_DMABUF)
146#include "pvr_linux_fence.h"
147#endif
148
146/* 149/*
147 * DRVNAME is the name we use to register our driver. 150 * DRVNAME is the name we use to register our driver.
148 * DEVNAME is the name we use to register actual device nodes. 151 * DEVNAME is the name we use to register actual device nodes.
@@ -170,10 +173,18 @@ module_param(gPVRDebugLevel, uint, 0644);
170MODULE_PARM_DESC(gPVRDebugLevel, "Sets the level of debug output (default 0x7)"); 173MODULE_PARM_DESC(gPVRDebugLevel, "Sets the level of debug output (default 0x7)");
171#endif /* defined(PVRSRV_NEED_PVR_DPF) */ 174#endif /* defined(PVRSRV_NEED_PVR_DPF) */
172 175
173/* Newer kernels no longer support __devinitdata */
174#if !defined(__devinitdata) 176#if !defined(__devinitdata)
175#define __devinitdata 177#define __devinitdata
176#endif 178#endif
179#if !defined(__devinit)
180#define __devinit
181#endif
182#if !defined(__devexit)
183#define __devexit
184#endif
185#if !defined(__devexit_p)
186#define __devexit_p(x) (&(x))
187#endif
177 188
178#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) 189#if defined(SUPPORT_PVRSRV_DEVICE_CLASS)
179/* PRQA S 3207 2 */ /* ignore 'not used' warning */ 190/* PRQA S 3207 2 */ /* ignore 'not used' warning */
@@ -262,34 +273,36 @@ struct pci_device_id powervr_id_table[] __devinitdata = {
262MODULE_DEVICE_TABLE(pci, powervr_id_table); 273MODULE_DEVICE_TABLE(pci, powervr_id_table);
263#endif 274#endif
264 275
276#if defined(PVR_USE_DEVICE_TREE)
277static struct of_device_id powervr_id_table[] = {
278 {
279 .compatible = SYS_SGX_DEV_NAME
280 },
281 {}
282};
283MODULE_DEVICE_TABLE(of, powervr_id_table);
284#else
265#if defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) 285#if defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
266static struct platform_device_id powervr_id_table[] __devinitdata = { 286static struct platform_device_id powervr_id_table[] __devinitdata = {
267 {SYS_SGX_DEV_NAME, 0}, 287 {SYS_SGX_DEV_NAME, 0},
268 {} 288 {}
269}; 289};
270#endif 290#endif
271
272#ifdef CONFIG_OF
273static const struct of_device_id omap_gpu_id_table[] = {
274 { .compatible = "ti,omap4-gpu" },
275 {}
276};
277MODULE_DEVICE_TABLE(of, omap_gpu_id_table);
278#endif 291#endif
279 292
280static LDM_DRV powervr_driver = { 293static LDM_DRV powervr_driver = {
281#if defined(PVR_LDM_PLATFORM_MODULE) 294#if defined(PVR_LDM_PLATFORM_MODULE)
282 .driver = { 295 .driver = {
283 .name = DRVNAME, 296 .name = DRVNAME,
284#ifdef CONFIG_OF 297#if defined(PVR_USE_DEVICE_TREE)
285 .of_match_table = of_match_ptr(omap_gpu_id_table), 298 .of_match_table = powervr_id_table,
286#endif 299#endif
287 }, 300 },
288#endif 301#endif
289#if defined(PVR_LDM_PCI_MODULE) 302#if defined(PVR_LDM_PCI_MODULE)
290 .name = DRVNAME, 303 .name = DRVNAME,
291#endif 304#endif
292#if defined(PVR_LDM_PCI_MODULE) || defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) 305#if (defined(PVR_LDM_PCI_MODULE) || defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)) && !defined(PVR_USE_DEVICE_TREE)
293 .id_table = powervr_id_table, 306 .id_table = powervr_id_table,
294#endif 307#endif
295 .probe = PVRSRVDriverProbe, 308 .probe = PVRSRVDriverProbe,
@@ -439,6 +452,16 @@ static void __devexit PVRSRVDriverRemove(LDM_DEV *pDevice)
439} 452}
440#endif /* defined(PVR_LDM_MODULE) */ 453#endif /* defined(PVR_LDM_MODULE) */
441 454
455#if !defined(SUPPORT_DRI_DRM)
456struct device *PVRLDMGetDevice(void)
457{
458#if defined(PVR_LDM_MODULE)
459 return &gpsPVRLDMDev->dev;
460#else
461 return NULL;
462#endif
463}
464#endif
442 465
443#if defined(PVR_LDM_MODULE) || defined(SUPPORT_DRI_DRM) 466#if defined(PVR_LDM_MODULE) || defined(SUPPORT_DRI_DRM)
444static PVRSRV_LINUX_MUTEX gsPMMutex; 467static PVRSRV_LINUX_MUTEX gsPMMutex;
@@ -975,9 +998,16 @@ static int __init PVRCore_Init(void)
975 goto init_failed; 998 goto init_failed;
976 } 999 }
977 1000
1001#if defined(SUPPORT_DMABUF)
1002 if (PVRLinuxFenceInit())
1003 {
1004 error = -ENOMEM;
1005 goto init_failed;
1006 }
1007#endif
1008
978 LinuxBridgeInit(); 1009 LinuxBridgeInit();
979 1010
980
981 PVRMMapInit(); 1011 PVRMMapInit();
982 1012
983#if defined(PVR_LDM_MODULE) 1013#if defined(PVR_LDM_MODULE)
@@ -1119,6 +1149,9 @@ init_failed:
1119 PVRMMapCleanup(); 1149 PVRMMapCleanup();
1120 LinuxMMCleanup(); 1150 LinuxMMCleanup();
1121 LinuxBridgeDeInit(); 1151 LinuxBridgeDeInit();
1152#if defined(SUPPORT_DMABUF)
1153 PVRLinuxFenceDeInit();
1154#endif
1122 PVROSFuncDeInit(); 1155 PVROSFuncDeInit();
1123 RemoveProcEntries(); 1156 RemoveProcEntries();
1124 return error; 1157 return error;
@@ -1224,6 +1257,10 @@ static void __exit PVRCore_Cleanup(void)
1224 1257
1225 LinuxBridgeDeInit(); 1258 LinuxBridgeDeInit();
1226 1259
1260#if defined(SUPPORT_DMABUF)
1261 PVRLinuxFenceDeInit();
1262#endif
1263
1227 PVROSFuncDeInit(); 1264 PVROSFuncDeInit();
1228 1265
1229 RemoveProcEntries(); 1266 RemoveProcEntries();
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c
index 8e57476..9e83d85 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c
@@ -57,6 +57,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57#include "mutils.h" 57#include "mutils.h"
58 58
59#if defined(SUPPORT_LINUX_X86_PAT) 59#if defined(SUPPORT_LINUX_X86_PAT)
60
61#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
62#define _PAGE_CACHE_WC pgprot_val(cachemode2pgprot(_PAGE_CACHE_MODE_WC))
63#endif
64
60#define PAT_LINUX_X86_WC 1 65#define PAT_LINUX_X86_WC 1
61 66
62#define PAT_X86_ENTRY_BITS 8 67#define PAT_X86_ENTRY_BITS 8
@@ -113,7 +118,11 @@ PVRLinuxX86PATProbe(IMG_VOID)
113 PVR_TRACE(("%s: Top 32 bits of PAT: 0x%.8x", __FUNCTION__, (IMG_UINT)(pat >> 32))); 118 PVR_TRACE(("%s: Top 32 bits of PAT: 0x%.8x", __FUNCTION__, (IMG_UINT)(pat >> 32)));
114 PVR_TRACE(("%s: Bottom 32 bits of PAT: 0x%.8x", __FUNCTION__, (IMG_UINT)(pat))); 119 PVR_TRACE(("%s: Bottom 32 bits of PAT: 0x%.8x", __FUNCTION__, (IMG_UINT)(pat)));
115 120
121#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
122 pat_index = pvr_pat_index(_PAGE_CACHE_MODE_WC);
123#else
116 pat_index = pvr_pat_index(_PAGE_CACHE_WC); 124 pat_index = pvr_pat_index(_PAGE_CACHE_WC);
125#endif
117 PVR_TRACE(("%s: PAT index for write combining: %u", __FUNCTION__, pat_index)); 126 PVR_TRACE(("%s: PAT index for write combining: %u", __FUNCTION__, pat_index));
118 127
119 pat_entry = pvr_pat_entry(pat, pat_index); 128 pat_entry = pvr_pat_entry(pat, pat_index);
@@ -152,7 +161,11 @@ pvr_pgprot_writecombine(pgprot_t prot)
152 */ 161 */
153 /* PRQA S 0481,0482 2 */ /* scalar expressions */ 162 /* PRQA S 0481,0482 2 */ /* scalar expressions */
154 return (g_write_combining_available) ? 163 return (g_write_combining_available) ?
164#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
165 __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_MASK) | _PAGE_CACHE_MODE_WC) : pgprot_noncached(prot);
166#else
155 __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_MASK) | _PAGE_CACHE_WC) : pgprot_noncached(prot); 167 __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_MASK) | _PAGE_CACHE_WC) : pgprot_noncached(prot);
168#endif
156} 169}
157#endif /* defined(SUPPORT_LINUX_X86_PAT) */ 170#endif /* defined(SUPPORT_LINUX_X86_PAT) */
158 171
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.h
index 1fe1eb1..61edf95 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.h
@@ -80,10 +80,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
80 #define IOREMAP(pa, bytes) ioremap_cache(pa, bytes) 80 #define IOREMAP(pa, bytes) ioremap_cache(pa, bytes)
81#else 81#else
82 #if defined(__arm__) 82 #if defined(__arm__)
83 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) 83 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
84 #define IOREMAP(pa, bytes) ioremap_cache(pa, bytes) 84 #define IOREMAP(pa, bytes) ioremap_cache(pa, bytes)
85 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) 85 #else
86 #define IOREMAP(pa, bytes) ioremap_cached(pa, bytes) 86 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
87 #define IOREMAP(pa, bytes) ioremap_cached(pa, bytes)
88 #else
89 #define IOREMAP(pa, bytes) ioremap(pa, bytes)
90 #endif
87 #endif 91 #endif
88 #else 92 #else
89 #define IOREMAP(pa, bytes) ioremap(pa, bytes) 93 #define IOREMAP(pa, bytes) ioremap(pa, bytes)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osfunc.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osfunc.c
index 369c0e1..1302edb 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osfunc.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osfunc.c
@@ -66,7 +66,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <asm/hardirq.h> 67#include <asm/hardirq.h>
68#include <linux/timer.h> 68#include <linux/timer.h>
69#if defined(MEM_TRACK_INFO_DEBUG) 69#if defined(MEM_TRACK_INFO_DEBUG) || defined (PVRSRV_DEVMEM_TIME_STATS)
70#include <linux/time.h> 70#include <linux/time.h>
71#endif 71#endif
72#include <linux/capability.h> 72#include <linux/capability.h>
@@ -94,10 +94,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
94#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 94#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
95#include "pvr_sync.h" 95#include "pvr_sync.h"
96#endif 96#endif
97
98#if defined (SUPPORT_ION) 97#if defined (SUPPORT_ION)
99#include "ion.h" 98#include "ion.h"
100#endif 99#endif
100#if defined(SUPPORT_DMABUF)
101#include "pvr_linux_fence.h"
102#endif
101 103
102#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) 104#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
103#define ON_EACH_CPU(func, info, wait) on_each_cpu(func, info, wait) 105#define ON_EACH_CPU(func, info, wait) on_each_cpu(func, info, wait)
@@ -146,7 +148,7 @@ PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uiSize, IMG_PVOID
146 } 148 }
147 149
148#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 150#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
149 *ppvCpuVAddr = _KMallocWrapper(uiSize, GFP_KERNEL | __GFP_NOWARN, pszFilename, ui32Line); 151 *ppvCpuVAddr = _KMallocWrapper(uiSize, GFP_KERNEL | __GFP_NOWARN, pszFilename, ui32Line, ui32Flags & PVRSRV_SWAP_BUFFER_ALLOCATION);
150#else 152#else
151 *ppvCpuVAddr = KMallocWrapper(uiSize, GFP_KERNEL | __GFP_NOWARN); 153 *ppvCpuVAddr = KMallocWrapper(uiSize, GFP_KERNEL | __GFP_NOWARN);
152#endif 154#endif
@@ -189,7 +191,7 @@ PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T uiSize, IMG_PVOID p
189 else 191 else
190 { 192 {
191#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 193#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
192 _KFreeWrapper(pvCpuVAddr, pszFilename, ui32Line); 194 _KFreeWrapper(pvCpuVAddr, pszFilename, ui32Line, ui32Flags & PVRSRV_SWAP_BUFFER_ALLOCATION);
193#else 195#else
194 KFreeWrapper(pvCpuVAddr); 196 KFreeWrapper(pvCpuVAddr);
195#endif 197#endif
@@ -562,10 +564,28 @@ IMG_VOID OSBreakResourceLock (PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID)
562******************************************************************************/ 564******************************************************************************/
563PVRSRV_ERROR OSCreateResource(PVRSRV_RESOURCE *psResource) 565PVRSRV_ERROR OSCreateResource(PVRSRV_RESOURCE *psResource)
564{ 566{
567#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
568 PVRSRV_ERROR eError = PVRSRV_OK;
569#endif
570
565 psResource->ui32ID = 0; 571 psResource->ui32ID = 0;
566 psResource->ui32Lock = 0; 572 psResource->ui32Lock = 0;
573#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
574 psResource->pOSSyncPrimitive = IMG_NULL;
567 575
568 return PVRSRV_OK; 576 eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(spinlock_t), (IMG_VOID**)&psResource->pOSSyncPrimitive, IMG_NULL,
577 "Resource Spinlock");
578
579 if (eError != PVRSRV_OK)
580 {
581 PVR_DPF((PVR_DBG_ERROR,"OSCreateResource: Spinlock could not be alloc'd"));
582 return eError;
583 }
584
585 spin_lock_init((spinlock_t*)psResource->pOSSyncPrimitive);
586#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
587
588 return PVRSRV_OK;
569} 589}
570 590
571 591
@@ -583,6 +603,13 @@ PVRSRV_ERROR OSCreateResource(PVRSRV_RESOURCE *psResource)
583******************************************************************************/ 603******************************************************************************/
584PVRSRV_ERROR OSDestroyResource (PVRSRV_RESOURCE *psResource) 604PVRSRV_ERROR OSDestroyResource (PVRSRV_RESOURCE *psResource)
585{ 605{
606#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
607 if (psResource->pOSSyncPrimitive)
608 {
609 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(spinlock_t), (IMG_VOID*)psResource->pOSSyncPrimitive, IMG_NULL);
610 }
611#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
612
586 OSBreakResourceLock (psResource, psResource->ui32ID); 613 OSBreakResourceLock (psResource, psResource->ui32ID);
587 614
588 return PVRSRV_OK; 615 return PVRSRV_OK;
@@ -683,6 +710,30 @@ IMG_VOID OSReleaseThreadQuanta(IMG_VOID)
683 schedule(); 710 schedule();
684} 711}
685 712
713#if defined (PVRSRV_DEVMEM_TIME_STATS)
714/*!
715******************************************************************************
716
717 @Function OSClockMonotonicus
718
719 @Description This function returns the raw monotonic clock time in microseconds
720 (i.e. un-affected by NTP or similar changes)
721
722 @Input void
723
724 @Return - monotonic clock time in (us)
725
726******************************************************************************/
727IMG_UINT64 OSClockMonotonicus(IMG_VOID)
728{
729 struct timespec ts;
730
731 getrawmonotonic(&ts);
732
733 return ((unsigned long)ts.tv_sec * 1000000ul + (unsigned long)ts.tv_nsec / 1000ul);
734}
735#endif
736
686 737
687/*! 738/*!
688****************************************************************************** 739******************************************************************************
@@ -1119,6 +1170,9 @@ static void MISRWrapper(
1119#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) 1170#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC)
1120 PVRSyncUpdateAllSyncs(); 1171 PVRSyncUpdateAllSyncs();
1121#endif 1172#endif
1173#if defined(SUPPORT_DMABUF)
1174 PVRLinuxFenceCheckAll();
1175#endif
1122} 1176}
1123 1177
1124 1178
@@ -1550,6 +1604,81 @@ PVRSRV_ERROR OSUnlockResource (PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID)
1550} 1604}
1551 1605
1552 1606
1607#if !defined(PVR_LINUX_USING_WORKQUEUES)
1608/*!
1609******************************************************************************
1610
1611 @Function OSLockResourceAndBlockMISR
1612
1613 @Description locks an OS dependant Resource and blocks MISR interrupts
1614
1615 @Input phResource - pointer to OS dependent Resource
1616 @Input bBlock - do we want to block?
1617
1618 @Return error status
1619
1620******************************************************************************/
1621PVRSRV_ERROR OSLockResourceAndBlockMISR ( PVRSRV_RESOURCE *psResource,
1622 IMG_UINT32 ui32ID)
1623
1624{
1625 PVRSRV_ERROR eError = PVRSRV_OK;
1626
1627 spin_lock_bh(psResource->pOSSyncPrimitive);
1628
1629 if(!OS_TAS(&psResource->ui32Lock))
1630 psResource->ui32ID = ui32ID;
1631 else
1632 eError = PVRSRV_ERROR_UNABLE_TO_LOCK_RESOURCE;
1633
1634 return eError;
1635}
1636
1637
1638/*!
1639******************************************************************************
1640
1641 @Function OSUnlockResourceAndUnblockMISR
1642
1643 @Description unlocks an OS dependant resource and unblocks MISR interrupts
1644
1645 @Input phResource - pointer to OS dependent resource structure
1646
1647 @Return
1648
1649******************************************************************************/
1650PVRSRV_ERROR OSUnlockResourceAndUnblockMISR (PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID)
1651{
1652 volatile IMG_UINT32 *pui32Access = (volatile IMG_UINT32 *)&psResource->ui32Lock;
1653 PVRSRV_ERROR eError = PVRSRV_OK;
1654
1655 if(*pui32Access)
1656 {
1657 if(psResource->ui32ID == ui32ID)
1658 {
1659 psResource->ui32ID = 0;
1660 smp_mb();
1661 *pui32Access = 0;
1662 spin_unlock_bh(psResource->pOSSyncPrimitive);
1663 }
1664 else
1665 {
1666 PVR_DPF((PVR_DBG_ERROR,"OSUnlockResourceAndUnblockMISR: Resource %p is not locked with expected value.", psResource));
1667 PVR_DPF((PVR_DBG_MESSAGE,"Should be %x is actually %x", ui32ID, psResource->ui32ID));
1668 eError = PVRSRV_ERROR_INVALID_LOCK_ID;
1669 }
1670 }
1671 else
1672 {
1673 PVR_DPF((PVR_DBG_ERROR,"OSUnlockResourceAndUnblockMISR: Resource %p is not locked", psResource));
1674 eError = PVRSRV_ERROR_RESOURCE_NOT_LOCKED;
1675 }
1676
1677 return eError;
1678}
1679#endif
1680
1681
1553/*! 1682/*!
1554****************************************************************************** 1683******************************************************************************
1555 1684
@@ -2040,7 +2169,7 @@ PVRSRV_ERROR OSBaseAllocContigMemory(IMG_SIZE_T uiSize, IMG_CPU_VIRTADDR *pvLinA
2040 IMG_VOID *pvKernLinAddr; 2169 IMG_VOID *pvKernLinAddr;
2041 2170
2042#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) 2171#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
2043 pvKernLinAddr = _KMallocWrapper(uiSize, GFP_KERNEL, __FILE__, __LINE__); 2172 pvKernLinAddr = _KMallocWrapper(uiSize, GFP_KERNEL, __FILE__, __LINE__, IMG_FALSE);
2044#else 2173#else
2045 pvKernLinAddr = KMallocWrapper(uiSize, GFP_KERNEL); 2174 pvKernLinAddr = KMallocWrapper(uiSize, GFP_KERNEL);
2046#endif 2175#endif
@@ -4634,10 +4763,9 @@ PVRSRV_ERROR PVROSFuncInit(IMG_VOID)
4634 } 4763 }
4635#endif 4764#endif
4636 4765
4637#if 0//defined (SUPPORT_ION) 4766#if defined(SUPPORT_ION) && !defined(LMA)
4638 { 4767 {
4639 PVRSRV_ERROR eError; 4768 PVRSRV_ERROR eError;
4640
4641 eError = IonInit(); 4769 eError = IonInit();
4642 if (eError != PVRSRV_OK) 4770 if (eError != PVRSRV_OK)
4643 { 4771 {
@@ -4654,7 +4782,7 @@ PVRSRV_ERROR PVROSFuncInit(IMG_VOID)
4654 */ 4782 */
4655IMG_VOID PVROSFuncDeInit(IMG_VOID) 4783IMG_VOID PVROSFuncDeInit(IMG_VOID)
4656{ 4784{
4657#if 0//defined (SUPPORT_ION) 4785#if defined (SUPPORT_ION)
4658 IonDeinit(); 4786 IonDeinit();
4659#endif 4787#endif
4660#if defined(PVR_LINUX_TIMERS_USING_WORKQUEUES) 4788#if defined(PVR_LINUX_TIMERS_USING_WORKQUEUES)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osperproc.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osperproc.c
index 5a79f75..9b014dc 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osperproc.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osperproc.c
@@ -47,7 +47,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47#if defined (SUPPORT_ION) 47#if defined (SUPPORT_ION)
48#include <linux/err.h> 48#include <linux/err.h>
49#include "ion.h" 49#include "ion.h"
50//extern struct ion_device *gpsIonDev; 50extern struct ion_device *gpsIonDev;
51#endif 51#endif
52 52
53extern IMG_UINT32 gui32ReleasePID; 53extern IMG_UINT32 gui32ReleasePID;
@@ -85,7 +85,7 @@ PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData)
85 INIT_LIST_HEAD(&psEnvPerProc->sDRMAuthListHead); 85 INIT_LIST_HEAD(&psEnvPerProc->sDRMAuthListHead);
86#endif 86#endif
87 87
88#if 0//defined(SUPPORT_ION) 88#if defined(SUPPORT_ION)
89 OSSNPrintf(psEnvPerProc->azIonClientName, ION_CLIENT_NAME_SIZE, "pvr_ion_client-%d", OSGetCurrentProcessIDKM()); 89 OSSNPrintf(psEnvPerProc->azIonClientName, ION_CLIENT_NAME_SIZE, "pvr_ion_client-%d", OSGetCurrentProcessIDKM());
90 psEnvPerProc->psIONClient = 90 psEnvPerProc->psIONClient =
91 ion_client_create(gpsIonDev, 91 ion_client_create(gpsIonDev,
@@ -114,7 +114,7 @@ PVRSRV_ERROR OSPerProcessPrivateDataDeInit(IMG_HANDLE hOsPrivateData)
114 114
115 psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)hOsPrivateData; 115 psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)hOsPrivateData;
116 116
117#if 0//defined(SUPPORT_ION) 117#if defined(SUPPORT_ION)
118 if (psEnvPerProc->psIONClient) 118 if (psEnvPerProc->psIONClient)
119 { 119 {
120 ion_client_destroy(psEnvPerProc->psIONClient); 120 ion_client_destroy(psEnvPerProc->psIONClient);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_debug.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_debug.c
index aece908..621a30d 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_debug.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_debug.c
@@ -462,17 +462,18 @@ IMG_VOID PVRSRVDebugPrintf (
462 } 462 }
463 else 463 else
464 { 464 {
465 const IMG_CHAR *pszShortName = strrchr(pszFileName, '/') + 1;
466 if(pszShortName)
467 pszFileName = pszShortName;
468 if (ui32DebugLevel & DBGPRIV_BUFFERED) 465 if (ui32DebugLevel & DBGPRIV_BUFFERED)
469 { 466 {
470 /* We don't need the full path here */ 467 /* We don't need the full path here */
468 const IMG_CHAR *pszShortName = strrchr(pszFileName, '/') + 1;
469 if(pszShortName)
470 pszFileName = pszShortName;
471
471 AddToBufferCCB(pszFileName, ui32Line, pszBuf); 472 AddToBufferCCB(pszFileName, ui32Line, pszBuf);
472 } 473 }
473 else 474 else
474 { 475 {
475 printk(KERN_INFO "%s (File: %s, Line: %d)\n", pszBuf, pszFileName, ui32Line); 476 printk(KERN_INFO "%s\n", pszBuf);
476 } 477 }
477 } 478 }
478 479
@@ -504,7 +505,7 @@ IMG_INT PVRDebugProcSetLevel(struct file *file, const IMG_CHAR *buffer, IMG_UINT
504 return -EINVAL; 505 return -EINVAL;
505 if (data_buffer[count - 1] != '\n') 506 if (data_buffer[count - 1] != '\n')
506 return -EINVAL; 507 return -EINVAL;
507 if (sscanf(data_buffer, "%i", &gPVRDebugLevel) == 0) 508 if (sscanf(data_buffer, "%u", &gPVRDebugLevel) == 0)
508 return -EINVAL; 509 return -EINVAL;
509 gPVRDebugLevel &= (1 << DBGPRIV_DBGLEVEL_COUNT) - 1; 510 gPVRDebugLevel &= (1 << DBGPRIV_DBGLEVEL_COUNT) - 1;
510 } 511 }
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.c
index 3a925ad..8b862a9 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.c
@@ -84,7 +84,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84#include "pvr_drm_mod.h" 84#include "pvr_drm_mod.h"
85#endif 85#endif
86 86
87#if (defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(PVR_LDM_PLATFORM_PRE_REGISTERED)) || defined(NO_HARDWARE) 87#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
88#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
89#endif
90
91#if (defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(PVR_LDM_DEVICE_TREE)) && !defined(NO_HARDWARE)
92#define PVR_USE_PRE_REGISTERED_PLATFORM_DEV
93#endif
94
95#if defined(PVR_LDM_DEVICE_TREE) && !defined(NO_HARDWARE)
96#define PVR_USE_DEVICE_TREE
97#endif
98
99#if (defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)) || defined(NO_HARDWARE)
88#define PVR_DRM_NAME SYS_SGX_DEV_NAME 100#define PVR_DRM_NAME SYS_SGX_DEV_NAME
89#else 101#else
90#define PVR_DRM_NAME PVRSRV_MODNAME 102#define PVR_DRM_NAME PVRSRV_MODNAME
@@ -116,6 +128,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
116#define PVR_DRI_DRM_USE_POST_CLOSE 128#define PVR_DRI_DRM_USE_POST_CLOSE
117#endif 129#endif
118 130
131#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
132#define PVR_DRM_DRIVER_RENDER DRIVER_RENDER
133#define PVR_DRM_RENDER_ALLOW DRM_RENDER_ALLOW
134#else
135#define PVR_DRM_DRIVER_RENDER 0
136#define PVR_DRM_RENDER_ALLOW 0
137#endif
138
119DECLARE_WAIT_QUEUE_HEAD(sWaitForInit); 139DECLARE_WAIT_QUEUE_HEAD(sWaitForInit);
120 140
121#if defined(SUPPORT_DRM_MODESET) 141#if defined(SUPPORT_DRM_MODESET)
@@ -128,6 +148,9 @@ IMG_BOOL bInitFailed;
128 148
129#if !defined(PVR_DRI_DRM_NOT_PCI) && !defined(SUPPORT_DRI_DRM_PLUGIN) 149#if !defined(PVR_DRI_DRM_NOT_PCI) && !defined(SUPPORT_DRI_DRM_PLUGIN)
130#if defined(PVR_DRI_DRM_PLATFORM_DEV) 150#if defined(PVR_DRI_DRM_PLATFORM_DEV)
151#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
152static struct platform_device *psPlatDev;
153#endif
131struct platform_device *gpsPVRLDMDev; 154struct platform_device *gpsPVRLDMDev;
132#else 155#else
133struct pci_dev *gpsPVRLDMDev; 156struct pci_dev *gpsPVRLDMDev;
@@ -143,6 +166,15 @@ struct drm_device *gpsPVRDRMDev;
143#define PVR_DRM_FILE struct drm_file * 166#define PVR_DRM_FILE struct drm_file *
144 167
145#if !defined(SUPPORT_DRI_DRM_EXT) && !defined(SUPPORT_DRI_DRM_PLUGIN) 168#if !defined(SUPPORT_DRI_DRM_EXT) && !defined(SUPPORT_DRI_DRM_PLUGIN)
169#if defined(PVR_USE_DEVICE_TREE)
170static struct of_device_id asPlatIdList[] = {
171 {
172 .compatible = SYS_SGX_DEV_NAME
173 },
174 {}
175};
176MODULE_DEVICE_TABLE(of, asPlatIdList);
177#else
146#if defined(PVR_DRI_DRM_PLATFORM_DEV) 178#if defined(PVR_DRI_DRM_PLATFORM_DEV)
147static struct platform_device_id asPlatIdList[] = { 179static struct platform_device_id asPlatIdList[] = {
148 {SYS_SGX_DEV_NAME, 0}, 180 {SYS_SGX_DEV_NAME, 0},
@@ -161,8 +193,15 @@ static struct pci_device_id asPciIdList[] = {
161 {0} 193 {0}
162}; 194};
163#endif /* defined(PVR_DRI_DRM_PLATFORM_DEV) */ 195#endif /* defined(PVR_DRI_DRM_PLATFORM_DEV) */
196#endif /* defined(PVR_DEVICE_TREE) */
164#endif /* !defined(SUPPORT_DRI_DRM_EXT) */ 197#endif /* !defined(SUPPORT_DRI_DRM_EXT) */
165 198
199struct device *
200PVRLDMGetDevice(void)
201{
202 return gpsPVRDRMDev->dev;
203}
204
166DRI_DRM_STATIC int 205DRI_DRM_STATIC int
167PVRSRVDrmLoad(struct drm_device *dev, unsigned long flags) 206PVRSRVDrmLoad(struct drm_device *dev, unsigned long flags)
168{ 207{
@@ -418,23 +457,20 @@ PVRSRVPciRemove(struct pci_dev *dev)
418#define PVR_DRM_UNLOCKED 0 457#define PVR_DRM_UNLOCKED 0
419#endif 458#endif
420 459
421#if !defined(SUPPORT_DRI_DRM_EXT) 460#if !defined(DRM_IOCTL_DEF_DRV)
422 461#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) DRM_IOCTL_DEF(DRM_##ioctl, _func, _flags)
423#if defined(DRM_IOCTL_DEF)
424#define PVR_DRM_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(DRM_##ioctl, _func, _flags)
425#else
426#define PVR_DRM_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)
427#endif 462#endif
428 463
464#if !defined(SUPPORT_DRI_DRM_EXT)
429struct drm_ioctl_desc sPVRDrmIoctls[] = { 465struct drm_ioctl_desc sPVRDrmIoctls[] = {
430 PVR_DRM_IOCTL_DEF(PVR_SRVKM, PVRSRV_BridgeDispatchKM, PVR_DRM_UNLOCKED), 466 DRM_IOCTL_DEF_DRV(PVR_SRVKM, PVRSRV_BridgeDispatchKM, PVR_DRM_RENDER_ALLOW | PVR_DRM_UNLOCKED),
431 PVR_DRM_IOCTL_DEF(PVR_IS_MASTER, PVRDRMIsMaster, DRM_MASTER | PVR_DRM_UNLOCKED), 467 DRM_IOCTL_DEF_DRV(PVR_IS_MASTER, PVRDRMIsMaster, PVR_DRM_RENDER_ALLOW | DRM_MASTER | PVR_DRM_UNLOCKED),
432 PVR_DRM_IOCTL_DEF(PVR_UNPRIV, PVRDRMUnprivCmd, PVR_DRM_UNLOCKED), 468 DRM_IOCTL_DEF_DRV(PVR_UNPRIV, PVRDRMUnprivCmd, PVR_DRM_RENDER_ALLOW | PVR_DRM_UNLOCKED),
433#if defined(PDUMP) 469#if defined(PDUMP)
434 PVR_DRM_IOCTL_DEF(PVR_DBGDRV, dbgdrv_ioctl, PVR_DRM_UNLOCKED), 470 DRM_IOCTL_DEF_DRV(PVR_DBGDRV, dbgdrv_ioctl, PVR_DRM_RENDER_ALLOW | PVR_DRM_UNLOCKED),
435#endif 471#endif
436#if defined(DISPLAY_CONTROLLER) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) 472#if defined(DISPLAY_CONTROLLER) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL)
437 PVR_DRM_IOCTL_DEF(PVR_DISP, PVRDRM_Display_ioctl, DRM_MASTER | PVR_DRM_UNLOCKED) 473 DRM_IOCTL_DEF_DRV(PVR_DISP, PVRDRM_Display_ioctl, DRM_MASTER | PVR_DRM_UNLOCKED)
438#endif 474#endif
439}; 475};
440 476
@@ -488,11 +524,11 @@ static const struct file_operations sPVRFileOps =
488 524
489static struct drm_driver sPVRDrmDriver = 525static struct drm_driver sPVRDrmDriver =
490{ 526{
527 .driver_features = PVR_DRM_DRIVER_RENDER
491#if defined(PVR_OLD_STYLE_DRM_PLATFORM_DEV) 528#if defined(PVR_OLD_STYLE_DRM_PLATFORM_DEV)
492 .driver_features = DRIVER_USE_PLATFORM_DEVICE, 529 | DRIVER_USE_PLATFORM_DEVICE
493#else
494 .driver_features = 0,
495#endif 530#endif
531 ,
496 .dev_priv_size = 0, 532 .dev_priv_size = 0,
497 .load = PVRSRVDrmLoad, 533 .load = PVRSRVDrmLoad,
498 .unload = PVRSRVDrmUnload, 534 .unload = PVRSRVDrmUnload,
@@ -556,7 +592,19 @@ static struct drm_driver sPVRDrmDriver =
556 }, 592 },
557#endif 593#endif
558#endif 594#endif
559 .name = PVR_DRM_NAME, 595
596#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
597#if defined(LDM_PLATFORM)
598 .set_busid = drm_platform_set_busid,
599#else
600#if defined(LDM_PCI)
601 .set_busid = drm_pci_set_busid,
602#else
603 #error "LDM_PLATFORM or LDM_PCI must be set"
604#endif
605#endif
606#endif
607 .name = "pvr",
560 .desc = PVR_DRM_DESC, 608 .desc = PVR_DRM_DESC,
561 .date = PVR_DRM_DATE, 609 .date = PVR_DRM_DATE,
562 .major = PVRVERSION_MAJ, 610 .major = PVRVERSION_MAJ,
@@ -579,26 +627,25 @@ static struct pci_driver sPVRPCIDriver =
579#endif 627#endif
580 628
581#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) 629#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV)
582#if !defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(NO_HARDWARE) 630#if !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
583static void PVRSRVDeviceRelease(struct device unref__ *pDevice) 631static struct platform_device_info sPVRPlatDeviceInfo = {
584{
585}
586
587static struct platform_device sPVRPlatDevice = {
588 .name = PVR_DRM_NAME, 632 .name = PVR_DRM_NAME,
589 .id = -1, 633 .id = -1,
590 .dev = { 634 .dma_mask = DMA_BIT_MASK(32)
591 .release = PVRSRVDeviceRelease
592 }
593}; 635};
594#endif 636#endif
595 637
596static struct platform_driver sPVRPlatDriver = 638static struct platform_driver sPVRPlatDriver =
597{ 639{
640#if !defined(PVR_USE_DEVICE_TREE)
598 .id_table = asPlatIdList, 641 .id_table = asPlatIdList,
642#endif
599 .driver = 643 .driver =
600 { 644 {
601 .name = PVR_DRM_NAME, 645 .name = PVR_DRM_NAME,
646#if defined(PVR_USE_DEVICE_TREE)
647 .of_match_table = asPlatIdList,
648#endif
602 }, 649 },
603 .probe = PVRSRVDrmProbe, 650 .probe = PVRSRVDrmProbe,
604 .remove = PVRSRVDrmRemove, 651 .remove = PVRSRVDrmRemove,
@@ -631,7 +678,7 @@ PVRSRVDrmRemove(struct platform_device *pDevice)
631{ 678{
632 PVR_TRACE(("PVRSRVDrmRemove")); 679 PVR_TRACE(("PVRSRVDrmRemove"));
633 680
634#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) 681#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0))
635 drm_platform_exit(&sPVRDrmDriver, gpsPVRLDMDev); 682 drm_platform_exit(&sPVRDrmDriver, gpsPVRLDMDev);
636#else 683#else
637 drm_put_dev(gpsPVRDRMDev); 684 drm_put_dev(gpsPVRDRMDev);
@@ -656,12 +703,14 @@ static int __init PVRSRVDrmInit(void)
656 703
657#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) 704#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV)
658 iRes = platform_driver_register(&sPVRPlatDriver); 705 iRes = platform_driver_register(&sPVRPlatDriver);
659#if !defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(NO_HARDWARE) 706#if !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
660 if (iRes == 0) 707 if (iRes == 0)
661 { 708 {
662 iRes = platform_device_register(&sPVRPlatDevice); 709 psPlatDev = platform_device_register_full(&sPVRPlatDeviceInfo);
663 if (iRes != 0) 710 if (IS_ERR(psPlatDev))
664 { 711 {
712 iRes = PTR_ERR(psPlatDev);
713 psPlatDev = NULL;
665 platform_driver_unregister(&sPVRPlatDriver); 714 platform_driver_unregister(&sPVRPlatDriver);
666 } 715 }
667 } 716 }
@@ -702,8 +751,8 @@ static int __init PVRSRVDrmInit(void)
702static void __exit PVRSRVDrmExit(void) 751static void __exit PVRSRVDrmExit(void)
703{ 752{
704#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) 753#if defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV)
705#if !defined(PVR_LDM_PLATFORM_PRE_REGISTERED) || defined(NO_HARDWARE) 754#if !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
706 platform_device_unregister(&sPVRPlatDevice); 755 platform_device_unregister(psPlatDev);
707#endif 756#endif
708 platform_driver_unregister(&sPVRPlatDriver); 757 platform_driver_unregister(&sPVRPlatDriver);
709#else /* defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) */ 758#else /* defined(PVR_NEW_STYLE_DRM_PLATFORM_DEV) */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.h
index c3ed413..1c53755 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_drm.h
@@ -142,17 +142,17 @@ typedef struct {
142 char dummy[4]; 142 char dummy[4];
143} drm_pvr_dummy_arg; 143} drm_pvr_dummy_arg;
144 144
145/* IOCTL numbers, relative to DRM_COMMAND_BASE */ 145/* IOCTL numbers */
146#define DRM_IOCTL_PVR_SRVKM _IOWR(0, DRM_PVR_SRVKM, PVRSRV_BRIDGE_PACKAGE) 146#define DRM_IOCTL_PVR_SRVKM DRM_IOWR(DRM_COMMAND_BASE + DRM_PVR_SRVKM, PVRSRV_BRIDGE_PACKAGE)
147#define DRM_IOCTL_PVR_IS_MASTER _IOW(0, DRM_PVR_IS_MASTER, drm_pvr_dummy_arg) 147#define DRM_IOCTL_PVR_IS_MASTER DRM_IOW(DRM_COMMAND_BASE + DRM_PVR_IS_MASTER, drm_pvr_dummy_arg)
148#define DRM_IOCTL_PVR_UNPRIV _IOWR(0, DRM_PVR_UNPRIV, drm_pvr_unpriv_cmd) 148#define DRM_IOCTL_PVR_UNPRIV DRM_IOWR(DRM_COMMAND_BASE + DRM_PVR_UNPRIV, drm_pvr_unpriv_cmd)
149 149
150#if defined(PDUMP) 150#if defined(PDUMP)
151#define DRM_IOCTL_PVR_DBGDRV _IOWR(0, DRM_PVR_DBGDRV, IOCTL_PACKAGE) 151#define DRM_IOCTL_PVR_DBGDRV DRM_IOWR(DRM_COMMAND_BASE + DRM_PVR_DBGDRV, IOCTL_PACKAGE)
152#endif 152#endif
153 153
154#if defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) 154#if defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL)
155#define DRM_IOCTL_PVR_DISP _IOWR(0, DRM_PVR_DISP, drm_pvr_display_cmd) 155#define DRM_IOCTL_PVR_DISP DRM_IOWR(DRM_COMMAND_BASE + DRM_PVR_DISP, drm_pvr_display_cmd)
156#endif 156#endif
157#endif /* !defined(SUPPORT_DRI_DRM_EXT) */ 157#endif /* !defined(SUPPORT_DRI_DRM_EXT) */
158 158
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.c
new file mode 100644
index 0000000..0a7c5ae
--- /dev/null
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.c
@@ -0,0 +1,1371 @@
1/*************************************************************************/ /*!
2@File
3@Title Linux fence interface
4@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5@Description Linux module setup
6@License Dual MIT/GPLv2
7
8The contents of this file are subject to the MIT license as set out below.
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20Alternatively, the contents of this file may be used under the terms of
21the GNU General Public License Version 2 ("GPL") in which case the provisions
22of GPL are applicable instead of those above.
23
24If you wish to allow use of your version of this file only under the terms of
25GPL, and not to allow others to use your version of this file under the terms
26of the MIT license, indicate your decision by deleting the provisions above
27and replace them with the notice and other provisions required by GPL as set
28out in the file called "GPL-COPYING" included in this distribution. If you do
29not delete the provisions above, a recipient may use your version of this file
30under the terms of either the MIT license or GPL.
31
32This License is also included in this distribution in the file called
33"MIT-COPYING".
34
35EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42*/ /**************************************************************************/
43
44#include <linux/version.h>
45
46#include "srvkm.h"
47#include "syscommon.h"
48#include "pvr_linux_fence.h"
49
50#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
51#include <linux/types.h>
52#include <linux/kernel.h>
53#include <linux/slab.h>
54#include <linux/workqueue.h>
55#include <linux/mutex.h>
56#include <linux/atomic.h>
57#include <linux/spinlock.h>
58#include <linux/fence.h>
59#include <linux/reservation.h>
60#include <linux/list.h>
61
62#include "dmabuf.h"
63
64#define BLOCKED_ON_READ 1
65#define BLOCKED_ON_WRITE 2
66
67struct pvr_fence_context
68{
69 struct mutex mutex;
70 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
71 IMG_HANDLE hNativeSync;
72 struct work_struct fence_work;
73 struct list_head fence_frame_list;
74 struct list_head fence_context_notify_list;
75 struct list_head fence_context_list;
76};
77
78struct pvr_fence_frame;
79
80struct pvr_blocking_fence
81{
82 struct fence *fence;
83 struct fence_cb cb;
84 struct pvr_fence_frame *pvr_fence_frame;
85 bool installed;
86};
87
88struct pvr_fence_frame
89{
90 struct list_head fence_frame_list;
91 struct pvr_fence_context *pvr_fence_context;
92 u32 tag;
93 bool is_dst;
94 IMG_UINT32 ui32ReadOpsPending;
95 IMG_UINT32 ui32ReadOps2Pending;
96 IMG_UINT32 ui32WriteOpsPending;
97 int blocked_on;
98 struct pvr_blocking_fence *blocking_fences;
99 unsigned blocking_fence_count;
100 atomic_t blocking_count;
101 struct fence *fence_to_signal;
102 bool unblock;
103};
104
105struct pvr_fence
106{
107 struct fence fence;
108 spinlock_t lock;
109 struct pvr_fence_context *pvr_fence_context;
110 u32 tag;
111};
112
113static LIST_HEAD(fence_context_list);
114static LIST_HEAD(fence_context_notify_list);
115static DEFINE_MUTEX(pvr_fence_mutex);
116
117static struct workqueue_struct *workqueue;
118static unsigned fence_context;
119static atomic_t fence_seqno = ATOMIC_INIT(0);
120static atomic_t fences_outstanding = ATOMIC_INIT(0);
121
122#if defined(DEBUG)
123static atomic_t fences_allocated = ATOMIC_INIT(0);
124static atomic_t fences_signalled = ATOMIC_INIT(0);
125static atomic_t callbacks_installed = ATOMIC_INIT(0);
126static atomic_t callbacks_called = ATOMIC_INIT(0);
127#endif
128
129#if defined(PVR_DRM_DRIVER_NAME)
130static const char *drvname = PVR_DRM_DRIVER_NAME;
131#else
132static const char *drvname = "pvr";
133#endif
134static const char *timeline_name = "PVR";
135
136static unsigned next_seqno(void)
137{
138 return atomic_inc_return(&fence_seqno) - 1;
139}
140
141static const char *get_driver_name(struct fence *fence)
142{
143 return drvname;
144}
145
146static const char *get_timeline_name(struct fence *fence)
147{
148 return timeline_name;
149}
150
151static bool enable_signaling(struct fence *fence)
152{
153 return true;
154}
155
156static void release_fence(struct fence *fence)
157{
158 struct pvr_fence *pvr_fence = container_of(fence, struct pvr_fence, fence);
159 kfree(pvr_fence);
160
161 atomic_dec(&fences_outstanding);
162}
163
164static struct fence_ops fence_ops =
165{
166 .get_driver_name = get_driver_name,
167 .get_timeline_name = get_timeline_name,
168 .enable_signaling = enable_signaling,
169 .wait = fence_default_wait,
170 .release = release_fence
171};
172
173static inline bool is_pvr_fence(struct fence *fence)
174{
175 return fence->ops == &fence_ops;
176}
177
178static struct fence *create_fence_to_signal(struct pvr_fence_frame *pvr_fence_frame)
179{
180 struct pvr_fence *pvr_fence;
181 unsigned seqno = next_seqno();
182
183 pvr_fence = kmalloc(sizeof(*pvr_fence), GFP_KERNEL);
184 if (!pvr_fence)
185 {
186 return NULL;
187 }
188
189 spin_lock_init(&pvr_fence->lock);
190
191 fence_init(&pvr_fence->fence, &fence_ops, &pvr_fence->lock, fence_context, seqno);
192
193 pvr_fence->pvr_fence_context = pvr_fence_frame->pvr_fence_context;
194 pvr_fence->tag = pvr_fence_frame->tag;
195
196 pvr_fence_frame->fence_to_signal = &pvr_fence->fence;
197
198#if defined(DEBUG)
199 atomic_inc(&fences_allocated);
200#endif
201 atomic_inc(&fences_outstanding);
202
203 return pvr_fence_frame->fence_to_signal;
204}
205
206static inline bool is_blocking_fence(struct fence *fence, struct pvr_fence_frame *pvr_fence_frame)
207{
208 if (is_pvr_fence(fence))
209 {
210 struct pvr_fence *pvr_fence = container_of(fence, struct pvr_fence, fence);
211
212 return pvr_fence->pvr_fence_context != pvr_fence_frame->pvr_fence_context && pvr_fence->tag != pvr_fence_frame->tag;
213 }
214
215 return true;
216}
217
218static void signal_and_put_fence(struct pvr_fence_frame *pvr_fence_frame)
219{
220 if (pvr_fence_frame->fence_to_signal)
221 {
222 struct pvr_fence_context *pvr_fence_context = pvr_fence_frame->pvr_fence_context;
223
224 fence_signal(pvr_fence_frame->fence_to_signal);
225 fence_put(pvr_fence_frame->fence_to_signal);
226
227 pvr_fence_frame->fence_to_signal = NULL;
228
229 queue_work(workqueue, &pvr_fence_context->fence_work);
230
231#if defined(DEBUG)
232 atomic_inc(&fences_signalled);
233#endif
234 }
235}
236
237static void blocking_fence_signalled(struct fence *fence, struct fence_cb *cb)
238{
239 struct pvr_blocking_fence *pvr_blocking_fence = container_of(cb, struct pvr_blocking_fence, cb);
240 struct pvr_fence_frame *pvr_fence_frame = pvr_blocking_fence->pvr_fence_frame;
241 struct pvr_fence_context *pvr_fence_context = pvr_fence_frame->pvr_fence_context;
242
243 if (atomic_dec_and_test(&pvr_fence_frame->blocking_count))
244 {
245 queue_work(workqueue, &pvr_fence_context->fence_work);
246 }
247#if defined(DEBUG)
248 atomic_inc(&callbacks_called);
249#endif
250}
251
252static bool allocate_blocking_fence_storage(struct pvr_fence_frame *pvr_fence_frame, unsigned count)
253{
254 pvr_fence_frame->blocking_fences = kzalloc(count * sizeof(*pvr_fence_frame->blocking_fences), GFP_KERNEL);
255 if (pvr_fence_frame->blocking_fences)
256 {
257 pvr_fence_frame->blocking_fence_count = count;
258 return true;
259 }
260 return false;
261}
262
263static void free_blocking_fence_storage(struct pvr_fence_frame *pvr_fence_frame)
264{
265 if (pvr_fence_frame->blocking_fence_count)
266 {
267 kfree(pvr_fence_frame->blocking_fences);
268 pvr_fence_frame->blocking_fence_count = 0;
269 }
270}
271
272static int install_and_get_blocking_fence(struct pvr_fence_frame *pvr_fence_frame, unsigned index, struct fence *fence)
273{
274 struct pvr_blocking_fence *pvr_blocking_fence = &pvr_fence_frame->blocking_fences[index];
275 int ret;
276
277 BUG_ON(index >= pvr_fence_frame->blocking_fence_count);
278
279 pvr_blocking_fence->fence = fence;
280 pvr_blocking_fence->pvr_fence_frame = pvr_fence_frame;
281
282 atomic_inc(&pvr_fence_frame->blocking_count);
283
284 ret = fence_add_callback(pvr_blocking_fence->fence,
285 &pvr_blocking_fence->cb,
286 blocking_fence_signalled);
287
288 pvr_blocking_fence->installed = !ret;
289 if (!pvr_blocking_fence->installed)
290 {
291 atomic_dec(&pvr_fence_frame->blocking_count);
292 return 1;
293 }
294 else
295 {
296 fence_get(fence);
297#if defined(DEBUG)
298 atomic_inc(&callbacks_installed);
299#endif
300 return 0;
301 }
302}
303
304static void uninstall_and_put_blocking_fence(struct pvr_fence_frame *pvr_fence_frame, unsigned index)
305{
306 struct pvr_blocking_fence *pvr_blocking_fence = &pvr_fence_frame->blocking_fences[index];
307
308 BUG_ON(index >= pvr_fence_frame->blocking_fence_count);
309
310 if (pvr_blocking_fence->installed)
311 {
312 if (fence_remove_callback(pvr_blocking_fence->fence, &pvr_blocking_fence->cb))
313 {
314 atomic_dec(&pvr_fence_frame->blocking_count);
315 }
316 fence_put(pvr_blocking_fence->fence);
317 }
318}
319
320static inline int update_reservation_return_value(int ret, bool blocked_on_write)
321{
322 return ret < 0 ? ret : (ret ? 0 : (blocked_on_write ? BLOCKED_ON_WRITE : BLOCKED_ON_READ));
323}
324
325static int update_reservation_object_fences_dst(struct pvr_fence_frame *pvr_fence_frame,
326 struct reservation_object *resv)
327{
328 struct reservation_object_list *flist;
329 struct fence *fence_to_signal;
330 unsigned shared_fence_count;
331 unsigned blocking_fence_count;
332 unsigned i;
333 int ret;
334
335 flist = reservation_object_get_list(resv);
336 shared_fence_count = flist ? flist->shared_count : 0;
337
338 fence_to_signal = create_fence_to_signal(pvr_fence_frame);
339 if (!fence_to_signal)
340 {
341 return -ENOMEM;
342 }
343
344 if (!shared_fence_count)
345 {
346 struct fence *fence = reservation_object_get_excl(resv);
347
348 if (fence && is_blocking_fence(fence, pvr_fence_frame))
349 {
350 if (allocate_blocking_fence_storage(pvr_fence_frame, 1))
351 {
352 ret = install_and_get_blocking_fence(pvr_fence_frame, 0, fence);
353 }
354 else
355 {
356 fence_put(fence_to_signal);
357 return -ENOMEM;
358 }
359 }
360 else
361 {
362 ret = 1;
363 }
364
365 reservation_object_add_excl_fence(resv, fence_to_signal);
366 return update_reservation_return_value(ret, true);
367 }
368
369 for (i = 0, blocking_fence_count = 0; i < shared_fence_count; i++)
370 {
371
372 struct fence *fence = rcu_dereference_protected(flist->shared[i], reservation_object_held(resv));
373
374 if (is_blocking_fence(fence, pvr_fence_frame))
375 {
376 blocking_fence_count++;
377 }
378 }
379
380 ret = 1;
381 if (blocking_fence_count)
382 {
383 if (allocate_blocking_fence_storage(pvr_fence_frame, blocking_fence_count))
384 {
385 for (i = 0; i < blocking_fence_count; i++)
386 {
387 struct fence *fence = rcu_dereference_protected(flist->shared[i], reservation_object_held(resv));
388
389 if (is_blocking_fence(fence, pvr_fence_frame))
390 {
391 if (!install_and_get_blocking_fence(pvr_fence_frame, i, fence))
392 {
393 ret = 0;
394 }
395 }
396 }
397 }
398 else
399 {
400 fence_put(fence_to_signal);
401 return -ENOMEM;
402 }
403 }
404
405 reservation_object_add_excl_fence(resv, fence_to_signal);
406 return update_reservation_return_value(ret, false);
407}
408
409static int update_reservation_object_fences_src(struct pvr_fence_frame *pvr_fence_frame,
410 struct reservation_object *resv)
411{
412 struct reservation_object_list *flist;
413 struct fence *fence_to_signal = NULL;
414 struct fence *blocking_fence = NULL;
415 bool reserve = true;
416 unsigned shared_fence_count;
417 unsigned i;
418 int ret;
419
420 flist = reservation_object_get_list(resv);
421 shared_fence_count = flist ? flist->shared_count : 0;
422
423 /*
424 * There can't be more than one shared fence for a given
425 * fence context, so if a PVR fence is already in the list,
426 * we don't need to reserve space for the new one, but need
427 * to block on it if it isn't ours.
428 */
429 for (i = 0; i < shared_fence_count; i++)
430 {
431 struct fence *fence = rcu_dereference_protected(flist->shared[i], reservation_object_held(resv));
432
433 if (is_pvr_fence(fence))
434 {
435 reserve = false;
436
437 if (is_blocking_fence(fence, pvr_fence_frame))
438 {
439 blocking_fence = fence;
440 }
441 break;
442 }
443 }
444
445 if (reserve)
446 {
447 ret = reservation_object_reserve_shared(resv);
448 if (ret)
449 {
450 return ret;
451 }
452 }
453
454 fence_to_signal = create_fence_to_signal(pvr_fence_frame);
455 if (!fence_to_signal)
456 {
457 return -ENOMEM;
458 }
459
460 if (!blocking_fence && !shared_fence_count)
461 {
462 struct fence *fence = reservation_object_get_excl(resv);
463
464 if (fence && is_blocking_fence(fence, pvr_fence_frame))
465 {
466 blocking_fence = fence;
467 }
468 }
469
470 if (blocking_fence)
471 {
472 if (allocate_blocking_fence_storage(pvr_fence_frame, 1))
473 {
474 ret = install_and_get_blocking_fence(pvr_fence_frame, 0, blocking_fence);
475 }
476 else
477 {
478 ret = -ENOMEM;
479 fence_put(fence_to_signal);
480 return ret;
481 }
482 }
483 else
484 {
485 ret = 1;
486 }
487
488 reservation_object_add_shared_fence(resv, fence_to_signal);
489
490 return update_reservation_return_value(ret, !shared_fence_count);
491}
492
493/* Must be called with pvr_fence_context mutex held */
494static void destroy_fence_frame(struct pvr_fence_frame *pvr_fence_frame)
495{
496 unsigned i;
497
498 signal_and_put_fence(pvr_fence_frame);
499
500 for (i = 0; i < pvr_fence_frame->blocking_fence_count; i++)
501 {
502 uninstall_and_put_blocking_fence(pvr_fence_frame, i);
503 }
504 free_blocking_fence_storage(pvr_fence_frame);
505
506 list_del(&pvr_fence_frame->fence_frame_list);
507
508 kfree(pvr_fence_frame);
509}
510
511static inline bool sync_GE(const u32 a, const u32 b)
512{
513 return (a - b) < (U32_MAX / 2);
514}
515static inline bool sync_GT(const u32 a, const u32 b)
516{
517 return (a != b) && sync_GE(a, b);
518}
519
520static bool sync_is_ready(struct pvr_fence_frame *pvr_fence_frame)
521{
522 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = pvr_fence_frame->pvr_fence_context->psSyncInfo;
523
524 return (!pvr_fence_frame->is_dst ||
525 sync_GE(psSyncInfo->psSyncData->ui32ReadOpsComplete,
526 pvr_fence_frame->ui32ReadOpsPending)) &&
527 sync_GE(psSyncInfo->psSyncData->ui32ReadOps2Complete,
528 pvr_fence_frame->ui32ReadOps2Pending) &&
529 sync_GE(psSyncInfo->psSyncData->ui32WriteOpsComplete,
530 pvr_fence_frame->ui32WriteOpsPending);
531}
532
533static bool sync_gpu_read_op_is_complete(struct pvr_fence_frame *pvr_fence_frame)
534{
535 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = pvr_fence_frame->pvr_fence_context->psSyncInfo;
536
537 return sync_GT(psSyncInfo->psSyncData->ui32ReadOpsComplete,
538 pvr_fence_frame->ui32ReadOpsPending);
539}
540
541static bool sync_gpu_write_op_is_complete(struct pvr_fence_frame *pvr_fence_frame)
542{
543 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = pvr_fence_frame->pvr_fence_context->psSyncInfo;
544
545 return sync_GT(psSyncInfo->psSyncData->ui32WriteOpsComplete,
546 pvr_fence_frame->ui32WriteOpsPending);
547}
548
549static void sync_complete_read_op(struct pvr_fence_frame *pvr_fence_frame)
550{
551 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = pvr_fence_frame->pvr_fence_context->psSyncInfo;
552
553 psSyncInfo->psSyncData->ui32ReadOps2Complete = ++pvr_fence_frame->ui32ReadOps2Pending;
554}
555
556static void sync_complete_write_op(struct pvr_fence_frame *pvr_fence_frame)
557{
558 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = pvr_fence_frame->pvr_fence_context->psSyncInfo;
559
560 psSyncInfo->psSyncData->ui32WriteOpsComplete = ++pvr_fence_frame->ui32WriteOpsPending;
561}
562
563static void do_fence_work(struct work_struct *work)
564{
565 struct pvr_fence_context *pvr_fence_context = container_of(work, struct pvr_fence_context, fence_work);
566 bool schedule_device_callbacks = false;
567
568 mutex_lock(&pvr_fence_context->mutex);
569 for(;;)
570 {
571 struct pvr_fence_frame *pvr_fence_frame;
572 bool reprocess = false;
573 bool next_frame = false;
574
575 pvr_fence_frame = list_first_entry_or_null(&pvr_fence_context->fence_frame_list, struct pvr_fence_frame, fence_frame_list);
576
577 if (pvr_fence_frame)
578 {
579 if (!atomic_read(&pvr_fence_frame->blocking_count) && sync_is_ready(pvr_fence_frame))
580 {
581 schedule_device_callbacks = true;
582
583 switch (pvr_fence_frame->blocked_on)
584 {
585 case BLOCKED_ON_READ:
586 sync_complete_read_op(pvr_fence_frame);
587 pvr_fence_frame->blocked_on = 0;
588 reprocess = true;
589 break;
590 case BLOCKED_ON_WRITE:
591 sync_complete_write_op(pvr_fence_frame);
592 pvr_fence_frame->blocked_on = 0;
593 reprocess = true;
594 break;
595 default:
596 next_frame = pvr_fence_frame->is_dst ? sync_gpu_write_op_is_complete(pvr_fence_frame) : sync_gpu_read_op_is_complete(pvr_fence_frame);
597 break;
598 }
599
600 next_frame |= pvr_fence_frame->unblock;
601 }
602 }
603
604 if (next_frame)
605 {
606 destroy_fence_frame(pvr_fence_frame);
607 }
608 else
609 {
610 if (!reprocess)
611 {
612 break;
613 }
614 }
615
616 }
617 mutex_unlock(&pvr_fence_context->mutex);
618
619 if (schedule_device_callbacks)
620 {
621 PVRSRVScheduleDeviceCallbacks();
622 }
623
624}
625
626void PVRLinuxFenceContextDestroy(IMG_HANDLE hFenceContext)
627{
628
629 struct pvr_fence_context *pvr_fence_context = (struct pvr_fence_context *)hFenceContext;
630 struct list_head *entry, *temp;
631
632 mutex_lock(&pvr_fence_mutex);
633 mutex_lock(&pvr_fence_context->mutex);
634
635 list_del(&pvr_fence_context->fence_context_list);
636 if (!list_empty(&pvr_fence_context->fence_context_notify_list))
637 {
638 list_del(&pvr_fence_context->fence_context_notify_list);
639 }
640 mutex_unlock(&pvr_fence_mutex);
641
642 list_for_each_safe(entry, temp, &pvr_fence_context->fence_frame_list)
643 {
644 struct pvr_fence_frame *pvr_fence_frame = list_entry(entry, struct pvr_fence_frame, fence_frame_list);
645
646 destroy_fence_frame(pvr_fence_frame);
647 }
648
649 mutex_unlock(&pvr_fence_context->mutex);
650
651 flush_work(&pvr_fence_context->fence_work);
652
653 mutex_destroy(&pvr_fence_context->mutex);
654
655 DmaBufFreeNativeSyncHandle(pvr_fence_context->hNativeSync);
656
657 kfree(pvr_fence_context);
658}
659
660IMG_HANDLE PVRLinuxFenceContextCreate(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_HANDLE hImport)
661{
662 struct pvr_fence_context *pvr_fence_context;
663
664 pvr_fence_context = kzalloc(sizeof(*pvr_fence_context), GFP_KERNEL);
665 if (!pvr_fence_context)
666 {
667 return NULL;
668 }
669
670 pvr_fence_context->hNativeSync = DmaBufGetNativeSyncHandle(hImport);
671 if (!pvr_fence_context->hNativeSync)
672 {
673 kfree(pvr_fence_context);
674 return NULL;
675 }
676
677 INIT_LIST_HEAD(&pvr_fence_context->fence_frame_list);
678 INIT_LIST_HEAD(&pvr_fence_context->fence_context_list);
679 INIT_LIST_HEAD(&pvr_fence_context->fence_context_notify_list);
680
681 mutex_init(&pvr_fence_context->mutex);
682
683 INIT_WORK(&pvr_fence_context->fence_work, do_fence_work);
684
685 pvr_fence_context->psSyncInfo = psSyncInfo;
686 mutex_lock(&pvr_fence_mutex);
687 list_add_tail(&pvr_fence_context->fence_context_list, &fence_context_list);
688 mutex_unlock(&pvr_fence_mutex);
689
690 return (IMG_HANDLE)pvr_fence_context;
691}
692
693static int process_reservation_object(struct pvr_fence_context *pvr_fence_context, struct reservation_object *resv, bool is_dst, u32 tag)
694{
695 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = pvr_fence_context->psSyncInfo;
696 struct pvr_fence_frame *pvr_fence_frame;
697 int ret;
698
699 pvr_fence_frame = kzalloc(sizeof(*pvr_fence_frame), GFP_KERNEL);
700 if (!pvr_fence_frame)
701 {
702 return -ENOMEM;
703 }
704
705 pvr_fence_frame->is_dst = is_dst;
706 pvr_fence_frame->tag = tag;
707 pvr_fence_frame->pvr_fence_context = pvr_fence_context;
708 INIT_LIST_HEAD(&pvr_fence_frame->fence_frame_list);
709
710 ret = is_dst ?
711 update_reservation_object_fences_dst(pvr_fence_frame, resv) :
712 update_reservation_object_fences_src(pvr_fence_frame, resv);
713 if (ret < 0)
714 {
715 kfree(pvr_fence_frame);
716 return ret;
717 }
718 else
719 {
720 pvr_fence_frame->blocked_on = ret;
721
722 pvr_fence_frame->ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOpsPending;
723
724 pvr_fence_frame->ui32ReadOps2Pending = (pvr_fence_frame->blocked_on == BLOCKED_ON_READ) ? SyncTakeReadOp2(psSyncInfo, SYNC_OP_CLASS_LINUX_FENCE) : psSyncInfo->psSyncData->ui32ReadOps2Pending;
725
726 pvr_fence_frame->ui32WriteOpsPending = (pvr_fence_frame->blocked_on == BLOCKED_ON_WRITE) ? SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_LINUX_FENCE) : psSyncInfo->psSyncData->ui32WriteOpsPending;
727
728 list_add_tail(&pvr_fence_frame->fence_frame_list, &pvr_fence_context->fence_frame_list);
729 }
730
731 return 0;
732}
733
734static int process_syncinfo(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, bool is_dst, u32 tag)
735{
736 struct pvr_fence_context *pvr_fence_context = (struct pvr_fence_context *)psSyncInfo->hFenceContext;
737 struct reservation_object *resv;
738 unsigned buf = 0;
739 int ret;
740
741 if (!pvr_fence_context)
742 {
743 return 0;
744 }
745
746 mutex_lock(&pvr_fence_context->mutex);
747 while ((resv = DmaBufGetReservationObject(pvr_fence_context->hNativeSync, buf++)))
748 {
749 ret = process_reservation_object(pvr_fence_context, resv, is_dst, tag);
750 if (ret)
751 {
752 break;
753 }
754 }
755 mutex_unlock(&pvr_fence_context->mutex);
756
757 mutex_lock(&pvr_fence_mutex);
758 mutex_lock(&pvr_fence_context->mutex);
759 if (list_empty(&pvr_fence_context->fence_context_notify_list))
760 {
761 list_add_tail(&pvr_fence_context->fence_context_notify_list, &fence_context_notify_list);
762 queue_work(workqueue, &pvr_fence_context->fence_work);
763 }
764 mutex_unlock(&pvr_fence_context->mutex);
765 mutex_unlock(&pvr_fence_mutex);
766
767 return ret;
768}
769
770
771static inline bool sync_enabled(const IMG_BOOL *pbEnabled,
772 const IMG_HANDLE *phSyncInfo,
773 unsigned index)
774{
775 return (!pbEnabled || pbEnabled[index]) && phSyncInfo && phSyncInfo[index];
776}
777
778static unsigned count_reservation_objects(unsigned num_syncs,
779 IMG_HANDLE *phSyncInfo,
780 const IMG_BOOL *pbEnabled)
781{
782 unsigned i;
783 unsigned count = 0;
784
785 for (i = 0; i < num_syncs; i++)
786 {
787 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
788 struct pvr_fence_context *pvr_fence_context;
789
790 if (!sync_enabled(pbEnabled, phSyncInfo, i))
791 {
792 continue;
793 }
794
795 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)phSyncInfo[i];
796 pvr_fence_context = (struct pvr_fence_context *)psSyncInfo->hFenceContext;
797 if (pvr_fence_context)
798 {
799 unsigned buf = 0;
800
801 while (DmaBufGetReservationObject(pvr_fence_context->hNativeSync, buf++))
802 {
803 count++;
804 }
805 }
806 }
807
808 return count;
809}
810
811static unsigned count_all_reservation_objects(IMG_UINT32 ui32NumSrcSyncs,
812 IMG_HANDLE *phSrcSyncInfo,
813 const IMG_BOOL *pbSrcEnabled,
814 IMG_UINT32 ui32NumDstSyncs,
815 IMG_HANDLE *phDstSyncInfo,
816 const IMG_BOOL *pbDstEnabled)
817{
818 return count_reservation_objects(ui32NumSrcSyncs,
819 phSrcSyncInfo,
820 pbSrcEnabled) +
821 count_reservation_objects(ui32NumDstSyncs,
822 phDstSyncInfo,
823 pbDstEnabled);
824}
825
826static unsigned get_reservation_objects(unsigned num_resvs,
827 struct reservation_object **resvs,
828 unsigned num_syncs,
829 IMG_HANDLE *phSyncInfo,
830 const IMG_BOOL *pbEnabled)
831{
832 unsigned i;
833 unsigned count = 0;
834
835 for (i = 0; i < num_syncs; i++)
836 {
837 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
838 struct pvr_fence_context *pvr_fence_context;
839
840 if (!sync_enabled(pbEnabled, phSyncInfo, i))
841 {
842 continue;
843 }
844
845 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)phSyncInfo[i];
846 pvr_fence_context = (struct pvr_fence_context *)psSyncInfo->hFenceContext;
847 if (pvr_fence_context)
848 {
849 struct reservation_object *resv;
850 unsigned buf = 0;
851
852 while ((resv = DmaBufGetReservationObject(pvr_fence_context->hNativeSync, buf++)))
853 {
854 BUG_ON(count >= num_resvs);
855 resvs[count++] = resv;
856 }
857 }
858 }
859
860 return count;
861}
862
863static void get_all_reservation_objects(unsigned num_resvs,
864 struct reservation_object **resvs,
865 IMG_UINT32 ui32NumSrcSyncs,
866 IMG_HANDLE *phSrcSyncInfo,
867 const IMG_BOOL *pbSrcEnabled,
868 IMG_UINT32 ui32NumDstSyncs,
869 IMG_HANDLE *phDstSyncInfo,
870 const IMG_BOOL *pbDstEnabled)
871{
872 unsigned num_src_resvs;
873
874 num_src_resvs = get_reservation_objects(num_resvs,
875 resvs,
876 ui32NumSrcSyncs,
877 phSrcSyncInfo,
878 pbSrcEnabled);
879
880 get_reservation_objects(num_resvs - num_src_resvs,
881 &resvs[num_src_resvs],
882 ui32NumDstSyncs,
883 phDstSyncInfo,
884 pbDstEnabled);
885}
886
887static void unlock_reservation_objects(unsigned num_resvs,
888 struct reservation_object **resvs)
889{
890 unsigned i;
891
892 for (i = 0; i < num_resvs; i++)
893 {
894 if (resvs[i])
895 {
896 ww_mutex_unlock(&(resvs[i]->lock));
897 }
898 }
899}
900
901static int lock_reservation_objects_no_retry(struct ww_acquire_ctx *ww_acquire_ctx,
902 unsigned num_resvs,
903 struct reservation_object **resvs,
904 struct reservation_object **contended_resv)
905{
906 unsigned i;
907
908 for (i = 0; i < num_resvs; i++)
909 {
910 int ret;
911
912 if (!resvs[i])
913 {
914 continue;
915 }
916 if (resvs[i] == *contended_resv)
917 {
918 *contended_resv = NULL;
919 continue;
920 }
921
922 ret = ww_mutex_lock_interruptible(&(resvs[i]->lock), ww_acquire_ctx);
923 if (ret)
924 {
925 if (ret == -EALREADY)
926 {
927 resvs[i] = NULL;
928 continue;
929 }
930
931 unlock_reservation_objects(i, resvs);
932
933 if (*contended_resv)
934 {
935 ww_mutex_unlock(&((*contended_resv)->lock));
936 *contended_resv = NULL;
937 }
938
939 if (ret == -EDEADLK)
940 {
941 *contended_resv = resvs[i];
942 }
943
944 return ret;
945 }
946 }
947
948 return 0;
949}
950
951static int lock_reservation_objects(struct ww_acquire_ctx *ww_acquire_ctx,
952 unsigned num_resvs,
953 struct reservation_object **resvs)
954{
955 int ret;
956 struct reservation_object *contended_resv = NULL;
957
958 do {
959 ret = lock_reservation_objects_no_retry(ww_acquire_ctx,
960 num_resvs,
961 resvs,
962 &contended_resv);
963 if (ret == -EDEADLK)
964 {
965 int res = ww_mutex_lock_slow_interruptible(&(contended_resv->lock), ww_acquire_ctx);
966 if (res)
967 {
968 return res;
969 }
970 }
971 } while (ret == -EDEADLK);
972
973 return ret;
974}
975
976static int process_syncinfos(u32 tag,
977 bool is_dst,
978 IMG_UINT32 ui32NumSyncs,
979 IMG_HANDLE *phSyncInfo,
980 const IMG_BOOL *pbEnabled)
981{
982 unsigned i;
983
984 for (i = 0; i < ui32NumSyncs; i++)
985 {
986 if (sync_enabled(pbEnabled, phSyncInfo, i))
987 {
988 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)phSyncInfo[i];
989 int ret;
990
991 ret = process_syncinfo(psSyncInfo, is_dst, tag);
992 if (ret)
993 {
994 break;
995 }
996 }
997 }
998
999 return 0;
1000}
1001
1002static int process_all_syncinfos(u32 tag,
1003 IMG_UINT32 ui32NumSrcSyncs,
1004 IMG_HANDLE *phSrcSyncInfo,
1005 const IMG_BOOL *pbSrcEnabled,
1006 IMG_UINT32 ui32NumDstSyncs,
1007 IMG_HANDLE *phDstSyncInfo,
1008 const IMG_BOOL *pbDstEnabled)
1009{
1010 int ret;
1011
1012 ret = process_syncinfos(tag,
1013 false,
1014 ui32NumSrcSyncs,
1015 phSrcSyncInfo,
1016 pbSrcEnabled);
1017
1018 if (ret)
1019 {
1020 return ret;
1021 }
1022
1023 ret = process_syncinfos(tag,
1024 true,
1025 ui32NumDstSyncs,
1026 phDstSyncInfo,
1027 pbDstEnabled);
1028
1029 return ret;
1030}
1031
1032static void unblock_frames(u32 tag,
1033 IMG_UINT32 ui32NumSyncs,
1034 IMG_HANDLE *phSyncInfo,
1035 const IMG_BOOL *pbEnabled)
1036{
1037 unsigned i;
1038
1039 for (i = 0; i < ui32NumSyncs; i++)
1040 {
1041 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
1042 struct pvr_fence_context *pvr_fence_context;
1043 struct list_head *entry;
1044
1045 if (!sync_enabled(pbEnabled, phSyncInfo, i))
1046 {
1047 continue;
1048 }
1049
1050 psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)phSyncInfo[i];
1051 pvr_fence_context = (struct pvr_fence_context *)psSyncInfo->hFenceContext;
1052 if (!pvr_fence_context)
1053 {
1054 continue;
1055 }
1056
1057
1058 mutex_lock(&pvr_fence_context->mutex);
1059
1060 list_for_each(entry, &pvr_fence_context->fence_frame_list)
1061 {
1062 struct pvr_fence_frame *pvr_fence_frame = list_entry(entry, struct pvr_fence_frame, fence_frame_list);
1063
1064 if (pvr_fence_frame->tag == tag)
1065 {
1066 pvr_fence_frame->unblock = true;
1067 }
1068 }
1069
1070 mutex_unlock(&pvr_fence_context->mutex);
1071 }
1072
1073 return;
1074}
1075
1076static void unblock_all_frames(u32 tag,
1077 IMG_UINT32 ui32NumSrcSyncs,
1078 IMG_HANDLE *phSrcSyncInfo,
1079 const IMG_BOOL *pbSrcEnabled,
1080 IMG_UINT32 ui32NumDstSyncs,
1081 IMG_HANDLE *phDstSyncInfo,
1082 const IMG_BOOL *pbDstEnabled)
1083{
1084 unblock_frames(tag,
1085 ui32NumSrcSyncs,
1086 phSrcSyncInfo,
1087 pbSrcEnabled);
1088
1089 unblock_frames(tag,
1090 ui32NumDstSyncs,
1091 phDstSyncInfo,
1092 pbDstEnabled);
1093}
1094
1095static PVRSRV_ERROR pvr_error(int error)
1096{
1097 switch(error)
1098 {
1099 case 0:
1100 return PVRSRV_OK;
1101 case -EINTR:
1102 return PVRSRV_ERROR_RETRY;
1103 case -ENOMEM:
1104 return PVRSRV_ERROR_OUT_OF_MEMORY;
1105 default:
1106 break;
1107 }
1108
1109 return PVRSRV_ERROR_OUT_OF_MEMORY;
1110}
1111
1112static u32 new_frame_tag(void)
1113{
1114 static u32 frame_tag;
1115
1116 return (++frame_tag) ? frame_tag : ++frame_tag;
1117}
1118
1119PVRSRV_ERROR PVRLinuxFenceProcess(IMG_UINT32 *puTag,
1120 IMG_UINT32 ui32NumSrcSyncs,
1121 IMG_HANDLE *phSrcSyncInfo,
1122 const IMG_BOOL *pbSrcEnabled,
1123 IMG_UINT32 ui32NumDstSyncs,
1124 IMG_HANDLE *phDstSyncInfo,
1125 const IMG_BOOL *pbDstEnabled)
1126{
1127 u32 tag;
1128 struct ww_acquire_ctx ww_acquire_ctx;
1129 unsigned num_resvs;
1130 struct reservation_object **resvs = NULL;
1131 int ret;
1132
1133 num_resvs = count_all_reservation_objects(ui32NumSrcSyncs,
1134 phSrcSyncInfo,
1135 pbSrcEnabled,
1136 ui32NumDstSyncs,
1137 phDstSyncInfo,
1138 pbDstEnabled);
1139 if (!num_resvs)
1140 {
1141 *puTag = 0;
1142 ret = 0;
1143 goto exit;
1144 }
1145 tag = new_frame_tag();
1146
1147 resvs = kmalloc(num_resvs * sizeof(*resvs), GFP_KERNEL);
1148 if (!resvs)
1149 {
1150 ret = -ENOMEM;
1151 goto exit;
1152 }
1153
1154 get_all_reservation_objects(num_resvs,
1155 resvs,
1156 ui32NumSrcSyncs,
1157 phSrcSyncInfo,
1158 pbSrcEnabled,
1159 ui32NumDstSyncs,
1160 phDstSyncInfo,
1161 pbDstEnabled);
1162
1163 ww_acquire_init(&ww_acquire_ctx, &reservation_ww_class);
1164
1165 ret = lock_reservation_objects(&ww_acquire_ctx, num_resvs, resvs);
1166 if (ret)
1167 {
1168 ww_acquire_fini(&ww_acquire_ctx);
1169 goto exit;
1170 }
1171 ww_acquire_done(&ww_acquire_ctx);
1172
1173 ret = process_all_syncinfos(tag,
1174 ui32NumSrcSyncs,
1175 phSrcSyncInfo,
1176 pbSrcEnabled,
1177 ui32NumDstSyncs,
1178 phDstSyncInfo,
1179 pbDstEnabled);
1180
1181 unlock_reservation_objects(num_resvs, resvs);
1182
1183 ww_acquire_fini(&ww_acquire_ctx);
1184
1185 if (ret)
1186 {
1187 unblock_all_frames(tag,
1188 ui32NumSrcSyncs,
1189 phSrcSyncInfo,
1190 pbSrcEnabled,
1191 ui32NumDstSyncs,
1192 phDstSyncInfo,
1193 pbDstEnabled);
1194 }
1195 else
1196 {
1197 *puTag = tag;
1198 }
1199
1200exit:
1201 if (resvs)
1202 {
1203 kfree(resvs);
1204 }
1205 return pvr_error(ret);
1206
1207}
1208
1209void PVRLinuxFenceRelease(IMG_UINT32 uTag,
1210 IMG_UINT32 ui32NumSrcSyncs,
1211 IMG_HANDLE *phSrcSyncInfo,
1212 const IMG_BOOL *pbSrcEnabled,
1213 IMG_UINT32 ui32NumDstSyncs,
1214 IMG_HANDLE *phDstSyncInfo,
1215 const IMG_BOOL *pbDstEnabled)
1216{
1217 if (uTag)
1218 {
1219 unblock_all_frames(uTag,
1220 ui32NumSrcSyncs,
1221 phSrcSyncInfo,
1222 pbSrcEnabled,
1223 ui32NumDstSyncs,
1224 phDstSyncInfo,
1225 pbDstEnabled);
1226 }
1227}
1228
1229static void check_frames(struct pvr_fence_context *pvr_fence_context)
1230{
1231 if (list_empty(&pvr_fence_context->fence_frame_list))
1232 {
1233 list_del_init(&pvr_fence_context->fence_context_notify_list);
1234 }
1235 else
1236 {
1237 queue_work(workqueue, &pvr_fence_context->fence_work);
1238 }
1239}
1240
1241void PVRLinuxFenceCheckAll(void)
1242{
1243 struct list_head *entry, *temp;
1244
1245 mutex_lock(&pvr_fence_mutex);
1246 list_for_each_safe(entry, temp, &fence_context_notify_list)
1247 {
1248 struct pvr_fence_context *pvr_fence_context = list_entry(entry, struct pvr_fence_context, fence_context_notify_list);
1249
1250 mutex_lock(&pvr_fence_context->mutex);
1251 check_frames(pvr_fence_context);
1252 mutex_unlock(&pvr_fence_context->mutex);
1253 }
1254 mutex_unlock(&pvr_fence_mutex);
1255}
1256
1257void PVRLinuxFenceDeInit(void)
1258{
1259 unsigned fences_remaining;
1260 bool contexts_leaked;
1261
1262 if (workqueue)
1263 {
1264 destroy_workqueue(workqueue);
1265 }
1266
1267 fences_remaining = atomic_read(&fences_outstanding);
1268 if (fences_remaining)
1269 {
1270 printk(KERN_WARNING "%s: %u fences leaked\n",
1271 __func__, fences_remaining);
1272 }
1273
1274#if defined(DEBUG)
1275 printk(KERN_INFO "%s: %u fences allocated\n",
1276 __func__, atomic_read(&fences_allocated));
1277
1278 printk(KERN_INFO "%s: %u fences signalled\n",
1279 __func__, atomic_read(&fences_signalled));
1280
1281 printk(KERN_INFO "%s: %u callbacks installed\n",
1282 __func__, atomic_read(&callbacks_installed));
1283
1284 printk(KERN_INFO "%s: %u callbacks called\n",
1285 __func__, atomic_read(&callbacks_called));
1286#endif
1287
1288 mutex_lock(&pvr_fence_mutex);
1289 contexts_leaked = !list_empty(&fence_context_list);
1290 mutex_unlock(&pvr_fence_mutex);
1291
1292 mutex_destroy(&pvr_fence_mutex);
1293
1294 BUG_ON(contexts_leaked);
1295}
1296
1297int PVRLinuxFenceInit(void)
1298{
1299 workqueue = create_workqueue("PVR Linux Fence");
1300 if (!workqueue)
1301 {
1302 return -ENOMEM;
1303 }
1304
1305 fence_context = fence_context_alloc(1);
1306
1307 return 0;
1308}
1309#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17)) */
1310IMG_HANDLE PVRLinuxFenceContextCreate(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_HANDLE hImport)
1311{
1312 (void) psSyncInfo;
1313 (void) hImport;
1314
1315 return (IMG_HANDLE)(IMG_UINTPTR_T)0xbad;
1316}
1317
1318void PVRLinuxFenceContextDestroy(IMG_HANDLE hFenceContext)
1319{
1320 (void) hFenceContext;
1321}
1322
1323PVRSRV_ERROR PVRLinuxFenceProcess(IMG_UINT32 *puTag,
1324 IMG_UINT32 ui32NumSrcSyncs,
1325 IMG_HANDLE *phSrcSyncInfo,
1326 const IMG_BOOL *pbSrcEnabled,
1327 IMG_UINT32 ui32NumDstSyncs,
1328 IMG_HANDLE *phDstSyncInfo,
1329 const IMG_BOOL *pbDstEnabled)
1330{
1331 (void) puTag;
1332 (void) ui32NumSrcSyncs;
1333 (void) phSrcSyncInfo;
1334 (void) pbSrcEnabled;
1335 (void) ui32NumDstSyncs;
1336 (void) phDstSyncInfo;
1337 (void) pbDstEnabled;
1338
1339 return PVRSRV_OK;
1340}
1341
1342void PVRLinuxFenceRelease(IMG_UINT32 uTag,
1343 IMG_UINT32 ui32NumSrcSyncs,
1344 IMG_HANDLE *phSrcSyncInfo,
1345 const IMG_BOOL *pbSrcEnabled,
1346 IMG_UINT32 ui32NumDstSyncs,
1347 IMG_HANDLE *phDstSyncInfo,
1348 const IMG_BOOL *pbDstEnabled)
1349{
1350 (void) uTag;
1351 (void) ui32NumSrcSyncs;
1352 (void) phSrcSyncInfo;
1353 (void) pbSrcEnabled;
1354 (void) ui32NumDstSyncs;
1355 (void) phDstSyncInfo;
1356 (void) pbDstEnabled;
1357}
1358
1359void PVRLinuxFenceCheckAll(void)
1360{
1361}
1362
1363int PVRLinuxFenceInit(void)
1364{
1365 return 0;
1366}
1367
1368void PVRLinuxFenceDeInit(void)
1369{
1370}
1371#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17)) */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.h
new file mode 100644
index 0000000..156def1
--- /dev/null
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_linux_fence.h
@@ -0,0 +1,71 @@
1/*************************************************************************/ /*!
2@File
3@Title PowerVR Linux fence interface
4@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5@Description drm module
6@License Dual MIT/GPLv2
7
8The contents of this file are subject to the MIT license as set out below.
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20Alternatively, the contents of this file may be used under the terms of
21the GNU General Public License Version 2 ("GPL") in which case the provisions
22of GPL are applicable instead of those above.
23
24If you wish to allow use of your version of this file only under the terms of
25GPL, and not to allow others to use your version of this file under the terms
26of the MIT license, indicate your decision by deleting the provisions above
27and replace them with the notice and other provisions required by GPL as set
28out in the file called "GPL-COPYING" included in this distribution. If you do
29not delete the provisions above, a recipient may use your version of this file
30under the terms of either the MIT license or GPL.
31
32This License is also included in this distribution in the file called
33"MIT-COPYING".
34
35EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42*/ /**************************************************************************/
43
44#if !defined(__PVR_LINUX_FENCE_H__)
45#define __PVR_LINUX_FENCE_H__
46
47IMG_HANDLE PVRLinuxFenceContextCreate(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_HANDLE hImport);
48void PVRLinuxFenceContextDestroy(IMG_HANDLE hFenceContext);
49
50PVRSRV_ERROR PVRLinuxFenceProcess(IMG_UINT32 *puTag,
51 IMG_UINT32 ui32NumSrcSyncs,
52 IMG_HANDLE *phSrcSyncInfo,
53 const IMG_BOOL *pbSrcEnabled,
54 IMG_UINT32 ui32NumDstSyncs,
55 IMG_HANDLE *phDstSyncInfo,
56 const IMG_BOOL *pbDstEnabled);
57
58void PVRLinuxFenceRelease(IMG_UINT32 uTag,
59 IMG_UINT32 ui32NumSrcSyncs,
60 IMG_HANDLE *phSrcSyncInfo,
61 const IMG_BOOL *pbSrcEnabled,
62 IMG_UINT32 ui32NumDstSyncs,
63 IMG_HANDLE *phDstSyncInfo,
64 const IMG_BOOL *pbDstEnabled);
65
66void PVRLinuxFenceCheckAll(void);
67
68int PVRLinuxFenceInit(void);
69void PVRLinuxFenceDeInit(void);
70
71#endif /* !defined(__PVR_LINUX_FENCE_H__) */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_sync.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_sync.c
index 476f0a8..235eaf3 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_sync.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_sync.c
@@ -68,6 +68,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
68#define DPF(fmt, ...) do {} while(0) 68#define DPF(fmt, ...) do {} while(0)
69#endif 69#endif
70 70
71#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0))
72
73static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt)
74{
75 return pt->parent;
76}
77
78#define for_each_sync_pt(s, f, c) \
79 (void)c; \
80list_for_each_entry((s), &(f)->pt_list_head, pt_list)
81
82#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) */
83
84#define for_each_sync_pt(s, f, c) \
85 for ((c) = 0, (s) = (struct sync_pt *)(f)->cbs[0].sync_pt; \
86 (c) < (f)->num_fences; \
87 (c)++, (s) = (struct sync_pt *)(f)->cbs[c].sync_pt)
88
89#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) */
90
71/* We can't support this code when the MISR runs in atomic context because 91/* We can't support this code when the MISR runs in atomic context because
72 * PVRSyncFreeSync() may be called by sync_timeline_signal() which may be 92 * PVRSyncFreeSync() may be called by sync_timeline_signal() which may be
73 * scheduled by the MISR. PVRSyncFreeSync() needs to protect the handle 93 * scheduled by the MISR. PVRSyncFreeSync() needs to protect the handle
@@ -402,7 +422,7 @@ static struct sync_pt *PVRSyncDup(struct sync_pt *sync_pt)
402 struct PVR_SYNC *psPt, *psParentPt = (struct PVR_SYNC *)sync_pt; 422 struct PVR_SYNC *psPt, *psParentPt = (struct PVR_SYNC *)sync_pt;
403 423
404 psPt = (struct PVR_SYNC *) 424 psPt = (struct PVR_SYNC *)
405 sync_pt_create(sync_pt->parent, sizeof(struct PVR_SYNC)); 425 sync_pt_create(sync_pt_parent(sync_pt), sizeof(struct PVR_SYNC));
406 if(!psPt) 426 if(!psPt)
407 { 427 {
408 PVR_DPF((PVR_DBG_ERROR, "%s: sync_pt_create failed", __func__)); 428 PVR_DPF((PVR_DBG_ERROR, "%s: sync_pt_create failed", __func__));
@@ -422,7 +442,7 @@ static int PVRSyncHasSignaled(struct sync_pt *sync_pt)
422{ 442{
423 struct PVR_SYNC *psPt = (struct PVR_SYNC *)sync_pt; 443 struct PVR_SYNC *psPt = (struct PVR_SYNC *)sync_pt;
424 struct PVR_SYNC_TIMELINE *psTimeline = 444 struct PVR_SYNC_TIMELINE *psTimeline =
425 (struct PVR_SYNC_TIMELINE *) sync_pt->parent; 445 (struct PVR_SYNC_TIMELINE *) sync_pt_parent(sync_pt);
426 PVRSRV_SYNC_DATA *psSyncData = 446 PVRSRV_SYNC_DATA *psSyncData =
427 psPt->psSyncData->psSyncInfo->psBase->psSyncData; 447 psPt->psSyncData->psSyncInfo->psBase->psSyncData;
428 448
@@ -448,6 +468,7 @@ static int PVRSyncCompare(struct sync_pt *a, struct sync_pt *b)
448 return -1; 468 return -1;
449} 469}
450 470
471#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0))
451static void PVRSyncPrintTimeline(struct seq_file *s, 472static void PVRSyncPrintTimeline(struct seq_file *s,
452 struct sync_timeline *psObj) 473 struct sync_timeline *psObj)
453{ 474{
@@ -468,7 +489,7 @@ static void PVRSyncPrint(struct seq_file *s, struct sync_pt *psPt)
468 psSync->psSyncData->ui64Stamp, 489 psSync->psSyncData->ui64Stamp,
469 atomic_read(&psSync->psSyncData->sRefcount), 490 atomic_read(&psSync->psSyncData->sRefcount),
470 psSync->psSyncData->ui32WOPSnapshot, 491 psSync->psSyncData->ui32WOPSnapshot,
471 psSync->pt.parent); 492 sync_pt_parent(&psSync->pt));
472 seq_printf(s, "\n WOP/WOC=0x%x/0x%x, " 493 seq_printf(s, "\n WOP/WOC=0x%x/0x%x, "
473 "ROP/ROC=0x%x/0x%x, ROP2/ROC2=0x%x/0x%x, " 494 "ROP/ROC=0x%x/0x%x, ROP2/ROC2=0x%x/0x%x, "
474 "WOC DevVA=0x%.8x, ROC DevVA=0x%.8x, " 495 "WOC DevVA=0x%.8x, ROC DevVA=0x%.8x, "
@@ -483,6 +504,42 @@ static void PVRSyncPrint(struct seq_file *s, struct sync_pt *psPt)
483 psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, 504 psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr,
484 psSyncInfo->sReadOps2CompleteDevVAddr.uiAddr); 505 psSyncInfo->sReadOps2CompleteDevVAddr.uiAddr);
485} 506}
507#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) */
508static void PVRSyncPrintTimeline(struct sync_timeline *psObj,
509 char *str, int size)
510{
511 struct PVR_SYNC_TIMELINE *psTimeline = (struct PVR_SYNC_TIMELINE *)psObj;
512
513 snprintf(str, size, "WOP/WOC=0x%x/0x%x",
514 psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsPending,
515 psTimeline->psSyncInfo->psBase->psSyncData->ui32WriteOpsComplete);
516}
517static void PVRSyncPrint(struct sync_pt *psPt, char *str, int size)
518{
519 struct PVR_SYNC *psSync = (struct PVR_SYNC *)psPt;
520 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo =
521 psSync->psSyncData->psSyncInfo->psBase;
522
523 snprintf(str, size, "ID=%llu, refs=%u, WOPSnapshot=0x%x, parent=%p",
524 psSync->psSyncData->ui64Stamp,
525 atomic_read(&psSync->psSyncData->sRefcount),
526 psSync->psSyncData->ui32WOPSnapshot,
527 sync_pt_parent(&psSync->pt));//psSync->pt.parent);
528 snprintf(str, size, "\n WOP/WOC=0x%x/0x%x, "
529 "ROP/ROC=0x%x/0x%x, ROP2/ROC2=0x%x/0x%x, "
530 "WOC DevVA=0x%.8x, ROC DevVA=0x%.8x, "
531 "ROC2 DevVA=0x%.8x",
532 psSyncInfo->psSyncData->ui32WriteOpsPending,
533 psSyncInfo->psSyncData->ui32WriteOpsComplete,
534 psSyncInfo->psSyncData->ui32ReadOpsPending,
535 psSyncInfo->psSyncData->ui32ReadOpsComplete,
536 psSyncInfo->psSyncData->ui32ReadOps2Pending,
537 psSyncInfo->psSyncData->ui32ReadOps2Complete,
538 psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr,
539 psSyncInfo->sReadOpsCompleteDevVAddr.uiAddr,
540 psSyncInfo->sReadOps2CompleteDevVAddr.uiAddr);
541}
542#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) */
486 543
487static void PVRSyncReleaseTimeline(struct sync_timeline *psObj) 544static void PVRSyncReleaseTimeline(struct sync_timeline *psObj)
488{ 545{
@@ -606,8 +663,13 @@ static struct sync_timeline_ops gsTimelineOps =
606 .has_signaled = PVRSyncHasSignaled, 663 .has_signaled = PVRSyncHasSignaled,
607 .compare = PVRSyncCompare, 664 .compare = PVRSyncCompare,
608 .release_obj = PVRSyncReleaseTimeline, 665 .release_obj = PVRSyncReleaseTimeline,
666#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0))
609 .print_obj = PVRSyncPrintTimeline, 667 .print_obj = PVRSyncPrintTimeline,
610 .print_pt = PVRSyncPrint, 668 .print_pt = PVRSyncPrint,
669#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) */
670 .timeline_value_str = PVRSyncPrintTimeline,
671 .pt_value_str = PVRSyncPrint,
672#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) */
611 .free_pt = PVRSyncFreeSync, 673 .free_pt = PVRSyncFreeSync,
612}; 674};
613 675
@@ -699,7 +761,7 @@ PVRSyncIOCTLCreate(struct PVR_SYNC_TIMELINE *psObj, void __user *pvData)
699 struct PVR_SYNC_KERNEL_SYNC_INFO *psProvidedSyncInfo = NULL; 761 struct PVR_SYNC_KERNEL_SYNC_INFO *psProvidedSyncInfo = NULL;
700 struct PVR_ALLOC_SYNC_DATA *psAllocSyncData; 762 struct PVR_ALLOC_SYNC_DATA *psAllocSyncData;
701 struct PVR_SYNC_CREATE_IOCTL_DATA sData; 763 struct PVR_SYNC_CREATE_IOCTL_DATA sData;
702 int err = -EFAULT, iFd = get_unused_fd(); 764 int err = -EFAULT, iFd = get_unused_fd_flags(O_CLOEXEC);
703 struct sync_fence *psFence; 765 struct sync_fence *psFence;
704 struct sync_pt *psPt; 766 struct sync_pt *psPt;
705 767
@@ -809,8 +871,8 @@ PVRSyncIOCTLDebug(struct PVR_SYNC_TIMELINE *psObj, void __user *pvData)
809{ 871{
810 struct PVR_SYNC_DEBUG_IOCTL_DATA sData; 872 struct PVR_SYNC_DEBUG_IOCTL_DATA sData;
811 struct sync_fence *psFence; 873 struct sync_fence *psFence;
812 struct list_head *psEntry; 874 struct sync_pt *sync_pt;
813 int i = 0, err = -EFAULT; 875 int i = 0, j, err = -EFAULT;
814 876
815 if(!access_ok(VERIFY_READ, pvData, sizeof(sData))) 877 if(!access_ok(VERIFY_READ, pvData, sizeof(sData)))
816 goto err_out; 878 goto err_out;
@@ -825,7 +887,7 @@ PVRSyncIOCTLDebug(struct PVR_SYNC_TIMELINE *psObj, void __user *pvData)
825 goto err_out; 887 goto err_out;
826 } 888 }
827 889
828 list_for_each(psEntry, &psFence->pt_list_head) 890 for_each_sync_pt(sync_pt, psFence, j)
829 { 891 {
830 PVR_SYNC_DEBUG *psMetaData = &sData.sSync[i].sMetaData; 892 PVR_SYNC_DEBUG *psMetaData = &sData.sSync[i].sMetaData;
831 PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; 893 PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo;
@@ -840,14 +902,13 @@ PVRSyncIOCTLDebug(struct PVR_SYNC_TIMELINE *psObj, void __user *pvData)
840 break; 902 break;
841 } 903 }
842 904
843 psPt = (struct PVR_SYNC *) 905 psPt = (struct PVR_SYNC *)sync_pt;
844 container_of(psEntry, struct sync_pt, pt_list);
845 906
846 /* Don't dump foreign points */ 907 /* Don't dump foreign points */
847 if(psPt->pt.parent->ops != &gsTimelineOps) 908 if(sync_pt_parent(&psPt->pt)->ops != &gsTimelineOps)
848 continue; 909 continue;
849 910
850 psTimeline = (struct PVR_SYNC_TIMELINE *)psPt->pt.parent; 911 psTimeline = (struct PVR_SYNC_TIMELINE *)sync_pt_parent(&psPt->pt);
851 psKernelSyncInfo = psPt->psSyncData->psSyncInfo->psBase; 912 psKernelSyncInfo = psPt->psSyncData->psSyncInfo->psBase;
852 PVR_ASSERT(psKernelSyncInfo != NULL); 913 PVR_ASSERT(psKernelSyncInfo != NULL);
853 914
@@ -923,7 +984,7 @@ static long
923PVRSyncIOCTLAlloc(struct PVR_SYNC_TIMELINE *psTimeline, void __user *pvData) 984PVRSyncIOCTLAlloc(struct PVR_SYNC_TIMELINE *psTimeline, void __user *pvData)
924{ 985{
925 struct PVR_ALLOC_SYNC_DATA *psAllocSyncData; 986 struct PVR_ALLOC_SYNC_DATA *psAllocSyncData;
926 int err = -EFAULT, iFd = get_unused_fd(); 987 int err = -EFAULT, iFd = get_unused_fd_flags(O_CLOEXEC);
927 struct PVR_SYNC_ALLOC_IOCTL_DATA sData; 988 struct PVR_SYNC_ALLOC_IOCTL_DATA sData;
928 PVRSRV_SYNC_DATA *psSyncData; 989 PVRSRV_SYNC_DATA *psSyncData;
929 struct file *psFile; 990 struct file *psFile;
@@ -1447,14 +1508,12 @@ CopyKernelSyncInfoToDeviceSyncObject(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo,
1447 1508
1448static IMG_BOOL FenceHasForeignPoints(struct sync_fence *psFence) 1509static IMG_BOOL FenceHasForeignPoints(struct sync_fence *psFence)
1449{ 1510{
1450 struct list_head *psEntry; 1511 struct sync_pt *psPt;
1512 int j;
1451 1513
1452 list_for_each(psEntry, &psFence->pt_list_head) 1514 for_each_sync_pt(psPt, psFence, j)
1453 { 1515 {
1454 struct sync_pt *psPt = 1516 if(sync_pt_parent(psPt)->ops != &gsTimelineOps)
1455 container_of(psEntry, struct sync_pt, pt_list);
1456
1457 if(psPt->parent->ops != &gsTimelineOps)
1458 return IMG_TRUE; 1517 return IMG_TRUE;
1459 } 1518 }
1460 1519
@@ -1495,13 +1554,13 @@ ExpandAndDeDuplicateFenceSyncs(IMG_UINT32 ui32NumSyncs,
1495{ 1554{
1496 IMG_UINT32 i, j, ui32FenceIndex = 0; 1555 IMG_UINT32 i, j, ui32FenceIndex = 0;
1497 IMG_BOOL bRet = IMG_TRUE; 1556 IMG_BOOL bRet = IMG_TRUE;
1557 struct sync_pt *psPt;
1498 1558
1499 *pui32NumRealSyncs = 0; 1559 *pui32NumRealSyncs = 0;
1500 1560
1501 for(i = 0; i < ui32NumSyncs; i++) 1561 for(i = 0; i < ui32NumSyncs; i++)
1502 { 1562 {
1503 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; 1563 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
1504 struct list_head *psEntry;
1505 1564
1506 /* Skip any invalid fence file descriptors without error */ 1565 /* Skip any invalid fence file descriptors without error */
1507 if(aiFenceFds[i] < 0) 1566 if(aiFenceFds[i] < 0)
@@ -1525,7 +1584,7 @@ ExpandAndDeDuplicateFenceSyncs(IMG_UINT32 ui32NumSyncs,
1525 * patched in userspace. That's really a userspace driver bug, so 1584 * patched in userspace. That's really a userspace driver bug, so
1526 * just fail here instead of not synchronizing. 1585 * just fail here instead of not synchronizing.
1527 */ 1586 */
1528 apsFence[ui32FenceIndex] = sync_fence_fdget(aiFenceFds[i]); 1587 apsFence[ui32FenceIndex] = sync_fence_fdget((IMG_INT32)aiFenceFds[i]);
1529 if(!apsFence[ui32FenceIndex]) 1588 if(!apsFence[ui32FenceIndex])
1530 { 1589 {
1531 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get fence from fd=%d", 1590 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get fence from fd=%d",
@@ -1546,7 +1605,7 @@ ExpandAndDeDuplicateFenceSyncs(IMG_UINT32 ui32NumSyncs,
1546 */ 1605 */
1547 if(FenceHasForeignPoints(apsFence[ui32FenceIndex])) 1606 if(FenceHasForeignPoints(apsFence[ui32FenceIndex]))
1548 { 1607 {
1549 psSyncInfo = ForeignSyncPointToSyncInfo(aiFenceFds[i]); 1608 psSyncInfo = ForeignSyncPointToSyncInfo((IMG_INT32)aiFenceFds[i]);
1550 if(psSyncInfo) 1609 if(psSyncInfo)
1551 { 1610 {
1552 if(!AddSyncInfoToArray(psSyncInfo, ui32SyncPointLimit, 1611 if(!AddSyncInfoToArray(psSyncInfo, ui32SyncPointLimit,
@@ -1563,10 +1622,8 @@ ExpandAndDeDuplicateFenceSyncs(IMG_UINT32 ui32NumSyncs,
1563 /* FIXME: The ForeignSyncPointToSyncInfo() path optimizes away already 1622 /* FIXME: The ForeignSyncPointToSyncInfo() path optimizes away already
1564 * signalled fences. Consider optimizing this path too. 1623 * signalled fences. Consider optimizing this path too.
1565 */ 1624 */
1566 list_for_each(psEntry, &apsFence[ui32FenceIndex]->pt_list_head) 1625 for_each_sync_pt(psPt, apsFence[ui32FenceIndex], j)
1567 { 1626 {
1568 struct sync_pt *psPt =
1569 container_of(psEntry, struct sync_pt, pt_list);
1570 1627
1571 psSyncInfo = 1628 psSyncInfo =
1572 ((struct PVR_SYNC *)psPt)->psSyncData->psSyncInfo->psBase; 1629 ((struct PVR_SYNC *)psPt)->psSyncData->psSyncInfo->psBase;
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxdefs.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxdefs.h
index ed24647..7acba79 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxdefs.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxdefs.h
@@ -48,6 +48,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48#if defined(SGX520) 48#if defined(SGX520)
49#include "sgx520defs.h" 49#include "sgx520defs.h"
50#else 50#else
51#if defined(SGX5300)
52#include "sgx5300defs.h"
53#else
51#if defined(SGX530) 54#if defined(SGX530)
52#include "sgx530defs.h" 55#include "sgx530defs.h"
53#else 56#else
@@ -88,6 +91,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88#endif 91#endif
89#endif 92#endif
90#endif 93#endif
94#endif
91 95
92#if defined(SGX_FEATURE_MP) 96#if defined(SGX_FEATURE_MP)
93#if defined(SGX554) 97#if defined(SGX554)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxerrata.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxerrata.h
index 42c1f18..e423d4f 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxerrata.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxerrata.h
@@ -57,16 +57,40 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57 57
58 #if SGX_CORE_REV == 111 58 #if SGX_CORE_REV == 111
59 #else 59 #else
60 #if SGX_CORE_REV == 112
61 #else
60 #if SGX_CORE_REV == SGX_CORE_REV_HEAD 62 #if SGX_CORE_REV == SGX_CORE_REV_HEAD
61 /* RTL head - no BRNs to apply */ 63 /* RTL head - no BRNs to apply */
62 #else 64 #else
63 #error "sgxerrata.h: SGX520 Core Revision unspecified" 65 #error "sgxerrata.h: SGX520 Core Revision unspecified"
64 #endif 66 #endif
65 #endif 67 #endif
68 #endif
66 /* signal that the Core Version has a valid definition */ 69 /* signal that the Core Version has a valid definition */
67 #define SGX_CORE_DEFINED 70 #define SGX_CORE_DEFINED
68#endif 71#endif
69 72
73#if defined(SGX5300) && !defined(SGX_CORE_DEFINED)
74 /* define the _current_ SGX5300 RTL head revision */
75 #define SGX_CORE_REV_HEAD 0
76 #if defined(USE_SGX_CORE_REV_HEAD)
77 /* build config selects Core Revision to be the Head */
78 #define SGX_CORE_REV SGX_CORE_REV_HEAD
79 #endif
80
81 #if SGX_CORE_REV == 112
82 #else
83 #if SGX_CORE_REV == SGX_CORE_REV_HEAD
84 /* RTL head - no BRNs to apply */
85 #else
86 #error "sgxerrata.h: SGX5300 Core Revision unspecified"
87 #endif
88 #endif
89 /* signal that the Core Version has a valid definition */
90 #define SGX_CORE_DEFINED
91
92#endif
93
70#if defined(SGX530) && !defined(SGX_CORE_DEFINED) 94#if defined(SGX530) && !defined(SGX_CORE_DEFINED)
71 /* define the _current_ SGX530 RTL head revision */ 95 /* define the _current_ SGX530 RTL head revision */
72 #define SGX_CORE_REV_HEAD 0 96 #define SGX_CORE_REV_HEAD 0
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxfeaturedefs.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxfeaturedefs.h
index 9efce89..de07cc8 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxfeaturedefs.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/hwdefs/sgxfeaturedefs.h
@@ -46,6 +46,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 #define SGX_FEATURE_AUTOCLOCKGATING 46 #define SGX_FEATURE_AUTOCLOCKGATING
47 #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1) 47 #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1)
48#else 48#else
49#if defined(SGX5300)
50 #define SGX_CORE_FRIENDLY_NAME "SGX5300"
51 #define SGX_CORE_ID SGX_CORE_ID_5300
52 #define SGX_FEATURE_ADDRESS_SPACE_SIZE (32)
53 #define SGX_FEATURE_ADDRESS_SPACE_EXTENSION
54 #define SGX_FEATURE_BIF_NUM_DIRLISTS (16)
55 #define SGX_FEATURE_NUM_USE_PIPES (1)
56 #define SGX_FEATURE_AUTOCLOCKGATING
57 #define SGX_FEATURE_PT_CACHE_ENTRIES_PER_LINE (1)
58#else
49#if defined(SGX530) 59#if defined(SGX530)
50 #define SGX_CORE_FRIENDLY_NAME "SGX530" 60 #define SGX_CORE_FRIENDLY_NAME "SGX530"
51 #define SGX_CORE_ID SGX_CORE_ID_530 61 #define SGX_CORE_ID SGX_CORE_ID_530
@@ -204,6 +214,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
204#endif 214#endif
205#endif 215#endif
206#endif 216#endif
217#endif
207 218
208#if defined(SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH) \ 219#if defined(SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH) \
209 || defined(SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH) 220 || defined(SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/buffer_manager.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/buffer_manager.h
index 49d023e..a23529a 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/buffer_manager.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/buffer_manager.h
@@ -71,7 +71,7 @@ struct _BM_MAPPING_
71 hm_wrapped_virtaddr, /*!< wrapped user supplied contiguous with virtual address*/ 71 hm_wrapped_virtaddr, /*!< wrapped user supplied contiguous with virtual address*/
72 hm_wrapped_scatter_virtaddr, /*!< wrapped user supplied scattered with virtual address*/ 72 hm_wrapped_scatter_virtaddr, /*!< wrapped user supplied scattered with virtual address*/
73 hm_env, /*!< obtained from environment */ 73 hm_env, /*!< obtained from environment */
74 hm_contiguous /*!< contigous arena */ 74 hm_contiguous /*!< contiguous arena */
75 } eCpuMemoryOrigin; 75 } eCpuMemoryOrigin;
76 76
77 BM_HEAP *pBMHeap; /* which BM heap */ 77 BM_HEAP *pBMHeap; /* which BM heap */
@@ -83,8 +83,13 @@ struct _BM_MAPPING_
83 IMG_SYS_PHYADDR *psSysAddr; 83 IMG_SYS_PHYADDR *psSysAddr;
84 IMG_SIZE_T uSize; 84 IMG_SIZE_T uSize;
85 IMG_SIZE_T uSizeVM; 85 IMG_SIZE_T uSizeVM;
86 IMG_HANDLE hOSMemHandle; 86 IMG_HANDLE hOSMemHandle;
87 IMG_UINT32 ui32Flags; 87 IMG_UINT32 ui32Flags;
88#if defined (PVRSRV_DEVMEM_TIME_STATS)
89 IMG_UINT32 ui32TimeToDevMap; /* Time taken (in microseconds) to map this memory in device MMU */
90 IMG_UINT32 *pui32TimeToDevUnmap; /* Time taken (in microseconds) to unmap this memory from Device MMU.
91 NOTE - API user provided address to store this info, if at all */
92#endif
88 93
89 /* Sparse mapping data */ 94 /* Sparse mapping data */
90 IMG_UINT32 ui32ChunkSize; 95 IMG_UINT32 ui32ChunkSize;
@@ -102,7 +107,7 @@ struct _BM_MAPPING_
102typedef struct _BM_BUF_ 107typedef struct _BM_BUF_
103{ 108{
104 IMG_CPU_VIRTADDR *CpuVAddr; 109 IMG_CPU_VIRTADDR *CpuVAddr;
105 IMG_VOID *hOSMemHandle; 110 IMG_VOID *hOSMemHandle;
106 IMG_CPU_PHYADDR CpuPAddr; 111 IMG_CPU_PHYADDR CpuPAddr;
107 IMG_DEV_VIRTADDR DevVAddr; 112 IMG_DEV_VIRTADDR DevVAddr;
108 113
@@ -178,8 +183,8 @@ typedef struct _XPROC_DATA_{
178 IMG_UINT32 ui32AllocFlags; 183 IMG_UINT32 ui32AllocFlags;
179 IMG_UINT32 ui32Size; 184 IMG_UINT32 ui32Size;
180 IMG_UINT32 ui32PageSize; 185 IMG_UINT32 ui32PageSize;
181 RA_ARENA *psArena; 186 RA_ARENA *psArena;
182 IMG_SYS_PHYADDR sSysPAddr; 187 IMG_SYS_PHYADDR sSysPAddr;
183 IMG_VOID *pvCpuVAddr; 188 IMG_VOID *pvCpuVAddr;
184 IMG_HANDLE hOSMemHandle; 189 IMG_HANDLE hOSMemHandle;
185} XPROC_DATA; 190} XPROC_DATA;
@@ -272,7 +277,7 @@ BM_DestroyHeap (IMG_HANDLE hDevMemHeap);
272 * @Description 277 * @Description
273 * 278 *
274 * Reinitialises the buffer manager after a power event. Calling this 279 * Reinitialises the buffer manager after a power event. Calling this
275 * function will reprogram MMU registers and renable the MMU. 280 * function will reprogram MMU registers and re-enable the MMU.
276 * 281 *
277 * @Input None 282 * @Input None
278 * @Return None 283 * @Return None
@@ -290,7 +295,7 @@ BM_Reinitialise (PVRSRV_DEVICE_NODE *psDeviceNode);
290 * maps. 295 * maps.
291 * 296 *
292 * @Input uSize - require size in bytes of the buffer. 297 * @Input uSize - require size in bytes of the buffer.
293 * @Input/Output pui32Flags - bit mask of buffer property flags + recieves heap flags. 298 * @Input/Output pui32Flags - bit mask of buffer property flags + receives heap flags.
294 * @Input uDevVAddrAlignment - required alignment in bytes, or 0. 299 * @Input uDevVAddrAlignment - required alignment in bytes, or 0.
295 * @Input pvPrivData - private data passed to OS allocator 300 * @Input pvPrivData - private data passed to OS allocator
296 * @Input ui32PrivDataLength - length of private data 301 * @Input ui32PrivDataLength - length of private data
@@ -298,6 +303,9 @@ BM_Reinitialise (PVRSRV_DEVICE_NODE *psDeviceNode);
298 * @Input ui32NumVirtChunks - Number of virtual chunks 303 * @Input ui32NumVirtChunks - Number of virtual chunks
299 * @Input ui32NumPhysChunks - Number of physical chunks 304 * @Input ui32NumPhysChunks - Number of physical chunks
300 * @Input pabMapChunk - Chunk mapping array 305 * @Input pabMapChunk - Chunk mapping array
306 * @Output pui32TimeToDevMap - Available only when PVRSRV_DEVMEM_TIME_STATS defined,
307 * contains time taken (in microseconds) to map this buffer
308 * to Device MMU.
301 * @Output phBuf - receives the buffer handle. 309 * @Output phBuf - receives the buffer handle.
302 * @Return IMG_TRUE - Success, IMG_FALSE - Failed. 310 * @Return IMG_TRUE - Success, IMG_FALSE - Failed.
303 */ 311 */
@@ -313,6 +321,9 @@ BM_Alloc (IMG_HANDLE hDevMemHeap,
313 IMG_UINT32 ui32NumVirtChunks, 321 IMG_UINT32 ui32NumVirtChunks,
314 IMG_UINT32 ui32NumPhysChunks, 322 IMG_UINT32 ui32NumPhysChunks,
315 IMG_BOOL *pabMapChunk, 323 IMG_BOOL *pabMapChunk,
324 #if defined (PVRSRV_DEVMEM_TIME_STATS)
325 IMG_UINT32 *pui32TimeToDevMap,
326 #endif
316 BM_HANDLE *phBuf); 327 BM_HANDLE *phBuf);
317 328
318/** 329/**
@@ -335,7 +346,7 @@ BM_Alloc (IMG_HANDLE hDevMemHeap,
335 */ 346 */
336IMG_BOOL 347IMG_BOOL
337BM_Wrap ( IMG_HANDLE hDevMemHeap, 348BM_Wrap ( IMG_HANDLE hDevMemHeap,
338 IMG_SIZE_T uSize, 349 IMG_SIZE_T uSize,
339 IMG_SIZE_T uOffset, 350 IMG_SIZE_T uOffset,
340 IMG_BOOL bPhysContig, 351 IMG_BOOL bPhysContig,
341 IMG_SYS_PHYADDR *psSysAddr, 352 IMG_SYS_PHYADDR *psSysAddr,
@@ -351,11 +362,17 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap,
351 * Free a buffer previously allocated via BM_Alloc. 362 * Free a buffer previously allocated via BM_Alloc.
352 * 363 *
353 * @Input hBuf - buffer handle. 364 * @Input hBuf - buffer handle.
365 * @Output pui32TimeToDevUnmap - Time taken in us to "unmap"
366 * the memory from Device MMU
354 * @Return None. 367 * @Return None.
355 */ 368 */
356IMG_VOID 369IMG_VOID
357BM_Free (BM_HANDLE hBuf, 370BM_Free (BM_HANDLE hBuf,
358 IMG_UINT32 ui32Flags); 371 IMG_UINT32 ui32Flags
372 #if defined(PVRSRV_DEVMEM_TIME_STATS)
373 , IMG_UINT32 *pui32TimeToDevUnmap
374 #endif
375 );
359 376
360 377
361/** 378/**
@@ -416,7 +433,7 @@ BM_HandleToOSMemHandle (BM_HANDLE hBuf);
416 * 433 *
417 * @Description 434 * @Description
418 * 435 *
419 * Retreive physical address backing dev V address 436 * Retrieve physical address backing dev V address
420 * 437 *
421 * @Input psMemInfo 438 * @Input psMemInfo
422 * @Input sDevVPageAddr 439 * @Input sDevVPageAddr
@@ -544,8 +561,8 @@ IMG_UINT32 BM_GetVirtualSize(IMG_HANDLE hBMHandle);
544****************************************************************************** 561******************************************************************************
545 @Function BM_MapPageAtOffset 562 @Function BM_MapPageAtOffset
546 563
547 @Description utility function check if the specificed offset in a BM mapping 564 @Description utility function check if the specified offset in a BM mapping
548 is a page that needs tp be mapped 565 is a page that needs to be mapped
549 566
550 @Input hBMHandle - Handle to BM mapping 567 @Input hBMHandle - Handle to BM mapping
551 568
@@ -557,10 +574,10 @@ IMG_BOOL BM_MapPageAtOffset(IMG_HANDLE hBMHandle, IMG_UINT32 ui32Offset);
557 574
558/*! 575/*!
559****************************************************************************** 576******************************************************************************
560 @Function BM_VirtOffsetToPhyscial 577 @Function BM_VirtOffsetToPhysical
561 578
562 @Description utility function find of physical offset of a sparse allocation 579 @Description utility function find of physical offset of a sparse allocation
563 from it's virtual offset. 580 from its virtual offset.
564 581
565 @Input hBMHandle - Handle to BM mapping 582 @Input hBMHandle - Handle to BM mapping
566 583
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/dmabuf_sync.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/dmabuf_sync.h
new file mode 100644
index 0000000..066bbee
--- /dev/null
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/dmabuf_sync.h
@@ -0,0 +1,69 @@
1/*************************************************************************/ /*!
2@Title Services dma_buf synchronisation integration
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2
5
6The contents of this file are subject to the MIT license as set out below.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18Alternatively, the contents of this file may be used under the terms of
19the GNU General Public License Version 2 ("GPL") in which case the provisions
20of GPL are applicable instead of those above.
21
22If you wish to allow use of your version of this file only under the terms of
23GPL, and not to allow others to use your version of this file under the terms
24of the MIT license, indicate your decision by deleting the provisions above
25and replace them with the notice and other provisions required by GPL as set
26out in the file called "GPL-COPYING" included in this distribution. If you do
27not delete the provisions above, a recipient may use your version of this file
28under the terms of either the MIT license or GPL.
29
30This License is also included in this distribution in the file called
31"MIT-COPYING".
32
33EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/ /**************************************************************************/
41
42#include "img_defs.h"
43#include "img_types.h"
44#include "servicesint.h"
45
46#ifndef __DMABUF_SYNC_H__
47#define __DMABUF_SYNC_H__
48
49typedef struct _PVRSRV_DMABUF_SYNC_INFO_ {
50 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
51 IMG_HANDLE hUnique;
52 IMG_UINT32 ui32RefCount;
53 IMG_UINT64 ui64Stamp;
54} PVRSRV_DMABUF_SYNC_INFO;
55
56PVRSRV_ERROR PVRSRVDmaBufSyncAcquire(IMG_HANDLE hUnique,
57 IMG_HANDLE hPriv,
58 IMG_HANDLE hDevCookie,
59 IMG_HANDLE hDevMemContext,
60 PVRSRV_DMABUF_SYNC_INFO **ppsDmaBufSyncInfo);
61
62IMG_VOID PVRSRVDmaBufSyncRelease(PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo);
63
64static INLINE IMG_UINT64 DmaBufSyncGetStamp(PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo)
65{
66 return psDmaBufSyncInfo->ui64Stamp;
67}
68
69#endif /* __DMABUF_SYNC_H__ */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/external_sync.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/ion_sync.h
index 9b64d1e..8600a19 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/external_sync.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/ion_sync.h
@@ -43,31 +43,31 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43#include "img_types.h" 43#include "img_types.h"
44#include "servicesint.h" 44#include "servicesint.h"
45 45
46#ifndef __EXTERNAL_SYNC_H__ 46#ifndef __ION_SYNC_H__
47#define __EXTERNAL_SYNC_H__ 47#define __ION_SYNC_H__
48 48
49typedef struct _PVRSRV_EXTERNAL_SYNC_INFO_ { 49typedef struct _PVRSRV_ION_SYNC_INFO_ {
50 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; 50 PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
51 IMG_HANDLE hUnique; 51 IMG_HANDLE hUnique;
52 IMG_UINT32 ui32RefCount; 52 IMG_UINT32 ui32RefCount;
53 IMG_UINT64 ui64Stamp; 53 IMG_UINT64 ui64Stamp;
54} PVRSRV_EXTERNAL_SYNC_INFO; 54} PVRSRV_ION_SYNC_INFO;
55 55
56PVRSRV_ERROR PVRSRVExternalBufferSyncAcquire(IMG_HANDLE hUnique, 56PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique,
57 IMG_HANDLE hDevCookie, 57 IMG_HANDLE hDevCookie,
58 IMG_HANDLE hDevMemContext, 58 IMG_HANDLE hDevMemContext,
59 PVRSRV_EXTERNAL_SYNC_INFO **ppsExternalSyncInfo); 59 PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo);
60 60
61IMG_VOID PVRSRVExternalBufferSyncRelease(PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo); 61IMG_VOID PVRSRVIonBufferSyncRelease(PVRSRV_ION_SYNC_INFO *psIonSyncInfo);
62 62
63static INLINE PVRSRV_KERNEL_SYNC_INFO *ExternalBufferSyncGetKernelSyncInfo(PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo) 63static INLINE PVRSRV_KERNEL_SYNC_INFO *IonBufferSyncGetKernelSyncInfo(PVRSRV_ION_SYNC_INFO *psIonSyncInfo)
64{ 64{
65 return psExternalSyncInfo->psSyncInfo; 65 return psIonSyncInfo->psSyncInfo;
66} 66}
67 67
68static INLINE IMG_UINT64 ExternalBufferSyncGetStamp(PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo) 68static INLINE IMG_UINT64 IonBufferSyncGetStamp(PVRSRV_ION_SYNC_INFO *psIonSyncInfo)
69{ 69{
70 return psExternalSyncInfo->ui64Stamp; 70 return psIonSyncInfo->ui64Stamp;
71} 71}
72 72
73#endif /* __EXTERNAL_SYNC_H__ */ 73#endif /* __ION_SYNC_H__ */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/osfunc.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/osfunc.h
index 9bb772c..6db5b2e 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/osfunc.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/osfunc.h
@@ -83,8 +83,15 @@ extern "C" {
83#define PVRSRV_OS_HEAP_MASK 0xf /* host heap flags mask */ 83#define PVRSRV_OS_HEAP_MASK 0xf /* host heap flags mask */
84#define PVRSRV_OS_PAGEABLE_HEAP 0x1 /* allocation pageable */ 84#define PVRSRV_OS_PAGEABLE_HEAP 0x1 /* allocation pageable */
85#define PVRSRV_OS_NON_PAGEABLE_HEAP 0x2 /* allocation non pageable */ 85#define PVRSRV_OS_NON_PAGEABLE_HEAP 0x2 /* allocation non pageable */
86#if defined (__linux__) && defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
87#define PVRSRV_SWAP_BUFFER_ALLOCATION 0x4 /* allocation for swap buffer */
88#else
89#define PVRSRV_SWAP_BUFFER_ALLOCATION 0x0
90#endif
86 91
87 92#if defined (PVRSRV_DEVMEM_TIME_STATS)
93IMG_UINT64 OSClockMonotonicus(IMG_VOID);
94#endif
88IMG_UINT32 OSClockus(IMG_VOID); 95IMG_UINT32 OSClockus(IMG_VOID);
89IMG_UINT32 OSGetPageSize(IMG_VOID); 96IMG_UINT32 OSGetPageSize(IMG_VOID);
90PVRSRV_ERROR OSInstallDeviceLISR(IMG_VOID *pvSysData, 97PVRSRV_ERROR OSInstallDeviceLISR(IMG_VOID *pvSysData,
@@ -521,6 +528,12 @@ PVRSRV_ERROR OSUnmapPhysToUserSpace(IMG_HANDLE hDevCookie,
521 528
522PVRSRV_ERROR OSLockResource(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID); 529PVRSRV_ERROR OSLockResource(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID);
523PVRSRV_ERROR OSUnlockResource(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID); 530PVRSRV_ERROR OSUnlockResource(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID);
531
532#if !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__)
533PVRSRV_ERROR OSLockResourceAndBlockMISR(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID);
534PVRSRV_ERROR OSUnlockResourceAndUnblockMISR(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID);
535#endif /* !defined(PVR_LINUX_USING_WORKQUEUES) && defined(__linux__) */
536
524IMG_BOOL OSIsResourceLocked(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID); 537IMG_BOOL OSIsResourceLocked(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID);
525PVRSRV_ERROR OSCreateResource(PVRSRV_RESOURCE *psResource); 538PVRSRV_ERROR OSCreateResource(PVRSRV_RESOURCE *psResource);
526PVRSRV_ERROR OSDestroyResource(PVRSRV_RESOURCE *psResource); 539PVRSRV_ERROR OSDestroyResource(PVRSRV_RESOURCE *psResource);
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/refcount.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/refcount.h
index 0f015b5..95493b7 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/refcount.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/refcount.h
@@ -43,9 +43,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43#define __REFCOUNT_H__ 43#define __REFCOUNT_H__
44 44
45#include "pvr_bridge_km.h" 45#include "pvr_bridge_km.h"
46#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 46#if defined(SUPPORT_ION)
47#include "external_sync.h" 47#include "ion_sync.h"
48#endif /* defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) */ 48#endif /* defined(SUPPORT_ION) */
49#if defined(SUPPORT_DMABUF)
50#include "dmabuf_sync.h"
51#endif /* defined(SUPPORT_DMABUF) */
49 52
50#if defined(PVRSRV_REFCOUNT_DEBUG) 53#if defined(PVRSRV_REFCOUNT_DEBUG)
51 54
@@ -114,23 +117,42 @@ void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
114void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, 117void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
115 PKV_OFFSET_STRUCT psOffsetStruct); 118 PKV_OFFSET_STRUCT psOffsetStruct);
116 119
117#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 120#if defined(SUPPORT_ION)
118#define PVRSRVExternalBufferSyncInfoIncRef(x...) \ 121#define PVRSRVIonBufferSyncInfoIncRef(x...) \
119 PVRSRVExternalBufferSyncInfoIncRef2(__FILE__, __LINE__, x) 122 PVRSRVIonBufferSyncInfoIncRef2(__FILE__, __LINE__, x)
120#define PVRSRVExternalBufferSyncInfoDecRef(x...) \ 123#define PVRSRVIonBufferSyncInfoDecRef(x...) \
121 PVRSRVExternalBufferSyncInfoDecRef2(__FILE__, __LINE__, x) 124 PVRSRVIonBufferSyncInfoDecRef2(__FILE__, __LINE__, x)
122 125
123PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, 126PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
124 IMG_HANDLE hUnique, 127 IMG_HANDLE hUnique,
125 IMG_HANDLE hDevCookie, 128 IMG_HANDLE hDevCookie,
126 IMG_HANDLE hDevMemContext, 129 IMG_HANDLE hDevMemContext,
127 PVRSRV_EXTERNAL_SYNC_INFO **ppsIonSyncInfo, 130 PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo,
128 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo); 131 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
129void PVRSRVExternalBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, 132void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
130 PVRSRV_EXTERNAL_SYNC_INFO *psIonSyncInfo, 133 PVRSRV_ION_SYNC_INFO *psIonSyncInfo,
131 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo); 134 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
132#endif /* defined (SUPPORT_ION) */ 135#endif /* defined (SUPPORT_ION) */
133 136
137#if defined(SUPPORT_DMABUF)
138#define PVRSRVDmaBufSyncInfoIncRef(x...) \
139 PVRSRVDmaBufSyncInfoIncRef2(__FILE__, __LINE__, x)
140#define PVRSRVDmaBufSyncInfoDecRef(x...) \
141 PVRSRVDmaBufSyncInfoDecRef2(__FILE__, __LINE__, x)
142
143PVRSRV_ERROR PVRSRVDmaBufSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
144 IMG_HANDLE hUnique,
145 IMG_HANDLE hPriv,
146 IMG_HANDLE hDevCookie,
147 IMG_HANDLE hDevMemContext,
148 PVRSRV_DMABUF_SYNC_INFO **ppsDmaBufSyncInfo,
149 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
150
151void PVRSRVDmaBufSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
152 PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo,
153 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
154#endif /* defined (SUPPORT_DMABUF) */
155
134#endif /* defined(__linux__) */ 156#endif /* defined(__linux__) */
135 157
136#else /* defined(PVRSRV_REFCOUNT_DEBUG) */ 158#else /* defined(PVRSRV_REFCOUNT_DEBUG) */
@@ -216,29 +238,54 @@ static INLINE void PVRSRVOffsetStructDecMapped(PKV_OFFSET_STRUCT psOffsetStruct)
216 psOffsetStruct->ui32Mapped--; 238 psOffsetStruct->ui32Mapped--;
217} 239}
218 240
219#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) 241#if defined(SUPPORT_ION)
220static INLINE PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef(IMG_HANDLE hUnique, 242static INLINE PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef(IMG_HANDLE hUnique,
221 IMG_HANDLE hDevCookie, 243 IMG_HANDLE hDevCookie,
222 IMG_HANDLE hDevMemContext, 244 IMG_HANDLE hDevMemContext,
223 PVRSRV_EXTERNAL_SYNC_INFO **ppsIonSyncInfo, 245 PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo,
224 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) 246 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
225{ 247{
226 PVR_UNREFERENCED_PARAMETER(psKernelMemInfo); 248 PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
227 249
228 return PVRSRVExternalBufferSyncAcquire(hUnique, 250 return PVRSRVIonBufferSyncAcquire(hUnique,
229 hDevCookie, 251 hDevCookie,
230 hDevMemContext, 252 hDevMemContext,
231 ppsIonSyncInfo); 253 ppsIonSyncInfo);
232} 254}
233 255
234static INLINE void PVRSRVExternalBufferSyncInfoDecRef(PVRSRV_EXTERNAL_SYNC_INFO *psIonSyncInfo, 256static INLINE void PVRSRVIonBufferSyncInfoDecRef(PVRSRV_ION_SYNC_INFO *psIonSyncInfo,
235 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) 257 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
236{ 258{
237 PVR_UNREFERENCED_PARAMETER(psKernelMemInfo); 259 PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
238 PVRSRVExternalBufferSyncRelease(psIonSyncInfo); 260 PVRSRVIonBufferSyncRelease(psIonSyncInfo);
239} 261}
240#endif /* defined (SUPPORT_ION) */ 262#endif /* defined (SUPPORT_ION) */
241 263
264#if defined(SUPPORT_DMABUF)
265static INLINE PVRSRV_ERROR PVRSRVDmaBufSyncInfoIncRef(IMG_HANDLE hUnique,
266 IMG_HANDLE hPriv,
267 IMG_HANDLE hDevCookie,
268 IMG_HANDLE hDevMemContext,
269 PVRSRV_DMABUF_SYNC_INFO **ppsDmaBufSyncInfo,
270 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
271{
272 PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
273
274 return PVRSRVDmaBufSyncAcquire(hUnique,
275 hPriv,
276 hDevCookie,
277 hDevMemContext,
278 ppsDmaBufSyncInfo);
279}
280
281static INLINE void PVRSRVDmaBufSyncInfoDecRef(PVRSRV_DMABUF_SYNC_INFO *psDmaBufSyncInfo,
282 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
283{
284 PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
285 PVRSRVDmaBufSyncRelease(psDmaBufSyncInfo);
286}
287#endif /* defined (SUPPORT_DMABUF) */
288
242#endif /* defined(__linux__) */ 289#endif /* defined(__linux__) */
243 290
244#endif /* defined(PVRSRV_REFCOUNT_DEBUG) */ 291#endif /* defined(PVRSRV_REFCOUNT_DEBUG) */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/resman.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/resman.h
index 75e09a9..14af110 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/resman.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/resman.h
@@ -80,7 +80,7 @@ enum {
80 RESMAN_TYPE_DEVICEMEM_WRAP, /*!< Device Memory Wrap Resource */ 80 RESMAN_TYPE_DEVICEMEM_WRAP, /*!< Device Memory Wrap Resource */
81 RESMAN_TYPE_DEVICEMEM_ALLOCATION, /*!< Device Memory Allocation Resource */ 81 RESMAN_TYPE_DEVICEMEM_ALLOCATION, /*!< Device Memory Allocation Resource */
82 RESMAN_TYPE_DEVICEMEM_ION, /*!< Device Memory Ion Resource */ 82 RESMAN_TYPE_DEVICEMEM_ION, /*!< Device Memory Ion Resource */
83 RESMAN_TYPE_DEVICEMEM_DMABUF, /*!< Device Memory Dmabuf Resource */ 83 RESMAN_TYPE_DEVICEMEM_DMABUF, /*!< Device Memory dma-buf Resource */
84 RESMAN_TYPE_EVENT_OBJECT, /*!< Event Object */ 84 RESMAN_TYPE_EVENT_OBJECT, /*!< Event Object */
85 RESMAN_TYPE_SHARED_MEM_INFO, /*!< Shared system memory meminfo */ 85 RESMAN_TYPE_SHARED_MEM_INFO, /*!< Shared system memory meminfo */
86 RESMAN_TYPE_MODIFY_SYNC_OPS, /*!< Syncobject synchronisation Resource*/ 86 RESMAN_TYPE_MODIFY_SYNC_OPS, /*!< Syncobject synchronisation Resource*/
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/srvkm.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/srvkm.h
index 45ac3b1..723037e 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/srvkm.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/srvkm/include/srvkm.h
@@ -81,7 +81,7 @@ extern "C" {
81#define SYNC_OP_CLASS_KICKTA (1<<2) 81#define SYNC_OP_CLASS_KICKTA (1<<2)
82#define SYNC_OP_CLASS_TQ_3D (1<<3) 82#define SYNC_OP_CLASS_TQ_3D (1<<3)
83#define SYNC_OP_CLASS_TQ_2D (1<<4) 83#define SYNC_OP_CLASS_TQ_2D (1<<4)
84 84#define SYNC_OP_CLASS_LINUX_FENCE (1<<5)
85#define SYNC_OP_TYPE_MASK 0x00f0000UL 85#define SYNC_OP_TYPE_MASK 0x00f0000UL
86#define SYNC_OP_TYPE_SHIFT 16 86#define SYNC_OP_TYPE_SHIFT 16
87#define SYNC_OP_TYPE_READOP (1<<0) 87#define SYNC_OP_TYPE_READOP (1<<0)
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap/sgxfreq.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap/sgxfreq.c
index 5159fd4..6e5571e 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap/sgxfreq.c
+++ b/jacinto6/sgx_src/eurasia_km/services4/system/omap/sgxfreq.c
@@ -346,8 +346,8 @@ err1:
346#endif 346#endif
347#endif 347#endif
348noerr: 348noerr:
349 return ret; 349 return ret;
350 } 350 }
351 return ret; 351 return ret;
352} 352}
353 353
@@ -356,7 +356,7 @@ static struct sgxfreq_governor *__find_governor(const char *name)
356 struct sgxfreq_governor *t; 356 struct sgxfreq_governor *t;
357 357
358 list_for_each_entry(t, &sfd.gov_list, governor_list) 358 list_for_each_entry(t, &sfd.gov_list, governor_list)
359 if (!strnicmp(name, t->name, SGXFREQ_NAME_LEN)) 359 if (!strncasecmp(name, t->name, SGXFREQ_NAME_LEN))
360 return t; 360 return t;
361 361
362 return NULL; 362 return NULL;
@@ -441,16 +441,16 @@ int sgxfreq_init(struct device *dev)
441 return -EINVAL; 441 return -EINVAL;
442#endif 442#endif
443 443
444#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
445 rcu_read_lock(); 444 rcu_read_lock();
446 445
446#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
447 sfd.freq_cnt = sfd.pdata->opp_get_opp_count(dev); 447 sfd.freq_cnt = sfd.pdata->opp_get_opp_count(dev);
448#else 448#else
449 ret = of_init_opp_table(dev); 449 ret = of_init_opp_table(dev);
450 if (ret) { 450 if (ret) {
451 pr_err("sgxfreq: failed to init OPP table: %d\n", ret); 451 pr_err("sgxfreq: failed to init OPP table: %d\n", ret);
452 return -EINVAL; 452 return -EINVAL;
453 } 453 }
454#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)) 454#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0))
455 sfd.freq_cnt = opp_get_opp_count(dev); 455 sfd.freq_cnt = opp_get_opp_count(dev);
456#else 456#else
@@ -459,9 +459,7 @@ int sgxfreq_init(struct device *dev)
459#endif 459#endif
460 if (sfd.freq_cnt < 1) { 460 if (sfd.freq_cnt < 1) {
461 pr_err("sgxfreq: failed to get operating frequencies\n"); 461 pr_err("sgxfreq: failed to get operating frequencies\n");
462#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
463 rcu_read_unlock(); 462 rcu_read_unlock();
464#endif
465 return -ENODEV; 463 return -ENODEV;
466 } 464 }
467 465
@@ -487,9 +485,7 @@ int sgxfreq_init(struct device *dev)
487#endif 485#endif
488 sfd.freq_list = kmalloc(sfd.freq_cnt * sizeof(unsigned long), GFP_ATOMIC); 486 sfd.freq_list = kmalloc(sfd.freq_cnt * sizeof(unsigned long), GFP_ATOMIC);
489 if (!sfd.freq_list) { 487 if (!sfd.freq_list) {
490#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
491 rcu_read_unlock(); 488 rcu_read_unlock();
492#endif
493 return -ENOMEM; 489 return -ENOMEM;
494 } 490 }
495 491
@@ -504,18 +500,14 @@ int sgxfreq_init(struct device *dev)
504 opp = dev_pm_opp_find_freq_ceil(dev, &freq); 500 opp = dev_pm_opp_find_freq_ceil(dev, &freq);
505#endif 501#endif
506 if (IS_ERR_OR_NULL(opp)) { 502 if (IS_ERR_OR_NULL(opp)) {
507#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
508 rcu_read_unlock(); 503 rcu_read_unlock();
509#endif
510 kfree(sfd.freq_list); 504 kfree(sfd.freq_list);
511 return -ENODEV; 505 return -ENODEV;
512 } 506 }
513 sfd.freq_list[i] = freq; 507 sfd.freq_list[i] = freq;
514 freq++; 508 freq++;
515 } 509 }
516#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
517 rcu_read_unlock(); 510 rcu_read_unlock();
518#endif
519 511
520#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) 512#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
521 sfd.core_clk = devm_clk_get(dev, "dpll_core_h14x2_ck"); 513 sfd.core_clk = devm_clk_get(dev, "dpll_core_h14x2_ck");
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap/sysconfig.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap/sysconfig.h
index faff7df..cd60ced 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap/sysconfig.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/system/omap/sysconfig.h
@@ -90,6 +90,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
90#define DEVICE_DISP_INTERRUPT (1<<2) 90#define DEVICE_DISP_INTERRUPT (1<<2)
91 91
92#if defined(__linux__) 92#if defined(__linux__)
93#if defined(PVR_LDM_DEVICE_TREE)
94#define SYS_SGX_DEV_NAME "ti,dra7-sgx544"
95#else
93/* 96/*
94 * Recent OMAP4 kernels register SGX as platform device "omap_gpu". 97 * Recent OMAP4 kernels register SGX as platform device "omap_gpu".
95 * This device must be used with the Linux power management calls 98 * This device must be used with the Linux power management calls
@@ -100,6 +103,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
100#else 103#else
101#define SYS_SGX_DEV_NAME "omap_gpu" 104#define SYS_SGX_DEV_NAME "omap_gpu"
102#endif /* defined(PVR_LDM_PLATFORM_PRE_REGISTERED_DEV) */ 105#endif /* defined(PVR_LDM_PLATFORM_PRE_REGISTERED_DEV) */
106#endif /* defined(PVR_LDM_DEVICE_TREE) */
103#endif /* defined(__linux__) */ 107#endif /* defined(__linux__) */
104 108
105/***************************************************************************** 109/*****************************************************************************
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap/syslocal.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap/syslocal.h
index ba312d6..bddbf6f 100644
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap/syslocal.h
+++ b/jacinto6/sgx_src/eurasia_km/services4/system/omap/syslocal.h
@@ -84,7 +84,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84#endif 84#endif
85 85
86#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) 86#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
87#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) 87#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,13))
88#include <plat/gpu.h> 88#include <plat/gpu.h>
89#endif 89#endif
90#if !defined(PVR_NO_OMAP_TIMER) 90#if !defined(PVR_NO_OMAP_TIMER)
@@ -93,10 +93,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
93#endif 93#endif
94#endif 94#endif
95 95
96#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
97#include <linux/wakelock.h>
98#endif
99
100#if !defined(PVR_NO_OMAP_TIMER) 96#if !defined(PVR_NO_OMAP_TIMER)
101#define PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA 97#define PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA
102#endif 98#endif
@@ -193,9 +189,6 @@ typedef struct _SYS_SPECIFIC_DATA_TAG_
193#if defined(PVR_OMAP_USE_DM_TIMER_API) 189#if defined(PVR_OMAP_USE_DM_TIMER_API)
194 struct omap_dm_timer *psGPTimer; 190 struct omap_dm_timer *psGPTimer;
195#endif 191#endif
196#if defined(CONFIG_HAS_WAKELOCK)
197 struct wake_lock wake_lock;
198#endif /* CONFIG_HAS_WAKELOCK */
199#endif /* defined(__linux__) */ 192#endif /* defined(__linux__) */
200} SYS_SPECIFIC_DATA; 193} SYS_SPECIFIC_DATA;
201 194
diff --git a/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.c b/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.c
index 848367a..8450046 100644
--- a/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.c
+++ b/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.c
@@ -864,7 +864,7 @@ static void Write(PDBG_STREAM psStream,IMG_PUINT8 pui8Data,IMG_UINT32 ui32InBuff
864 @param bNewLine - line wrapping 864 @param bNewLine - line wrapping
865 @return none 865 @return none
866*****************************************************************************/ 866*****************************************************************************/
867void MonoOut(IMG_CHAR * pszString,IMG_BOOL bNewLine) 867void MonoOut(const IMG_CHAR * pszString,IMG_BOOL bNewLine)
868{ 868{
869#if defined (_WIN64) 869#if defined (_WIN64)
870 PVR_UNREFERENCED_PARAMETER(pszString); 870 PVR_UNREFERENCED_PARAMETER(pszString);
@@ -1054,7 +1054,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName,
1054 PDBG_STREAM_CONTROL psCtrl; 1054 PDBG_STREAM_CONTROL psCtrl;
1055 IMG_UINT32 ui32Off; 1055 IMG_UINT32 ui32Off;
1056 IMG_VOID * pvBase; 1056 IMG_VOID * pvBase;
1057 static IMG_CHAR pszNameInitSuffix[] = "_Init"; 1057 static const IMG_CHAR pszNameInitSuffix[] = "_Init";
1058 IMG_UINT32 ui32OffSuffix; 1058 IMG_UINT32 ui32OffSuffix;
1059 1059
1060 /* 1060 /*
@@ -1072,18 +1072,31 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName,
1072 Allocate memory for control structures 1072 Allocate memory for control structures
1073 */ 1073 */
1074 psStream = HostNonPageablePageAlloc(1); 1074 psStream = HostNonPageablePageAlloc(1);
1075 if (!psStream)
1076 {
1077 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc Stream\n\r"));
1078 goto exit_stream_alloc_failed;
1079 }
1080
1075 psInitStream = HostNonPageablePageAlloc(1); 1081 psInitStream = HostNonPageablePageAlloc(1);
1082 if (!psInitStream)
1083 {
1084 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc InitStream\n\r"));
1085 goto exit_stream_init_alloc_failed;
1086 }
1087
1076 psLFBuffer = HostNonPageablePageAlloc(1); 1088 psLFBuffer = HostNonPageablePageAlloc(1);
1089 if (!psLFBuffer)
1090 {
1091 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc LFBuffer\n\r"));
1092 goto exit_lfbuffer_alloc_failed;
1093 }
1094
1077 psCtrl = HostNonPageablePageAlloc(1); 1095 psCtrl = HostNonPageablePageAlloc(1);
1078 if ( 1096 if (!psCtrl)
1079 (!psStream) ||
1080 (!psInitStream) ||
1081 (!psLFBuffer) ||
1082 (!psCtrl)
1083 )
1084 { 1097 {
1085 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc control structs\n\r")); 1098 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc Ctrl struct\n\r"));
1086 return((IMG_VOID *) 0); 1099 goto exit_ctrl_alloc_failed;
1087 } 1100 }
1088 1101
1089 /* Allocate memory for buffer */ 1102 /* Allocate memory for buffer */
@@ -1099,8 +1112,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName,
1099 if (!pvBase) 1112 if (!pvBase)
1100 { 1113 {
1101 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc Stream buffer\n\r")); 1114 PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc Stream buffer\n\r"));
1102 HostNonPageablePageFree(psStream); 1115 goto exit_stream_buffer_failed;
1103 return((IMG_VOID *) 0);
1104 } 1116 }
1105 1117
1106 /* Setup control state */ 1118 /* Setup control state */
@@ -1151,8 +1163,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName,
1151 { 1163 {
1152 HostPageablePageFree(psStream->pvBase); 1164 HostPageablePageFree(psStream->pvBase);
1153 } 1165 }
1154 HostNonPageablePageFree(psStream); 1166 goto exit_stream_buffer_failed;
1155 return((IMG_VOID *) 0);
1156 } 1167 }
1157 1168
1158 /* Initialise the stream for the init phase */ 1169 /* Initialise the stream for the init phase */
@@ -1216,6 +1227,17 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName,
1216 AddSIDEntry(psStream); 1227 AddSIDEntry(psStream);
1217 1228
1218 return((IMG_VOID *) psStream); 1229 return((IMG_VOID *) psStream);
1230
1231exit_stream_buffer_failed:
1232 HostNonPageablePageFree(psCtrl);
1233exit_ctrl_alloc_failed:
1234 HostNonPageablePageFree(psLFBuffer);
1235exit_lfbuffer_alloc_failed:
1236 HostNonPageablePageFree(psInitStream);
1237exit_stream_init_alloc_failed:
1238 HostNonPageablePageFree(psStream);
1239exit_stream_alloc_failed:
1240 return((IMG_VOID *) 0);
1219} 1241}
1220 1242
1221/*!**************************************************************************** 1243/*!****************************************************************************
@@ -1388,7 +1410,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivFindStream(IMG_CHAR * pszName, IMG_BOOL bResetStr
1388 1410
1389 if(bResetStream && psStream) 1411 if(bResetStream && psStream)
1390 { 1412 {
1391 static IMG_CHAR szComment[] = "-- Init phase terminated\r\n"; 1413 static const IMG_CHAR szComment[] = "-- Init phase terminated\r\n";
1392 psStream->psInitStream->ui32RPtr = 0; 1414 psStream->psInitStream->ui32RPtr = 0;
1393 psStream->ui32RPtr = 0; 1415 psStream->ui32RPtr = 0;
1394 psStream->ui32WPtr = 0; 1416 psStream->ui32WPtr = 0;
diff --git a/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.h b/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.h
index e56d881..8aaf6d6 100644
--- a/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.h
+++ b/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/common/dbgdriv.h
@@ -103,7 +103,7 @@ IMG_UINT32 AtoI(IMG_CHAR *szIn);
103 103
104IMG_VOID HostMemSet(IMG_VOID *pvDest,IMG_UINT8 ui8Value,IMG_UINT32 ui32Size); 104IMG_VOID HostMemSet(IMG_VOID *pvDest,IMG_UINT8 ui8Value,IMG_UINT32 ui32Size);
105IMG_VOID HostMemCopy(IMG_VOID *pvDest,IMG_VOID *pvSrc,IMG_UINT32 ui32Size); 105IMG_VOID HostMemCopy(IMG_VOID *pvDest,IMG_VOID *pvSrc,IMG_UINT32 ui32Size);
106IMG_VOID MonoOut(IMG_CHAR * pszString,IMG_BOOL bNewLine); 106IMG_VOID MonoOut(const IMG_CHAR * pszString,IMG_BOOL bNewLine);
107 107
108/***************************************************************************** 108/*****************************************************************************
109 Secure handle Function prototypes 109 Secure handle Function prototypes
diff --git a/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/linux/main.c b/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/linux/main.c
index b35cac4..2cf310c 100644
--- a/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/linux/main.c
+++ b/jacinto6/sgx_src/eurasia_km/tools/intern/debug/dbgdriv/linux/main.c
@@ -277,6 +277,7 @@ long dbgdrv_ioctl(struct file *file, unsigned int ioctlCmd, unsigned long arg)
277 psStream = SID2PStream(psReadInParams->hStream); 277 psStream = SID2PStream(psReadInParams->hStream);
278 if(!psStream) 278 if(!psStream)
279 { 279 {
280 vfree(ui8Tmp);
280 goto init_failed; 281 goto init_failed;
281 } 282 }
282 283