Create shared copy of policy for Shared Server/Client so application doesn't have...
authorJustin Sobota <jsobota@ti.com>
Tue, 9 Apr 2013 20:19:51 +0000 (16:19 -0400)
committerJustin Sobota <jsobota@ti.com>
Tue, 9 Apr 2013 20:19:51 +0000 (16:19 -0400)
include/rm_internal.h
include/rm_loc.h
src/rm.c
src/rm_allocator.c
test/k2h/c66/bios/rm_mem_test.cfg
test/k2h/c66/bios/rm_shared_test.cfg
test/k2k/c66/bios/rm_mem_test.cfg
test/k2k/c66/bios/rm_shared_test.cfg

index 73adccc9420ee791e057914b086516e36922d2b1..44ec8c420097ed92d56d40af42d10192dee758c2 100644 (file)
@@ -54,6 +54,9 @@ extern "C" {
 #define RM_FALSE 0
 #define RM_TRUE  1
 
+/* RM cache alignment */
+#define RM_MAX_CACHE_ALIGN 128
+
 /* Shared server enter critical section macro */
 #define RM_SS_INST_INV_ENTER_CS(csKey)                          \
     if (rmInst->instType == Rm_instType_SHARED_SERVER) {        \
index 06c224102c7752d399a17a9e37769ecd00621426..daef888312e86d2e7e6e73adbb5315f3f32d16be 100644 (file)
@@ -90,6 +90,8 @@ typedef struct Rm_Transaction_s {
 typedef struct {
     /* Pointer to the global policy */
     void                   *globalPolicy;
+    /* Policy size in bytes */
+    uint32_t                policySize;
     /* Pointer to root entry of the global policy valid instance tree */
     Rm_PolicyValidInstTree *globalValidInstTree;
     /* Pointer to the linked list of allocators */
index d19ca1c34a2779e8a939af04eb3da74257df3342..1cfd0a41313066b758685b5d0b3e7655eae4b439 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -1061,12 +1061,13 @@ void Rm_instanceStatus(Rm_Handle rmHandle)
  */
 Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
 {
-    Rm_Inst *rmInst = NULL;
-    Rm_Inst *sharedServerInst = NULL;
-    void    *globalResourceDtb = NULL;
-    void    *linuxResourceDtb = NULL;
-    int      addLinux = RM_FALSE;   
-    void    *key;     
+    Rm_Inst  *rmInst = NULL;
+    Rm_Inst  *sharedServerInst = NULL;
+    uint32_t  policySize;
+    void     *globalResourceDtb = NULL;
+    void     *linuxResourceDtb = NULL;
+    int       addLinux = RM_FALSE;   
+    void     *key;     
 
     *result = RM_OK;
     
@@ -1082,8 +1083,8 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
     }
 
     /* Create and initialize instance */
-    rmInst = Rm_osalMalloc (sizeof(Rm_Inst));
-    memset ((void *) rmInst, 0, sizeof(Rm_Inst));
+    rmInst = Rm_osalMalloc(sizeof(*rmInst));
+    memset ((void *)rmInst, 0, sizeof(*rmInst));
     rmInst->isLocked = RM_FALSE;
     rmInst->registeredWithDelegateOrServer = RM_FALSE;
     rmInst->transactionSeqNum = transactionInitSequenceNum();
@@ -1099,7 +1100,21 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
             goto errorExit;
         }
 
-        rmInst->u.server.globalPolicy = initCfg->instCfg.serverCfg.globalPolicy;
+        if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+            /* Shared Server makes copy of policy in shared memory for Shared Clients
+             * on other cores */
+            policySize = fdt_totalsize(initCfg->instCfg.serverCfg.globalPolicy);
+            /* Align policy size to cache boundary */
+            if (policySize % RM_MAX_CACHE_ALIGN) {
+                policySize += (RM_MAX_CACHE_ALIGN - (policySize % RM_MAX_CACHE_ALIGN));
+            }
+            rmInst->u.server.policySize = policySize;
+            rmInst->u.server.globalPolicy = Rm_osalMalloc(rmInst->u.server.policySize);
+            memcpy(rmInst->u.server.globalPolicy, initCfg->instCfg.serverCfg.globalPolicy, rmInst->u.server.policySize);
+        }
+        else {
+            rmInst->u.server.globalPolicy = initCfg->instCfg.serverCfg.globalPolicy;
+        }
 
         if (initCfg->instCfg.serverCfg.linuxDtb) {
             linuxResourceDtb = initCfg->instCfg.serverCfg.linuxDtb;
@@ -1182,6 +1197,11 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
                 Rm_osalCsExit(key);
                 goto errorExit;
             }
+            else {
+                /* Invalidate the policy */
+                Rm_osalBeginMemAccess((void *)sharedServerInst->u.server.globalPolicy, 
+                                      sharedServerInst->u.server.policySize);
+            }
             Rm_osalCsExit(key);
         }
         else {
@@ -1191,8 +1211,9 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
     }
 
     if (initCfg->instType == Rm_instType_SHARED_SERVER) {
-        /* Writeback the instance for other cores */
+        /* Writeback the instance and policy for other cores */
         Rm_osalEndMemAccess ((void *)rmInst, sizeof(Rm_Inst));
+        Rm_osalEndMemAccess ((void *)rmInst->u.server.globalPolicy, rmInst->u.server.policySize);
     }
     else if (rmInst->instType != Rm_instType_SHARED_CLIENT) {
         /* Create the instance's task blocking mechanism */
@@ -1238,6 +1259,10 @@ int32_t Rm_delete(Rm_Handle rmHandle, int ignorePendingServices)
         rmAllocatorDeleteResources(rmHandle);
         rmNameServerDelete(rmHandle);
         rmInst->u.server.allocators = NULL;
+
+        if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+            Rm_osalFree((void *)rmInst->u.server.globalPolicy, rmInst->u.server.policySize);
+        }
     }
     else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
         rmAllocatorDeleteResources(rmHandle);
index 8e2d72c6aec9db24fb1191b7e2903f50fd271dcc..59d44c9ff302ef16058c327058ebd110753d5cb9 100644 (file)
@@ -320,8 +320,10 @@ static void allocatorResNodeOwnerDelete(Rm_Handle rmHandle, Rm_ResourceNode *nod
 /* FUNCTION PURPOSE: Copies the owners of a resource node
  ***********************************************************************
  * DESCRIPTION: Creates a list of resource owners for the destination
- *              resource node that is equivalent to the the 
- *              source resource node's owners
+ *              resource node that is equivalent to the source resource
+ *              node's owners
+ *
+ *              dstNode must be a newly created node without any owners.
  */
 static void allocatorResNodeOwnerCopy(Rm_Handle rmHandle, Rm_ResourceNode *dstNode, Rm_ResourceNode *srcNode)
 {
@@ -330,6 +332,9 @@ static void allocatorResNodeOwnerCopy(Rm_Handle rmHandle, Rm_ResourceNode *dstNo
     Rm_Owner *dstNewOwner;
     Rm_Owner *dstPrevOwner;
 
+    if (dstNode->ownerList != NULL) {
+        return;
+    }
     dstNode->allocationCount = srcNode->allocationCount;
 
     while (srcOwnerList) {
index c50ed1a495ad516aec230807e8c534c79a34f1ea..518d134e6ae8d0ffdf447a3abc1c575f3287a6fb 100644 (file)
@@ -72,7 +72,7 @@ Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
 Program.sectMap[".sharedGlobalPolicy"] = "L2SRAM";
 
 Program.sectMap[".sharedPolicy"] = new Program.SectionSpec();
-Program.sectMap[".sharedPolicy"] = "MSMCSRAM";
+Program.sectMap[".sharedPolicy"] = "L2SRAM";
 
 Program.sectMap[".rm"] = new Program.SectionSpec();
 Program.sectMap[".rm"] = "MSMCSRAM";
index 85a826f11d568ff240d8567b8f8d526fc2064fc6..67df97a6cc791a77917989d0c64541853bf9b373 100644 (file)
@@ -73,7 +73,7 @@ Program.sectMap[".sharedGRL"] = new Program.SectionSpec();
 Program.sectMap[".sharedGRL"] = "L2SRAM";
 
 Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
-Program.sectMap[".sharedGlobalPolicy"] = "MSMCSRAM";
+Program.sectMap[".sharedGlobalPolicy"] = "L2SRAM";
 
 /* Synchronize all processors (this will be done in Ipc_start) */
 Ipc.procSync = Ipc.ProcSync_ALL;
index ae8c491ec1bbcaa78eae71da20d91a95f0e646f4..b6466fe2de55b77bcc1f1bf4ebb2bde59ad191e0 100644 (file)
@@ -72,7 +72,7 @@ Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
 Program.sectMap[".sharedGlobalPolicy"] = "L2SRAM";
 
 Program.sectMap[".sharedPolicy"] = new Program.SectionSpec();
-Program.sectMap[".sharedPolicy"] = "MSMCSRAM";
+Program.sectMap[".sharedPolicy"] = "L2SRAM";
 
 Program.sectMap[".rm"] = new Program.SectionSpec();
 Program.sectMap[".rm"] = "MSMCSRAM";
index bb11d721d607c99460085eedbba95f1afb3d88b8..9f06b2786024ccdc093db189a83fc5acc331736f 100644 (file)
@@ -73,7 +73,7 @@ Program.sectMap[".sharedGRL"] = new Program.SectionSpec();
 Program.sectMap[".sharedGRL"] = "L2SRAM";
 
 Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
-Program.sectMap[".sharedGlobalPolicy"] = "MSMCSRAM";
+Program.sectMap[".sharedGlobalPolicy"] = "L2SRAM";
 
 /* Synchronize all processors (this will be done in Ipc_start) */
 Ipc.procSync = Ipc.ProcSync_ALL;