Merge branch '3.30' into ipc-next 3.35.00.05 3.36.00.00_eng
authorRobert Tivy <rtivy@ti.com>
Fri, 27 Feb 2015 19:21:00 +0000 (11:21 -0800)
committerRobert Tivy <rtivy@ti.com>
Fri, 27 Feb 2015 19:21:00 +0000 (11:21 -0800)
android/src/api/Android.mk
linux/src/daemon/GateMP_daemon.c
packages/ti/ipc/remoteproc/rsc_table_vayu_dsp.h
packages/ti/ipc/rpmsg/RPMessage.c
qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/transports/virtio/VirtQueue.c

index 2378ac372356054a47d019a7396a828da7ed46ea..f24deb178865487b84833eb7b32d333c3b1b74cb 100644 (file)
@@ -39,7 +39,7 @@ LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
                      $(LOCAL_PATH)/$(IPC_ROOT)/packages \
                      $(LOCAL_PATH)/$(IPC_ROOT)/hlos_common/include
 
-LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID -DGATEMP_SUPPORT
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID -DGATEMP_SUPPORT -fPIC
 LOCAL_MODULE_TAGS:= optional
 
 LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/api/MultiProc.c \
index afb1bbd52688c333964efb1caaede7380c58b5c6..d2db25d3bed18809991fd4058ad5ef34ed658f03 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -133,6 +133,7 @@ Int GateMP_setup(Void)
     UInt32            len;
     UInt32            size;
     UInt32            alignDiff;
+    UInt32            offset;
     Int32             fdMem;
 
     NameServer_Params_init(&params);
@@ -191,59 +192,77 @@ Int GateMP_setup(Void)
             size = GateMP_module->numRemoteSystem * sizeof (UInt8) +
                 (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1));
             size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE));
+            offset = nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1);
+#if defined(IPC_BUILDOS_ANDROID)
+            GateMP_module->remoteSystemInUse = mmap64(NULL, size,
+                (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
+                (off64_t)offset);
+#else
             GateMP_module->remoteSystemInUse = mmap(NULL, size,
                 (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
-                (off_t)nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                (off_t)offset);
+#endif
             if (GateMP_module->remoteSystemInUse == MAP_FAILED) {
-                 GateMP_module->remoteSystemInUse = NULL;
-                 status = GateMP_E_MEMORY;
                  LOG1("Failed to map remoteSystemInUse=0x%p to host address" \
                       "  space!", GateMP_module->remoteSystemInUse);
+                 GateMP_module->remoteSystemInUse = NULL;
+                 status = GateMP_E_MEMORY;
             }
             else {
-                alignDiff = (off_t)nsValue[0] -
-                    ((off_t)nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                alignDiff = nsValue[0] - offset;
                 GateMP_module->remoteSystemInUse =
                     GateMP_module->remoteSystemInUse + alignDiff;
             }
 
             size = GateMP_module->numRemoteCustom1 * sizeof (UInt8) +
-                (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1));
+                (nsValue[1] & (sysconf(_SC_PAGE_SIZE) - 1));
             size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE));
+            offset = nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1);
             if (status == GateMP_S_SUCCESS) {
+#if defined(IPC_BUILDOS_ANDROID)
+                GateMP_module->remoteCustom1InUse = mmap64(NULL, size,
+                    (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
+                    (off64_t)offset);
+#else
                 GateMP_module->remoteCustom1InUse = mmap(NULL, size,
                     (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
-                    (off_t)nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                    (off_t)offset);
+#endif
                 if (GateMP_module->remoteCustom1InUse == MAP_FAILED) {
-                    GateMP_module->remoteCustom1InUse = NULL;
-                    status = GateMP_E_MEMORY;
                     LOG1("Failed to map remoteCustom1InUse=%p to host address" \
                         " space!", GateMP_module->remoteCustom1InUse);
+                    GateMP_module->remoteCustom1InUse = NULL;
+                    status = GateMP_E_MEMORY;
                 }
                 else {
-                    alignDiff = (off_t)nsValue[1] -
-                        ((off_t)nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                    alignDiff = nsValue[1] - offset;
                     GateMP_module->remoteCustom1InUse =
                         GateMP_module->remoteCustom1InUse + alignDiff;
                 }
             }
 
             size = GateMP_module->numRemoteCustom2 * sizeof (UInt8) +
-                (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1));
+                (nsValue[2] & (sysconf(_SC_PAGE_SIZE) - 1));
             size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE));
+            offset = nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1);
             if (status == GateMP_S_SUCCESS) {
+#if defined(IPC_BUILDOS_ANDROID)
+                GateMP_module->remoteCustom2InUse = mmap64(NULL, size,
+                    (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
+                    (off64_t)offset);
+#else
                 GateMP_module->remoteCustom2InUse = mmap(NULL, size,
                     (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
-                    (off_t)nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                    (off_t)offset);
+#endif
                 if (GateMP_module->remoteCustom2InUse == MAP_FAILED) {
-                    GateMP_module->remoteCustom2InUse = NULL;
-                    status = GateMP_E_MEMORY;
                     LOG1("Failed to map remoteCustom2InUse=%p to host address" \
                         " space!", GateMP_module->remoteCustom2InUse);
+                    GateMP_module->remoteCustom2InUse = NULL;
+                    status = GateMP_E_MEMORY;
                 }
                 else {
-                    alignDiff = (off_t)nsValue[2] -
-                        ((off_t)nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                    alignDiff = nsValue[2] - offset;
                     GateMP_module->remoteCustom2InUse =
                         GateMP_module->remoteCustom2InUse + alignDiff;
                 }
index b1a061309cbffd2a8112d5de1f6ab96466f9681f..ea4b7d06505153145d019b2a179febfdb77ecce0 100644 (file)
@@ -65,9 +65,6 @@
 #define L3_PERIPHERAL_DMM       0x4E000000
 #define DSP_PERIPHERAL_DMM      0x4E000000
 
-#define L3_PERIPHERAL_ISS       0x52000000
-#define DSP_PERIPHERAL_ISS      0x52000000
-
 #define L3_TILER_MODE_0_1       0x60000000
 #define DSP_TILER_MODE_0_1      0x60000000
 
@@ -177,9 +174,6 @@ struct my_resource_table {
 
     /* devmem entry */
     struct fw_rsc_devmem devmem10;
-
-    /* devmem entry */
-    struct fw_rsc_devmem devmem11;
 };
 
 #define TRACEBUFADDR (UInt32)&ti_trace_SysMin_Module_State_0_outbuf__A
@@ -189,7 +183,7 @@ struct my_resource_table {
 
 struct my_resource_table ti_ipc_remoteproc_ResourceTable = {
     1,      /* we're the first version that implements this */
-    18,     /* number of entries in the table */
+    17,     /* number of entries in the table */
     0, 0,   /* reserved, must be zero */
     /* offsets to entries */
     {
@@ -210,7 +204,6 @@ struct my_resource_table ti_ipc_remoteproc_ResourceTable = {
         offsetof(struct my_resource_table, devmem8),
         offsetof(struct my_resource_table, devmem9),
         offsetof(struct my_resource_table, devmem10),
-        offsetof(struct my_resource_table, devmem11),
     },
 
     /* rpmsg vdev entry */
@@ -316,12 +309,6 @@ struct my_resource_table ti_ipc_remoteproc_ResourceTable = {
         DSP_PERIPHERAL_DMM, L3_PERIPHERAL_DMM,
         SZ_1M, 0, 0, "DSP_PERIPHERAL_DMM",
     },
-
-    {
-        TYPE_DEVMEM,
-        DSP_PERIPHERAL_ISS, L3_PERIPHERAL_ISS,
-        SZ_256K, 0, 0, "DSP_PERIPHERAL_ISS",
-    },
 };
 
 #endif /* _RSC_TABLE_VAYU_DSP_H_ */
index a4de07df788bbe939c52d1cbc35aba81cf4064ff..e837ae34d1efea8a3e1aec7fe76d98624d7b692a 100644 (file)
@@ -531,7 +531,7 @@ Int RPMessage_recv(RPMessage_Handle handle, Ptr data, UInt16 *len,
     }
     else  {
        payload = (Queue_elem *)List_get(obj->queue);
-       Assert_isTrue((!payload), NULL);
+       Assert_isTrue((payload), NULL);
     }
 
     if (status == RPMessage_S_SUCCESS)  {
index d74621dd13063f7673aadea36e2e2aeda1f6a560..54074f060133639934e9a81050069133e13e1816 100644 (file)
@@ -69,6 +69,7 @@
 #include "virtio_ring.h"
 #include "_rpmsg.h"
 #include <ipu_pm.h>
+#include <pthread.h>
 
 /* Used for defining the size of the virtqueue registry */
 #define NUM_QUEUES                      2
@@ -103,6 +104,9 @@ typedef struct VirtQueue_Object {
 
     /* Private arg from user */
     void *                  arg;
+
+    /* Mutex to protect vrings from multi-thread access */
+    pthread_mutex_t         mutex;
 } VirtQueue_Object;
 
 static UInt numQueues = 0;
@@ -138,12 +142,11 @@ Void VirtQueue_cb(Void *buf, VirtQueue_Handle vq)
  */
 Void VirtQueue_kick(VirtQueue_Handle vq)
 {
-    /* For now, simply interrupt remote processor */
-    if (vq->vring.used->flags & VRING_USED_F_NO_NOTIFY) {
-        GT_0trace(curTrace, GT_3CLASS,
-                "VirtQueue_kick: no kick because of VRING_USED_F_NO_NOTIFY");
-        return;
-    }
+    /*
+     * We need to expose available array entries before sending an
+     * interrupt.
+     */
+    asm("   DSB ST");
 
     GT_2trace(curTrace, GT_2CLASS,
             "VirtQueue_kick: Sending interrupt to proc %d with payload 0x%x",
@@ -198,6 +201,8 @@ Int VirtQueue_addAvailBuf(VirtQueue_Handle vq, Void *buf, UInt32 len, Int16 head
 {
     UInt16 avail;
 
+    pthread_mutex_lock(&vq->mutex);
+
     if (vq->num_free == 0) {
         /* There's no more space */
         GT_setFailureReason (curTrace,
@@ -217,9 +222,17 @@ Int VirtQueue_addAvailBuf(VirtQueue_Handle vq, Void *buf, UInt32 len, Int16 head
         vq->vring.desc[head].len = len;
         vq->vring.desc[head].flags = 0;
 
+        /*
+         * Descriptors and available array need to be set before we expose the
+         * new available array entries.
+         */
+        asm("   DMB ST");
+
         vq->vring.avail->idx++;
     }
 
+    pthread_mutex_unlock(&vq->mutex);
+
     return (vq->num_free);
 }
 
@@ -230,14 +243,21 @@ Int16 VirtQueue_getUsedBuf(VirtQueue_Object *vq, Void **buf)
 {
     UInt16 head;
 
+    pthread_mutex_lock(&vq->mutex);
+
     /* There's nothing available? */
     if (vq->last_used_idx == vq->vring.used->idx) {
         /* We need to know about added buffers */
         vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
 
+        pthread_mutex_unlock(&vq->mutex);
+
         return (-1);
     }
 
+    /* Only get used array entries after they have been exposed. */
+    asm("   DMB");
+
     /* No need to know be kicked about added buffers anymore */
     //vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; // disabling for now, since there seems to be a race condition where an M3->A9 message is not detected because the interrupt isn't sent.
 
@@ -245,6 +265,8 @@ Int16 VirtQueue_getUsedBuf(VirtQueue_Object *vq, Void **buf)
     vq->last_used_idx++;
     vq->num_free++;
 
+    pthread_mutex_unlock(&vq->mutex);
+
     *buf = mapPAtoVA(vq, vq->vring.desc[head].addr);
 
     return (head);
@@ -385,6 +407,9 @@ VirtQueue_Handle VirtQueue_create (VirtQueue_callback callback, UInt16 procId,
         vq = NULL;
     }
 
+    /* Initialize mutex */
+    pthread_mutex_init(&vq->mutex, NULL);
+
     return (vq);
 }