erpc icon indicating copy to clipboard operation
erpc copied to clipboard

[QUESTION] About mem for rpmsg transport

Open CC-AD opened this issue 1 year ago • 3 comments

hi nxp erpc is a great project for rpc. I use rpmsg as transport for imx8mp to make Core-A to Core-M and Core-M to Core-A. but i can't understand in erpc_c/transports/erpc_rpmsg_lite_transport.cpp function RPMsgTransport::send

erpc_status_t RPMsgTransport::send(MessageBuffer *message)
{
    int32_t ret_val = rpmsg_lite_send_nocopy(s_rpmsg, m_rpmsg_ept, m_dst_addr, reinterpret_cast<char *>(message->get()),
                                             message->getUsed());
    message->set(NULL, 0);

    return (ret_val != RL_SUCCESS) ? kErpcStatus_SendFailed : kErpcStatus_Success;
}

if there make message buf to NULL and size to zero, how to free this message buf? I know this memory from virtio queue. Could it be that don't need free? I test this problem. add log to setup_mbf_rpmsg and log format is

printf("create: %p %d\n", buf, size);

printf("dispose: %p %d\n", tmp, buf->getLength());

and test result is

dispose: 0x80e65664 16
create: 0x55408010 4080
dispose: 0x80e65664 16
create: 0x55409010 4080
dispose: 0x80e65664 16
create: 0x5540a010  4080

memory address for 0x55408010 0x55409010 0x5540a010 don't free. look forward for your reply.

CC-AD avatar Feb 17 '25 07:02 CC-AD

Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.

github-actions[bot] avatar Feb 17 '25 07:02 github-actions[bot]

Hi @ADragonKnight , are you aware of that message buffers created on one side are freed on other side? There are N/2 buffer amounts for every side. Each half is used for creating and writing on one side and reading and freeing on other side.

Hadatko avatar Feb 17 '25 08:02 Hadatko

Wow,I know this from OpenAMP project. this framework very efficient。 thinks for your reply.

CC-AD avatar Feb 17 '25 08:02 CC-AD