The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
	virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
	hch@infradead.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH V5 1/9] virtio_ring: constify virtqueue pointer for DMA helpers
Date: Sun, 21 Sep 2025 17:42:10 -0400	[thread overview]
Message-ID: <20250921174203-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20250921165434-mutt-send-email-mst@kernel.org>

On Sun, Sep 21, 2025 at 04:55:10PM -0400, Michael S. Tsirkin wrote:
> On Wed, Aug 13, 2025 at 01:48:23PM +0800, Jason Wang wrote:
> > This patch consities virtqueue point for DMA helpers.
> 
> constifies the virtqueue pointer

note that i fixed it for now

> > 
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> >  drivers/virtio/virtio_ring.c | 25 +++++++++++++------------
> >  include/linux/virtio.h       | 12 ++++++------
> >  2 files changed, 19 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > index f5062061c408..103bad8cffff 100644
> > --- a/drivers/virtio/virtio_ring.c
> > +++ b/drivers/virtio/virtio_ring.c
> > @@ -3149,12 +3149,12 @@ EXPORT_SYMBOL_GPL(virtqueue_get_vring);
> >   *
> >   * return DMA address. Caller should check that by virtqueue_dma_mapping_error().
> >   */
> > -dma_addr_t virtqueue_dma_map_single_attrs(struct virtqueue *_vq, void *ptr,
> > +dma_addr_t virtqueue_dma_map_single_attrs(const struct virtqueue *_vq, void *ptr,
> >  					  size_t size,
> >  					  enum dma_data_direction dir,
> >  					  unsigned long attrs)
> >  {
> > -	struct vring_virtqueue *vq = to_vvq(_vq);
> > +	const struct vring_virtqueue *vq = to_vvq(_vq);
> >  
> >  	if (!vq->use_dma_api) {
> >  		kmsan_handle_dma(virt_to_page(ptr), offset_in_page(ptr), size, dir);
> > @@ -3176,11 +3176,12 @@ EXPORT_SYMBOL_GPL(virtqueue_dma_map_single_attrs);
> >   * Unmap the address that is mapped by the virtqueue_dma_map_* APIs.
> >   *
> >   */
> > -void virtqueue_dma_unmap_single_attrs(struct virtqueue *_vq, dma_addr_t addr,
> > +void virtqueue_dma_unmap_single_attrs(const struct virtqueue *_vq,
> > +				      dma_addr_t addr,
> >  				      size_t size, enum dma_data_direction dir,
> >  				      unsigned long attrs)
> >  {
> > -	struct vring_virtqueue *vq = to_vvq(_vq);
> > +	const struct vring_virtqueue *vq = to_vvq(_vq);
> >  
> >  	if (!vq->use_dma_api)
> >  		return;
> > @@ -3196,9 +3197,9 @@ EXPORT_SYMBOL_GPL(virtqueue_dma_unmap_single_attrs);
> >   *
> >   * Returns 0 means dma valid. Other means invalid dma address.
> >   */
> > -int virtqueue_dma_mapping_error(struct virtqueue *_vq, dma_addr_t addr)
> > +int virtqueue_dma_mapping_error(const struct virtqueue *_vq, dma_addr_t addr)
> >  {
> > -	struct vring_virtqueue *vq = to_vvq(_vq);
> > +	const struct vring_virtqueue *vq = to_vvq(_vq);
> >  
> >  	if (!vq->use_dma_api)
> >  		return 0;
> > @@ -3217,9 +3218,9 @@ EXPORT_SYMBOL_GPL(virtqueue_dma_mapping_error);
> >   *
> >   * return bool
> >   */
> > -bool virtqueue_dma_need_sync(struct virtqueue *_vq, dma_addr_t addr)
> > +bool virtqueue_dma_need_sync(const struct virtqueue *_vq, dma_addr_t addr)
> >  {
> > -	struct vring_virtqueue *vq = to_vvq(_vq);
> > +	const struct vring_virtqueue *vq = to_vvq(_vq);
> >  
> >  	if (!vq->use_dma_api)
> >  		return false;
> > @@ -3240,12 +3241,12 @@ EXPORT_SYMBOL_GPL(virtqueue_dma_need_sync);
> >   * the DMA address really needs to be synchronized
> >   *
> >   */
> > -void virtqueue_dma_sync_single_range_for_cpu(struct virtqueue *_vq,
> > +void virtqueue_dma_sync_single_range_for_cpu(const struct virtqueue *_vq,
> >  					     dma_addr_t addr,
> >  					     unsigned long offset, size_t size,
> >  					     enum dma_data_direction dir)
> >  {
> > -	struct vring_virtqueue *vq = to_vvq(_vq);
> > +	const struct vring_virtqueue *vq = to_vvq(_vq);
> >  	struct device *dev = vring_dma_dev(vq);
> >  
> >  	if (!vq->use_dma_api)
> > @@ -3266,12 +3267,12 @@ EXPORT_SYMBOL_GPL(virtqueue_dma_sync_single_range_for_cpu);
> >   * Before calling this function, use virtqueue_dma_need_sync() to confirm that
> >   * the DMA address really needs to be synchronized
> >   */
> > -void virtqueue_dma_sync_single_range_for_device(struct virtqueue *_vq,
> > +void virtqueue_dma_sync_single_range_for_device(const struct virtqueue *_vq,
> >  						dma_addr_t addr,
> >  						unsigned long offset, size_t size,
> >  						enum dma_data_direction dir)
> >  {
> > -	struct vring_virtqueue *vq = to_vvq(_vq);
> > +	const struct vring_virtqueue *vq = to_vvq(_vq);
> >  	struct device *dev = vring_dma_dev(vq);
> >  
> >  	if (!vq->use_dma_api)
> > diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> > index 8b745ce0cf5f..cf8def717dfd 100644
> > --- a/include/linux/virtio.h
> > +++ b/include/linux/virtio.h
> > @@ -259,18 +259,18 @@ void unregister_virtio_driver(struct virtio_driver *drv);
> >  	module_driver(__virtio_driver, register_virtio_driver, \
> >  			unregister_virtio_driver)
> >  
> > -dma_addr_t virtqueue_dma_map_single_attrs(struct virtqueue *_vq, void *ptr, size_t size,
> > +dma_addr_t virtqueue_dma_map_single_attrs(const struct virtqueue *_vq, void *ptr, size_t size,
> >  					  enum dma_data_direction dir, unsigned long attrs);
> > -void virtqueue_dma_unmap_single_attrs(struct virtqueue *_vq, dma_addr_t addr,
> > +void virtqueue_dma_unmap_single_attrs(const struct virtqueue *_vq, dma_addr_t addr,
> >  				      size_t size, enum dma_data_direction dir,
> >  				      unsigned long attrs);
> > -int virtqueue_dma_mapping_error(struct virtqueue *_vq, dma_addr_t addr);
> > +int virtqueue_dma_mapping_error(const struct virtqueue *_vq, dma_addr_t addr);
> >  
> > -bool virtqueue_dma_need_sync(struct virtqueue *_vq, dma_addr_t addr);
> > -void virtqueue_dma_sync_single_range_for_cpu(struct virtqueue *_vq, dma_addr_t addr,
> > +bool virtqueue_dma_need_sync(const struct virtqueue *_vq, dma_addr_t addr);
> > +void virtqueue_dma_sync_single_range_for_cpu(const struct virtqueue *_vq, dma_addr_t addr,
> >  					     unsigned long offset, size_t size,
> >  					     enum dma_data_direction dir);
> > -void virtqueue_dma_sync_single_range_for_device(struct virtqueue *_vq, dma_addr_t addr,
> > +void virtqueue_dma_sync_single_range_for_device(const struct virtqueue *_vq, dma_addr_t addr,
> >  						unsigned long offset, size_t size,
> >  						enum dma_data_direction dir);
> >  
> > -- 
> > 2.31.1


  reply	other threads:[~2025-09-21 21:42 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  5:48 [PATCH V5 0/9] Refine virtio mapping API Jason Wang
2025-08-13  5:48 ` [PATCH V5 1/9] virtio_ring: constify virtqueue pointer for DMA helpers Jason Wang
2025-08-13  7:14   ` Eugenio Perez Martin
2025-09-21 20:55   ` Michael S. Tsirkin
2025-09-21 21:42     ` Michael S. Tsirkin [this message]
2025-08-13  5:48 ` [PATCH V5 2/9] virtio_ring: switch to use dma_{map|unmap}_page() Jason Wang
2025-08-13  7:15   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 3/9] virtio: rename dma helpers Jason Wang
2025-08-13  7:16   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 4/9] virtio: introduce vring_mapping_token Jason Wang
2025-08-13  7:46   ` Eugenio Perez Martin
2025-08-13  8:55   ` Michael S. Tsirkin
2025-08-13  9:13     ` Eugenio Perez Martin
2025-08-14  3:39       ` Jason Wang
2025-08-14  3:36     ` Jason Wang
2025-08-14 10:42       ` Michael S. Tsirkin
2025-08-15  1:02         ` Jason Wang
2025-08-15 10:04           ` Michael S. Tsirkin
2025-08-18  9:09         ` Eugenio Perez Martin
2025-08-18 12:02           ` Michael S. Tsirkin
2025-08-13  8:58   ` Michael S. Tsirkin
2025-08-14  3:37     ` Jason Wang
2025-08-13  5:48 ` [PATCH V5 5/9] virtio_ring: rename dma_handle to map_handle Jason Wang
2025-08-13  7:47   ` Eugenio Perez Martin
2025-09-21 20:54   ` Michael S. Tsirkin
2025-09-21 21:41     ` Michael S. Tsirkin
2025-08-13  5:48 ` [PATCH V5 6/9] virtio: introduce map ops in virtio core Jason Wang
2025-08-13  8:40   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 7/9] vdpa: support mapping token Jason Wang
2025-08-13  8:45   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 8/9] vdpa: introduce map ops Jason Wang
2025-08-13  8:46   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 9/9] vduse: switch to use virtio map API instead of DMA API Jason Wang
2025-08-13  9:02   ` Eugenio Perez Martin
2025-08-14  3:33     ` Jason Wang
2025-08-14  6:42       ` Eugenio Perez Martin

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=20250921174203-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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