From: Ramsey Harris Date: Wed, 8 Jul 2015 21:40:50 +0000 (-0700) Subject: SDOCM00115097 RPMessage (Linux) has large data footprint X-Git-Tag: 3.36.02.13~2 X-Git-Url: https://git.ti.com/gitweb?p=ipc%2Fipcdev.git;a=commitdiff_plain;h=de226d75348f4af6ab504d935d60ae3d24f2f4d8 SDOCM00115097 RPMessage (Linux) has large data footprint Replace dynamic creation of message pool with static creation using config params. This allows for the configuration of the pool size from the application config script. Make RPMessage into a meta-only module. Add module template file to generate a C symbol for the config param. --- diff --git a/packages/ti/ipc/rpmsg/RPMessage.c b/packages/ti/ipc/rpmsg/RPMessage.c index e837ae3..d3ebf99 100644 --- a/packages/ti/ipc/rpmsg/RPMessage.c +++ b/packages/ti/ipc/rpmsg/RPMessage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Texas Instruments Incorporated + * Copyright (c) 2011-2015 Texas Instruments Incorporated - http://www.ti.com * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,10 +119,6 @@ /* Various arbitrary limits: */ #define MAXMESSAGEQOBJECTS 256 -#define MAXMESSAGEBUFFERS 512 -#define MSGBUFFERSIZE 512 /* Max payload + sizeof(ListElem) */ -#define MAXHEAPSIZE (MAXMESSAGEBUFFERS * MSGBUFFERSIZE) -#define HEAPALIGNMENT 8 /* The RPMessage Object */ typedef struct RPMessage_Object { @@ -172,6 +168,11 @@ typedef struct RPMessage_Transport { Semaphore_Handle semHandle_toHost; } RPMessage_Transport; +/* generated in RPMessage.xs: module$use() */ +extern const HeapBuf_Handle ti_ipc_rpmsg_RPMessage_heap; + +/* generated in template file RPMessage.xdt */ +extern const UInt ti_ipc_rpmsg_RPMessage_messageBufferSize; /* module diags mask */ Registry_Desc Registry_CURDESC; @@ -179,10 +180,6 @@ Registry_Desc Registry_CURDESC; static RPMessage_Module module; static RPMessage_Transport transport; -/* We create a fixed size heap over this memory for copying received msgs */ -#pragma DATA_ALIGN (recv_buffers, HEAPALIGNMENT) -static UInt8 recv_buffers[MAXHEAPSIZE]; - /* Module ref count: */ static Int curInit = 0; @@ -259,7 +256,6 @@ static Void callback_availBufReady(VirtQueue_Handle vq) Void RPMessage_init(UInt16 remoteProcId) { GateHwi_Params gatePrms; - HeapBuf_Params prms; Semaphore_Params semParams; int i; Registry_Result result; @@ -289,16 +285,8 @@ Void RPMessage_init(UInt16 remoteProcId) module.msgqObjects[i] = NULL; } - HeapBuf_Params_init(&prms); - prms.blockSize = MSGBUFFERSIZE; - prms.numBlocks = MAXMESSAGEBUFFERS; - prms.buf = recv_buffers; - prms.bufSize = MAXHEAPSIZE; - prms.align = HEAPALIGNMENT; - module.heap = HeapBuf_create(&prms, NULL); - if (module.heap == 0) { - System_abort("RPMessage_init: HeapBuf_create returned 0\n"); - } + /* store handle to heap created at config time */ + module.heap = ti_ipc_rpmsg_RPMessage_heap; Semaphore_Params_init(&semParams); semParams.mode = Semaphore_Mode_BINARY; @@ -356,8 +344,6 @@ Void RPMessage_finalize() } /* Tear down Module */ - HeapBuf_delete(&(module.heap)); - Swi_delete(&(transport.swiHandle)); GateHwi_delete(&module.gateH); @@ -471,7 +457,8 @@ Int RPMessage_delete(RPMessage_Handle *handlePtr) /* Free/discard all queued message buffers: */ while ((payload = (Queue_elem *)List_get(obj->queue)) != NULL) { - HeapBuf_free(module.heap, (Ptr)payload, MSGBUFFERSIZE); + HeapBuf_free(module.heap, (Ptr)payload, + ti_ipc_rpmsg_RPMessage_messageBufferSize); } List_delete(&(obj->queue)); diff --git a/packages/ti/ipc/rpmsg/RPMessage.xdc b/packages/ti/ipc/rpmsg/RPMessage.xdc new file mode 100644 index 0000000..9b9a242 --- /dev/null +++ b/packages/ti/ipc/rpmsg/RPMessage.xdc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ======== RPMessage.xdc ======== + */ +package ti.ipc.rpmsg; + +/*! + * ======== RPMessage ======== + * Message manager to interface with a Linux virtio_rp_msg transport + */ +@Template("./RPMessage.xdt") + +metaonly module RPMessage +{ + /*! + * ======== numMessageBuffers ======== + * The number of message buffers available in the pool + */ + config UInt numMessageBuffers = 512; + + /*! + * ======== messageBufferSize ======== + * The size (in bytes) of each message buffer + */ + config UInt messageBufferSize = 512; +} diff --git a/packages/ti/ipc/rpmsg/RPMessage.xdt b/packages/ti/ipc/rpmsg/RPMessage.xdt new file mode 100644 index 0000000..323079d --- /dev/null +++ b/packages/ti/ipc/rpmsg/RPMessage.xdt @@ -0,0 +1,37 @@ +%%{ +/* + * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +var pkg = this.$package.$name.replace(/\./g, "_"); + +%%} +const UInt `pkg`_RPMessage_messageBufferSize = `this.messageBufferSize`; diff --git a/packages/ti/ipc/rpmsg/RPMessage.xs b/packages/ti/ipc/rpmsg/RPMessage.xs new file mode 100644 index 0000000..45ef4a3 --- /dev/null +++ b/packages/ti/ipc/rpmsg/RPMessage.xs @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ======== RPMessage.xs ======== + */ +var HeapBuf; +var Program; + +/* + * ======== module$use ======== + * Use other modules required by this module + */ +function module$use() +{ + xdc.useModule('xdc.runtime.Assert'); + xdc.useModule('xdc.runtime.Diags'); + xdc.useModule('xdc.runtime.Log'); + xdc.useModule('xdc.runtime.Memory'); + xdc.useModule('xdc.runtime.Registry'); + xdc.useModule('xdc.runtime.System'); + + xdc.useModule('ti.sysbios.BIOS'); + xdc.useModule('ti.sysbios.gates.GateHwi'); + xdc.useModule('ti.sysbios.knl.Semaphore'); + xdc.useModule('ti.sysbios.knl.Swi'); + + xdc.useModule('ti.sdo.utils.List'); + xdc.useModule('ti.sdo.utils.MultiProc'); + + Program = xdc.useModule('xdc.cfg.Program'); + HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf'); + + /* create message pool */ + var params = new HeapBuf.Params(); + + params.blockSize = this.messageBufferSize; + params.numBlocks = this.numMessageBuffers; + params.bufSize = this.messageBufferSize * this.numMessageBuffers; + params.align = 8; + + var pkg = this.$package.$name.replace(/\./g, "_"); + Program.global[pkg+"_RPMessage_heap"] = HeapBuf.create(params); +} diff --git a/packages/ti/ipc/rpmsg/package.xdc b/packages/ti/ipc/rpmsg/package.xdc index cac6282..41f714e 100644 --- a/packages/ti/ipc/rpmsg/package.xdc +++ b/packages/ti/ipc/rpmsg/package.xdc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013, Texas Instruments Incorporated + * Copyright (c) 2011-2015 Texas Instruments Incorporated - http://www.ti.com * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,5 +38,6 @@ * IPC over Virtio vrings (RPMSG). */ -package ti.ipc.rpmsg [1,0,0] { +package ti.ipc.rpmsg [1,0,1] { + module RPMessage; }