Hi,
This is a follow up question to this question where I managed to adapt the rpmsg driver for two channels. Now I want to increase the buffer size, since 512-byte payloads are not fast enough (I need around 200kBytes/s, looks like rpmsg can’t follow this speed with default payload size).
Looking at the driver on the Linux side (rpmsg « drivers - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules) there are several places where the size can be changed. Inside imx_rpmsg.c :
#define RPMSG_NUM_BUFS (512)
#define RPMSG_BUF_SIZE (512)
#define RPMSG_BUFS_SPACE (RPMSG_NUM_BUFS * RPMSG_BUF_SIZE)
#define RPMSG_VRING_ALIGN (4096)
#define RPMSG_RING_SIZE ((DIV_ROUND_UP(vring_size(RPMSG_NUM_BUFS / 2, \
RPMSG_VRING_ALIGN), PAGE_SIZE)) * PAGE_SIZE)
Inside imx_rpmsg_tty.c :
/* this needs to be less then (RPMSG_BUF_SIZE - sizeof(struct rpmsg_hdr)) */
#define RPMSG_MAX_SIZE 256
and inside virtio_rpmsg_bus.c :
/*
* We're allocating buffers of 512 bytes each for communications. The
* number of buffers will be computed from the number of buffers supported
* by the vring, upto a maximum of 512 buffers (256 in each direction).
*
* Each buffer will have 16 bytes for the msg header and 496 bytes for
* the payload.
*
* This will utilize a maximum total space of 256KB for the buffers.
*
* We might also want to add support for user-provided buffers in time.
* This will allow bigger buffer size flexibility, and can also be used
* to achieve zero-copy messaging.
*
* Note that these numbers are purely a decision of this driver - we
* can change this without changing anything in the firmware of the remote
* processor.
*/
#define MAX_RPMSG_NUM_BUFS (512)
#define MAX_RPMSG_BUF_SIZE (512)
On the M4 side, there is rpmsg_config.h :
//! @def RL_BUFFER_PAYLOAD_SIZE
//!
//! Size of the buffer payload, it must be equal to (240, 496, 1008, ...)
//! [2^n - 16]. Ensure the same value is defined on both sides of rpmsg
//! communication. The default value is 496U.
#define RL_BUFFER_PAYLOAD_SIZE (496U)
//! @def RL_BUFFER_COUNT
//!
//! Number of the buffers, it must be power of two (2, 4, ...).
//! The default value is 2U.
//! Note this value defines the buffer count for one direction of the rpmsg
//! communication only, i.e. if the default value of 2 is used
//! in rpmsg_config.h files for the master and the remote side, 4 buffers
//! in total are created in the shared memory.
#define RL_BUFFER_COUNT (256)
Needless to say I find the naming system confusing, since buffer count sometimes reffers to whole ring buffer, and sometimes to one half (tx or rx half). Since I allocate 128kb of memory for the ring buffers in my device tree, if I double the buffer size I also divide the buffer count in half (512x512 to 1024x256 etc.).
My first tests show: changing the linux side does nothing, M4 still receives 496
bytes hello world message. As soon as I change the rpmsg_config.h on the M4 side, even just halving the number of buffers to 128, hello world message is not received anymore and the driver isn’t working.
Thanks in advance!