Linux virtualization list
 help / color / mirror / Atom feed
From: Alexander Graf <graf@amazon.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowangio@gmail.com>
Cc: nh-open-source@amazon.com,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v2 02/12] virtio: drop the sync operations from virtio_map_ops
Date: Tue, 18 Aug 2026 21:14:15 +0000	[thread overview]
Message-ID: <20260818211425.91009-3-graf@amazon.com> (raw)
In-Reply-To: <20260818211425.91009-1-graf@amazon.com>

With the map sync API gone, sync_single_for_cpu, sync_single_for_device
and need_sync in struct virtio_map_ops are members the virtqueue never
calls. vduse is the only implementation in the tree and provides all
three, and the next implementer has to decide what to put in them.

Drop the three members and their kernel-doc, and remove the vduse
functions that provided them. vduse_domain_bounce() stays, because
vduse_domain_map_page() and vduse_domain_unmap_page() bounce through it
as well. That way the struct asks an implementation for six operations
instead of nine.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Assisted-by: Kiro:claude-opus-5 checkpatch
Signed-off-by: Alexander Graf <graf@amazon.com>
---
 drivers/vdpa/vdpa_user/iova_domain.c | 20 --------------
 drivers/vdpa/vdpa_user/iova_domain.h |  8 ------
 drivers/vdpa/vdpa_user/vduse_dev.c   | 40 ----------------------------
 include/linux/virtio_config.h        | 20 --------------
 4 files changed, 88 deletions(-)

diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
index 4dc76c0d0d13..094fe1ec02c3 100644
--- a/drivers/vdpa/vdpa_user/iova_domain.c
+++ b/drivers/vdpa/vdpa_user/iova_domain.c
@@ -424,26 +424,6 @@ static void vduse_domain_free_iova(struct iova_domain *iovad,
 	free_iova_fast(iovad, iova >> shift, iova_len);
 }
 
-void vduse_domain_sync_single_for_device(struct vduse_iova_domain *domain,
-				      dma_addr_t dma_addr, size_t size,
-				      enum dma_data_direction dir)
-{
-	read_lock(&domain->bounce_lock);
-	if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
-		vduse_domain_bounce(domain, dma_addr, size, DMA_TO_DEVICE);
-	read_unlock(&domain->bounce_lock);
-}
-
-void vduse_domain_sync_single_for_cpu(struct vduse_iova_domain *domain,
-				      dma_addr_t dma_addr, size_t size,
-				      enum dma_data_direction dir)
-{
-	read_lock(&domain->bounce_lock);
-	if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
-		vduse_domain_bounce(domain, dma_addr, size, DMA_FROM_DEVICE);
-	read_unlock(&domain->bounce_lock);
-}
-
 dma_addr_t vduse_domain_map_page(struct vduse_iova_domain *domain,
 				 struct page *page, unsigned long offset,
 				 size_t size, enum dma_data_direction dir,
diff --git a/drivers/vdpa/vdpa_user/iova_domain.h b/drivers/vdpa/vdpa_user/iova_domain.h
index e50e55d1396f..66f14764a5db 100644
--- a/drivers/vdpa/vdpa_user/iova_domain.h
+++ b/drivers/vdpa/vdpa_user/iova_domain.h
@@ -48,14 +48,6 @@ int vduse_domain_set_map(struct vduse_iova_domain *domain,
 void vduse_domain_clear_map(struct vduse_iova_domain *domain,
 			    struct vhost_iotlb *iotlb);
 
-void vduse_domain_sync_single_for_device(struct vduse_iova_domain *domain,
-				      dma_addr_t dma_addr, size_t size,
-				      enum dma_data_direction dir);
-
-void vduse_domain_sync_single_for_cpu(struct vduse_iova_domain *domain,
-				      dma_addr_t dma_addr, size_t size,
-				      enum dma_data_direction dir);
-
 dma_addr_t vduse_domain_map_page(struct vduse_iova_domain *domain,
 				 struct page *page, unsigned long offset,
 				 size_t size, enum dma_data_direction dir,
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 10dcf016bfb0..7a1a344539b8 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -932,34 +932,6 @@ static const struct vdpa_config_ops vduse_vdpa_config_ops = {
 	.free			= vduse_vdpa_free,
 };
 
-static void vduse_dev_sync_single_for_device(union virtio_map token,
-					     dma_addr_t dma_addr, size_t size,
-					     enum dma_data_direction dir)
-{
-	struct vduse_iova_domain *domain;
-
-	if (!token.group)
-		return;
-
-	guard(vq_group_as_read_lock)(token.group);
-	domain = token.group->as->domain;
-	vduse_domain_sync_single_for_device(domain, dma_addr, size, dir);
-}
-
-static void vduse_dev_sync_single_for_cpu(union virtio_map token,
-					     dma_addr_t dma_addr, size_t size,
-					     enum dma_data_direction dir)
-{
-	struct vduse_iova_domain *domain;
-
-	if (!token.group)
-		return;
-
-	guard(vq_group_as_read_lock)(token.group);
-	domain = token.group->as->domain;
-	vduse_domain_sync_single_for_cpu(domain, dma_addr, size, dir);
-}
-
 static dma_addr_t vduse_dev_map_page(union virtio_map token, struct page *page,
 				     unsigned long offset, size_t size,
 				     enum dma_data_direction dir,
@@ -1037,15 +1009,6 @@ static void vduse_dev_free_coherent(union virtio_map token, size_t size,
 	free_pages_exact(vaddr, size);
 }
 
-static bool vduse_dev_need_sync(union virtio_map token, dma_addr_t dma_addr)
-{
-	if (!token.group)
-		return false;
-
-	guard(vq_group_as_read_lock)(token.group);
-	return dma_addr < token.group->as->domain->bounce_size;
-}
-
 static int vduse_dev_mapping_error(union virtio_map token, dma_addr_t dma_addr)
 {
 	if (unlikely(dma_addr == DMA_MAPPING_ERROR))
@@ -1063,13 +1026,10 @@ static size_t vduse_dev_max_mapping_size(union virtio_map token)
 }
 
 static const struct virtio_map_ops vduse_map_ops = {
-	.sync_single_for_device = vduse_dev_sync_single_for_device,
-	.sync_single_for_cpu = vduse_dev_sync_single_for_cpu,
 	.map_page = vduse_dev_map_page,
 	.unmap_page = vduse_dev_unmap_page,
 	.alloc = vduse_dev_alloc_coherent,
 	.free = vduse_dev_free_coherent,
-	.need_sync = vduse_dev_need_sync,
 	.mapping_error = vduse_dev_mapping_error,
 	.max_mapping_size = vduse_dev_max_mapping_size,
 };
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 69f84ea85d71..eb38c876a628 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -157,16 +157,6 @@ struct virtio_config_ops {
  *      size: the buffer size
  *      dir: mapping direction
  *      attrs: unmapping attributes
- * @sync_single_for_cpu: sync a single buffer from device to cpu
- *      map: metadata for performing mapping
- *      map_handle: the mapping address to sync
- *      size: the size of the buffer
- *      dir: synchronization direction
- * @sync_single_for_device: sync a single buffer from cpu to device
- *      map: metadata for performing mapping
- *      map_handle: the mapping address to sync
- *      size: the size of the buffer
- *      dir: synchronization direction
  * @alloc: alloc a coherent buffer mapping
  *      map: metadata for performing mapping
  *      size: the size of the buffer
@@ -179,10 +169,6 @@ struct virtio_config_ops {
  *      vaddr: virtual address of the buffer
  *      map_handle: the mapping address that needs to be freed
  *      attrs: unmapping attributes
- * @need_sync: if the buffer needs synchronization
- *      map: metadata for performing mapping
- *      map_handle: the mapped address
- *      Returns whether the buffer needs synchronization
  * @mapping_error: if the mapping address is error
  *      map: metadata for performing mapping
  *      map_handle: the mapped address
@@ -197,16 +183,10 @@ struct virtio_map_ops {
 	void (*unmap_page)(union virtio_map map, dma_addr_t map_handle,
 			   size_t size, enum dma_data_direction dir,
 			   unsigned long attrs);
-	void (*sync_single_for_cpu)(union virtio_map map, dma_addr_t map_handle,
-				    size_t size, enum dma_data_direction dir);
-	void (*sync_single_for_device)(union virtio_map map,
-				       dma_addr_t map_handle, size_t size,
-				       enum dma_data_direction dir);
 	void *(*alloc)(union virtio_map map, size_t size,
 		       dma_addr_t *map_handle, gfp_t gfp);
 	void (*free)(union virtio_map map, size_t size, void *vaddr,
 		     dma_addr_t map_handle, unsigned long attrs);
-	bool (*need_sync)(union virtio_map map, dma_addr_t map_handle);
 	int (*mapping_error)(union virtio_map map, dma_addr_t map_handle);
 	size_t (*max_mapping_size)(union virtio_map map);
 };

  parent reply	other threads:[~2026-08-18 21:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 21:14 [PATCH v2 00/12] virtio: support devices that own their virtqueue memory Alexander Graf
2026-08-18 21:14 ` [PATCH v2 01/12] virtio_ring: remove the unused map sync API Alexander Graf
2026-08-18 21:14 ` Alexander Graf [this message]
2026-08-18 21:14 ` [PATCH v2 03/12] vdpa: drop the VIRTIO_DEVICE_F_MASK example value Alexander Graf
2026-08-18 21:14 ` [PATCH v2 04/12] virtio_ring: return -ENOMEM when a packed ring mapping fails Alexander Graf
2026-08-18 21:14 ` [PATCH v2 05/12] virtio: add the VIRTIO_F_DMB feature bit Alexander Graf
2026-08-18 21:14 ` [PATCH v2 06/12] virtio_pci: read the device memory buffer registers Alexander Graf
2026-08-18 21:14 ` [PATCH v2 07/12] virtio_pci: create virtqueues with the device's mapping token Alexander Graf
2026-08-18 21:14 ` [PATCH v2 08/12] virtio: add a device memory buffer region allocator Alexander Graf
2026-08-18 21:14 ` [PATCH v2 09/12] virtio: locate the device memory buffer after feature negotiation Alexander Graf
2026-08-18 21:14 ` [PATCH v2 10/12] virtio: treat VIRTIO_F_DMB as implying VIRTIO_F_ACCESS_PLATFORM Alexander Graf
2026-08-18 21:14 ` [PATCH v2 11/12] virtio_pci: support VIRTIO_F_DMB Alexander Graf
2026-08-18 21:14 ` [PATCH v2 12/12] virtio: expose device memory buffer occupancy over debugfs Alexander Graf

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=20260818211425.91009-3-graf@amazon.com \
    --to=graf@amazon.com \
    --cc=eperezma@redhat.com \
    --cc=jasowangio@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=nh-open-source@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=stefanha@redhat.com \
    --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