summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuden <luden@ghostmail.com>2016-04-24 16:27:18 +0200
committerMichael Gernoth <michael@gernoth.net>2016-05-01 07:05:00 -0700
commit10f354f46d8bd442fadb97be4ccc49ba87898f02 (patch)
tree6099766c5979b3ed6025f3458c718b64e2f758f6
parentc0ab422014daa616c39215703da43209f5ef55c3 (diff)
downloadhardware_ti_omap4-10f354f46d8bd442fadb97be4ccc49ba87898f02.zip
hardware_ti_omap4-10f354f46d8bd442fadb97be4ccc49ba87898f02.tar.gz
hardware_ti_omap4-10f354f46d8bd442fadb97be4ccc49ba87898f02.tar.bz2
domx: connection robustness improvements
CMA-enabled kernel for tuna devices will unload Ducati firmware when it's not in use to free extra memory for applications. On the first access to /dev/rpmsg-omx1 it will reload the firmware. However, in the process of this reloading device drivers will be reset, therefore causing errors when either opening the device or performing the first operation on it. Moreover, the previously opened handle will be invalidated in this case. Therefore, the connection loop is modified to retry both open() and first ioctl()calls instead of just open() and to reopen the device on retries. Also, because the reload can happen relatively fast when there are not too many pages to migrate, we use smaller waiting period but increased number of retries to improve camera start latency. Change-Id: I4b919f457c0e3bc43f99381c405e364b3326f583
-rwxr-xr-xdomx/domx/omx_rpc/src/omx_rpc.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/domx/domx/omx_rpc/src/omx_rpc.c b/domx/domx/omx_rpc/src/omx_rpc.c
index e78d92b..3a6c33c 100755
--- a/domx/domx/omx_rpc/src/omx_rpc.c
+++ b/domx/domx/omx_rpc/src/omx_rpc.c
@@ -72,7 +72,7 @@
#define RPC_MSGPIPE_SIZE (4)
#define RPC_MSG_SIZE_FOR_PIPE (sizeof(OMX_PTR))
-#define MAX_ATTEMPTS 15
+#define MAX_ATTEMPTS 60
#define RPC_getPacket(nPacketSize, pPacket) do { \
pPacket = TIMM_OSAL_Malloc(nPacketSize, TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); \
@@ -124,16 +124,29 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName,
"Malloc failed");
TIMM_OSAL_Memset(pRPCCtx, 0, sizeof(RPC_OMX_CONTEXT));
- /*Assuming that open maintains an internal count for multi instance */
- DOMX_DEBUG("Calling open on the device");
+ DOMX_DEBUG("Calling open and OMX_IOCCONNECT ioctl on the device");
while (1)
{
pRPCCtx->fd_omx = open("/dev/rpmsg-omx1", O_RDWR);
- if(pRPCCtx->fd_omx >= 0 || errno != ENOENT || nAttempts == MAX_ATTEMPTS)
- break;
- DOMX_DEBUG("errno from open= %d, REATTEMPTING OPEN!!!!",errno);
+ if(pRPCCtx->fd_omx >= 0)
+ {
+ status = ioctl(pRPCCtx->fd_omx, OMX_IOCCONNECT, &sReq);
+ if (status >= 0)
+ break;
+ if (errno != ENXIO || nAttempts == MAX_ATTEMPTS)
+ break;
+ DOMX_DEBUG("errno from ioctl = %d, retrying...",errno);
+ close(pRPCCtx->fd_omx);
+ }
+ else
+ {
+ if ((errno != ENOENT && errno != ENXIO) || nAttempts == MAX_ATTEMPTS)
+ break;
+ DOMX_DEBUG("errno from open= %d, retrying...",errno);
+ }
+
nAttempts++;
- usleep(1000000);
+ usleep(250000);
}
if(pRPCCtx->fd_omx < 0)
{
@@ -141,15 +154,15 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName,
eError = RPC_OMX_ErrorInsufficientResources;
goto EXIT;
}
- DOMX_DEBUG("Open was successful, pRPCCtx->fd_omx = %d",
- pRPCCtx->fd_omx);
-//AD
-// strncpy(sReq.name, cComponentName, OMX_MAX_STRINGNAME_SIZE);
-
- DOMX_DEBUG("Calling ioctl");
- status = ioctl(pRPCCtx->fd_omx, OMX_IOCCONNECT, &sReq);
- RPC_assert(status >= 0, RPC_OMX_ErrorInsufficientResources,
- "Can't connect");
+ if(status < 0)
+ {
+ DOMX_ERROR("Can't ioctl device, errorno from ioctl = %d",errno);
+ eError = RPC_OMX_ErrorInsufficientResources;
+ close(pRPCCtx->fd_omx);
+ goto EXIT;
+ }
+ DOMX_DEBUG("Open and OMX_IOCCONNECT were successful, pRPCCtx->fd_omx = %d, ioctl status = %d",
+ pRPCCtx->fd_omx, status);
for (i = 0; i < RPC_OMX_MAX_FUNCTION_LIST; i++)
{