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 <[email protected]>
>> + * 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 via email to