summaryrefslogtreecommitdiffstats
path: root/driver/rsdRuntimeStubs.cpp
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-01-29 17:06:49 -0800
committerPirama Arumuga Nainar <pirama@google.com>2015-01-29 18:00:56 -0800
commit7153e1c8232882ee2bd7b975791a21e1ed9732fd (patch)
tree6e004060cb0cdca18e553f597fa091a9f520b434 /driver/rsdRuntimeStubs.cpp
parent104c694d67a224adda7b673de04b763bc63d6c3f (diff)
downloadandroid_frameworks_rs-7153e1c8232882ee2bd7b975791a21e1ed9732fd.tar.gz
android_frameworks_rs-7153e1c8232882ee2bd7b975791a21e1ed9732fd.tar.bz2
android_frameworks_rs-7153e1c8232882ee2bd7b975791a21e1ed9732fd.zip
Fail if non-threadable calls are in a kernel
bug 19095896 Calling rsAllocationIoSend, rsAllocationIoReceive, rsAllocationCopy1DRange or rsAllocationCopy2DRange in a kernel is bad. For one, they are not threadsafe. Calls to these functions in an invokable are common, so we do not want to summarily mark scripts as not threadable if these functions are called. Instead, this patch to the driver detects if these functions are called inside a kernel and if so, sends a fatal error message. Change-Id: I10d3ef06cb8ed19a6bde686e71092d14ea58f5ec
Diffstat (limited to 'driver/rsdRuntimeStubs.cpp')
-rw-r--r--driver/rsdRuntimeStubs.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index b7e676e9..1bfbf9f1 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -157,6 +157,24 @@ static inline RS_TY_ALLOC rsTyCast(::rs_allocation *a) {
#endif
+// Some RS functions are not threadsafe but can be called from an invoke
+// function. Instead of summarily marking scripts that call these functions as
+// not-threadable we detect calls to them in the driver and sends a fatal error
+// message.
+static bool failIfInKernel(Context *rsc, const char *funcName) {
+ RsdHal *dc = (RsdHal *)rsc->mHal.drv;
+ RsdCpuReference *impl = (RsdCpuReference *) dc->mCpuRef;
+
+ if (impl->getInForEach()) {
+ char buf[256];
+ sprintf(buf, "Error: Call to unsupported function %s "
+ "in kernel", funcName);
+ rsc->setError(RS_ERROR_FATAL_DRIVER, buf);
+ return true;
+ }
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////////
// Allocation
//////////////////////////////////////////////////////////////////////////////
@@ -181,6 +199,9 @@ static void SC_AllocationCopy1DRange(RS_TY_ALLOC dstAlloc,
RS_TY_ALLOC srcAlloc,
uint32_t srcOff, uint32_t srcMip) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationCopy1DRange"))
+ return;
+
rsrAllocationCopy1DRange(rsc, rsGetObjPtr(dstAlloc), dstOff, dstMip, count,
rsGetObjPtr(srcAlloc), srcOff, srcMip);
}
@@ -193,6 +214,9 @@ static void SC_AllocationCopy2DRange(RS_TY_ALLOC dstAlloc,
uint32_t srcXoff, uint32_t srcYoff,
uint32_t srcMip, uint32_t srcFace) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationCopy2DRange"))
+ return;
+
rsrAllocationCopy2DRange(rsc, rsGetObjPtr(dstAlloc),
dstXoff, dstYoff, dstMip, dstFace,
width, height, rsGetObjPtr(srcAlloc),
@@ -201,12 +225,18 @@ static void SC_AllocationCopy2DRange(RS_TY_ALLOC dstAlloc,
static void SC_AllocationIoSend(RS_TY_ALLOC alloc) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationIoSend"))
+ return;
+
rsrAllocationIoSend(rsc, rsGetObjPtr(alloc));
}
static void SC_AllocationIoReceive(RS_TY_ALLOC alloc) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationIoReceive"))
+ return;
+
rsrAllocationIoReceive(rsc, rsGetObjPtr(alloc));
}
@@ -219,6 +249,9 @@ static void SC_AllocationCopy1DRange(RS_TY_ALLOC dstAlloc,
RS_TY_ALLOC srcAlloc,
uint32_t srcOff, uint32_t srcMip) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationCopy1DRange"))
+ return;
+
rsrAllocationCopy1DRange(rsc, rsGetObjPtr(dstAlloc), dstOff, dstMip, count,
rsGetObjPtr(srcAlloc), srcOff, srcMip);
}
@@ -231,6 +264,9 @@ static void SC_AllocationCopy2DRange(RS_TY_ALLOC dstAlloc,
uint32_t srcXoff, uint32_t srcYoff,
uint32_t srcMip, uint32_t srcFace) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationCopy2DRange"))
+ return;
+
rsrAllocationCopy2DRange(rsc, rsGetObjPtr(dstAlloc),
dstXoff, dstYoff, dstMip, dstFace,
width, height,
@@ -240,12 +276,18 @@ static void SC_AllocationCopy2DRange(RS_TY_ALLOC dstAlloc,
static void SC_AllocationIoSend(RS_TY_ALLOC alloc) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationIoSend"))
+ return;
+
rsrAllocationIoSend(rsc, rsGetObjPtr(alloc));
}
static void SC_AllocationIoReceive(RS_TY_ALLOC alloc) {
Context *rsc = RsdCpuReference::getTlsContext();
+ if (failIfInKernel(rsc, "rsAllocationIoReceive"))
+ return;
+
rsrAllocationIoReceive(rsc, rsGetObjPtr(alloc));
}