aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunita Nadampalli2015-01-30 10:17:17 -0600
committerSunita Nadampalli2015-01-30 10:17:17 -0600
commit74ce64ad788921b1db9d9ebee0562db57caa95e7 (patch)
tree90bf1d24cce31b071e7d3c6e8e19302dd0d1617c
parente7cf246bec2118890021e1aeb66757f5ad894923 (diff)
downloadrepo-libdce-74ce64ad788921b1db9d9ebee0562db57caa95e7.tar.gz
repo-libdce-74ce64ad788921b1db9d9ebee0562db57caa95e7.tar.xz
repo-libdce-74ce64ad788921b1db9d9ebee0562db57caa95e7.zip
libdce: Add mutex protection for dce_buf_lock/dce_buf_unlock
The dce_buf_lock and dce_buf_unlock are meant for any video buffer locking and unlocking with the GEM allocator. Currently, these methods are being called from libdce apis with ipc mutex held. In order to enable other media components to make use of these buffer lock/unlock apis, explicit ipc mutex protection is added. Change-Id: I6d63a4cdcffec62a346341ff515a7ebb03dea8c0 Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rw-r--r--libdce.c2
-rw-r--r--libdce_android.c11
-rw-r--r--memplugin_android.c7
3 files changed, 18 insertions, 2 deletions
diff --git a/libdce.c b/libdce.c
index 6b664bd..881516e 100644
--- a/libdce.c
+++ b/libdce.c
@@ -50,7 +50,7 @@
50/* Handle used for Remote Communication */ 50/* Handle used for Remote Communication */
51MmRpc_Handle MmRpcHandle[MAX_REMOTEDEVICES] = { NULL}; 51MmRpc_Handle MmRpcHandle[MAX_REMOTEDEVICES] = { NULL};
52Engine_Handle gEngineHandle[MAX_INSTANCES][MAX_REMOTEDEVICES] = { {NULL, NULL}}; 52Engine_Handle gEngineHandle[MAX_INSTANCES][MAX_REMOTEDEVICES] = { {NULL, NULL}};
53static pthread_mutex_t ipc_mutex = PTHREAD_MUTEX_INITIALIZER; 53pthread_mutex_t ipc_mutex = PTHREAD_MUTEX_INITIALIZER;
54static int __ClientCount[MAX_REMOTEDEVICES] = {0}; 54static int __ClientCount[MAX_REMOTEDEVICES] = {0};
55int dce_debug = DCE_DEBUG_LEVEL; 55int dce_debug = DCE_DEBUG_LEVEL;
56const String DCE_DEVICE_NAME[MAX_REMOTEDEVICES]= {"rpmsg-dce","rpmsg-dce-dsp"}; 56const String DCE_DEVICE_NAME[MAX_REMOTEDEVICES]= {"rpmsg-dce","rpmsg-dce-dsp"};
diff --git a/libdce_android.c b/libdce_android.c
index 300c311..9480926 100644
--- a/libdce_android.c
+++ b/libdce_android.c
@@ -33,6 +33,7 @@
33#include <stdlib.h> 33#include <stdlib.h>
34#include <string.h> 34#include <string.h>
35#include <stdio.h> 35#include <stdio.h>
36#include <pthread.h>
36 37
37#include <ti/ipc/mm/MmRpc.h> 38#include <ti/ipc/mm/MmRpc.h>
38#include "dce_priv.h" 39#include "dce_priv.h"
@@ -42,6 +43,7 @@
42 43
43 44
44extern MmRpc_Handle MmRpcHandle[]; 45extern MmRpc_Handle MmRpcHandle[];
46extern pthread_mutex_t ipc_mutex;
45 47
46int dce_buf_lock(int num, size_t *handle) 48int dce_buf_lock(int num, size_t *handle)
47{ 49{
@@ -49,6 +51,8 @@ int dce_buf_lock(int num, size_t *handle)
49 MmRpc_BufDesc *desc = NULL; 51 MmRpc_BufDesc *desc = NULL;
50 dce_error_status eError = DCE_EOK; 52 dce_error_status eError = DCE_EOK;
51 53
54 pthread_mutex_lock(&ipc_mutex);
55
52 _ASSERT(num > 0, DCE_EINVALID_INPUT); 56 _ASSERT(num > 0, DCE_EINVALID_INPUT);
53 57
54 desc = malloc(num * sizeof(MmRpc_BufDesc)); 58 desc = malloc(num * sizeof(MmRpc_BufDesc));
@@ -65,6 +69,8 @@ EXIT:
65 if( desc ) { 69 if( desc ) {
66 free(desc); 70 free(desc);
67 } 71 }
72 pthread_mutex_unlock(&ipc_mutex);
73
68 return (eError); 74 return (eError);
69} 75}
70 76
@@ -74,6 +80,8 @@ int dce_buf_unlock(int num, size_t *handle)
74 MmRpc_BufDesc *desc = NULL; 80 MmRpc_BufDesc *desc = NULL;
75 dce_error_status eError = DCE_EOK; 81 dce_error_status eError = DCE_EOK;
76 82
83 pthread_mutex_lock(&ipc_mutex);
84
77 _ASSERT(num > 0, DCE_EINVALID_INPUT); 85 _ASSERT(num > 0, DCE_EINVALID_INPUT);
78 86
79 desc = malloc(num * sizeof(MmRpc_BufDesc)); 87 desc = malloc(num * sizeof(MmRpc_BufDesc));
@@ -90,6 +98,9 @@ EXIT:
90 if( desc ) { 98 if( desc ) {
91 free(desc); 99 free(desc);
92 } 100 }
101
102 pthread_mutex_unlock(&ipc_mutex);
103
93 return (eError); 104 return (eError);
94} 105}
95 106
diff --git a/memplugin_android.c b/memplugin_android.c
index d2f5b35..307dc9e 100644
--- a/memplugin_android.c
+++ b/memplugin_android.c
@@ -34,7 +34,7 @@
34#include <sys/ioctl.h> 34#include <sys/ioctl.h>
35#include <sys/mman.h> 35#include <sys/mman.h>
36#include <sys/eventfd.h> 36#include <sys/eventfd.h>
37#include <fcntl.h> 37#include <pthread.h>
38 38
39#include "memplugin.h" 39#include "memplugin.h"
40#include "libdce.h" 40#include "libdce.h"
@@ -50,6 +50,7 @@
50 50
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;
53 54
54int memplugin_open() 55int memplugin_open()
55{ 56{
@@ -70,6 +71,10 @@ int memplugin_open()
70 return MEM_EOPEN_FAILURE; 71 return MEM_EOPEN_FAILURE;
71 } 72 }
72 73
74 pthread_mutexattr_t attr;
75 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
76 pthread_mutex_init(&ipc_mutex, &attr);
77
73 if (dce_ipc_init(IPU) != MEM_EOK) { 78 if (dce_ipc_init(IPU) != MEM_EOK) {
74 omap_device_del(OmapDev); 79 omap_device_del(OmapDev);
75 OmapDev = NULL; 80 OmapDev = NULL;