aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunita Nadampalli2016-08-29 15:42:00 -0500
committerSunita Nadampalli2016-08-29 15:46:27 -0500
commit281e466ff5b0344f538ec4e76076290e60774516 (patch)
tree16e36090faf125a253bdf7491dac2606cddb251b
parentf83e785d2b98404fed9e3a6264bf4945c65abd12 (diff)
downloadrepo-libdce-281e466ff5b0344f538ec4e76076290e60774516.tar.gz
repo-libdce-281e466ff5b0344f538ec4e76076290e60774516.tar.xz
repo-libdce-281e466ff5b0344f538ec4e76076290e60774516.zip
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.c9
-rw-r--r--memplugin_android.c17
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 @@
44 44
45extern MmRpc_Handle MmRpcHandle[]; 45extern MmRpc_Handle MmRpcHandle[];
46extern pthread_mutex_t ipc_mutex; 46extern pthread_mutex_t ipc_mutex;
47int is_ipc_ready = 0;
47 48
48int dce_buf_lock(int num, size_t *handle) 49int dce_buf_lock(int num, size_t *handle)
49{ 50{
@@ -53,6 +54,14 @@ int dce_buf_lock(int num, size_t *handle)
53 54
54 pthread_mutex_lock(&ipc_mutex); 55 pthread_mutex_lock(&ipc_mutex);
55 56
57 if (!is_ipc_ready) {
58 if (dce_ipc_init(IPU) != MEM_EOK) {
59 pthread_mutex_unlock(&ipc_mutex);
60 return DCE_EIPC_CALL_FAIL;
61 }
62 is_ipc_ready = 0x1234;
63 }
64
56 _ASSERT(num > 0, DCE_EINVALID_INPUT); 65 _ASSERT(num > 0, DCE_EINVALID_INPUT);
57 66
58 desc = malloc(num * sizeof(MmRpc_BufDesc)); 67 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 @@
51int OmapDrm_FD = INVALID_DRM_FD; 51int OmapDrm_FD = INVALID_DRM_FD;
52struct omap_device *OmapDev = NULL; 52struct omap_device *OmapDev = NULL;
53extern pthread_mutex_t ipc_mutex; 53extern pthread_mutex_t ipc_mutex;
54extern int is_ipc_ready;
54 55
55int memplugin_open() 56int memplugin_open()
56{ 57{
@@ -75,14 +76,6 @@ int memplugin_open()
75 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 76 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
76 pthread_mutex_init(&ipc_mutex, &attr); 77 pthread_mutex_init(&ipc_mutex, &attr);
77 78
78 if (dce_ipc_init(IPU) != MEM_EOK) {
79 omap_device_del(OmapDev);
80 OmapDev = NULL;
81 close(OmapDrm_FD);
82 OmapDrm_FD = INVALID_DRM_FD;
83 return MEM_EOPEN_FAILURE;
84 }
85
86 return MEM_EOK; 79 return MEM_EOK;
87} 80}
88 81
@@ -99,7 +92,15 @@ int memplugin_close()
99 * this channel is used only for GEM buffer register/unregister, 92 * this channel is used only for GEM buffer register/unregister,
100 * hence call deinit with -1 for the engine table index 93 * hence call deinit with -1 for the engine table index
101 */ 94 */
95
96 /*Acquire permission to use IPC*/
97 pthread_mutex_lock(&ipc_mutex);
98
102 dce_ipc_deinit(IPU, -1); 99 dce_ipc_deinit(IPU, -1);
100 is_ipc_ready = 0;
101
102 /*Relinquish IPC*/
103 pthread_mutex_unlock(&ipc_mutex);
103 104
104 return MEM_EOK; 105 return MEM_EOK;
105} 106}