diff options
author | Sunita Nadampalli <sunitan@ti.com> | 2016-08-29 15:42:00 -0500 |
---|---|---|
committer | Sunita Nadampalli <sunitan@ti.com> | 2016-08-29 15:46:27 -0500 |
commit | 281e466ff5b0344f538ec4e76076290e60774516 (patch) | |
tree | 16e36090faf125a253bdf7491dac2606cddb251b | |
parent | f83e785d2b98404fed9e3a6264bf4945c65abd12 (diff) | |
download | dce-281e466ff5b0344f538ec4e76076290e60774516.tar.gz |
libdce[Android]: Defer rpmsg_dce device open till buffer lock phase
In the current architecture, rpmsg_dce device is opened
during memplugin_open(), which can be called from any process
context. With Android system configured in SE Linux Enforcement
mode, it is not allowed to open rpmsg_dce in any process other than
mediaserver. Hence the device open logic is deferred till
dce buffer lock API where the actual device ioctls are needed.
Change-Id: Iedacfd3327e0ee975a8a492b057aac576d7f7c10
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rw-r--r-- | libdce_android.c | 9 | ||||
-rw-r--r-- | memplugin_android.c | 17 |
2 files changed, 18 insertions, 8 deletions
diff --git a/libdce_android.c b/libdce_android.c index 9480926..de6a5c8 100644 --- a/libdce_android.c +++ b/libdce_android.c @@ -44,6 +44,7 @@ extern MmRpc_Handle MmRpcHandle[]; extern pthread_mutex_t ipc_mutex; +int is_ipc_ready = 0; int dce_buf_lock(int num, size_t *handle) { @@ -53,6 +54,14 @@ int dce_buf_lock(int num, size_t *handle) pthread_mutex_lock(&ipc_mutex); + if (!is_ipc_ready) { + if (dce_ipc_init(IPU) != MEM_EOK) { + pthread_mutex_unlock(&ipc_mutex); + return DCE_EIPC_CALL_FAIL; + } + is_ipc_ready = 0x1234; + } + _ASSERT(num > 0, DCE_EINVALID_INPUT); desc = malloc(num * sizeof(MmRpc_BufDesc)); diff --git a/memplugin_android.c b/memplugin_android.c index 7235de2..97ea44a 100644 --- a/memplugin_android.c +++ b/memplugin_android.c @@ -51,6 +51,7 @@ int OmapDrm_FD = INVALID_DRM_FD; struct omap_device *OmapDev = NULL; extern pthread_mutex_t ipc_mutex; +extern int is_ipc_ready; int memplugin_open() { @@ -75,14 +76,6 @@ int memplugin_open() pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&ipc_mutex, &attr); - if (dce_ipc_init(IPU) != MEM_EOK) { - omap_device_del(OmapDev); - OmapDev = NULL; - close(OmapDrm_FD); - OmapDrm_FD = INVALID_DRM_FD; - return MEM_EOPEN_FAILURE; - } - return MEM_EOK; } @@ -99,7 +92,15 @@ int memplugin_close() * this channel is used only for GEM buffer register/unregister, * hence call deinit with -1 for the engine table index */ + + /*Acquire permission to use IPC*/ + pthread_mutex_lock(&ipc_mutex); + dce_ipc_deinit(IPU, -1); + is_ipc_ready = 0; + + /*Relinquish IPC*/ + pthread_mutex_unlock(&ipc_mutex); return MEM_EOK; } |