Linux Documentation
 help / color / mirror / Atom feed
From: "Shah, Tanmay" <tanmays@amd.com>
To: Mathieu Poirier <mathieu.poirier@linaro.org>,
	Tanmay Shah <tanmay.shah@amd.com>
Cc: <andersson@kernel.org>, <corbet@lwn.net>,
	<skhan@linuxfoundation.org>, <linux-remoteproc@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 3/5] rpmsg: virtio_rpmsg_bus: get buffer size from config space
Date: Wed, 15 Jul 2026 12:28:26 -0500	[thread overview]
Message-ID: <66e4a85c-be14-4bd8-8328-bf17d2437994@amd.com> (raw)
In-Reply-To: <ale0KIu6hXNvN0q9@p14s>

Hi,

Please find my response below:

On 7/15/2026 11:24 AM, Mathieu Poirier wrote:
> On Fri, Jul 10, 2026 at 12:28:29PM -0700, Tanmay Shah wrote:
>> 512 bytes isn't always suitable for all case, let firmware
>> maker decide the best value from resource table.
>> enable by VIRTIO_RPMSG_F_BUFSZ feature bit.
>>
>> Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
>> ---
>> Changes in v5:
>>
>>   - fix documentation about alignment of the buffer size
>>   - change version field from u16 to u8
>>   - remove buffer alignment check
>>   - Separate buffer alignment vs MTU of a single buffer
>>   - Use buffer alignment only to get next buffer address at alignment
>>     boundary
>>

[...]

>> +#ifndef _LINUX_VIRTIO_RPMSG_H
>> +#define _LINUX_VIRTIO_RPMSG_H
>> +
>> +#include <linux/types.h>
>> +#include <linux/virtio_types.h>
>> +
>> +/* The feature bitmap for virtio rpmsg */
>> +#define VIRTIO_RPMSG_F_NS	0 /* RP supports name service notifications */
>> +#define VIRTIO_RPMSG_F_BUFSZ	1 /* RP get buffer size from config space */
>> +
>> +/* Version of struct virtio_rpmsg_config understood by this driver */
>> +#define RPMSG_VDEV_CONFIG_V1	1
>> +
>> +/**
>> + * struct virtio_rpmsg_config - config space for rpmsg virtio device
>> + *
>> + * @version:	version of this structure, currently %RPMSG_VDEV_CONFIG_V1.
>> + * @size:	size of this structure in bytes.
>> + * @rpmsg_buf_align: alignment in bytes for each buffer. Must be a power of
>> + *		     two. If 0 then no alignment will be done. This alignment
>> + *		     will not decide actual size of the buffer but will be
>> + *		     used to decided the start address of the buffer. The
>> + *		     actual size of the buffer can be different than the
>> + *		     aligned size of the buffer.
> 
> Is there really a need to have a buffer size different from its alignment?  It's
> not like the (small) delta between the buffer size and its alignment will be
> used for something else.  I'm fine with a buffer alignment requirement but in
> those cases, the firmware should set the size of the buffer in accordance with
> its alignment requirement.  Otherwise, the complexity needed to manage the
> discrpancy between the two yields a driver that is hard to maintain and prone to
> bugs.
> 

I had the same concern before. However, following example changed my mind:

So, a single buffer size is the MTU size of a packet for the protocol
supported by the firmware. Now that can be different than the aligned
size of the buffer.

For example, the higher level protocol (not rpmsg) has 430 bytes as the
max size of a payload. However, cache line alignment is 64-bytes. Then
in that case, the aligned buffer size is 448 bytes. But, that doesn't
mean we can say protocol's MTU size is 448 bytes. If user end up
treating MTU size 448 bytes and use space beyond 430 bytes, then the
higher level apps might discard that data and communication may fail.

The alignment field is used only to decide where the next buffer start
address is to ease cache operations.

Sure, we need to maintain this complexity, but I think it's worth it.

Thanks,
Tanmay

>> + * @txbuf_size:	Tx buf size from remote's view. For Linux this is rx buf size.
>> + * @rxbuf_size:	Rx buf size from remote's view. For Linux this is tx buf size.
>> + *
>> + * This is the configuration structure shared by the device and the driver,
>> + * read when %VIRTIO_RPMSG_F_BUFSZ is negotiated. The fields are laid out so
>> + * the structure is naturally 32-bit aligned.
>> + */
>> +struct virtio_rpmsg_config {
>> +	u8 version;
>> +	__virtio16 size;
>> +	__virtio16 rpmsg_buf_align;
>> +	/* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
>> +	__virtio32 txbuf_size;
>> +	__virtio32 rxbuf_size;
>> +} __packed;
>> +
>> +#endif /* _LINUX_VIRTIO_RPMSG_H */
>> -- 
>> 2.34.1
>>


  reply	other threads:[~2026-07-15 17:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 19:28 [PATCH v5 0/5] Enhance RPMsg buffer management Tanmay Shah
2026-07-10 19:28 ` [PATCH v5 1/5] rpmsg: virtio_rpmsg_bus: rename rbufs and sbufs Tanmay Shah
2026-07-10 19:28 ` [PATCH v5 2/5] rpmsg: virtio_rpmsg_bus: allow different size of tx and rx bufs Tanmay Shah
2026-07-10 19:28 ` [PATCH v5 3/5] rpmsg: virtio_rpmsg_bus: get buffer size from config space Tanmay Shah
2026-07-15 16:24   ` Mathieu Poirier
2026-07-15 17:28     ` Shah, Tanmay [this message]
2026-07-10 19:28 ` [PATCH v5 4/5] docs: rpmsg: add virtio config space details Tanmay Shah
2026-07-10 19:28 ` [PATCH v5 5/5] samples: rpmsg: add MTU size info Tanmay Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66e4a85c-be14-4bd8-8328-bf17d2437994@amd.com \
    --to=tanmays@amd.com \
    --cc=andersson@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tanmay.shah@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox