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 v6 3/5] rpmsg: virtio_rpmsg_bus: get buffer size from config space
Date: Thu, 27 Aug 2026 15:01:01 -0500	[thread overview]
Message-ID: <b17047b9-ae6a-460a-b806-ba78e454674a@amd.com> (raw)
In-Reply-To: <aoxywkQPy7VPaIFm@p14s>



On 8/24/2026 11:35 AM, Mathieu Poirier wrote:

>> +		dev_dbg(&vdev->dev,
>> +			"vdev config: ver=%u, rx sz = 0x%x, tx sz = 0x%x\n",
>> +			version, vrp->rx_buf_size, vrp->tx_buf_size);
>> +	} else {
>> +		vrp->rx_buf_size = DEFAULT_RPMSG_BUF_SIZE;
>> +		vrp->tx_buf_size = DEFAULT_RPMSG_BUF_SIZE;
>> +	}
>>
> 
> Please move the above to a distinct funtion.
> 
> I am done reviewing this set.
> 
> Thanks,
> Mathieu
>   

Thank You Mathieu.

I started addressing the comments, but missed to ack here. I agree to
all the comments and will be addressed in the next revision.

Tanmay

>> -	total_buf_space = (vrp->num_rx_buf + vrp->num_tx_buf) * vrp->buf_size;
>> +	total_buf_space = (vrp->num_rx_buf * vrp->rx_buf_size) +
>> +			  (vrp->num_tx_buf * vrp->tx_buf_size);
>>  
>>  	/* allocate coherent memory for the buffers */
>>  	bufs_va = dma_alloc_coherent(vdev->dev.parent,
>> @@ -873,15 +925,14 @@ static int rpmsg_probe(struct virtio_device *vdev)
>>  	/* first part of the buffers is dedicated for RX */
>>  	vrp->rx_bufs = bufs_va;
>>  
>> -	/* and second part is dedicated for TX */
>> -	vrp->tx_bufs = bufs_va + vrp->num_rx_buf * vrp->buf_size;
>> +	vrp->tx_bufs = bufs_va + (vrp->num_rx_buf * vrp->rx_buf_size);
>>  
>>  	/* set up the receive buffers */
>>  	for (i = 0; i < vrp->num_rx_buf; i++) {
>>  		struct scatterlist sg;
>> -		void *cpu_addr = vrp->rx_bufs + i * vrp->buf_size;
>> +		void *cpu_addr = vrp->rx_bufs + i * vrp->rx_buf_size;
>>  
>> -		rpmsg_sg_init(&sg, cpu_addr, vrp->buf_size);
>> +		rpmsg_sg_init(&sg, cpu_addr, vrp->rx_buf_size);
>>  
>>  		err = virtqueue_add_inbuf(vrp->rvq, &sg, 1, cpu_addr,
>>  					  GFP_KERNEL);
>> @@ -964,8 +1015,8 @@ static int rpmsg_remove_device(struct device *dev, void *data)
>>  static void rpmsg_remove(struct virtio_device *vdev)
>>  {
>>  	struct virtproc_info *vrp = vdev->priv;
>> -	unsigned int num_bufs = vrp->num_rx_buf + vrp->num_tx_buf;
>> -	size_t total_buf_space = num_bufs * vrp->buf_size;
>> +	size_t total_buf_space = (vrp->num_rx_buf * vrp->rx_buf_size) +
>> +				 (vrp->num_tx_buf * vrp->tx_buf_size);
>>  	int ret;
>>  
>>  	virtio_reset_device(vdev);
>> @@ -991,6 +1042,7 @@ static struct virtio_device_id id_table[] = {
>>  
>>  static unsigned int features[] = {
>>  	VIRTIO_RPMSG_F_NS,
>> +	VIRTIO_RPMSG_F_BUFSZ,
>>  };
>>  
>>  static struct virtio_driver virtio_ipc_driver = {
>> diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h
>> new file mode 100644
>> index 000000000000..e28144253a12
>> --- /dev/null
>> +++ b/include/linux/rpmsg/virtio_rpmsg.h
>> @@ -0,0 +1,41 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Copyright (C) Pinecone Inc. 2019
>> + * Copyright (C) Xiang Xiao <xiaoxiang@pinecone.net>
>> + * Copyright (C) Advanced Micro Devices, Inc. 2026
>> + */
>> +
>> +#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.
>> + * @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;
>> +	/* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
>> +	__virtio32 txbuf_size;
>> +	__virtio32 rxbuf_size;
>> +} __packed;
>> +
>> +#endif /* _LINUX_VIRTIO_RPMSG_H */
>> -- 
>> 2.43.0
>>


  reply	other threads:[~2026-08-27 20:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  4:42 [PATCH v6 0/5] Enhance RPMsg buffer management Tanmay Shah
2026-08-14  4:42 ` [PATCH v6 1/5] rpmsg: virtio_rpmsg_bus: rename rbufs and sbufs Tanmay Shah
2026-08-14  4:42 ` [PATCH v6 2/5] rpmsg: virtio_rpmsg_bus: allow different size of tx and rx bufs Tanmay Shah
2026-08-14  4:42 ` [PATCH v6 3/5] rpmsg: virtio_rpmsg_bus: get buffer size from config space Tanmay Shah
2026-08-24 16:32   ` Mathieu Poirier
2026-08-24 16:35   ` Mathieu Poirier
2026-08-27 20:01     ` Shah, Tanmay [this message]
2026-08-24 16:37   ` Mathieu Poirier
2026-08-14  4:42 ` [PATCH v6 4/5] docs: rpmsg: add virtio config space details Tanmay Shah
2026-08-24 16:33   ` Mathieu Poirier
2026-08-14  4:42 ` [PATCH v6 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=b17047b9-ae6a-460a-b806-ba78e454674a@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