Remove DSP2 from invalid list and improve error handling for non-existing core
authorvwan@ti.com <vwan@ti.com>
Fri, 20 Mar 2015 18:47:12 +0000 (11:47 -0700)
committerRobert Tivy <rtivy@ti.com>
Wed, 25 Mar 2015 23:41:41 +0000 (16:41 -0700)
This commit removes DSP2 from the invalid processor list, and improves
error handling in case the IPC driver is asked to load DSP2
when it does not exist (e.g. on J6 Eco)

Signed-off-by: VW <vwan@ti.com>
qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_main.c

index 8edddf7cd6b060d2b9411c618185c2a6c00dc181..3f24b246ac6f44484ce2f83058a955db41f1ed47 100644 (file)
@@ -97,13 +97,8 @@ static char * logFilename = NULL;
 static int numAttach = 0;
 
 #if defined(IPC_PLATFORM_VAYU)
 static int numAttach = 0;
 
 #if defined(IPC_PLATFORM_VAYU)
-/* DSP2 is invalid on Vayu */
-#define INVALID_PROC     "DSP2"
-
 static bool gatempEnabled = false;
 static Int32 sr0OwnerProcId = -1;
 static bool gatempEnabled = false;
 static Int32 sr0OwnerProcId = -1;
-#else
-#define INVALID_PROC     ""
 #endif
 
 // IPC hibernation global variables
 #endif
 
 // IPC hibernation global variables
@@ -335,11 +330,6 @@ static int slave_state_read(resmgr_context_t *ctp, io_read_t *msg,
         return (ENOSYS);
     }
 
         return (ENOSYS);
     }
 
-    if (strcmp(MultiProc_getName(procId), INVALID_PROC) == 0) {
-        fprintf(stderr, "Unsupported core\n");
-        return (EPERM);
-    }
-
     pthread_mutex_lock(&dev->firmwareLock);
 
     for (i = 0; i < ipc_num_cores; i++) {
     pthread_mutex_lock(&dev->firmwareLock);
 
     for (i = 0; i < ipc_num_cores; i++) {
@@ -421,11 +411,6 @@ static int slave_state_write(resmgr_context_t *ctp, io_write_t *msg,
         return (ENOSYS);
     }
 
         return (ENOSYS);
     }
 
-    if (strcmp(MultiProc_getName(procId), INVALID_PROC) == 0) {
-        fprintf(stderr, "Unsupported core\n");
-        return (EPERM);
-    }
-
     /* set up the number of bytes (returned by client's write()) */
     _IO_SET_WRITE_NBYTES (ctp, msg->i.nbytes);
 
     /* set up the number of bytes (returned by client's write()) */
     _IO_SET_WRITE_NBYTES (ctp, msg->i.nbytes);
 
@@ -462,7 +447,14 @@ static int slave_state_write(resmgr_context_t *ctp, io_write_t *msg,
     if (strcmp("1", buf) == 0) {
         if ((ipc_firmware[i].procState == RESET_STATE) &&
            (ipc_firmware[i].firmware != NULL)) {
     if (strcmp("1", buf) == 0) {
         if ((ipc_firmware[i].procState == RESET_STATE) &&
            (ipc_firmware[i].firmware != NULL)) {
-            runSlave(ocb->ocb.attr->dev, procId, &ipc_firmware[i]);
+            status = runSlave(ocb->ocb.attr->dev, procId, &ipc_firmware[i]);
+            if (status < 0) {
+                pthread_mutex_unlock(&dev->firmwareLock);
+                free(buf);
+                fprintf(stderr, "IPC: failed to run slave core %s\n",
+                    MultiProc_getName(procId));
+                return (EIO);
+            }
 #if defined(IPC_PLATFORM_VAYU)
             if (gatempEnabled) {
                 if (sr0OwnerProcId == -1) {
 #if defined(IPC_PLATFORM_VAYU)
             if (gatempEnabled) {
                 if (sr0OwnerProcId == -1) {
@@ -472,6 +464,7 @@ static int slave_state_write(resmgr_context_t *ctp, io_write_t *msg,
                         resetSlave(ocb->ocb.attr->dev, procId);
                         pthread_mutex_unlock(&dev->firmwareLock);
                         free(buf);
                         resetSlave(ocb->ocb.attr->dev, procId);
                         pthread_mutex_unlock(&dev->firmwareLock);
                         free(buf);
+                        fprintf(stderr, "GateMP_setup failed\n");
                         return (EIO);
                     }
                     else if (status == 0) {
                         return (EIO);
                     }
                     else if (status == 0) {
@@ -493,8 +486,17 @@ static int slave_state_write(resmgr_context_t *ctp, io_write_t *msg,
             ipc_firmware[i].reload = true;
             status = init_ipc_trace_device(dev);
             if (status < 0) {
             ipc_firmware[i].reload = true;
             status = init_ipc_trace_device(dev);
             if (status < 0) {
+#if defined(IPC_PLATFORM_VAYU)
+                if ((gatempEnabled) && (procId == sr0OwnerProcId)) {
+                    sr0OwnerProcId = -1;
+                    GateMP_destroy(FALSE);
+                }
+#endif
+                resetSlave(ocb->ocb.attr->dev, procId);
                 pthread_mutex_unlock(&dev->firmwareLock);
                 free(buf);
                 pthread_mutex_unlock(&dev->firmwareLock);
                 free(buf);
+                fprintf(stderr, "IPC: init_ipc_trace_device failed %d\n",
+                    status);
                 return (EIO);
             }
             printf("Core %s has been started.\n", MultiProc_getName(procId));
                 return (EIO);
             }
             printf("Core %s has been started.\n", MultiProc_getName(procId));
@@ -515,14 +517,21 @@ static int slave_state_write(resmgr_context_t *ctp, io_write_t *msg,
                 }
             }
 #endif
                 }
             }
 #endif
-            resetSlave(ocb->ocb.attr->dev, procId);
+            status = resetSlave(ocb->ocb.attr->dev, procId);
+            if (status < 0) {
+                pthread_mutex_unlock(&dev->firmwareLock);
+                free(buf);
+                fprintf(stderr, "IPC: failed to reset slave core %s\n",
+                    MultiProc_getName(procId));
+                return (EIO);
+            }
             ipc_firmware[i].procState = RESET_STATE;
             ipc_firmware[i].reload = false;
             status = deinit_ipc_trace_device(dev);
             if (status < 0) {
                 pthread_mutex_unlock(&dev->firmwareLock);
                 free(buf);
             ipc_firmware[i].procState = RESET_STATE;
             ipc_firmware[i].reload = false;
             status = deinit_ipc_trace_device(dev);
             if (status < 0) {
                 pthread_mutex_unlock(&dev->firmwareLock);
                 free(buf);
-                Osal_printf("IPC: deinit_ipc_trace_device failed %d",
+                fprintf(stderr, "IPC: deinit_ipc_trace_device failed %d\n",
                     status);
                 return (EIO);
             }
                     status);
                 return (EIO);
             }
@@ -564,11 +573,6 @@ static int slave_file_read(resmgr_context_t *ctp, io_read_t *msg,
         return (ENOSYS);
     }
 
         return (ENOSYS);
     }
 
-    if (strcmp(MultiProc_getName(procId), INVALID_PROC) == 0) {
-        fprintf(stderr, "Unsupported core\n");
-        return (EPERM);
-    }
-
     pthread_mutex_lock(&dev->firmwareLock);
     for (i = 0; i < ipc_num_cores; i++) {
         if (ipc_firmware[i].proc_id == procId) {
     pthread_mutex_lock(&dev->firmwareLock);
     for (i = 0; i < ipc_num_cores; i++) {
         if (ipc_firmware[i].proc_id == procId) {
@@ -659,11 +663,6 @@ static int slave_file_write(resmgr_context_t *ctp, io_write_t *msg,
         return (ENOSYS);
     }
 
         return (ENOSYS);
     }
 
-    if (strcmp(MultiProc_getName(procId), INVALID_PROC) == 0) {
-        fprintf(stderr, "Unsupported core\n");
-        return (EPERM);
-    }
-
     /* set up the number of bytes (returned by client's write()) */
     _IO_SET_WRITE_NBYTES (ctp, msg->i.nbytes);
 
     /* set up the number of bytes (returned by client's write()) */
     _IO_SET_WRITE_NBYTES (ctp, msg->i.nbytes);
 
@@ -1349,6 +1348,8 @@ int init_ipc(ipc_dev_t * dev, ipc_firmware_info * firmware, bool recover)
                     continue;
                 }
                 else {
                     continue;
                 }
                 else {
+                    fprintf(stderr, "Failed to run core %s\n",
+                        MultiProc_getName(procId));
                     break;
                 }
             }
                     break;
                 }
             }
@@ -1643,10 +1644,6 @@ int main(int argc, char *argv[])
             printUsage(argv[0]);
             return (error);
         }
             printUsage(argv[0]);
             return (error);
         }
-        if (strcmp(argv[optind], INVALID_PROC) == 0) {
-            fprintf (stderr, "Unsupported core specified\n");
-            return (error);
-        }
 
         ipc_firmware[ipc_num_cores].proc = argv [optind];
         ipc_firmware[ipc_num_cores].attachOnly =
 
         ipc_firmware[ipc_num_cores].proc = argv [optind];
         ipc_firmware[ipc_num_cores].attachOnly =